@axiom-lattice/gateway 8.0.2 → 8.1.1

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 (28) hide show
  1. package/dist/embed/{embed-page-AgentDetailSideApp-23TCREK6.js → embed-page-AgentDetailSideApp-RY4FAEAM.js} +1 -1
  2. package/dist/embed/{embed-page-AgentGovernanceWorkbench-N3F65F3W.js → embed-page-AgentGovernanceWorkbench-UFDULZ5A.js} +1 -1
  3. package/dist/embed/{embed-page-LangfuseDashboard-WBE7GJPU.js → embed-page-LangfuseDashboard-GNNJGAA2.js} +1 -1
  4. package/dist/embed/{embed-page-MessageGraph-T3EFAXTX.js → embed-page-MessageGraph-S7GCLNLR.js} +1 -1
  5. package/dist/embed/{embed-page-ReactChart-FJFQU4IV.js → embed-page-ReactChart-LWZPH244.js} +1 -1
  6. package/dist/embed/{embed-page-SkillFlow-2BUXCLAL.js → embed-page-SkillFlow-OVIGJFUH.js} +1 -1
  7. package/dist/embed/{embed-page-TasksSideApp-VFKEYFGR.js → embed-page-TasksSideApp-AOS4MZAI.js} +1 -1
  8. package/dist/embed/{embed-page-ThreadMaintenancePanel-EPBJ4J3L.js → embed-page-ThreadMaintenancePanel-PXL2TJBO.js} +1 -1
  9. package/dist/embed/{embed-page-TopologyRuntimeView-OWESU7IK.js → embed-page-TopologyRuntimeView-GRM34Z2Z.js} +1 -1
  10. package/dist/embed/{embed-page-WorkflowAutomationView-5J2RQTZ7.js → embed-page-WorkflowAutomationView-JV26AHRB.js} +1 -1
  11. package/dist/embed/{embed-page-chunk-WKQHSEZ4.js → embed-page-chunk-3UK7XM33.js} +1 -1
  12. package/dist/embed/{embed-page-chunk-6QLLZJVH.js → embed-page-chunk-5XP4FJW7.js} +1 -1
  13. package/dist/embed/{embed-page-chunk-R7TLHZR3.js → embed-page-chunk-6ZHR5GWS.js} +1 -1
  14. package/dist/embed/{embed-page-chunk-2ZBEWYJQ.js → embed-page-chunk-ABGWNVMG.js} +1 -1
  15. package/dist/embed/{embed-page-chunk-JMTQCORF.js → embed-page-chunk-NNQHJZ5Q.js} +1 -1
  16. package/dist/embed/{embed-page-chunk-CQLDPGEG.js → embed-page-chunk-ONXC5S22.js} +1 -1
  17. package/dist/embed/{embed-page-chunk-BFVNPGSW.js → embed-page-chunk-OQUMCCF5.js} +1 -1
  18. package/dist/embed/{embed-page-chunk-CKUSXUKW.js → embed-page-chunk-SQSVDSG6.js} +176 -176
  19. package/dist/embed/{embed-page-chunk-L7TDL27M.js → embed-page-chunk-YCTDKWKW.js} +1 -1
  20. package/dist/embed/{embed-page-chunk-EU32IF7M.js → embed-page-chunk-YM76GTXK.js} +1 -1
  21. package/dist/embed/{embed-page-en-TSCGSJAI.js → embed-page-en-ISNUZBPO.js} +1 -1
  22. package/dist/embed/{embed-page-zh-Q22DIOB3.js → embed-page-zh-MDJTBW2K.js} +1 -1
  23. package/dist/embed/embed-page.js +1 -1
  24. package/dist/index.js +81 -11
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +81 -11
  27. package/dist/index.mjs.map +1 -1
  28. package/package.json +7 -7
