@abloatai/ablo 0.17.0 → 0.19.0

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/BaseSyncedStore.d.ts +5 -4
  3. package/dist/BaseSyncedStore.js +38 -14
  4. package/dist/NetworkMonitor.js +3 -1
  5. package/dist/ObjectPool.d.ts +14 -1
  6. package/dist/ObjectPool.js +8 -1
  7. package/dist/SyncClient.js +7 -1
  8. package/dist/SyncEngineContext.js +2 -0
  9. package/dist/ai-sdk/coordination-context.d.ts +2 -1
  10. package/dist/ai-sdk/coordination-context.js +3 -3
  11. package/dist/ai-sdk/index.d.ts +3 -4
  12. package/dist/ai-sdk/index.js +2 -3
  13. package/dist/ai-sdk/wrap.d.ts +13 -18
  14. package/dist/ai-sdk/wrap.js +2 -6
  15. package/dist/cli.cjs +459 -205
  16. package/dist/client/Ablo.d.ts +116 -23
  17. package/dist/client/Ablo.js +128 -38
  18. package/dist/client/ApiClient.d.ts +2 -2
  19. package/dist/client/ApiClient.js +27 -32
  20. package/dist/client/auth.d.ts +26 -0
  21. package/dist/client/auth.js +209 -1
  22. package/dist/client/createModelProxy.d.ts +16 -11
  23. package/dist/client/createModelProxy.js +15 -15
  24. package/dist/client/sessionMint.d.ts +10 -0
  25. package/dist/client/sessionMint.js +8 -1
  26. package/dist/coordination/schema.d.ts +10 -10
  27. package/dist/coordination/schema.js +7 -8
  28. package/dist/coordination/trace.d.ts +91 -0
  29. package/dist/coordination/trace.js +147 -0
  30. package/dist/core/StoreManager.js +3 -1
  31. package/dist/errorCodes.d.ts +2 -0
  32. package/dist/errorCodes.js +2 -0
  33. package/dist/errors.d.ts +10 -2
  34. package/dist/errors.js +20 -9
  35. package/dist/index.d.ts +7 -1
  36. package/dist/index.js +12 -0
  37. package/dist/interfaces/index.d.ts +45 -2
  38. package/dist/policy/types.d.ts +33 -9
  39. package/dist/policy/types.js +42 -11
  40. package/dist/react/AbloProvider.d.ts +2 -2
  41. package/dist/schema/ddl.d.ts +36 -0
  42. package/dist/schema/ddl.js +66 -0
  43. package/dist/schema/index.d.ts +1 -1
  44. package/dist/schema/index.js +1 -1
  45. package/dist/surface.d.ts +1 -1
  46. package/dist/surface.js +2 -0
  47. package/dist/sync/HydrationCoordinator.js +7 -3
  48. package/dist/sync/SyncWebSocket.d.ts +11 -2
  49. package/dist/sync/SyncWebSocket.js +68 -4
  50. package/dist/sync/awaitClaimGrant.js +9 -2
  51. package/dist/sync/createClaimStream.d.ts +9 -2
  52. package/dist/sync/createClaimStream.js +41 -7
  53. package/dist/sync/participants.d.ts +12 -11
  54. package/dist/sync/participants.js +5 -5
  55. package/dist/transactions/TransactionQueue.d.ts +1 -0
  56. package/dist/transactions/TransactionQueue.js +40 -3
  57. package/dist/types/streams.d.ts +57 -135
  58. package/dist/wire/errorEnvelope.d.ts +13 -0
  59. package/docs/coordination.md +16 -0
  60. package/docs/debugging.md +194 -0
  61. package/docs/index.md +1 -0
  62. package/package.json +1 -1
  63. package/dist/ai-sdk/claim-broadcast.d.ts +0 -83
  64. package/dist/ai-sdk/claim-broadcast.js +0 -79
