@copilotkit/core 2.0.0-rc.46 → 2.0.0-rc.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -18889,19 +18889,29 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18889
18889
  * status is `valid` or `expiring` and `checkFeature("threads")` is `true`.
18890
18890
  * - `licensePending` is `true` while the status is `null` (the runtime has
18891
18891
  * not reported yet). Show the loading state then, not the locked view.
18892
+ * - A connected runtime that reports no license status and no entitlements
18893
+ * (a runtime without Intelligence) never will, so its `null` status is
18894
+ * not pending: it counts as `unknown` and the threads endpoint decides.
18892
18895
  *
18893
18896
  * @param context - The license context from {@link ɵresolveLicenseState}.
18897
+ * @param runtime - Core's runtime info snapshot (`core.ɵruntimeInfo`), or
18898
+ * `undefined` when there is no core.
18894
18899
  *
18895
18900
  * @example
18896
18901
  * ```ts
18897
- * const { licensed, licensePending } = ɵresolveThreadsLicense(context);
18902
+ * const { licensed, licensePending } = ɵresolveThreadsLicense(
18903
+ * context,
18904
+ * core.ɵruntimeInfo,
18905
+ * );
18898
18906
  * ```
18899
18907
  */
18900
- function ɵresolveThreadsLicense(context) {
18908
+ function ɵresolveThreadsLicense(context, runtime) {
18901
18909
  const { status } = context;
18910
+ const isLicensePresent = status === "valid" || status === "expiring";
18911
+ const hasNoLicenseAuthority = (runtime === null || runtime === void 0 ? void 0 : runtime.status) === CopilotKitCoreRuntimeConnectionStatus.Connected && runtime.licenseStatus === void 0 && runtime.runtimeEntitlements === void 0;
18902
18912
  return {
18903
- licensed: status === "unknown" || (status === "valid" || status === "expiring") && context.checkFeature("threads"),
18904
- licensePending: status === null
18913
+ licensed: status === "unknown" || status === null && hasNoLicenseAuthority || isLicensePresent && context.checkFeature("threads"),
18914
+ licensePending: status === null && !hasNoLicenseAuthority
18905
18915
  };
18906
18916
  }
18907
18917
  const PRICING_URL = "https://copilotkit.ai/pricing";
@@ -22015,6 +22025,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
22015
22025
  }
22016
22026
  const RUNTIME_URL_MISSING = "Runtime URL is not configured";
22017
22027
  const THREAD_ENDPOINTS_UNAVAILABLE = "Thread endpoints are not available on this CopilotKit runtime";
22028
+ const THREAD_LIST_NEEDS_IDENTITY = "Listing threads needs a caller identity. Set identifyUser on CopilotRuntime.";
22018
22029
  const THREAD_MUTATIONS_UNAVAILABLE = "Thread mutations are not available on this CopilotKit runtime";
22019
22030
  function isSameThreadsSnapshot(a, b) {
22020
22031
  return a.threads === b.threads && a.isLoading === b.isLoading && a.error === b.error && a.listError === b.listError && a.fetchMoreError === b.fetchMoreError && a.hasMoreThreads === b.hasMoreThreads && a.isFetchingMoreThreads === b.isFetchingMoreThreads && a.isMutating === b.isMutating;
@@ -22028,6 +22039,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
22028
22039
  var _configErrorDismissed = /* @__PURE__ */ new WeakMap();
22029
22040
  var _runtimeError = /* @__PURE__ */ new WeakMap();
22030
22041
  var _endpointsError = /* @__PURE__ */ new WeakMap();
22042
+ var _listAccessError = /* @__PURE__ */ new WeakMap();
22031
22043
  var _mutationsError = /* @__PURE__ */ new WeakMap();
22032
22044
  var _storeThreads = /* @__PURE__ */ new WeakMap();
22033
22045
  var _threads = /* @__PURE__ */ new WeakMap();
@@ -22066,6 +22078,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
22066
22078
  _classPrivateFieldInitSpec(this, _configErrorDismissed, false);
22067
22079
  _classPrivateFieldInitSpec(this, _runtimeError, null);
22068
22080
  _classPrivateFieldInitSpec(this, _endpointsError, null);
22081
+ _classPrivateFieldInitSpec(this, _listAccessError, null);
22069
22082
  _classPrivateFieldInitSpec(this, _mutationsError, null);
22070
22083
  _classPrivateFieldInitSpec(this, _storeThreads, null);
22071
22084
  _classPrivateFieldInitSpec(this, _threads, []);
@@ -22168,6 +22181,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
22168
22181
  function _get_endpointsUnavailable() {
22169
22182
  return !!_get_runtimeUrl.call(_assertClassBrand(_ɵThreadsController_brand, this)) && _get_isConnected.call(_assertClassBrand(_ɵThreadsController_brand, this)) && !_get_listSupported.call(_assertClassBrand(_ɵThreadsController_brand, this));
22170
22183
  }
22184
+ /**
22185
+ * The runtime refuses to list threads because the caller has no identity:
22186
+ * it reads a thread by id but does not list. Only the runtime's anonymous
22187
+ * thread access policy (no `identifyUser`, default `owner` access) reports
22188
+ * that pair; a runtime without thread endpoints reports neither.
22189
+ */
22190
+ function _get_listNeedsIdentity() {
22191
+ var _get_core$call$ɵrunt2;
22192
+ return _get_endpointsUnavailable.call(_assertClassBrand(_ɵThreadsController_brand, this)) && ((_get_core$call$ɵrunt2 = _get_core.call(_assertClassBrand(_ɵThreadsController_brand, this)).ɵruntimeInfo.threadEndpoints) === null || _get_core$call$ɵrunt2 === void 0 ? void 0 : _get_core$call$ɵrunt2.inspect) === true;
22193
+ }
22171
22194
  function _guard(mutation) {
22172
22195
  if (_classPrivateFieldGet2(_mutationsError, this)) return Promise.reject(_classPrivateFieldGet2(_mutationsError, this));
22173
22196
  return mutation();
@@ -22191,7 +22214,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
22191
22214
  _classPrivateFieldSet2(_registeredCore, this, null);
22192
22215
  }
22193
22216
  function _syncContext() {
22194
- var _get_core$call$ɵrunt2;
22217
+ var _get_core$call$ɵrunt3;
22195
22218
  const runtimeUrl = _get_runtimeUrl.call(_assertClassBrand(_ɵThreadsController_brand, this));
22196
22219
  if (!_classPrivateFieldGet2(_input, this).enabled || !runtimeUrl) {
22197
22220
  _assertClassBrand(_ɵThreadsController_brand, this, _clearContext).call(this);
@@ -22205,7 +22228,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
22205
22228
  const { agentId, includeArchived, limit } = _classPrivateFieldGet2(_input, this);
22206
22229
  const context = {
22207
22230
  runtimeUrl,
22208
- wsUrl: (_get_core$call$ɵrunt2 = _get_core.call(_assertClassBrand(_ɵThreadsController_brand, this)).ɵruntimeInfo.intelligence) === null || _get_core$call$ɵrunt2 === void 0 ? void 0 : _get_core$call$ɵrunt2.wsUrl,
22231
+ wsUrl: (_get_core$call$ɵrunt3 = _get_core.call(_assertClassBrand(_ɵThreadsController_brand, this)).ɵruntimeInfo.intelligence) === null || _get_core$call$ɵrunt3 === void 0 ? void 0 : _get_core$call$ɵrunt3.wsUrl,
22209
22232
  agentId,
22210
22233
  includeArchived,
22211
22234
  limit
@@ -22225,21 +22248,24 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
22225
22248
  _classPrivateFieldSet2(_lastContextSignature, this, null);
22226
22249
  }
22227
22250
  function _syncConfigErrors() {
22228
- var _get_core$call$ɵrunt3;
22251
+ var _get_core$call$ɵrunt4;
22229
22252
  const hasRuntimeError = !_get_runtimeUrl.call(_assertClassBrand(_ɵThreadsController_brand, this));
22230
- const hasEndpointsError = _get_endpointsUnavailable.call(_assertClassBrand(_ɵThreadsController_brand, this));
22253
+ const listNeedsIdentity = _get_listNeedsIdentity.call(_assertClassBrand(_ɵThreadsController_brand, this));
22254
+ const hasEndpointsError = _get_endpointsUnavailable.call(_assertClassBrand(_ɵThreadsController_brand, this)) && !listNeedsIdentity;
22231
22255
  const runtimeChanged = hasRuntimeError !== (_classPrivateFieldGet2(_runtimeError, this) !== null);
22232
22256
  const endpointsChanged = hasEndpointsError !== (_classPrivateFieldGet2(_endpointsError, this) !== null);
22233
22257
  if (runtimeChanged) _classPrivateFieldSet2(_runtimeError, this, hasRuntimeError ? new Error(RUNTIME_URL_MISSING) : null);
22234
22258
  if (endpointsChanged) _classPrivateFieldSet2(_endpointsError, this, hasEndpointsError ? new Error(THREAD_ENDPOINTS_UNAVAILABLE) : null);
22259
+ if (listNeedsIdentity !== (_classPrivateFieldGet2(_listAccessError, this) !== null)) _classPrivateFieldSet2(_listAccessError, this, listNeedsIdentity ? new Error(THREAD_LIST_NEEDS_IDENTITY) : null);
22235
22260
  if (runtimeChanged || endpointsChanged) _classPrivateFieldSet2(_configErrorDismissed, this, false);
22236
- if (((_get_core$call$ɵrunt3 = _get_core.call(_assertClassBrand(_ɵThreadsController_brand, this)).ɵruntimeInfo.threadEndpoints) === null || _get_core$call$ɵrunt3 === void 0 ? void 0 : _get_core$call$ɵrunt3.mutations) !== false) _classPrivateFieldSet2(_mutationsError, this, null);
22261
+ if (((_get_core$call$ɵrunt4 = _get_core.call(_assertClassBrand(_ɵThreadsController_brand, this)).ɵruntimeInfo.threadEndpoints) === null || _get_core$call$ɵrunt4 === void 0 ? void 0 : _get_core$call$ɵrunt4.mutations) !== false) _classPrivateFieldSet2(_mutationsError, this, null);
22237
22262
  else {
22238
22263
  var _classPrivateFieldGet3;
22239
22264
  (_classPrivateFieldGet3 = _classPrivateFieldGet2(_mutationsError, this)) !== null && _classPrivateFieldGet3 !== void 0 || _classPrivateFieldSet2(_mutationsError, this, new Error(THREAD_MUTATIONS_UNAVAILABLE));
22240
22265
  }
22241
22266
  }
22242
22267
  function _compute(state = _classPrivateFieldGet2(_store, this).getState()) {
22268
+ var _this$listAccessError;
22243
22269
  const selectors = _classPrivateFieldGet2(_store, this).selectors;
22244
22270
  const storeThreads = selectors.threads(state);
22245
22271
  if (storeThreads !== _classPrivateFieldGet2(_storeThreads, this)) {
@@ -22250,7 +22276,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
22250
22276
  const endpointsError = _classPrivateFieldGet2(_configErrorDismissed, this) ? null : _classPrivateFieldGet2(_endpointsError, this);
22251
22277
  const configError = runtimeError !== null && runtimeError !== void 0 ? runtimeError : endpointsError;
22252
22278
  const preConnectLoading = _classPrivateFieldGet2(_input, this).enabled && !!_get_runtimeUrl.call(_assertClassBrand(_ɵThreadsController_brand, this)) && !_get_endpointsUnavailable.call(_assertClassBrand(_ɵThreadsController_brand, this)) && !_classPrivateFieldGet2(_hasDispatchedContext, this);
22253
- const listError = selectors.error(state);
22279
+ const listError = (_this$listAccessError = _classPrivateFieldGet2(_listAccessError, this)) !== null && _this$listAccessError !== void 0 ? _this$listAccessError : selectors.error(state);
22254
22280
  return {
22255
22281
  threads: _classPrivateFieldGet2(_threads, this),
22256
22282
  isLoading: configError ? false : preConnectLoading || selectors.isLoading(state),