package/dist/index.mjs CHANGED
@@ -2782,6 +2782,52 @@ import {
2782
2782
 
2783
2783
  // src/services/threads/threadOwnership.ts
2784
2784
  import { getStoreLattice as getStoreLattice5 } from "@axiom-lattice/core";
2785
+ var DELEGATED_THREAD_SEPARATOR = "____";
2786
+ var MAX_DELEGATED_THREAD_LINEAGE = 8;
2787
+ async function threadHasTenantRecord(tenantId, threadId) {
2788
+ try {
2789
+ const thread = await getStoreLattice5("default", "thread").store.getThreadById(
2790
+ tenantId,
2791
+ threadId
2792
+ );
2793
+ if (thread) return true;
2794
+ } catch {
2795
+ }
2796
+ try {
2797
+ const ledger = getStoreLattice5("default", "agentRun").store;
2798
+ const runs = await ledger.listRuns(tenantId, threadId, { limit: 1 });
2799
+ if (runs.length > 0) return true;
2800
+ } catch {
2801
+ }
2802
+ try {
2803
+ const tasks = getStoreLattice5("default", "task").store;
2804
+ const matches = await tasks.list({ tenantId, threadId, limit: 1 });
2805
+ return matches.length > 0;
2806
+ } catch {
2807
+ return false;
2808
+ }
2809
+ }
2810
+ async function threadLineageRootedInTenant(tenantId, threadId) {
2811
+ let candidate = threadId;
2812
+ for (let depth = 0; depth < MAX_DELEGATED_THREAD_LINEAGE; depth += 1) {
2813
+ if (await threadHasTenantRecord(tenantId, candidate)) return true;
2814
+ const boundary = candidate.lastIndexOf(DELEGATED_THREAD_SEPARATOR);
2815
+ if (boundary <= 0) return false;
2816
+ candidate = candidate.slice(0, boundary);
2817
+ }
2818
+ return false;
2819
+ }
2820
+ async function delegatedThreadOwnedBy(tenantId, assistantId, threadId) {
2821
+ const marker = `${DELEGATED_THREAD_SEPARATOR}${assistantId}_`;
2822
+ let boundary = threadId.indexOf(marker);
2823
+ while (boundary > 0) {
2824
+ if (await threadLineageRootedInTenant(tenantId, threadId.slice(0, boundary))) {
2825
+ return true;
2826
+ }
2827
+ boundary = threadId.indexOf(marker, boundary + DELEGATED_THREAD_SEPARATOR.length);
2828
+ }
2829
+ return false;
2830
+ }
2785
2831
  async function threadOwnedBy(tenantId, assistantId, threadId) {
2786
2832
  try {
2787
2833
  const thread = await getStoreLattice5("default", "thread").store.getThreadById(
@@ -2800,10 +2846,12 @@ async function threadOwnedBy(tenantId, assistantId, threadId) {
2800
2846
  try {
2801
2847
  const tasks = getStoreLattice5("default", "task").store;
2802
2848
  const matches = await tasks.list({ tenantId, threadId, limit: 1 });
2803
- return matches.some((task) => task.ownerType === "agent" && task.ownerId === assistantId);
2849
+ if (matches.some((task) => task.ownerType === "agent" && task.ownerId === assistantId)) {
2850
+ return true;
2851
+ }
2804
2852
  } catch {
2805
- return false;
2806
2853
  }
2854
+ return delegatedThreadOwnedBy(tenantId, assistantId, threadId);
2807
2855
  }
2808
2856
  async function threadIsNewForTenant(tenantId, threadId) {
2809
2857
  try {
@@ -22296,6 +22344,9 @@ var ModelProviderService = class {
22296
22344
  resolveDiscoveryTimeoutMs()
22297
22345
  );
22298
22346
  const previous = await this.deps.providerStore.listModels(tenantId, id3);
22347
+ const previousById = new Map(
22348
+ previous.map((model) => [model.modelId, model])
22349
+ );
22299
22350
  const previousIds = new Set(previous.map((model) => model.modelId));
22300
22351
  let discovered;
22301
22352
  try {
@@ -22324,6 +22375,9 @@ var ModelProviderService = class {
22324
22375
  id3,
22325
22376
  discovered.map((model) => ({
22326
22377
  ...model,
22378
+ // A tenant may have renamed a model. Discovery must not overwrite that
22379
+ // override with the upstream name; brand-new rows take the upstream one.
22380
+ displayName: previousById.get(model.id)?.displayName ?? model.displayName,
22327
22381
  // Same rule as `setModels`: a row this provider just brought in starts
22328
22382
  // with the default config, a row already stored keeps the tenant's.
22329
22383
  extra: previousIds.has(model.id) ? void 0 : { ...DEFAULT_MODEL_EXTRA }
@@ -22505,30 +22559,36 @@ var ModelProviderService = class {
22505
22559
  async setModels(userId, tenantId, id3, selection) {
22506
22560
  await this.assertAdmin(userId, tenantId);
22507
22561
  const provider = await this.requireProvider(tenantId, id3);
22508
- if (selection.filter((entry) => entry.isDefault === true).length > 1) {
22562
+ const previous = await this.deps.providerStore.listModels(tenantId, id3);
22563
+ const previousById = new Map(
22564
+ previous.map((model) => [model.modelId, model])
22565
+ );
22566
+ const normalized = selection.map((entry) => {
22567
+ const stored = previousById.get(entry.modelId);
22568
+ const kindChanged = stored !== void 0 && entry.kind !== void 0 && entry.kind !== (stored.kind ?? "chat");
22569
+ return kindChanged ? { ...entry, isDefault: false } : entry;
22570
+ });
22571
+ if (normalized.filter((entry) => entry.isDefault === true).length > 1) {
22509
22572
  throw new ModelProviderServiceError(
22510
22573
  "INVALID_INPUT",
22511
22574
  400,
22512
22575
  "Only one model can be the tenant's default"
22513
22576
  );
22514
22577
  }
22515
- const previous = await this.deps.providerStore.listModels(tenantId, id3);
22516
- const previousById = new Map(
22517
- previous.map((model) => [model.modelId, model])
22518
- );
22519
22578
  await this.deps.providerStore.replaceProviderModels(
22520
22579
  tenantId,
22521
22580
  id3,
22522
- selection.map((entry) => ({
22581
+ normalized.map((entry) => ({
22523
22582
  id: entry.modelId,
22524
22583
  enabled: entry.enabled,
22525
22584
  // A model the upstream stopped offering stays in the set, flagged
22526
22585
  // rather than dropped: deleting it would silently break anything
22527
22586
  // referencing its key.
22528
22587
  stale: entry.stale ?? false,
22529
- // The selection carries only ids and states, so a model already in the
22530
- // snapshot keeps the metadata discovery gave it.
22531
- displayName: previousById.get(entry.modelId)?.displayName,
22588
+ // The selection carries only edited rows' names, so a model already in
22589
+ // the snapshot keeps its name when the field is omitted. An empty
22590
+ // string clears the tenant override.
22591
+ displayName: entry.displayName !== void 0 ? entry.displayName.trim() || void 0 : previousById.get(entry.modelId)?.displayName,
22532
22592
  ownedBy: previousById.get(entry.modelId)?.ownedBy,
22533
22593
  // An omitted `extra` means "keep what is stored" — the picker sends no
22534
22594
  // config, and a sync must not wipe one set by hand. The store resolves
@@ -22604,6 +22664,10 @@ var ModelProviderService = class {
22604
22664
  providerId2,
22605
22665
  providerModels.map((model) => ({
22606
22666
  id: model.modelId,
22667
+ // This is a whole-set write: any field left out is cleared, so the
22668
+ // metadata that only discovery knows must travel with it.
22669
+ displayName: model.displayName,
22670
+ ownedBy: model.ownedBy,
22607
22671
  enabled: model.enabled,
22608
22672
  stale: model.stale,
22609
22673
  extra: model.extra,
@@ -22636,6 +22700,9 @@ var ModelProviderService = class {
22636
22700
  provider.id,
22637
22701
  rows.map((row) => ({
22638
22702
  id: row.modelId,
22703
+ // Whole-set write: keep the metadata this method is not changing.
22704
+ displayName: row.displayName,
22705
+ ownedBy: row.ownedBy,
22639
22706
  enabled: row.enabled,
22640
22707
  stale: row.stale,
22641
22708
  kind: row.kind,
@@ -22894,6 +22961,9 @@ var setModelsSchema = z9.object({
22894
22961
  models: z9.array(
22895
22962
  z9.object({
22896
22963
  modelId: z9.string().trim().min(1).max(512),
22964
+ // Omitted means "leave the stored name alone"; an empty string
22965
+ // clears a tenant override. Same rule as `extra`.
22966
+ displayName: z9.string().trim().max(255).optional(),
22897
22967
  enabled: z9.boolean(),
22898
22968
  stale: z9.boolean().optional(),
22899
22969
  // Omitted means "leave the stored config alone" — the picker sends