package/dist/cli.cjs CHANGED
@@ -6044,8 +6044,8 @@ var require_typescript = __commonJS({
6044
6044
  function createGetCanonicalFileName(useCaseSensitiveFileNames2) {
6045
6045
  return useCaseSensitiveFileNames2 ? identity : toFileNameLowerCase;
6046
6046
  }
6047
- function patternText({ prefix, suffix }) {
6048
- return `${prefix}*${suffix}`;
6047
+ function patternText({ prefix: prefix2, suffix }) {
6048
+ return `${prefix2}*${suffix}`;
6049
6049
  }
6050
6050
  function matchedText(pattern, candidate) {
6051
6051
  Debug.assert(isPatternMatch(pattern, candidate));
@@ -6064,17 +6064,17 @@ var require_typescript = __commonJS({
6064
6064
  }
6065
6065
  return matchedValue;
6066
6066
  }
6067
- function startsWith(str, prefix, ignoreCase) {
6068
- return ignoreCase ? equateStringsCaseInsensitive(str.slice(0, prefix.length), prefix) : str.lastIndexOf(prefix, 0) === 0;
6067
+ function startsWith(str, prefix2, ignoreCase) {
6068
+ return ignoreCase ? equateStringsCaseInsensitive(str.slice(0, prefix2.length), prefix2) : str.lastIndexOf(prefix2, 0) === 0;
6069
6069
  }
6070
- function removePrefix(str, prefix) {
6071
- return startsWith(str, prefix) ? str.substr(prefix.length) : str;
6070
+ function removePrefix(str, prefix2) {
6071
+ return startsWith(str, prefix2) ? str.substr(prefix2.length) : str;
6072
6072
  }
6073
- function tryRemovePrefix(str, prefix, getCanonicalFileName = identity) {
6074
- return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : void 0;
6073
+ function tryRemovePrefix(str, prefix2, getCanonicalFileName = identity) {
6074
+ return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix2)) ? str.substring(prefix2.length) : void 0;
6075
6075
  }
6076
- function isPatternMatch({ prefix, suffix }, candidate) {
6077
- return candidate.length >= prefix.length + suffix.length && startsWith(candidate, prefix) && endsWith(candidate, suffix);
6076
+ function isPatternMatch({ prefix: prefix2, suffix }, candidate) {
6077
+ return candidate.length >= prefix2.length + suffix.length && startsWith(candidate, prefix2) && endsWith(candidate, suffix);
6078
6078
  }
6079
6079
  function and(f, g2) {
6080
6080
  return (arg) => f(arg) && g2(arg);
@@ -11848,8 +11848,8 @@ ${lanes.join("\n")}
11848
11848
  );
11849
11849
  const firstComponent = pathComponents2[0];
11850
11850
  if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
11851
- const prefix = firstComponent.charAt(0) === directorySeparator ? "file://" : "file:///";
11852
- pathComponents2[0] = prefix + firstComponent;
11851
+ const prefix2 = firstComponent.charAt(0) === directorySeparator ? "file://" : "file:///";
11852
+ pathComponents2[0] = prefix2 + firstComponent;
11853
11853
  }
11854
11854
  return getPathFromPathComponents(pathComponents2);
11855
11855
  }
@@ -28865,12 +28865,12 @@ ${lanes.join("\n")}
28865
28865
  node.symbol = void 0;
28866
28866
  return node;
28867
28867
  }
28868
- function createBaseGeneratedIdentifier(text, autoGenerateFlags, prefix, suffix) {
28868
+ function createBaseGeneratedIdentifier(text, autoGenerateFlags, prefix2, suffix) {
28869
28869
  const node = createBaseIdentifier(escapeLeadingUnderscores(text));
28870
28870
  setIdentifierAutoGenerate(node, {
28871
28871
  flags: autoGenerateFlags,
28872
28872
  id: nextAutoGenerateId,
28873
- prefix,
28873
+ prefix: prefix2,
28874
28874
  suffix
28875
28875
  });
28876
28876
  nextAutoGenerateId++;
@@ -28893,10 +28893,10 @@ ${lanes.join("\n")}
28893
28893
  }
28894
28894
  return node;
28895
28895
  }
28896
- function createTempVariable(recordTempVariable, reservedInNestedScopes, prefix, suffix) {
28896
+ function createTempVariable(recordTempVariable, reservedInNestedScopes, prefix2, suffix) {
28897
28897
  let flags2 = 1;
28898
28898
  if (reservedInNestedScopes) flags2 |= 8;
28899
- const name = createBaseGeneratedIdentifier("", flags2, prefix, suffix);
28899
+ const name = createBaseGeneratedIdentifier("", flags2, prefix2, suffix);
28900
28900
  if (recordTempVariable) {
28901
28901
  recordTempVariable(name);
28902
28902
  }
@@ -28914,23 +28914,23 @@ ${lanes.join("\n")}
28914
28914
  void 0
28915
28915
  );
28916
28916
  }
28917
- function createUniqueName(text, flags2 = 0, prefix, suffix) {
28917
+ function createUniqueName(text, flags2 = 0, prefix2, suffix) {
28918
28918
  Debug.assert(!(flags2 & 7), "Argument out of range: flags");
28919
28919
  Debug.assert((flags2 & (16 | 32)) !== 32, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic");
28920
- return createBaseGeneratedIdentifier(text, 3 | flags2, prefix, suffix);
28920
+ return createBaseGeneratedIdentifier(text, 3 | flags2, prefix2, suffix);
28921
28921
  }
28922
- function getGeneratedNameForNode(node, flags2 = 0, prefix, suffix) {
28922
+ function getGeneratedNameForNode(node, flags2 = 0, prefix2, suffix) {
28923
28923
  Debug.assert(!(flags2 & 7), "Argument out of range: flags");
28924
28924
  const text = !node ? "" : isMemberName(node) ? formatGeneratedName(
28925
28925
  /*privateName*/
28926
28926
  false,
28927
- prefix,
28927
+ prefix2,
28928
28928
  node,
28929
28929
  suffix,
28930
28930
  idText
28931
28931
  ) : `generated@${getNodeId(node)}`;
28932
- if (prefix || suffix) flags2 |= 16;
28933
- const name = createBaseGeneratedIdentifier(text, 4 | flags2, prefix, suffix);
28932
+ if (prefix2 || suffix) flags2 |= 16;
28933
+ const name = createBaseGeneratedIdentifier(text, 4 | flags2, prefix2, suffix);
28934
28934
  name.original = node;
28935
28935
  return name;
28936
28936
  }
@@ -28947,33 +28947,33 @@ ${lanes.join("\n")}
28947
28947
  if (!startsWith(text, "#")) Debug.fail("First character of private identifier must be #: " + text);
28948
28948
  return createBasePrivateIdentifier(escapeLeadingUnderscores(text));
28949
28949
  }
28950
- function createBaseGeneratedPrivateIdentifier(text, autoGenerateFlags, prefix, suffix) {
28950
+ function createBaseGeneratedPrivateIdentifier(text, autoGenerateFlags, prefix2, suffix) {
28951
28951
  const node = createBasePrivateIdentifier(escapeLeadingUnderscores(text));
28952
28952
  setIdentifierAutoGenerate(node, {
28953
28953
  flags: autoGenerateFlags,
28954
28954
  id: nextAutoGenerateId,
28955
- prefix,
28955
+ prefix: prefix2,
28956
28956
  suffix
28957
28957
  });
28958
28958
  nextAutoGenerateId++;
28959
28959
  return node;
28960
28960
  }
28961
- function createUniquePrivateName(text, prefix, suffix) {
28961
+ function createUniquePrivateName(text, prefix2, suffix) {
28962
28962
  if (text && !startsWith(text, "#")) Debug.fail("First character of private identifier must be #: " + text);
28963
28963
  const autoGenerateFlags = 8 | (text ? 3 : 1);
28964
- return createBaseGeneratedPrivateIdentifier(text ?? "", autoGenerateFlags, prefix, suffix);
28964
+ return createBaseGeneratedPrivateIdentifier(text ?? "", autoGenerateFlags, prefix2, suffix);
28965
28965
  }
28966
- function getGeneratedPrivateNameForNode(node, prefix, suffix) {
28966
+ function getGeneratedPrivateNameForNode(node, prefix2, suffix) {
28967
28967
  const text = isMemberName(node) ? formatGeneratedName(
28968
28968
  /*privateName*/
28969
28969
  true,
28970
- prefix,
28970
+ prefix2,
28971
28971
  node,
28972
28972
  suffix,
28973
28973
  idText
28974
28974
  ) : `#generated@${getNodeId(node)}`;
28975
- const flags2 = prefix || suffix ? 16 : 0;
28976
- const name = createBaseGeneratedPrivateIdentifier(text, 4 | flags2, prefix, suffix);
28975
+ const flags2 = prefix2 || suffix ? 16 : 0;
28976
+ const name = createBaseGeneratedPrivateIdentifier(text, 4 | flags2, prefix2, suffix);
28977
28977
  name.original = node;
28978
28978
  return name;
28979
28979
  }
@@ -33775,13 +33775,13 @@ ${lanes.join("\n")}
33775
33775
  [expr]
33776
33776
  );
33777
33777
  }
33778
- function createSetFunctionNameHelper(f, name, prefix) {
33778
+ function createSetFunctionNameHelper(f, name, prefix2) {
33779
33779
  context.requestEmitHelper(setFunctionNameHelper);
33780
33780
  return context.factory.createCallExpression(
33781
33781
  getUnscopedHelperName("__setFunctionName"),
33782
33782
  /*typeArguments*/
33783
33783
  void 0,
33784
- prefix ? [f, name, context.factory.createStringLiteral(prefix)] : [f, name]
33784
+ prefix2 ? [f, name, context.factory.createStringLiteral(prefix2)] : [f, name]
33785
33785
  );
33786
33786
  }
33787
33787
  function createValuesHelper(expression) {
@@ -36118,11 +36118,11 @@ ${lanes.join("\n")}
36118
36118
  function formatIdentifierWorker(node, generateName) {
36119
36119
  return isGeneratedPrivateIdentifier(node) ? generateName(node).slice(1) : isGeneratedIdentifier(node) ? generateName(node) : isPrivateIdentifier(node) ? node.escapedText.slice(1) : idText(node);
36120
36120
  }
36121
- function formatGeneratedName(privateName, prefix, baseName, suffix, generateName) {
36122
- prefix = formatGeneratedNamePart(prefix, generateName);
36121
+ function formatGeneratedName(privateName, prefix2, baseName, suffix, generateName) {
36122
+ prefix2 = formatGeneratedNamePart(prefix2, generateName);
36123
36123
  suffix = formatGeneratedNamePart(suffix, generateName);
36124
36124
  baseName = formatIdentifier(baseName, generateName);
36125
- return `${privateName ? "#" : ""}${prefix}${baseName}${suffix}`;
36125
+ return `${privateName ? "#" : ""}${prefix2}${baseName}${suffix}`;
36126
36126
  }
36127
36127
  function createAccessorPropertyBackingField(factory2, node, modifiers, initializer) {
36128
36128
  return factory2.updatePropertyDeclaration(
@@ -56197,11 +56197,11 @@ ${lanes.join("\n")}
56197
56197
  candidates.push({ ending: void 0, value: relativeToBaseUrl });
56198
56198
  }
56199
56199
  if (indexOfStar !== -1) {
56200
- const prefix = pattern.substring(0, indexOfStar);
56200
+ const prefix2 = pattern.substring(0, indexOfStar);
56201
56201
  const suffix = pattern.substring(indexOfStar + 1);
56202
56202
  for (const { ending, value } of candidates) {
56203
- if (value.length >= prefix.length + suffix.length && startsWith(value, prefix) && endsWith(value, suffix) && validateEnding({ ending, value })) {
56204
- const matchedStar = value.substring(prefix.length, value.length - suffix.length);
56203
+ if (value.length >= prefix2.length + suffix.length && startsWith(value, prefix2) && endsWith(value, suffix) && validateEnding({ ending, value })) {
56204
+ const matchedStar = value.substring(prefix2.length, value.length - suffix.length);
56205
56205
  if (!pathIsRelative(matchedStar)) {
56206
56206
  return replaceFirstStar(key, matchedStar);
56207
56207
  }
@@ -75900,9 +75900,9 @@ ${lanes.join("\n")}
75900
75900
  }
75901
75901
  secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]);
75902
75902
  } else {
75903
- const prefix = msg.code === Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || msg.code === Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ? "new " : "";
75903
+ const prefix2 = msg.code === Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || msg.code === Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ? "new " : "";
75904
75904
  const params = msg.code === Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || msg.code === Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ? "" : "...";
75905
- path = `${prefix}${path}(${params})`;
75905
+ path = `${prefix2}${path}(${params})`;
75906
75906
  }
75907
75907
  break;
75908
75908
  }
@@ -110744,13 +110744,13 @@ ${lanes.join("\n")}
110744
110744
  }
110745
110745
  function createHoistedVariableForClass(name, node, suffix) {
110746
110746
  const { className } = getPrivateIdentifierEnvironment().data;
110747
- const prefix = className ? { prefix: "_", node: className, suffix: "_" } : "_";
110748
- const identifier = typeof name === "object" ? factory2.getGeneratedNameForNode(name, 16 | 8, prefix, suffix) : typeof name === "string" ? factory2.createUniqueName(name, 16, prefix, suffix) : factory2.createTempVariable(
110747
+ const prefix2 = className ? { prefix: "_", node: className, suffix: "_" } : "_";
110748
+ const identifier = typeof name === "object" ? factory2.getGeneratedNameForNode(name, 16 | 8, prefix2, suffix) : typeof name === "string" ? factory2.createUniqueName(name, 16, prefix2, suffix) : factory2.createTempVariable(
110749
110749
  /*recordTempVariable*/
110750
110750
  void 0,
110751
110751
  /*reservedInNestedScopes*/
110752
110752
  true,
110753
- prefix,
110753
+ prefix2,
110754
110754
  suffix
110755
110755
  );
110756
110756
  if (resolver.hasNodeCheckFlag(
@@ -111823,7 +111823,7 @@ ${lanes.join("\n")}
111823
111823
  if (!decoratorExpressions) {
111824
111824
  return void 0;
111825
111825
  }
111826
- const prefix = getClassMemberPrefix(node, member);
111826
+ const prefix2 = getClassMemberPrefix(node, member);
111827
111827
  const memberName = getExpressionForPropertyName(
111828
111828
  member,
111829
111829
  /*generateNameForComputedPropertyName*/
@@ -111836,7 +111836,7 @@ ${lanes.join("\n")}
111836
111836
  const descriptor = isPropertyDeclaration(member) && !hasAccessorModifier(member) ? factory2.createVoidZero() : factory2.createNull();
111837
111837
  const helper = emitHelpers().createDecorateHelper(
111838
111838
  decoratorExpressions,
111839
- prefix,
111839
+ prefix2,
111840
111840
  memberName,
111841
111841
  descriptor
111842
111842
  );
@@ -113739,13 +113739,13 @@ ${lanes.join("\n")}
113739
113739
  3072
113740
113740
  /* NoComments */
113741
113741
  );
113742
- const prefix = kind === "get" || kind === "set" ? kind : void 0;
113742
+ const prefix2 = kind === "get" || kind === "set" ? kind : void 0;
113743
113743
  const functionName = factory2.createStringLiteralFromNode(
113744
113744
  name,
113745
113745
  /*isSingleQuote*/
113746
113746
  void 0
113747
113747
  );
113748
- const namedFunction = emitHelpers().createSetFunctionNameHelper(func, functionName, prefix);
113748
+ const namedFunction = emitHelpers().createSetFunctionNameHelper(func, functionName, prefix2);
113749
113749
  const method = factory2.createPropertyAssignment(factory2.createIdentifier(kind), namedFunction);
113750
113750
  setOriginalNode(method, original);
113751
113751
  setSourceMapRange(method, moveRangePastDecorators(original));
@@ -134525,9 +134525,9 @@ ${lanes.join("\n")}
134525
134525
  emitExpression(node, parenthesizerRule);
134526
134526
  }
134527
134527
  }
134528
- function emitNodeWithPrefix(prefix, prefixWriter, node, emit2) {
134528
+ function emitNodeWithPrefix(prefix2, prefixWriter, node, emit2) {
134529
134529
  if (node) {
134530
- prefixWriter(prefix);
134530
+ prefixWriter(prefix2);
134531
134531
  emit2(node);
134532
134532
  }
134533
134533
  }
@@ -135265,10 +135265,10 @@ ${lanes.join("\n")}
135265
135265
  return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
135266
135266
  }
135267
135267
  }
135268
- function generateNameCached(node, privateName, flags, prefix, suffix) {
135268
+ function generateNameCached(node, privateName, flags, prefix2, suffix) {
135269
135269
  const nodeId = getNodeId(node);
135270
135270
  const cache = privateName ? nodeIdToGeneratedPrivateName : nodeIdToGeneratedName;
135271
- return cache[nodeId] || (cache[nodeId] = generateNameForNode(node, privateName, flags ?? 0, formatGeneratedNamePart(prefix, generateName), formatGeneratedNamePart(suffix)));
135271
+ return cache[nodeId] || (cache[nodeId] = generateNameForNode(node, privateName, flags ?? 0, formatGeneratedNamePart(prefix2, generateName), formatGeneratedNamePart(suffix)));
135272
135272
  }
135273
135273
  function isUniqueName(name, privateName) {
135274
135274
  return isFileLevelUniqueNameInCurrentFile(name, privateName) && !isReservedName(name, privateName) && !generatedNames.has(name);
@@ -135335,15 +135335,15 @@ ${lanes.join("\n")}
135335
135335
  break;
135336
135336
  }
135337
135337
  }
135338
- function makeTempVariableName(flags, reservedInNestedScopes, privateName, prefix, suffix) {
135339
- if (prefix.length > 0 && prefix.charCodeAt(0) === 35) {
135340
- prefix = prefix.slice(1);
135338
+ function makeTempVariableName(flags, reservedInNestedScopes, privateName, prefix2, suffix) {
135339
+ if (prefix2.length > 0 && prefix2.charCodeAt(0) === 35) {
135340
+ prefix2 = prefix2.slice(1);
135341
135341
  }
135342
- const key = formatGeneratedName(privateName, prefix, "", suffix);
135342
+ const key = formatGeneratedName(privateName, prefix2, "", suffix);
135343
135343
  let tempFlags2 = getTempFlags(key);
135344
135344
  if (flags && !(tempFlags2 & flags)) {
135345
135345
  const name = flags === 268435456 ? "_i" : "_n";
135346
- const fullName = formatGeneratedName(privateName, prefix, name, suffix);
135346
+ const fullName = formatGeneratedName(privateName, prefix2, name, suffix);
135347
135347
  if (isUniqueName(fullName, privateName)) {
135348
135348
  tempFlags2 |= flags;
135349
135349
  if (privateName) {
@@ -135360,7 +135360,7 @@ ${lanes.join("\n")}
135360
135360
  tempFlags2++;
135361
135361
  if (count !== 8 && count !== 13) {
135362
135362
  const name = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26);
135363
- const fullName = formatGeneratedName(privateName, prefix, name, suffix);
135363
+ const fullName = formatGeneratedName(privateName, prefix2, name, suffix);
135364
135364
  if (isUniqueName(fullName, privateName)) {
135365
135365
  if (privateName) {
135366
135366
  reservePrivateNameInNestedScopes(fullName);
@@ -135373,15 +135373,15 @@ ${lanes.join("\n")}
135373
135373
  }
135374
135374
  }
135375
135375
  }
135376
- function makeUniqueName2(baseName, checkFn = isUniqueName, optimistic, scoped, privateName, prefix, suffix) {
135376
+ function makeUniqueName2(baseName, checkFn = isUniqueName, optimistic, scoped, privateName, prefix2, suffix) {
135377
135377
  if (baseName.length > 0 && baseName.charCodeAt(0) === 35) {
135378
135378
  baseName = baseName.slice(1);
135379
135379
  }
135380
- if (prefix.length > 0 && prefix.charCodeAt(0) === 35) {
135381
- prefix = prefix.slice(1);
135380
+ if (prefix2.length > 0 && prefix2.charCodeAt(0) === 35) {
135381
+ prefix2 = prefix2.slice(1);
135382
135382
  }
135383
135383
  if (optimistic) {
135384
- const fullName = formatGeneratedName(privateName, prefix, baseName, suffix);
135384
+ const fullName = formatGeneratedName(privateName, prefix2, baseName, suffix);
135385
135385
  if (checkFn(fullName, privateName)) {
135386
135386
  if (privateName) {
135387
135387
  reservePrivateNameInNestedScopes(fullName);
@@ -135398,7 +135398,7 @@ ${lanes.join("\n")}
135398
135398
  }
135399
135399
  let i = 1;
135400
135400
  while (true) {
135401
- const fullName = formatGeneratedName(privateName, prefix, baseName + i, suffix);
135401
+ const fullName = formatGeneratedName(privateName, prefix2, baseName + i, suffix);
135402
135402
  if (checkFn(fullName, privateName)) {
135403
135403
  if (privateName) {
135404
135404
  reservePrivateNameInNestedScopes(fullName);
@@ -135495,7 +135495,7 @@ ${lanes.join("\n")}
135495
135495
  ""
135496
135496
  );
135497
135497
  }
135498
- function generateNameForMethodOrAccessor(node, privateName, prefix, suffix) {
135498
+ function generateNameForMethodOrAccessor(node, privateName, prefix2, suffix) {
135499
135499
  if (isIdentifier3(node.name)) {
135500
135500
  return generateNameCached(node.name, privateName);
135501
135501
  }
@@ -135504,11 +135504,11 @@ ${lanes.join("\n")}
135504
135504
  /*reservedInNestedScopes*/
135505
135505
  false,
135506
135506
  privateName,
135507
- prefix,
135507
+ prefix2,
135508
135508
  suffix
135509
135509
  );
135510
135510
  }
135511
- function generateNameForNode(node, privateName, flags, prefix, suffix) {
135511
+ function generateNameForNode(node, privateName, flags, prefix2, suffix) {
135512
135512
  switch (node.kind) {
135513
135513
  case 80:
135514
135514
  case 81:
@@ -135518,20 +135518,20 @@ ${lanes.join("\n")}
135518
135518
  !!(flags & 16),
135519
135519
  !!(flags & 8),
135520
135520
  privateName,
135521
- prefix,
135521
+ prefix2,
135522
135522
  suffix
135523
135523
  );
135524
135524
  case 267:
135525
135525
  case 266:
135526
- Debug.assert(!prefix && !suffix && !privateName);
135526
+ Debug.assert(!prefix2 && !suffix && !privateName);
135527
135527
  return generateNameForModuleOrEnum(node);
135528
135528
  case 272:
135529
135529
  case 278:
135530
- Debug.assert(!prefix && !suffix && !privateName);
135530
+ Debug.assert(!prefix2 && !suffix && !privateName);
135531
135531
  return generateNameForImportOrExportDeclaration(node);
135532
135532
  case 262:
135533
135533
  case 263: {
135534
- Debug.assert(!prefix && !suffix && !privateName);
135534
+ Debug.assert(!prefix2 && !suffix && !privateName);
135535
135535
  const name = node.name;
135536
135536
  if (name && !isGeneratedIdentifier(name)) {
135537
135537
  return generateNameForNode(
@@ -135539,29 +135539,29 @@ ${lanes.join("\n")}
135539
135539
  /*privateName*/
135540
135540
  false,
135541
135541
  flags,
135542
- prefix,
135542
+ prefix2,
135543
135543
  suffix
135544
135544
  );
135545
135545
  }
135546
135546
  return generateNameForExportDefault();
135547
135547
  }
135548
135548
  case 277:
135549
- Debug.assert(!prefix && !suffix && !privateName);
135549
+ Debug.assert(!prefix2 && !suffix && !privateName);
135550
135550
  return generateNameForExportDefault();
135551
135551
  case 231:
135552
- Debug.assert(!prefix && !suffix && !privateName);
135552
+ Debug.assert(!prefix2 && !suffix && !privateName);
135553
135553
  return generateNameForClassExpression();
135554
135554
  case 174:
135555
135555
  case 177:
135556
135556
  case 178:
135557
- return generateNameForMethodOrAccessor(node, privateName, prefix, suffix);
135557
+ return generateNameForMethodOrAccessor(node, privateName, prefix2, suffix);
135558
135558
  case 167:
135559
135559
  return makeTempVariableName(
135560
135560
  0,
135561
135561
  /*reservedInNestedScopes*/
135562
135562
  true,
135563
135563
  privateName,
135564
- prefix,
135564
+ prefix2,
135565
135565
  suffix
135566
135566
  );
135567
135567
  default:
@@ -135570,18 +135570,18 @@ ${lanes.join("\n")}
135570
135570
  /*reservedInNestedScopes*/
135571
135571
  false,
135572
135572
  privateName,
135573
- prefix,
135573
+ prefix2,
135574
135574
  suffix
135575
135575
  );
135576
135576
  }
135577
135577
  }
135578
135578
  function makeName(name) {
135579
135579
  const autoGenerate = name.emitNode.autoGenerate;
135580
- const prefix = formatGeneratedNamePart(autoGenerate.prefix, generateName);
135580
+ const prefix2 = formatGeneratedNamePart(autoGenerate.prefix, generateName);
135581
135581
  const suffix = formatGeneratedNamePart(autoGenerate.suffix);
135582
135582
  switch (autoGenerate.flags & 7) {
135583
135583
  case 1:
135584
- return makeTempVariableName(0, !!(autoGenerate.flags & 8), isPrivateIdentifier(name), prefix, suffix);
135584
+ return makeTempVariableName(0, !!(autoGenerate.flags & 8), isPrivateIdentifier(name), prefix2, suffix);
135585
135585
  case 2:
135586
135586
  Debug.assertNode(name, isIdentifier3);
135587
135587
  return makeTempVariableName(
@@ -135589,7 +135589,7 @@ ${lanes.join("\n")}
135589
135589
  !!(autoGenerate.flags & 8),
135590
135590
  /*privateName*/
135591
135591
  false,
135592
- prefix,
135592
+ prefix2,
135593
135593
  suffix
135594
135594
  );
135595
135595
  case 3:
@@ -135599,7 +135599,7 @@ ${lanes.join("\n")}
135599
135599
  !!(autoGenerate.flags & 16),
135600
135600
  !!(autoGenerate.flags & 8),
135601
135601
  isPrivateIdentifier(name),
135602
- prefix,
135602
+ prefix2,
135603
135603
  suffix
135604
135604
  );
135605
135605
  }
@@ -152155,8 +152155,8 @@ ${lanes.join("\n")}
152155
152155
  }
152156
152156
  function buildLinkParts(link, checker) {
152157
152157
  var _a;
152158
- const prefix = isJSDocLink(link) ? "link" : isJSDocLinkCode(link) ? "linkcode" : "linkplain";
152159
- const parts = [linkPart(`{@${prefix} `)];
152158
+ const prefix2 = isJSDocLink(link) ? "link" : isJSDocLinkCode(link) ? "linkcode" : "linkplain";
152159
+ const parts = [linkPart(`{@${prefix2} `)];
152160
152160
  if (!link.name) {
152161
152161
  if (link.text) {
152162
152162
  parts.push(linkTextPart(link.text));
@@ -153629,9 +153629,9 @@ ${lanes.join("\n")}
153629
153629
  let token = 0;
153630
153630
  let lastNonTriviaToken = 0;
153631
153631
  const templateStack = [];
153632
- const { prefix, pushTemplate } = getPrefixFromLexState(lexState);
153633
- text = prefix + text;
153634
- const offset = prefix.length;
153632
+ const { prefix: prefix2, pushTemplate } = getPrefixFromLexState(lexState);
153633
+ text = prefix2 + text;
153634
+ const offset = prefix2.length;
153635
153635
  if (pushTemplate) {
153636
153636
  templateStack.push(
153637
153637
  16
@@ -162789,11 +162789,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
162789
162789
  if (decls && decls.some((d3) => d3.parent === scopeDecl)) {
162790
162790
  return factory.createIdentifier(symbol.name);
162791
162791
  }
162792
- const prefix = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.parent, scopeDecl, isTypeNode2);
162793
- if (prefix === void 0) {
162792
+ const prefix2 = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.parent, scopeDecl, isTypeNode2);
162793
+ if (prefix2 === void 0) {
162794
162794
  return void 0;
162795
162795
  }
162796
- return isTypeNode2 ? factory.createQualifiedName(prefix, factory.createIdentifier(symbol.name)) : factory.createPropertyAccessExpression(prefix, symbol.name);
162796
+ return isTypeNode2 ? factory.createQualifiedName(prefix2, factory.createIdentifier(symbol.name)) : factory.createPropertyAccessExpression(prefix2, symbol.name);
162797
162797
  }
162798
162798
  }
162799
162799
  function getExtractableParent(node) {
@@ -164108,13 +164108,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164108
164108
  if (textChangeRange) {
164109
164109
  if (version2 !== sourceFile.version) {
164110
164110
  let newText;
164111
- const prefix = textChangeRange.span.start !== 0 ? sourceFile.text.substr(0, textChangeRange.span.start) : "";
164111
+ const prefix2 = textChangeRange.span.start !== 0 ? sourceFile.text.substr(0, textChangeRange.span.start) : "";
164112
164112
  const suffix = textSpanEnd(textChangeRange.span) !== sourceFile.text.length ? sourceFile.text.substr(textSpanEnd(textChangeRange.span)) : "";
164113
164113
  if (textChangeRange.newLength === 0) {
164114
- newText = prefix && suffix ? prefix + suffix : prefix || suffix;
164114
+ newText = prefix2 && suffix ? prefix2 + suffix : prefix2 || suffix;
164115
164115
  } else {
164116
164116
  const changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength);
164117
- newText = prefix && suffix ? prefix + changedText + suffix : prefix ? prefix + changedText : changedText + suffix;
164117
+ newText = prefix2 && suffix ? prefix2 + changedText + suffix : prefix2 ? prefix2 + changedText : changedText + suffix;
164118
164118
  }
164119
164119
  const newSourceFile = updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
164120
164120
  setSourceFileFields(newSourceFile, scriptSnapshot, version2);
@@ -166244,8 +166244,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166244
166244
  const end = pos + 6;
166245
166245
  const typeChecker = program.getTypeChecker();
166246
166246
  const symbol = typeChecker.getSymbolAtLocation(node.parent);
166247
- const prefix = symbol ? `${typeChecker.symbolToString(symbol, node.parent)} ` : "";
166248
- return { text: `${prefix}static {}`, pos, end };
166247
+ const prefix2 = symbol ? `${typeChecker.symbolToString(symbol, node.parent)} ` : "";
166248
+ return { text: `${prefix2}static {}`, pos, end };
166249
166249
  }
166250
166250
  const declName = isAssignedExpression(node) ? node.parent.name : Debug.checkDefined(getNameOfDeclaration(node), "Expected call hierarchy item to have a name");
166251
166251
  let text = isIdentifier3(declName) ? idText(declName) : isStringOrNumericLiteralLike(declName) ? declName.text : isComputedPropertyName(declName) ? isStringOrNumericLiteralLike(declName.expression) ? declName.expression.text : void 0 : void 0;
@@ -169591,18 +169591,18 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
169591
169591
  const commentNode = node.parent;
169592
169592
  const { leftSibling, rightSibling } = getLeftAndRightSiblings(node);
169593
169593
  let pos = commentNode.getStart();
169594
- let prefix = "";
169594
+ let prefix2 = "";
169595
169595
  if (!leftSibling && commentNode.comment) {
169596
169596
  pos = findEndOfTextBetween(commentNode, commentNode.getStart(), node.getStart());
169597
- prefix = `${newLine} */${newLine}`;
169597
+ prefix2 = `${newLine} */${newLine}`;
169598
169598
  }
169599
169599
  if (leftSibling) {
169600
169600
  if (fixAll && isJSDocTypedefTag(leftSibling)) {
169601
169601
  pos = node.getStart();
169602
- prefix = "";
169602
+ prefix2 = "";
169603
169603
  } else {
169604
169604
  pos = findEndOfTextBetween(commentNode, leftSibling.getStart(), node.getStart());
169605
- prefix = `${newLine} */${newLine}`;
169605
+ prefix2 = `${newLine} */${newLine}`;
169606
169606
  }
169607
169607
  }
169608
169608
  let end = commentNode.getEnd();
@@ -169616,7 +169616,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
169616
169616
  suffix = `${newLine}/**${newLine} * `;
169617
169617
  }
169618
169618
  }
169619
- changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix, suffix });
169619
+ changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix: prefix2, suffix });
169620
169620
  }
169621
169621
  function getLeftAndRightSiblings(typedefNode) {
169622
169622
  const commentNode = typedefNode.parent;
@@ -174034,9 +174034,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
174034
174034
  result.push(createDeleteFix(deletion, [Diagnostics.Remove_unused_declaration_for_Colon_0, name.getText(sourceFile)]));
174035
174035
  }
174036
174036
  }
174037
- const prefix = ts_textChanges_exports.ChangeTracker.with(context, (t) => tryPrefixDeclaration(t, errorCode, sourceFile, token));
174038
- if (prefix.length) {
174039
- result.push(createCodeFixAction(fixName3, prefix, [Diagnostics.Prefix_0_with_an_underscore, token.getText(sourceFile)], fixIdPrefix, Diagnostics.Prefix_all_unused_declarations_with_where_possible));
174037
+ const prefix2 = ts_textChanges_exports.ChangeTracker.with(context, (t) => tryPrefixDeclaration(t, errorCode, sourceFile, token));
174038
+ if (prefix2.length) {
174039
+ result.push(createCodeFixAction(fixName3, prefix2, [Diagnostics.Prefix_0_with_an_underscore, token.getText(sourceFile)], fixIdPrefix, Diagnostics.Prefix_all_unused_declarations_with_where_possible));
174040
174040
  }
174041
174041
  return result;
174042
174042
  },
@@ -183737,9 +183737,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
183737
183737
  function getDirectoryMatches(directoryName) {
183738
183738
  return mapDefined(tryGetDirectories(host, directoryName), (dir) => dir === "node_modules" ? void 0 : directoryResult(dir));
183739
183739
  }
183740
- function trimPrefixAndSuffix(path, prefix) {
183740
+ function trimPrefixAndSuffix(path, prefix2) {
183741
183741
  return firstDefined(matchingSuffixes, (suffix) => {
183742
- const inner = withoutStartAndEnd(normalizePath(path), prefix, suffix);
183742
+ const inner = withoutStartAndEnd(normalizePath(path), prefix2, suffix);
183743
183743
  return inner === void 0 ? void 0 : removeLeadingDirectorySeparator(inner);
183744
183744
  });
183745
183745
  }
@@ -183772,7 +183772,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
183772
183772
  if (!match) {
183773
183773
  return void 0;
183774
183774
  }
183775
- const [, prefix, kind, toComplete] = match;
183775
+ const [, prefix2, kind, toComplete] = match;
183776
183776
  const scriptPath = getDirectoryPath(sourceFile.path);
183777
183777
  const names = kind === "path" ? getCompletionEntriesForDirectoryFragment(
183778
183778
  toComplete,
@@ -183785,7 +183785,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
183785
183785
  true,
183786
183786
  sourceFile.path
183787
183787
  ) : kind === "types" ? getCompletionEntriesFromTypings(program, host, moduleSpecifierResolutionHost, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions, 1, sourceFile)) : Debug.fail();
183788
- return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values()));
183788
+ return addReplacementSpans(toComplete, range.pos + prefix2.length, arrayFrom(names.values()));
183789
183789
  }
183790
183790
  function getCompletionEntriesFromTypings(program, host, moduleSpecifierResolutionHost, scriptPath, fragmentDirectory, extensionOptions, result = createNameAndKindSet()) {
183791
183791
  const options = program.getCompilerOptions();
@@ -190136,8 +190136,8 @@ ${content}
190136
190136
  ), spacePart()];
190137
190137
  function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) {
190138
190138
  const infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile);
190139
- return map(infos, ({ isVariadic, parameters, prefix, suffix }) => {
190140
- const prefixDisplayParts = [...callTargetDisplayParts, ...prefix];
190139
+ return map(infos, ({ isVariadic, parameters, prefix: prefix2, suffix }) => {
190140
+ const prefixDisplayParts = [...callTargetDisplayParts, ...prefix2];
190141
190141
  const suffixDisplayParts = [...suffix, ...returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)];
190142
190142
  const documentation = candidateSignature.getDocumentationComment(checker);
190143
190143
  const tags = candidateSignature.getJsDocTags();
@@ -192224,11 +192224,11 @@ ${options.prefix}` : "\n" : options.prefix
192224
192224
  const noIndent = options.indentation !== void 0 || getLineStartPositionForPosition(pos, targetSourceFile) === pos ? text : text.replace(/^\s+/, "");
192225
192225
  return (options.prefix || "") + noIndent + (!options.suffix || endsWith(noIndent, options.suffix) ? "" : options.suffix);
192226
192226
  }
192227
- function getFormattedTextOfNode(nodeIn, targetSourceFile, sourceFile, pos, { indentation, prefix, delta }, newLineCharacter, formatContext, validate) {
192227
+ function getFormattedTextOfNode(nodeIn, targetSourceFile, sourceFile, pos, { indentation, prefix: prefix2, delta }, newLineCharacter, formatContext, validate) {
192228
192228
  const { node, text } = getNonformattedText(nodeIn, targetSourceFile, newLineCharacter);
192229
192229
  if (validate) validate(node, text);
192230
192230
  const formatOptions = getFormatCodeSettingsForWriting(formatContext, targetSourceFile);
192231
- const initialIndentation = indentation !== void 0 ? indentation : ts_formatting_exports.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || getLineStartPositionForPosition(pos, targetSourceFile) === pos);
192231
+ const initialIndentation = indentation !== void 0 ? indentation : ts_formatting_exports.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix2 === newLineCharacter || getLineStartPositionForPosition(pos, targetSourceFile) === pos);
192232
192232
  if (delta === void 0) {
192233
192233
  delta = ts_formatting_exports.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? formatOptions.indentSize || 0 : 0;
192234
192234
  }
@@ -209953,9 +209953,9 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
209953
209953
  );
209954
209954
  if (completions === void 0) return void 0;
209955
209955
  if (kind === "completions-full") return completions;
209956
- const prefix = args.prefix || "";
209956
+ const prefix2 = args.prefix || "";
209957
209957
  const entries = mapDefined(completions.entries, (entry) => {
209958
- if (completions.isMemberCompletion || startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) {
209958
+ if (completions.isMemberCompletion || startsWith(entry.name.toLowerCase(), prefix2.toLowerCase())) {
209959
209959
  const convertedSpan = entry.replacementSpan ? toProtocolTextSpan(entry.replacementSpan, scriptInfo) : void 0;
209960
209960
  return {
209961
209961
  ...entry,
@@ -214868,15 +214868,15 @@ var require_to_regex_range = __commonJS({
214868
214868
  }
214869
214869
  return tokens;
214870
214870
  }
214871
- function filterPatterns(arr, comparison, prefix, intersection, options) {
214871
+ function filterPatterns(arr, comparison, prefix2, intersection, options) {
214872
214872
  let result = [];
214873
214873
  for (let ele of arr) {
214874
214874
  let { string } = ele;
214875
214875
  if (!intersection && !contains(comparison, "string", string)) {
214876
- result.push(prefix + string);
214876
+ result.push(prefix2 + string);
214877
214877
  }
214878
214878
  if (intersection && contains(comparison, "string", string)) {
214879
- result.push(prefix + string);
214879
+ result.push(prefix2 + string);
214880
214880
  }
214881
214881
  }
214882
214882
  return result;
@@ -214987,7 +214987,7 @@ var require_fill_range = __commonJS({
214987
214987
  var toSequence = (parts, options, maxLen) => {
214988
214988
  parts.negatives.sort((a, b4) => a < b4 ? -1 : a > b4 ? 1 : 0);
214989
214989
  parts.positives.sort((a, b4) => a < b4 ? -1 : a > b4 ? 1 : 0);
214990
- let prefix = options.capture ? "" : "?:";
214990
+ let prefix2 = options.capture ? "" : "?:";
214991
214991
  let positives = "";
214992
214992
  let negatives = "";
214993
214993
  let result;
@@ -214995,7 +214995,7 @@ var require_fill_range = __commonJS({
214995
214995
  positives = parts.positives.map((v) => toMaxLen(String(v), maxLen)).join("|");
214996
214996
  }
214997
214997
  if (parts.negatives.length) {
214998
- negatives = `-(${prefix}${parts.negatives.map((v) => toMaxLen(String(v), maxLen)).join("|")})`;
214998
+ negatives = `-(${prefix2}${parts.negatives.map((v) => toMaxLen(String(v), maxLen)).join("|")})`;
214999
214999
  }
215000
215000
  if (positives && negatives) {
215001
215001
  result = `${positives}|${negatives}`;
@@ -215003,7 +215003,7 @@ var require_fill_range = __commonJS({
215003
215003
  result = positives || negatives;
215004
215004
  }
215005
215005
  if (options.wrap) {
215006
- return `(${prefix}${result})`;
215006
+ return `(${prefix2}${result})`;
215007
215007
  }
215008
215008
  return result;
215009
215009
  };
@@ -215019,8 +215019,8 @@ var require_fill_range = __commonJS({
215019
215019
  var toRegex = (start, end, options) => {
215020
215020
  if (Array.isArray(start)) {
215021
215021
  let wrap = options.wrap === true;
215022
- let prefix = options.capture ? "" : "?:";
215023
- return wrap ? `(${prefix}${start.join("|")})` : start.join("|");
215022
+ let prefix2 = options.capture ? "" : "?:";
215023
+ return wrap ? `(${prefix2}${start.join("|")})` : start.join("|");
215024
215024
  }
215025
215025
  return toRegexRange(start, end, options);
215026
215026
  };
@@ -215142,20 +215142,20 @@ var require_compile = __commonJS({
215142
215142
  const invalidBlock = utils.isInvalidBrace(parent);
215143
215143
  const invalidNode = node.invalid === true && options.escapeInvalid === true;
215144
215144
  const invalid = invalidBlock === true || invalidNode === true;
215145
- const prefix = options.escapeInvalid === true ? "\\" : "";
215145
+ const prefix2 = options.escapeInvalid === true ? "\\" : "";
215146
215146
  let output = "";
215147
215147
  if (node.isOpen === true) {
215148
- return prefix + node.value;
215148
+ return prefix2 + node.value;
215149
215149
  }
215150
215150
  if (node.isClose === true) {
215151
- console.log("node.isClose", prefix, node.value);
215152
- return prefix + node.value;
215151
+ console.log("node.isClose", prefix2, node.value);
215152
+ return prefix2 + node.value;
215153
215153
  }
215154
215154
  if (node.type === "open") {
215155
- return invalid ? prefix + node.value : "(";
215155
+ return invalid ? prefix2 + node.value : "(";
215156
215156
  }
215157
215157
  if (node.type === "close") {
215158
- return invalid ? prefix + node.value : ")";
215158
+ return invalid ? prefix2 + node.value : ")";
215159
215159
  }
215160
215160
  if (node.type === "comma") {
215161
215161
  return node.prev.type === "comma" ? "" : invalid ? node.value : "|";
@@ -216191,10 +216191,10 @@ var require_scan = __commonJS({
216191
216191
  isGlob = false;
216192
216192
  }
216193
216193
  let base = str;
216194
- let prefix = "";
216194
+ let prefix2 = "";
216195
216195
  let glob = "";
216196
216196
  if (start > 0) {
216197
- prefix = str.slice(0, start);
216197
+ prefix2 = str.slice(0, start);
216198
216198
  str = str.slice(start);
216199
216199
  lastIndex -= start;
216200
216200
  }
@@ -216219,7 +216219,7 @@ var require_scan = __commonJS({
216219
216219
  }
216220
216220
  }
216221
216221
  const state = {
216222
- prefix,
216222
+ prefix: prefix2,
216223
216223
  input,
216224
216224
  start,
216225
216225
  base,
@@ -216248,7 +216248,7 @@ var require_scan = __commonJS({
216248
216248
  if (opts.tokens) {
216249
216249
  if (idx === 0 && start !== 0) {
216250
216250
  tokens[idx].isPrefix = true;
216251
- tokens[idx].value = prefix;
216251
+ tokens[idx].value = prefix2;
216252
216252
  } else {
216253
216253
  tokens[idx].value = value;
216254
216254
  }
@@ -220466,8 +220466,8 @@ ${nodeLocation}` : message;
220466
220466
  errors.ArgumentTypeError = ArgumentTypeError;
220467
220467
  class PathNotFoundError extends BaseError {
220468
220468
  path;
220469
- constructor(path2, prefix = "Path") {
220470
- super(`${prefix} not found: ${path2}`);
220469
+ constructor(path2, prefix2 = "Path") {
220470
+ super(`${prefix2} not found: ${path2}`);
220471
220471
  this.path = path2;
220472
220472
  }
220473
220473
  code = "ENOENT";
@@ -276700,7 +276700,7 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
276700
276700
  };
276701
276701
 
276702
276702
  // src/cli/index.ts
276703
- var import_picocolors18 = __toESM(require_picocolors(), 1);
276703
+ var import_picocolors19 = __toESM(require_picocolors(), 1);
276704
276704
  var import_fs12 = require("fs");
276705
276705
  var import_path7 = require("path");
276706
276706
  var import_child_process2 = require("child_process");
@@ -276770,6 +276770,7 @@ var ERROR_CODES = {
276770
276770
  browser_database_url_blocked: client("auth", "A database connection string must not be used from a browser context \u2014 it carries DB credentials."),
276771
276771
  datasource_registration_failed: client("auth", "Failed to register the provided databaseUrl as a datasource."),
276772
276772
  datasource_connection_unsupported: wire("validation", 400, false, "This deployment cannot register a direct (connection string) datasource \u2014 use the signed endpoint kind."),
276773
+ datasource_direct_deprecated: wire("validation", 410, false, "The direct (connection string) datasource is deprecated. Register a signed Data Source endpoint instead \u2014 your app owns the write and your credentials never leave it."),
276773
276774
  // ── permission / capability (403) ──────────────────────────────────
276774
276775
  capability_scope_denied: wire("capability", 403, false, "The connection's resolved scope does not cover the attempted action."),
276775
276776
  issuer_register_forbidden: wire("permission", 403, false, "Registering a trusted issuer requires a secret (sk_) API key."),
@@ -276846,6 +276847,7 @@ var ERROR_CODES = {
276846
276847
  unique_violation: wire("conflict", 409, false, "A value violates a uniqueness constraint."),
276847
276848
  check_violation: wire("validation", 400, false, "A value violates a database check constraint."),
276848
276849
  constraint_violation: wire("validation", 400, false, "A database integrity constraint was violated."),
276850
+ column_type_mismatch: wire("validation", 400, false, 'A structured (JSON) value was written to a column whose database type is not jsonb. The column was not provisioned as jsonb (often a pre-existing column adopted by `ablo push`); storing the value would silently corrupt it to "[object Object]". Run `ablo migrate` to alter the column to jsonb.'),
276849
276851
  // ── tenant / unknown model (400) ───────────────────────────────────
276850
276852
  server_execute_unknown_model: wire("tenant", 400, false, "Wrote to a model the server does not know. The server keeps its own copy of the schema \u2014 run `ablo push` (or keep `ablo dev` running) to upload `ablo/schema.ts` before writing to new or changed models."),
276851
276853
  mutate_create_unknown_model: wire("tenant", 400, false, "Created a model the server does not know. Run `ablo push` (or keep `ablo dev` running) to upload `ablo/schema.ts` first \u2014 the server keeps its own copy of the schema."),
@@ -277009,6 +277011,18 @@ var ERROR_CODES = {
277009
277011
  invalid_schema: wire("validation", 400, false, "The submitted schema could not be parsed."),
277010
277012
  incompatible_change: wire("conflict", 409, false, "The schema change is incompatible with the current schema.")
277011
277013
  };
277014
+ function errorCodeSpec(code) {
277015
+ return ERROR_CODES[code];
277016
+ }
277017
+ function classifyRecovery(code) {
277018
+ const spec = errorCodeSpec(code);
277019
+ if (!spec) return "none";
277020
+ if (spec.recovery) return spec.recovery;
277021
+ if (spec.retryable) return "transient";
277022
+ if (spec.httpStatus === 403) return "permission";
277023
+ if (spec.category === "auth") return "auth_blocked";
277024
+ return "none";
277025
+ }
277012
277026
 
277013
277027
  // src/coordination/schema.ts
277014
277028
  init_cjs_shims();
@@ -277134,8 +277148,8 @@ var claimStatusSchema = import_zod3.z.enum([
277134
277148
  ]);
277135
277149
  var wireClaimBaseSchema = targetRefSchema.extend({
277136
277150
  claimId: import_zod3.z.string(),
277137
- /** Verb the agent expects: 'update' | 'create' | 'editing' | 'reviewing' … */
277138
- action: import_zod3.z.string(),
277151
+ /** Human-readable phase: 'editing' | 'reviewing' | 'forecasting' … */
277152
+ reason: import_zod3.z.string(),
277139
277153
  /** Server-stamped declaration time (epoch ms). */
277140
277154
  declaredAt: import_zod3.z.number(),
277141
277155
  /** Server-computed TTL deadline (epoch ms). Readers treat as advisory. */
@@ -277144,7 +277158,7 @@ var wireClaimBaseSchema = targetRefSchema.extend({
277144
277158
  });
277145
277159
  var wireClaimSummarySchema = wireClaimBaseSchema.pick({
277146
277160
  claimId: true,
277147
- action: true,
277161
+ reason: true,
277148
277162
  declaredAt: true,
277149
277163
  expiresAt: true,
277150
277164
  entityType: true,
@@ -277189,8 +277203,7 @@ var modelClaimSchema = import_zod3.z.object({
277189
277203
  id: import_zod3.z.string(),
277190
277204
  actor: import_zod3.z.string(),
277191
277205
  participantKind: wireParticipantKindSchema,
277192
- /** Human-readable phase (`'editing'`). The public SDK field; the WS/HTTP
277193
- * wire carries the same value as `action` (healed on read). */
277206
+ /** Human-readable phase (`'editing'`). */
277194
277207
  reason: import_zod3.z.string(),
277195
277208
  description: import_zod3.z.string().optional(),
277196
277209
  field: import_zod3.z.string().optional(),
@@ -277201,7 +277214,7 @@ var modelClaimSchema = import_zod3.z.object({
277201
277214
  }).readonly();
277202
277215
  var claimBeginPayloadSchema = targetRefSchema.extend({
277203
277216
  claimId: import_zod3.z.string(),
277204
- action: import_zod3.z.string(),
277217
+ reason: import_zod3.z.string(),
277205
277218
  /** Hint for `expiresAt`; the server caps it. */
277206
277219
  estimatedMs: import_zod3.z.number().optional(),
277207
277220
  /**
@@ -277331,6 +277344,20 @@ var AbloError = class extends Error {
277331
277344
  ...this.details ?? {}
277332
277345
  };
277333
277346
  }
277347
+ /**
277348
+ * A single, leak-proof line for logs and `String(err)` / template
277349
+ * interpolation: `AbloValidationError [code]: message (see docs) [request_id: …]`.
277350
+ *
277351
+ * Deliberately does NOT dump `details`, `cause`, or the stack — the thing that
277352
+ * makes `console.error(richError)` an unreadable wall of text. The structured
277353
+ * payload stays available via {@link toJSON}; this is the human one-liner.
277354
+ */
277355
+ toString() {
277356
+ const code = this.code ? ` [${this.code}]` : "";
277357
+ const docs = this.docUrl ? ` (see ${this.docUrl})` : "";
277358
+ const req = this.requestId ? ` [request_id: ${this.requestId}]` : "";
277359
+ return `${this.name}${code}: ${this.message}${docs}${req}`;
277360
+ }
277334
277361
  };
277335
277362
  function docUrlForCode(code) {
277336
277363
  return `https://docs.abloatai.com/errors#${code}`;
@@ -279530,6 +279557,16 @@ function readProjectDatabaseUrl(cwd = process.cwd()) {
279530
279557
  }
279531
279558
  return null;
279532
279559
  }
279560
+ function readProjectApiKey(cwd = process.cwd()) {
279561
+ if (process.env.ABLO_API_KEY) return { key: process.env.ABLO_API_KEY, source: "env" };
279562
+ for (const name of [".env.local", ".env"]) {
279563
+ const path = (0, import_path.resolve)(cwd, name);
279564
+ if (!(0, import_fs2.existsSync)(path)) continue;
279565
+ const match = (0, import_fs2.readFileSync)(path, "utf8").match(/^ABLO_API_KEY=(.+)$/m);
279566
+ if (match?.[1]) return { key: match[1].trim().replace(/^["']|["']$/g, ""), source: name };
279567
+ }
279568
+ return null;
279569
+ }
279533
279570
 
279534
279571
  // src/cli/migrate.ts
279535
279572
  var import_schema3 = require("@abloatai/ablo/schema");
@@ -279548,8 +279585,8 @@ var KIND_BY_PREFIX = [
279548
279585
  ["pk_", "publishable"]
279549
279586
  ];
279550
279587
  function classifyCredentialKind(value) {
279551
- for (const [prefix, kind] of KIND_BY_PREFIX) {
279552
- if (value.startsWith(prefix)) return kind;
279588
+ for (const [prefix2, kind] of KIND_BY_PREFIX) {
279589
+ if (value.startsWith(prefix2)) return kind;
279553
279590
  }
279554
279591
  return null;
279555
279592
  }
@@ -279726,6 +279763,38 @@ function modeFromKey(key) {
279726
279763
  if (/^(sk|rk)_live_/.test(key)) return "production";
279727
279764
  return void 0;
279728
279765
  }
279766
+ function prefix(key) {
279767
+ return key ? key.slice(0, 12) : null;
279768
+ }
279769
+ function describeEffectiveKey(activeMode, envKey, storedEntry) {
279770
+ const effectiveKey = envKey ?? storedEntry?.apiKey;
279771
+ const keySource = envKey ? "env" : storedEntry ? "stored" : null;
279772
+ const keyMode = effectiveKey ? modeFromKey(effectiveKey) ?? null : null;
279773
+ const keyMatchesActiveMode = keyMode ? keyMode === activeMode : null;
279774
+ const keyMatchesStoredActiveKey = envKey && storedEntry?.apiKey ? envKey === storedEntry.apiKey : null;
279775
+ let keyMismatch = null;
279776
+ if (keyMode && keyMode !== activeMode) {
279777
+ const sourceLabel = envKey ? "ABLO_API_KEY" : "stored active key";
279778
+ keyMismatch = {
279779
+ code: "key_mode_mismatch",
279780
+ message: `${sourceLabel} is a ${keyMode} key but the CLI mode is ${activeMode}. Requests use ${sourceLabel} (${prefix(effectiveKey)}...), not the active CLI mode.`
279781
+ };
279782
+ } else if (envKey && storedEntry?.apiKey && envKey !== storedEntry.apiKey) {
279783
+ keyMismatch = {
279784
+ code: "env_key_overrides_stored",
279785
+ message: `ABLO_API_KEY (${prefix(envKey)}...) overrides the stored ${activeMode} key (${prefix(storedEntry.apiKey)}...).`
279786
+ };
279787
+ }
279788
+ return {
279789
+ keyPrefix: prefix(effectiveKey),
279790
+ keySource,
279791
+ keyMode,
279792
+ storedKeyPrefix: prefix(storedEntry?.apiKey),
279793
+ keyMatchesActiveMode,
279794
+ keyMatchesStoredActiveKey,
279795
+ keyMismatch
279796
+ };
279797
+ }
279729
279798
  function normalizeMode(value) {
279730
279799
  return normalizeStoredMode(value);
279731
279800
  }
@@ -279886,6 +279955,21 @@ async function loadSchema(schemaPath, exportName) {
279886
279955
  }
279887
279956
  return schema;
279888
279957
  }
279958
+ function maskKey(key) {
279959
+ return key ? `${key.slice(0, 12)}\u2026` : "(none)";
279960
+ }
279961
+ function describeKeySource(source) {
279962
+ switch (source) {
279963
+ case "env":
279964
+ return "ABLO_API_KEY (environment)";
279965
+ case ".env.local":
279966
+ return ".env.local";
279967
+ case ".env":
279968
+ return ".env";
279969
+ case "login":
279970
+ return "`ablo login` (stored sandbox config)";
279971
+ }
279972
+ }
279889
279973
  async function push(argv) {
279890
279974
  let args;
279891
279975
  try {
@@ -279894,7 +279978,17 @@ async function push(argv) {
279894
279978
  console.error(import_picocolors2.default.red(` ${err instanceof Error ? err.message : String(err)}`));
279895
279979
  process.exit(1);
279896
279980
  }
279897
- if (!args.apiKey) args.apiKey = resolveApiKey();
279981
+ let keySource = "env";
279982
+ if (!args.apiKey) {
279983
+ const fromProject = readProjectApiKey();
279984
+ if (fromProject) {
279985
+ args.apiKey = fromProject.key;
279986
+ keySource = fromProject.source;
279987
+ } else {
279988
+ args.apiKey = resolveApiKey();
279989
+ keySource = "login";
279990
+ }
279991
+ }
279898
279992
  if (!args.apiKey) {
279899
279993
  console.error(
279900
279994
  import_picocolors2.default.red(` No API key.`) + import_picocolors2.default.dim(
@@ -279953,6 +280047,7 @@ async function push(argv) {
279953
280047
  const code = body.code ?? body.reason;
279954
280048
  const serverMsg = body.message ?? body.reason;
279955
280049
  console.error(import_picocolors2.default.red(` Forbidden${code ? ` [${code}]` : ""}: ${serverMsg ?? "permission denied"}`));
280050
+ console.error(import_picocolors2.default.dim(` Push used ${import_picocolors2.default.bold(maskKey(args.apiKey))} from ${describeKeySource(keySource)}.`));
279956
280051
  if (code === "database_role_cannot_enforce_rls") {
279957
280052
  console.error(
279958
280053
  import_picocolors2.default.dim(
@@ -279971,6 +280066,12 @@ async function push(argv) {
279971
280066
  ` Schema pushes need a SECRET key: ${import_picocolors2.default.bold("sk_test_")} (sandbox dev loop) or a dashboard ${import_picocolors2.default.bold("sk_live_")} (production deploy: ${import_picocolors2.default.bold("ABLO_API_KEY=sk_live_\u2026 npx ablo push")}).`
279972
280067
  )
279973
280068
  );
280069
+ } else {
280070
+ console.error(
280071
+ import_picocolors2.default.dim(
280072
+ ` This key isn't authorized to push schema (needs ${import_picocolors2.default.bold("schema:push")}). ` + (keySource === "login" ? `It's your stored ${import_picocolors2.default.bold("ablo login")} sandbox key \u2014 a key in ${import_picocolors2.default.bold(".env.local")} or ${import_picocolors2.default.bold("ABLO_API_KEY")} takes precedence, so put a schema:push key there (sandbox ${import_picocolors2.default.bold("sk_test_")} or production ${import_picocolors2.default.bold("sk_live_")}) and re-push. ` : `Use a schema:push key \u2014 a sandbox ${import_picocolors2.default.bold("sk_test_")} or production ${import_picocolors2.default.bold("sk_live_")}. `) + `Manage keys at https://abloatai.com`
280073
+ )
280074
+ );
279974
280075
  }
279975
280076
  } else {
279976
280077
  console.error(import_picocolors2.default.red(` Push failed (${status2}): ${body.message ?? body.reason ?? bodyText}`));
@@ -281134,20 +281235,50 @@ async function ping(apiUrl2) {
281134
281235
  clearTimeout(t);
281135
281236
  }
281136
281237
  }
281238
+ async function fetchPushedSchema(apiUrl2, apiKey) {
281239
+ if (!apiKey) return null;
281240
+ const ctrl = new AbortController();
281241
+ const t = setTimeout(() => ctrl.abort(), 3e3);
281242
+ try {
281243
+ const res = await fetch(`${apiUrl2}/api/schema`, {
281244
+ headers: { authorization: `Bearer ${apiKey}` },
281245
+ signal: ctrl.signal
281246
+ });
281247
+ if (!res.ok) return null;
281248
+ return await res.json();
281249
+ } catch {
281250
+ return null;
281251
+ } finally {
281252
+ clearTimeout(t);
281253
+ }
281254
+ }
281255
+ function formatConflict(conflict) {
281256
+ if (!conflict) return "";
281257
+ const parts = ["user", "agent", "system"].flatMap((k3) => conflict[k3] ? [`${k3}:${conflict[k3]}`] : []);
281258
+ return parts.length ? `{${parts.join(",")}}` : "";
281259
+ }
281137
281260
  async function status(args = []) {
281138
281261
  const apiUrl2 = (process.env.ABLO_API_URL ?? DEFAULT_URL).replace(/\/+$/, "");
281139
281262
  const cfg = readConfig();
281140
281263
  const mode2 = getMode();
281141
281264
  if (args.includes("--json")) {
281142
281265
  const entry = getKeyEntry(mode2);
281266
+ const key2 = describeEffectiveKey(mode2, process.env.ABLO_API_KEY, entry);
281143
281267
  const plan2 = resolvePushPlan();
281144
281268
  const activeProject2 = getActiveProject();
281269
+ const introspectKey = process.env.ABLO_API_KEY ?? entry?.apiKey;
281270
+ const pushed = await fetchPushedSchema(apiUrl2, introspectKey);
281145
281271
  const out = {
281146
281272
  mode: mode2,
281147
281273
  // The locally-active project (`ablo projects use`); null = org-default.
281148
281274
  project: activeProject2 ?? null,
281149
- keyPrefix: process.env.ABLO_API_KEY ? process.env.ABLO_API_KEY.slice(0, 12) : entry?.apiKey.slice(0, 12) ?? null,
281150
- keySource: process.env.ABLO_API_KEY ? "env" : entry ? "stored" : null,
281275
+ keyPrefix: key2.keyPrefix,
281276
+ keySource: key2.keySource,
281277
+ keyMode: key2.keyMode,
281278
+ storedKeyPrefix: key2.storedKeyPrefix,
281279
+ keyMatchesActiveMode: key2.keyMatchesActiveMode,
281280
+ keyMatchesStoredActiveKey: key2.keyMatchesStoredActiveKey,
281281
+ keyMismatch: key2.keyMismatch,
281151
281282
  organizationId: entry?.organizationId ?? null,
281152
281283
  // What `ablo push` would do right now — the one-command answer to
281153
281284
  // "why did push demand a different key" (2026-06-11 live-key incident).
@@ -281156,6 +281287,15 @@ async function status(args = []) {
281156
281287
  keyPrefix: plan2.apiKey?.slice(0, 12) ?? null,
281157
281288
  keySource: plan2.source
281158
281289
  },
281290
+ // The schema ACTIVE on this key's plane — the typename/conflict the
281291
+ // engine enforces, which may differ from local `schema.ts`. null = the
281292
+ // server didn't answer (unreachable / old server / no key).
281293
+ schema: pushed ? {
281294
+ active: pushed.active,
281295
+ version: pushed.version ?? null,
281296
+ pushedAt: pushed.pushedAt ?? null,
281297
+ models: pushed.models
281298
+ } : null,
281159
281299
  apiUrl: apiUrl2,
281160
281300
  reachable: await ping(apiUrl2)
281161
281301
  };
@@ -281173,6 +281313,11 @@ async function status(args = []) {
281173
281313
  console.log(` ${import_picocolors10.default.yellow("!")} Not logged in \u2014 run ${import_picocolors10.default.bold("ablo login")}.`);
281174
281314
  }
281175
281315
  console.log(` ${import_picocolors10.default.dim("mode")} ${import_picocolors10.default.bold(mode2)}`);
281316
+ const activeEntry = getKeyEntry(mode2);
281317
+ const key = describeEffectiveKey(mode2, process.env.ABLO_API_KEY, activeEntry);
281318
+ if (key.keyMismatch) {
281319
+ console.log(` ${import_picocolors10.default.yellow("!")} ${import_picocolors10.default.yellow(key.keyMismatch.message)}`);
281320
+ }
281176
281321
  const activeProject = getActiveProject();
281177
281322
  console.log(
281178
281323
  ` ${import_picocolors10.default.dim("project")} ${activeProject ? `${import_picocolors10.default.bold(activeProject.slug)} ${import_picocolors10.default.dim(`(${activeProject.id})`)}` : import_picocolors10.default.bold("default")}`
@@ -281187,14 +281332,32 @@ async function status(args = []) {
281187
281332
  console.log(` ${marker} ${m2.padEnd(10)} ${import_picocolors10.default.dim("\u2014 no key")}`);
281188
281333
  }
281189
281334
  }
281190
- const org = getKeyEntry(mode2)?.organizationId;
281335
+ const org = activeEntry?.organizationId;
281191
281336
  if (org) console.log(` ${import_picocolors10.default.dim("org")} ${org}`);
281192
281337
  const plan = resolvePushPlan();
281193
281338
  console.log(
281194
281339
  ` ${import_picocolors10.default.dim("push")} ${plan.apiKey ? `${import_picocolors10.default.bold(plan.flow)} ${import_picocolors10.default.dim(`with ${plan.apiKey.slice(0, 12)}\u2026 (${plan.source})`)}` : `${import_picocolors10.default.bold(plan.flow)} ${import_picocolors10.default.yellow("\u2014 no credential")} ${import_picocolors10.default.dim(`(run ${import_picocolors10.default.bold("ablo login")} or set ${import_picocolors10.default.bold("ABLO_API_KEY")})`)}`}`
281195
281340
  );
281196
281341
  process.stdout.write(` ${import_picocolors10.default.dim("api")} ${apiUrl2} `);
281197
- console.log(await ping(apiUrl2) ? import_picocolors10.default.green("reachable") : import_picocolors10.default.red("unreachable"));
281342
+ const reachable = await ping(apiUrl2);
281343
+ console.log(reachable ? import_picocolors10.default.green("reachable") : import_picocolors10.default.red("unreachable"));
281344
+ if (reachable) {
281345
+ const introspectKey = process.env.ABLO_API_KEY ?? activeEntry?.apiKey;
281346
+ const pushed = await fetchPushedSchema(apiUrl2, introspectKey);
281347
+ if (pushed && pushed.active) {
281348
+ const when = pushed.pushedAt ? ` ${import_picocolors10.default.dim(`@ ${pushed.pushedAt.slice(0, 10)}`)}` : "";
281349
+ const ver = pushed.version != null ? ` ${import_picocolors10.default.dim(`(rev ${pushed.version})`)}` : "";
281350
+ console.log(` ${import_picocolors10.default.dim("schema")} ${import_picocolors10.default.bold(`${pushed.models.length} models pushed`)}${ver}${when}`);
281351
+ for (const m2 of pushed.models) {
281352
+ const tn = m2.typename === m2.key ? import_picocolors10.default.dim(`typename=${m2.typename}`) : import_picocolors10.default.yellow(`typename=${m2.typename}`);
281353
+ const conflict = formatConflict(m2.conflict);
281354
+ const conflictStr = conflict ? ` ${import_picocolors10.default.dim(`conflict=${conflict}`)}` : "";
281355
+ console.log(` ${import_picocolors10.default.dim("\u2022")} ${m2.key.padEnd(14)} ${tn}${conflictStr}`);
281356
+ }
281357
+ } else if (pushed && !pushed.active) {
281358
+ console.log(` ${import_picocolors10.default.dim("schema")} ${import_picocolors10.default.yellow("none pushed")} ${import_picocolors10.default.dim(`(run ${import_picocolors10.default.bold("ablo push")} or ${import_picocolors10.default.bold("ablo dev")})`)}`);
281359
+ }
281360
+ }
281198
281361
  console.log();
281199
281362
  }
281200
281363
 
@@ -282500,9 +282663,86 @@ async function drizzlePull(argv) {
282500
282663
  );
282501
282664
  }
282502
282665
 
282666
+ // src/cli/renderError.ts
282667
+ init_cjs_shims();
282668
+ var import_picocolors18 = __toESM(require_picocolors(), 1);
282669
+ var RECOVERY_HINT = {
282670
+ transient: "This looks transient \u2014 retry in a moment.",
282671
+ permission: "Your key isn't allowed to do this \u2014 check its scopes or role.",
282672
+ session_expiry: "Your session expired \u2014 sign in again.",
282673
+ access_credential_expiry: "Your access credential expired \u2014 refresh it and retry.",
282674
+ auth_blocked: "Authentication was blocked."
282675
+ };
282676
+ function titleForType(type) {
282677
+ const core = type.replace(/^Ablo/, "").replace(/Error$/, "");
282678
+ const spaced = core.replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim();
282679
+ if (!spaced) return "Error";
282680
+ return /error$/i.test(spaced) ? spaced : `${spaced} error`;
282681
+ }
282682
+ function isStringArray(v) {
282683
+ return Array.isArray(v) && v.every((x2) => typeof x2 === "string");
282684
+ }
282685
+ function renderKnownDetails(details, line) {
282686
+ if (!details) return;
282687
+ const { retryAfterSeconds, missingIds, requiredCapability, unexecutable, errors } = details;
282688
+ if (typeof retryAfterSeconds === "number") line(` ${import_picocolors18.default.dim("retry")} after ${retryAfterSeconds}s`);
282689
+ if (isStringArray(missingIds) && missingIds.length > 0) {
282690
+ const shown = missingIds.slice(0, 5).join(", ");
282691
+ const more = missingIds.length > 5 ? ` (+${missingIds.length - 5} more)` : "";
282692
+ line(` ${import_picocolors18.default.dim("missing")} ${shown}${more}`);
282693
+ }
282694
+ if (typeof requiredCapability === "string") line(` ${import_picocolors18.default.dim("needs")} ${requiredCapability}`);
282695
+ if (Array.isArray(unexecutable) && unexecutable.length > 0) {
282696
+ line(` ${import_picocolors18.default.dim("blocked")} ${unexecutable.length} change(s) can't be applied \u2014 see \`unexecutable\` (--verbose)`);
282697
+ }
282698
+ if (Array.isArray(errors)) {
282699
+ for (const e2 of errors.slice(0, 8)) {
282700
+ if (e2 && typeof e2 === "object") {
282701
+ const rec = e2;
282702
+ const where = typeof rec.param === "string" ? `${rec.param}: ` : "";
282703
+ const msg = typeof rec.message === "string" ? rec.message : "";
282704
+ if (msg) line(` ${import_picocolors18.default.dim("\xB7")} ${where}${msg}`);
282705
+ }
282706
+ }
282707
+ }
282708
+ }
282709
+ function renderCliError(err, opts = {}) {
282710
+ const line = opts.write ?? ((l2) => console.error(l2));
282711
+ const verbose = opts.verbose ?? (process.argv.includes("--verbose") || process.env.ABLO_VERBOSE === "1");
282712
+ if (err instanceof AbloError) {
282713
+ const codeTag = err.code ? ` ${import_picocolors18.default.dim(`[${err.code}]`)}` : "";
282714
+ line("");
282715
+ line(` ${brand("ablo")} ${import_picocolors18.default.red("\u2717")} ${import_picocolors18.default.bold(titleForType(err.type))}${codeTag}`);
282716
+ line("");
282717
+ line(` ${err.message}`);
282718
+ if (err.param) line(` ${import_picocolors18.default.dim("field")} ${err.param}`);
282719
+ renderKnownDetails(err.details, line);
282720
+ const hint = err.code ? RECOVERY_HINT[classifyRecovery(err.code)] : void 0;
282721
+ if (hint) line(` ${import_picocolors18.default.dim(hint)}`);
282722
+ if (err.docUrl) line(` ${import_picocolors18.default.dim("docs")} ${err.docUrl}`);
282723
+ if (err.requestId) line(` ${import_picocolors18.default.dim("ref")} ${err.requestId}`);
282724
+ if (verbose) {
282725
+ if (err.details && Object.keys(err.details).length > 0) {
282726
+ line(` ${import_picocolors18.default.dim("details")} ${JSON.stringify(err.details)}`);
282727
+ }
282728
+ if (err.stack) line(import_picocolors18.default.dim(err.stack));
282729
+ }
282730
+ line("");
282731
+ process.exitCode = 1;
282732
+ return;
282733
+ }
282734
+ const message = err instanceof Error ? err.message : String(err);
282735
+ line("");
282736
+ line(` ${brand("ablo")} ${import_picocolors18.default.red("\u2717")} ${message}`);
282737
+ if (verbose && err instanceof Error && err.stack) line(import_picocolors18.default.dim(err.stack));
282738
+ else line(` ${import_picocolors18.default.dim("Run with --verbose for the full error.")}`);
282739
+ line("");
282740
+ process.exitCode = 1;
282741
+ }
282742
+
282503
282743
  // src/cli/index.ts
282504
282744
  var LOGO = `
282505
- ${brand("ablo")} ${import_picocolors18.default.dim("sync engine")}
282745
+ ${brand("ablo")} ${import_picocolors19.default.dim("sync engine")}
282506
282746
  `;
282507
282747
  var SUBCOMMAND_USAGE = {
282508
282748
  connect: CONNECT_USAGE,
@@ -282537,7 +282777,7 @@ async function main() {
282537
282777
  const devArgs = process.argv.slice(3);
282538
282778
  const oneShot = devArgs.includes("--no-watch");
282539
282779
  console.log(
282540
- import_picocolors18.default.dim(
282780
+ import_picocolors19.default.dim(
282541
282781
  oneShot ? " `ablo dev --no-watch` is `ablo push` (push once, no watcher) \u2014 running that." : " `ablo dev` is now `ablo push --watch` \u2014 running that."
282542
282782
  )
282543
282783
  );
@@ -282564,14 +282804,14 @@ async function main() {
282564
282804
  const guard = guardActiveProjectKey();
282565
282805
  if (!guard.ok && guard.available.length > 0 && !rest.includes("--url")) {
282566
282806
  console.error(
282567
- ` ${import_picocolors18.default.yellow("\u26A0")} active project ${import_picocolors18.default.bold(guard.activeProfile)} has no stored key ${import_picocolors18.default.dim(
282807
+ ` ${import_picocolors19.default.yellow("\u26A0")} active project ${import_picocolors19.default.bold(guard.activeProfile)} has no stored key ${import_picocolors19.default.dim(
282568
282808
  `(you have keys for: ${guard.available.join(", ")})`
282569
282809
  )}`
282570
282810
  );
282571
282811
  const loginCmd = guard.activeProfile === "default" ? "ablo login" : `ablo login --project ${guard.activeProfile}`;
282572
282812
  console.error(
282573
- import_picocolors18.default.dim(
282574
- ` Mint one with ${import_picocolors18.default.bold(loginCmd)}, or switch with ${import_picocolors18.default.bold("ablo projects use <slug>")}.`
282813
+ import_picocolors19.default.dim(
282814
+ ` Mint one with ${import_picocolors19.default.bold(loginCmd)}, or switch with ${import_picocolors19.default.bold("ablo projects use <slug>")}.`
282575
282815
  )
282576
282816
  );
282577
282817
  process.exitCode = 1;
@@ -282589,13 +282829,13 @@ async function main() {
282589
282829
  await generate(process.argv.slice(3));
282590
282830
  } else if (command === "schema") {
282591
282831
  console.error(
282592
- ` ${import_picocolors18.default.red("\u2717")} \`ablo schema push\` was renamed to \`${brand("ablo push")}\`.`
282832
+ ` ${import_picocolors19.default.red("\u2717")} \`ablo schema push\` was renamed to \`${brand("ablo push")}\`.`
282593
282833
  );
282594
282834
  console.error(` Run \`ablo push${process.argv.slice(4).join(" ") ? " " + process.argv.slice(4).join(" ") : ""}\` instead.`);
282595
282835
  process.exitCode = 1;
282596
282836
  } else {
282597
282837
  console.log(LOGO);
282598
- console.log(` ${import_picocolors18.default.bold("Usage:")}`);
282838
+ console.log(` ${import_picocolors19.default.bold("Usage:")}`);
282599
282839
  console.log(` npx ablo init Scaffold ablo/ directory + starter schema`);
282600
282840
  console.log(` npx ablo init --yes [--framework nextjs] Non-interactive (agents/CI): no prompts, flag-driven`);
282601
282841
  console.log(` [--auth apikey] [--storage direct|endpoint] [--project <slug>] [--no-project]`);
@@ -282630,10 +282870,10 @@ async function main() {
282630
282870
  console.log(` npx ablo generate Emit TypeScript types from your schema`);
282631
282871
  console.log(` npx ablo generate --out path.ts Write generated types to a path`);
282632
282872
  console.log();
282633
- console.log(` ${import_picocolors18.default.bold("Schema workflow:")}`);
282873
+ console.log(` ${import_picocolors19.default.bold("Schema workflow:")}`);
282634
282874
  console.log(` The server holds its own copy of your schema \u2014 edit ${brand("ablo/schema.ts")}, then`);
282635
282875
  console.log(` run ${brand("ablo push")} (or keep ${brand("ablo dev")} running) before the server will accept`);
282636
- console.log(` writes to new or changed models. Skip it and writes fail with ${import_picocolors18.default.yellow("server_execute_unknown_model")}.`);
282876
+ console.log(` writes to new or changed models. Skip it and writes fail with ${import_picocolors19.default.yellow("server_execute_unknown_model")}.`);
282637
282877
  console.log();
282638
282878
  }
282639
282879
  }
@@ -282645,7 +282885,7 @@ function bailIfCancelled(value) {
282645
282885
  }
282646
282886
  var INIT_FRAMEWORKS = ["nextjs", "vite", "remix", "vanilla"];
282647
282887
  var INIT_AUTHS = ["apikey", "firebase", "auth0", "clerk", "supabase", "betterauth", "jwt"];
282648
- var INIT_STORAGES = ["direct", "endpoint", "datasource"];
282888
+ var INIT_STORAGES = ["endpoint", "direct", "datasource"];
282649
282889
  function parseInitArgs(args) {
282650
282890
  const has = (flag2) => args.includes(flag2);
282651
282891
  const val = (flag2) => {
@@ -282684,7 +282924,7 @@ async function ensureInitProject(opts) {
282684
282924
  const ensured = await ensureProject(slug);
282685
282925
  if (ensured) {
282686
282926
  console.log(
282687
- ` ${import_picocolors18.default.green("\u2713")} ${ensured.created ? "Created" : "Using"} project ${import_picocolors18.default.bold(ensured.slug)} ${import_picocolors18.default.dim(`(${ensured.id})`)} \u2014 keys you mint for it are isolated from the org's other apps.`
282927
+ ` ${import_picocolors19.default.green("\u2713")} ${ensured.created ? "Created" : "Using"} project ${import_picocolors19.default.bold(ensured.slug)} ${import_picocolors19.default.dim(`(${ensured.id})`)} \u2014 keys you mint for it are isolated from the org's other apps.`
282688
282928
  );
282689
282929
  }
282690
282930
  }
@@ -282726,7 +282966,7 @@ async function chooseBool(flagValue, fallback, interactive, prompt) {
282726
282966
  async function init(args = []) {
282727
282967
  const opts = parseInitArgs(args);
282728
282968
  const interactive = Boolean(process.stdin.isTTY) && !opts.yes && !process.env.CI;
282729
- Ie(`${brand("ablo")} ${import_picocolors18.default.dim("sync engine")}`);
282969
+ Ie(`${brand("ablo")} ${import_picocolors19.default.dim("sync engine")}`);
282730
282970
  if (!(0, import_fs12.existsSync)("package.json")) {
282731
282971
  xe("No package.json found. Run this from your project root.");
282732
282972
  process.exit(1);
@@ -282771,19 +283011,18 @@ async function init(args = []) {
282771
283011
  const storageChoice = await chooseOption(
282772
283012
  "storage",
282773
283013
  opts.storage,
282774
- "direct",
283014
+ "endpoint",
282775
283015
  INIT_STORAGES,
282776
- interactive,
282777
- () => ve({
282778
- message: "How should Ablo reach your database?",
282779
- initialValue: "direct",
282780
- options: [
282781
- { value: "direct", label: "Connection string (DATABASE_URL) \u2014 recommended" },
282782
- { value: "endpoint", label: "Signed endpoint in my app (credentials never leave it)" }
282783
- ]
282784
- })
283016
+ false,
283017
+ () => Promise.resolve("endpoint")
282785
283018
  );
282786
283019
  const storage = storageChoice === "datasource" ? "endpoint" : storageChoice;
283020
+ if (storage === "direct") {
283021
+ Me(
283022
+ "`--storage direct` uses the deprecated databaseUrl connector. The signed Data\nSource endpoint is the supported path.",
283023
+ import_picocolors19.default.yellow("Deprecated")
283024
+ );
283025
+ }
282787
283026
  const agent = await chooseBool(
282788
283027
  opts.agent,
282789
283028
  true,
@@ -282811,7 +283050,7 @@ async function init(args = []) {
282811
283050
  if (pullExisting) {
282812
283051
  const dbUrl = process.env.DATABASE_URL ?? process.env.ABLO_DATABASE_URL;
282813
283052
  if (!dbUrl) {
282814
- schemaNote = import_picocolors18.default.dim(" (no DATABASE_URL \u2014 wrote starter; run `ablo pull` later)");
283053
+ schemaNote = import_picocolors19.default.dim(" (no DATABASE_URL \u2014 wrote starter; run `ablo pull` later)");
282815
283054
  } else {
282816
283055
  try {
282817
283056
  const pulled = await buildSchemaSourceFromDb({
@@ -282821,12 +283060,12 @@ async function init(args = []) {
282821
283060
  });
282822
283061
  if (pulled.models.length > 0) {
282823
283062
  schemaSource = pulled.source;
282824
- schemaNote = import_picocolors18.default.dim(` (pulled ${pulled.models.length} models)`);
283063
+ schemaNote = import_picocolors19.default.dim(` (pulled ${pulled.models.length} models)`);
282825
283064
  } else {
282826
- schemaNote = import_picocolors18.default.dim(" (no adoptable tables \u2014 wrote starter)");
283065
+ schemaNote = import_picocolors19.default.dim(" (no adoptable tables \u2014 wrote starter)");
282827
283066
  }
282828
283067
  } catch {
282829
- schemaNote = import_picocolors18.default.dim(" (pull failed \u2014 wrote starter)");
283068
+ schemaNote = import_picocolors19.default.dim(" (pull failed \u2014 wrote starter)");
282830
283069
  }
282831
283070
  }
282832
283071
  }
@@ -282852,14 +283091,14 @@ async function init(args = []) {
282852
283091
  const existing = (0, import_fs12.readFileSync)(envFile, "utf-8");
282853
283092
  if (!existing.includes("ABLO_")) {
282854
283093
  (0, import_fs12.writeFileSync)(envFile, existing + "\n" + envBody);
282855
- created.push(`${envFile} ${import_picocolors18.default.dim("(appended)")}`);
283094
+ created.push(`${envFile} ${import_picocolors19.default.dim("(appended)")}`);
282856
283095
  } else {
282857
- created.push(`${envFile} ${import_picocolors18.default.dim("(already configured)")}`);
283096
+ created.push(`${envFile} ${import_picocolors19.default.dim("(already configured)")}`);
282858
283097
  }
282859
283098
  }
282860
283099
  if (wireRealKey && resolvedKey) {
282861
283100
  wireEnvLocal(resolvedKey);
282862
- created.push(`.env.local ${import_picocolors18.default.dim("(ABLO_API_KEY set from your login)")}`);
283101
+ created.push(`.env.local ${import_picocolors19.default.dim("(ABLO_API_KEY set from your login)")}`);
282863
283102
  }
282864
283103
  if (agent) {
282865
283104
  (0, import_fs12.writeFileSync)((0, import_path7.join)(abloDir, "agent.ts"), generateAgent());
@@ -282874,17 +283113,17 @@ async function init(args = []) {
282874
283113
  }
282875
283114
  const providersPath = (0, import_path7.join)(layout.appBase, "providers.tsx");
282876
283115
  (0, import_fs12.writeFileSync)(providersPath, generateProviders());
282877
- created.push(`${providersPath} ${import_picocolors18.default.dim(`(wrap ${(0, import_path7.join)(layout.appBase, "layout.tsx")} in <Providers>)`)}`);
283116
+ created.push(`${providersPath} ${import_picocolors19.default.dim(`(wrap ${(0, import_path7.join)(layout.appBase, "layout.tsx")} in <Providers>)`)}`);
282878
283117
  const sessionDir = (0, import_path7.join)(layout.appBase, "api", "ablo-session");
282879
283118
  (0, import_fs12.mkdirSync)(sessionDir, { recursive: true });
282880
283119
  (0, import_fs12.writeFileSync)((0, import_path7.join)(sessionDir, "route.ts"), generateSessionRoute());
282881
- created.push(`${(0, import_path7.join)(sessionDir, "route.ts")} ${import_picocolors18.default.dim("(wire your auth)")}`);
283120
+ created.push(`${(0, import_path7.join)(sessionDir, "route.ts")} ${import_picocolors19.default.dim("(wire your auth)")}`);
282882
283121
  }
282883
283122
  if (framework !== "vanilla") {
282884
283123
  (0, import_fs12.writeFileSync)((0, import_path7.join)(abloDir, "TaskList.tsx"), generateComponent());
282885
283124
  created.push(`${abloDir}/TaskList.tsx`);
282886
283125
  }
282887
- Me(created.map((f) => `${import_picocolors18.default.green("\u2713")} ${f}`).join("\n"), "Created");
283126
+ Me(created.map((f) => `${import_picocolors19.default.green("\u2713")} ${f}`).join("\n"), "Created");
282888
283127
  const pm = detectPackageManager();
282889
283128
  if (opts.install) {
282890
283129
  const s = Y2();
@@ -282893,45 +283132,45 @@ async function init(args = []) {
282893
283132
  (0, import_child_process2.execSync)(`${pm} add @abloatai/ablo`, { stdio: "ignore" });
282894
283133
  s.stop("Installed @abloatai/ablo");
282895
283134
  } catch {
282896
- s.stop(`${import_picocolors18.default.yellow("!")} Couldn't auto-install \u2014 run ${import_picocolors18.default.bold(`${pm} install @abloatai/ablo`)}`);
283135
+ s.stop(`${import_picocolors19.default.yellow("!")} Couldn't auto-install \u2014 run ${import_picocolors19.default.bold(`${pm} install @abloatai/ablo`)}`);
282897
283136
  }
282898
283137
  }
282899
283138
  const steps = [
282900
- `Get a ${import_picocolors18.default.bold("sk_test_")} key at ${import_picocolors18.default.cyan("https://abloatai.com")}`,
282901
- `Run ${import_picocolors18.default.bold("npx ablo login")} (or add ${import_picocolors18.default.bold("ABLO_API_KEY")} to ${import_picocolors18.default.bold(envFile)})`,
282902
- `Set ${import_picocolors18.default.bold("DATABASE_URL")} in ${import_picocolors18.default.bold(envFile)} \u2014 your Postgres is the system of record; rows live there, never with Ablo`,
282903
- `Run ${import_picocolors18.default.bold("npx ablo dev")} \u2014 pushes your schema definition and watches for changes`,
283139
+ `Get a ${import_picocolors19.default.bold("sk_test_")} key at ${import_picocolors19.default.cyan("https://abloatai.com")}`,
283140
+ `Run ${import_picocolors19.default.bold("npx ablo login")} (or add ${import_picocolors19.default.bold("ABLO_API_KEY")} to ${import_picocolors19.default.bold(envFile)})`,
283141
+ `Set ${import_picocolors19.default.bold("DATABASE_URL")} in ${import_picocolors19.default.bold(envFile)} \u2014 your Postgres is the system of record; rows live there, never with Ablo`,
283142
+ `Run ${import_picocolors19.default.bold("npx ablo dev")} \u2014 pushes your schema definition and watches for changes`,
282904
283143
  ...storage === "direct" ? [
282905
- `Provision your DB: ${import_picocolors18.default.bold("npx ablo migrate")} (creates your synced-model tables with row-level security; keep your own migrations for everything else)`
283144
+ `Provision your DB: ${import_picocolors19.default.bold("npx ablo migrate")} (creates your synced-model tables with row-level security; keep your own migrations for everything else)`
282906
283145
  ] : [
282907
- `Provision your DB: ${import_picocolors18.default.bold("npx ablo migrate")} (creates your Ablo-model tables + the adapter tables; keep your own migrations for everything else), then mount ${import_picocolors18.default.bold(`${abloDir}/data-source.ts`)} at ${import_picocolors18.default.bold("/api/ablo/source")}`
283146
+ `Provision your DB: ${import_picocolors19.default.bold("npx ablo migrate")} (creates your Ablo-model tables + the adapter tables; keep your own migrations for everything else), then mount ${import_picocolors19.default.bold(`${abloDir}/data-source.ts`)} at ${import_picocolors19.default.bold("/api/ablo/source")}`
282908
283147
  ],
282909
283148
  ...framework === "nextjs" ? [
282910
- `Wrap ${import_picocolors18.default.bold((0, import_path7.join)(layout.appBase, "layout.tsx"))} in ${import_picocolors18.default.bold("<Providers>")} (${(0, import_path7.join)(layout.appBase, "providers.tsx")}) and add your auth to ${import_picocolors18.default.bold((0, import_path7.join)(layout.appBase, "api", "ablo-session", "route.ts"))}`
283149
+ `Wrap ${import_picocolors19.default.bold((0, import_path7.join)(layout.appBase, "layout.tsx"))} in ${import_picocolors19.default.bold("<Providers>")} (${(0, import_path7.join)(layout.appBase, "providers.tsx")}) and add your auth to ${import_picocolors19.default.bold((0, import_path7.join)(layout.appBase, "api", "ablo-session", "route.ts"))}`
282911
283150
  ] : [],
282912
- `Run ${import_picocolors18.default.bold(`${pm} run dev`)} and open two browser tabs \u2014 changes sync in real-time`,
283151
+ `Run ${import_picocolors19.default.bold(`${pm} run dev`)} and open two browser tabs \u2014 changes sync in real-time`,
282913
283152
  ...agent ? [
282914
- `Run ${import_picocolors18.default.bold(`npx tsx ${abloDir}/agent.ts`)} \u2014 an AI teammate edits the same tasks`,
282915
- `Run ${import_picocolors18.default.bold("npx ablo logs")} to watch human + agent commits stream by`
283153
+ `Run ${import_picocolors19.default.bold(`npx tsx ${abloDir}/agent.ts`)} \u2014 an AI teammate edits the same tasks`,
283154
+ `Run ${import_picocolors19.default.bold("npx ablo logs")} to watch human + agent commits stream by`
282916
283155
  ] : []
282917
283156
  ];
282918
283157
  Me(steps.map((s, i) => `${i + 1}. ${s}`).join("\n"), "Next steps");
282919
283158
  const existingKey = resolveApiKey("sandbox");
282920
283159
  if (existingKey) {
282921
283160
  await ensureInitProject(opts);
282922
- Se(`Already authorized ${import_picocolors18.default.dim(`(${existingKey.slice(0, 11)}\u2026)`)} \u2014 run ${import_picocolors18.default.bold("npx ablo push")} next. ${import_picocolors18.default.dim("Docs:")} https://abloatai.com/docs`);
283161
+ Se(`Already authorized ${import_picocolors19.default.dim(`(${existingKey.slice(0, 11)}\u2026)`)} \u2014 run ${import_picocolors19.default.bold("npx ablo push")} next. ${import_picocolors19.default.dim("Docs:")} https://abloatai.com/docs`);
282923
283162
  return;
282924
283163
  }
282925
283164
  if (interactive && opts.login) {
282926
283165
  const loginNow = await ye({ message: "Log in now? (opens your browser)", initialValue: true });
282927
283166
  if (!pD(loginNow) && loginNow) {
282928
- Se(`${import_picocolors18.default.dim("Docs:")} https://abloatai.com/docs`);
283167
+ Se(`${import_picocolors19.default.dim("Docs:")} https://abloatai.com/docs`);
282929
283168
  await login();
282930
283169
  await ensureInitProject(opts);
282931
283170
  return;
282932
283171
  }
282933
283172
  }
282934
- Se(`Run ${import_picocolors18.default.bold("npx ablo login")} when ready. ${import_picocolors18.default.dim("Docs:")} https://abloatai.com/docs`);
283173
+ Se(`Run ${import_picocolors19.default.bold("npx ablo login")} when ready. ${import_picocolors19.default.dim("Docs:")} https://abloatai.com/docs`);
282935
283174
  }
282936
283175
  function generateSchema() {
282937
283176
  return `import { defineSchema, model, relation, z } from '@abloatai/ablo/schema';
@@ -282962,7 +283201,7 @@ export const schema = defineSchema({
282962
283201
  }
282963
283202
  function generateSyncConfig(auth, storage) {
282964
283203
  const databaseLine = storage === "direct" ? `
282965
- databaseUrl: process.env.DATABASE_URL, // your Postgres \u2014 rows live here, never with Ablo` : "";
283204
+ databaseUrl: process.env.DATABASE_URL, // deprecated direct connector` : "";
282966
283205
  const authLine = auth === "apikey" ? "" : auth === "firebase" ? `
282967
283206
  auth: async () => {
282968
283207
  const { getAuth } = await import('firebase/auth');
@@ -282977,11 +283216,10 @@ function generateSyncConfig(auth, storage) {
282977
283216
  return `import Ablo from '@abloatai/ablo';
282978
283217
  import { schema } from './schema';
282979
283218
 
282980
- // SERVER-ONLY client \u2014 it holds your \`sk_\` key (and in direct mode your
282981
- // database URL). Use it from server code: the agent script and the
282982
- // /api/ablo-session route. Do NOT import this into a browser ('use client')
282983
- // component; the browser uses app/providers.tsx, which authenticates via the
282984
- // session route and never touches the key or the database URL.
283219
+ // SERVER-ONLY client \u2014 it holds your \`sk_\` key. Use it from server code: the
283220
+ // agent script and the /api/ablo-session route. Do NOT import this into a browser
283221
+ // ('use client') component; the browser uses app/providers.tsx, which authenticates
283222
+ // via the session route and never touches the key.
282985
283223
  export const sync = Ablo({
282986
283224
  apiKey: process.env.ABLO_API_KEY,${databaseLine}${authLine}
282987
283225
  schema,
@@ -283007,7 +283245,7 @@ export {};
283007
283245
  }
283008
283246
  function generateEnv(storage, opts = {}) {
283009
283247
  const { includeApiKey = true } = opts;
283010
- const databaseBlock = storage === "direct" ? "# Your Postgres \u2014 the system of record. The client registers this connection\n# (sent once over TLS, stored sealed) and every row lives HERE, never with Ablo.\n# Use a dedicated non-superuser role; the browser never sees this value.\nDATABASE_URL=postgres://user:password@host:5432/db\n" : "# Used by ablo/data-source.ts (your DB endpoint) + `ablo migrate` \u2014 NOT the client.\n# Ablo never sees it; the browser never sees it. Your DB stays in your app.\nDATABASE_URL=postgres://user:password@host:5432/db\n";
283248
+ const databaseBlock = storage === "direct" ? "# DEPRECATED direct connector. The client registers this connection (sent once\n# over TLS, stored sealed) so Ablo dials into your Postgres. Prefer a signed Data\n# Source endpoint; to keep the transaction log in your infra too, self-host the engine.\n# Use a dedicated non-superuser role; the browser never sees this value.\nDATABASE_URL=postgres://user:password@host:5432/db\n" : "# Used by ablo/data-source.ts (your DB endpoint) + `ablo migrate` \u2014 NOT the client.\n# Ablo never sees it; the browser never sees it. Your DB stays in your app.\nDATABASE_URL=postgres://user:password@host:5432/db\n";
283011
283249
  const webhookBlock = storage === "endpoint" ? "# Signing secret for the webhook receiver (app/api/ablo/webhooks/route.ts).\n# Ablo mints this when you register the endpoint's URL (POST /v1/webhook_endpoints\n# or the dashboard) and returns it once \u2014 paste it here.\nABLO_WEBHOOK_SECRET=whsec_your_endpoint_secret_here\n" : "";
283012
283250
  const apiKeyBlock = includeApiKey ? "# Ablo Sync Engine \u2014 use a sk_test_ key for local dev (`npx ablo push`)\nABLO_API_KEY=sk_test_your_key_here\n" : "";
283013
283251
  return `${apiKeyBlock}${webhookBlock}${databaseBlock}`;
@@ -283209,7 +283447,9 @@ async function main() {
283209
283447
  }
283210
283448
 
283211
283449
  main().catch((err) => {
283212
- console.error(err);
283450
+ // Ablo errors stringify to one clean line (code + message + docs link),
283451
+ // never a stack/object dump \u2014 see AbloError.toString().
283452
+ console.error(String(err));
283213
283453
  process.exit(1);
283214
283454
  });
283215
283455
  `;
@@ -283296,22 +283536,33 @@ export function Providers({ children }: { children: React.ReactNode }) {
283296
283536
  `;
283297
283537
  }
283298
283538
  function generateSessionRoute() {
283299
- return `import { sync } from '@/ablo';
283539
+ return `import { headers } from 'next/headers';
283540
+ import { sync } from '@/ablo';
283541
+ import { auth } from '@/lib/auth'; // your server-side betterAuth({ ... }) instance
283300
283542
 
283301
283543
  // Mints the browser's session token. The browser never sees your sk_ key \u2014 it
283302
- // only gets this token, which already names your org + the user you assert here.
283303
- // Replace getCurrentUser() with your real auth (NextAuth / Clerk / Better Auth / \u2026).
283544
+ // only gets this short-lived token, already scoped to your org + the user you
283545
+ // assert here. The browser fetches THIS route at a relative URL
283546
+ // ('/api/ablo-session') \u2014 that's correct + best practice (same-origin, cookies
283547
+ // flow automatically); the SDK refreshes it in the browser only.
283304
283548
  export async function POST(): Promise<Response> {
283305
- const user = await getCurrentUser(); // \u2190 your auth: who is making this request?
283549
+ const user = await getCurrentUser();
283306
283550
  if (!user) return new Response('Unauthorized', { status: 401 });
283307
283551
 
283308
283552
  const { token } = await sync.sessions.create({ user: { id: user.id } });
283309
283553
  return Response.json({ token });
283310
283554
  }
283311
283555
 
283312
- // TODO: replace with your auth provider's "current user" lookup.
283556
+ // Validate the signed-in user SERVER-SIDE. This ships wired for Better Auth;
283557
+ // \`getSession\` is the server method \u2014 pass the request headers (async in current
283558
+ // Next.js), it does NOT read cookies implicitly. Using a different provider?
283559
+ // Replace the body:
283560
+ // \u2022 NextAuth: const s = await auth(); return s?.user ? { id: s.user.id } : null;
283561
+ // \u2022 Clerk: const { userId } = await auth(); return userId ? { id: userId } : null;
283562
+ // \u2022 Supabase: const { data } = await supabase.auth.getUser(); return data.user ? { id: data.user.id } : null;
283313
283563
  async function getCurrentUser(): Promise<{ id: string } | null> {
283314
- return null;
283564
+ const session = await auth.api.getSession({ headers: await headers() });
283565
+ return session?.user ? { id: session.user.id } : null;
283315
283566
  }
283316
283567
  `;
283317
283568
  }
@@ -283321,7 +283572,10 @@ function detectPackageManager() {
283321
283572
  if ((0, import_fs12.existsSync)("bun.lockb")) return "bun";
283322
283573
  return "npm";
283323
283574
  }
283324
- main().catch(console.error);
283575
+ main().catch((err) => {
283576
+ renderCliError(err);
283577
+ process.exit(process.exitCode ?? 1);
283578
+ });
283325
283579
  /*! Bundled license information:
283326
283580
 
283327
283581
  @ts-morph/common/dist/typescript.js: