@axiom-lattice/core 13.1.0 → 13.2.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.
package/dist/index.js CHANGED
@@ -1621,7 +1621,7 @@ __export(index_exports, {
1621
1621
  AgentRunInputCommandConflictError: () => AgentRunInputCommandConflictError,
1622
1622
  AgentRunInvalidTaskIdError: () => AgentRunInvalidTaskIdError,
1623
1623
  AgentRunTenantQuotaExceededError: () => AgentRunTenantQuotaExceededError,
1624
- AgentType: () => import_protocols25.AgentType,
1624
+ AgentType: () => import_protocols26.AgentType,
1625
1625
  AuthProviderAlreadyRegisteredError: () => AuthProviderAlreadyRegisteredError,
1626
1626
  BUILTIN_PLUGINS: () => BUILTIN_PLUGINS,
1627
1627
  BUILTIN_SKILLS: () => BUILTIN_SKILLS,
@@ -1707,6 +1707,7 @@ __export(index_exports, {
1707
1707
  InMemoryProjectRoomReadStateStore: () => InMemoryProjectRoomReadStateStore,
1708
1708
  InMemoryProjectRoomStore: () => InMemoryProjectRoomStore,
1709
1709
  InMemoryProjectStore: () => InMemoryProjectStore,
1710
+ InMemorySessionStore: () => InMemorySessionStore,
1710
1711
  InMemorySharedResourceStore: () => InMemorySharedResourceStore,
1711
1712
  InMemoryStore: () => InMemoryStore,
1712
1713
  InMemoryTaskStore: () => InMemoryTaskStore,
@@ -5476,11 +5477,13 @@ var InMemoryUserStore = class {
5476
5477
  if (updates.email !== void 0) {
5477
5478
  this.assertEmailAvailable(updates.email, id);
5478
5479
  }
5480
+ const authEpoch = updates.authEpoch !== void 0 ? updates.authEpoch : existing.authEpoch;
5479
5481
  const updated = {
5480
5482
  id: existing.id,
5481
5483
  email: updates.email ?? existing.email,
5482
5484
  name: updates.name ?? existing.name,
5483
5485
  status: updates.status ?? existing.status,
5486
+ ...authEpoch !== void 0 ? { authEpoch } : {},
5484
5487
  metadata: updates.metadata ?? existing.metadata,
5485
5488
  createdAt: existing.createdAt,
5486
5489
  updatedAt: /* @__PURE__ */ new Date()
@@ -11251,11 +11254,62 @@ var InMemoryChannelReplyJobStore = class {
11251
11254
  }
11252
11255
  };
11253
11256
 
11257
+ // src/store_lattice/InMemorySessionStore.ts
11258
+ var InMemorySessionStore = class {
11259
+ constructor() {
11260
+ this.byId = /* @__PURE__ */ new Map();
11261
+ this.byHash = /* @__PURE__ */ new Map();
11262
+ }
11263
+ async create(record) {
11264
+ this.byId.set(record.id, { ...record });
11265
+ this.byHash.set(record.refreshTokenHash, record.id);
11266
+ }
11267
+ async findByRefreshTokenHash(hash) {
11268
+ const id = this.byHash.get(hash);
11269
+ return id ? { ...this.byId.get(id) } : null;
11270
+ }
11271
+ async findByFamilyId(familyId) {
11272
+ const rows = [...this.byId.values()].filter((row) => row.familyId === familyId);
11273
+ const active = rows.filter((row) => !row.replacedBy && !row.revokedAt);
11274
+ const pool = active.length > 0 ? active : rows;
11275
+ pool.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
11276
+ return pool[0] ? { ...pool[0] } : null;
11277
+ }
11278
+ async rotate(oldId, next) {
11279
+ const old = this.byId.get(oldId);
11280
+ if (!old) return;
11281
+ old.replacedBy = next.id;
11282
+ old.lastUsedAt = next.createdAt;
11283
+ this.byId.set(oldId, old);
11284
+ await this.create(next);
11285
+ }
11286
+ async revokeFamily(familyId, _reason) {
11287
+ const now = /* @__PURE__ */ new Date();
11288
+ for (const row of this.byId.values()) {
11289
+ if (row.familyId === familyId && !row.revokedAt) row.revokedAt = now;
11290
+ }
11291
+ }
11292
+ async revokeAllForUser(userId, _reason) {
11293
+ const now = /* @__PURE__ */ new Date();
11294
+ for (const row of this.byId.values()) {
11295
+ if (row.userId === userId && !row.revokedAt) row.revokedAt = now;
11296
+ }
11297
+ }
11298
+ async touch(id, lastUsedAt) {
11299
+ const row = this.byId.get(id);
11300
+ if (row) row.lastUsedAt = lastUsedAt;
11301
+ }
11302
+ async listForUser(userId) {
11303
+ return [...this.byId.values()].filter((row) => row.userId === userId).map((row) => ({ ...row }));
11304
+ }
11305
+ };
11306
+
11254
11307
  // src/store_lattice/configureStores.ts
11255
11308
  var _disposables = [];
11256
11309
  var _cleanupRegistered = false;
11257
11310
  var _inMemoryAgentRunWarningEmitted = false;
11258
11311
  var _inMemoryChannelReplyJobWarningEmitted = false;
11312
+ var _inMemorySessionWarningEmitted = false;
11259
11313
  function registerSignalCleanup() {
11260
11314
  if (_cleanupRegistered) return;
11261
11315
  _cleanupRegistered = true;
@@ -11315,6 +11369,20 @@ async function configureStores(stores, options = {}) {
11315
11369
  }
11316
11370
  storeLatticeManager.registerLattice("default", "channelReplyJob", channelReplyJob);
11317
11371
  }
11372
+ if (stores.session === void 0 && options.customStores?.session === void 0) {
11373
+ if (!_inMemorySessionWarningEmitted) {
11374
+ _inMemorySessionWarningEmitted = true;
11375
+ console.warn(
11376
+ "[configureStores] session is using InMemorySessionStore: sessions are non-durable and lost on restart. Configure a PostgreSQL session store for production."
11377
+ );
11378
+ }
11379
+ const session = new InMemorySessionStore();
11380
+ await initAndRegister(session, localDisposables);
11381
+ if (storeLatticeManager.hasLattice("default", "session")) {
11382
+ storeLatticeManager.removeLattice("default", "session");
11383
+ }
11384
+ storeLatticeManager.registerLattice("default", "session", session);
11385
+ }
11318
11386
  if (storeLatticeManager.hasLattice("default", "connection")) {
11319
11387
  const connectionStore = storeLatticeManager.getStoreLattice("default", "connection").store;
11320
11388
  ConnectionRegistry.setStore(connectionStore);
@@ -16786,6 +16854,7 @@ function getBindingRegistry() {
16786
16854
  }
16787
16855
 
16788
16856
  // src/tool_lattice/manage_binding/index.ts
16857
+ var import_protocols25 = require("@axiom-lattice/protocols");
16789
16858
  function getInstallationStore() {
16790
16859
  return getStoreLattice("default", "channelInstallation").store;
16791
16860
  }
@@ -16822,6 +16891,8 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
16822
16891
  const tenantId2 = getTenantId(config);
16823
16892
  if (!tenantId2) return failure("manage_binding requires tenant execution context");
16824
16893
  if (input.channel === "room") return failure("Internal room bindings cannot be managed");
16894
+ const personalAssistantId = await resolvePersonalAssistantId(tenantId2, config);
16895
+ const personalInstallationIds = personalAssistantId ? await listPersonalInstallationIds(registry4, tenantId2, personalAssistantId) : null;
16825
16896
  switch (input.action) {
16826
16897
  case "list_installations": {
16827
16898
  const store2 = getInstallationStore();
@@ -16829,27 +16900,42 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
16829
16900
  tenantId2,
16830
16901
  input.channel
16831
16902
  );
16832
- return JSON.stringify({ success: true, data: installations.filter(isPublicInstallation) });
16903
+ return JSON.stringify({
16904
+ success: true,
16905
+ data: installations.filter(isPublicInstallation).filter((installation) => !personalInstallationIds || personalInstallationIds.has(installation.id)).map(import_protocols25.maskChannelInstallationSecrets)
16906
+ });
16833
16907
  }
16834
16908
  case "create": {
16835
- if (!input.channel || !input.senderId || !input.agentId) {
16909
+ if (!input.channel || !input.senderId) {
16910
+ return JSON.stringify({ success: false, error: "create requires channel, senderId, and agentId" });
16911
+ }
16912
+ if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
16913
+ return failure("A personal assistant can only bind senders to itself");
16914
+ }
16915
+ const agentId = personalAssistantId ?? input.agentId;
16916
+ if (!agentId) {
16836
16917
  return JSON.stringify({ success: false, error: "create requires channel, senderId, and agentId" });
16837
16918
  }
16838
- const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2);
16919
+ const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
16839
16920
  if (!installId) {
16840
16921
  return JSON.stringify({
16841
16922
  success: false,
16842
16923
  error: `No channelInstallationId provided and unable to auto-detect. Use action=list_installations to find available installations for channel "${input.channel}".`
16843
16924
  });
16844
16925
  }
16845
- const validation = await validatePublicInstallation(installId, tenantId2, input.channel);
16926
+ const validation = await validatePublicInstallation(
16927
+ installId,
16928
+ tenantId2,
16929
+ input.channel,
16930
+ personalInstallationIds
16931
+ );
16846
16932
  if (validation) return failure(validation);
16847
16933
  const binding = await registry4.create({
16848
16934
  channel: input.channel,
16849
16935
  channelInstallationId: installId,
16850
16936
  tenantId: tenantId2,
16851
16937
  senderId: input.senderId,
16852
- agentId: input.agentId,
16938
+ agentId,
16853
16939
  threadMode: input.threadMode,
16854
16940
  senderDisplayName: input.senderDisplayName
16855
16941
  });
@@ -16859,14 +16945,22 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
16859
16945
  if (!input.channel || !input.senderId) {
16860
16946
  return JSON.stringify({ success: false, error: "update requires channel and senderId" });
16861
16947
  }
16862
- const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2);
16948
+ if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
16949
+ return failure("A personal assistant can only bind senders to itself");
16950
+ }
16951
+ const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
16863
16952
  if (!installId) {
16864
16953
  return JSON.stringify({
16865
16954
  success: false,
16866
16955
  error: `No channelInstallationId provided and unable to auto-detect. Use action=list_installations first.`
16867
16956
  });
16868
16957
  }
16869
- const validation = await validatePublicInstallation(installId, tenantId2, input.channel);
16958
+ const validation = await validatePublicInstallation(
16959
+ installId,
16960
+ tenantId2,
16961
+ input.channel,
16962
+ personalInstallationIds
16963
+ );
16870
16964
  if (validation) return failure(validation);
16871
16965
  const existing = await registry4.findBySubject({
16872
16966
  channel: input.channel,
@@ -16880,8 +16974,11 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
16880
16974
  if (existing.channel === "room") {
16881
16975
  return failure("Internal room bindings cannot be managed");
16882
16976
  }
16977
+ if (personalAssistantId && existing.agentId !== personalAssistantId) {
16978
+ return JSON.stringify({ success: false, error: "Binding not found" });
16979
+ }
16883
16980
  const updated = await registry4.update(tenantId2, existing.id, {
16884
- agentId: input.agentId,
16981
+ agentId: personalAssistantId ?? input.agentId,
16885
16982
  threadMode: input.threadMode,
16886
16983
  senderDisplayName: input.senderDisplayName
16887
16984
  });
@@ -16891,14 +16988,19 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
16891
16988
  if (!input.channel || !input.senderId) {
16892
16989
  return JSON.stringify({ success: false, error: "delete requires channel and senderId" });
16893
16990
  }
16894
- const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2);
16991
+ const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
16895
16992
  if (!installId) {
16896
16993
  return JSON.stringify({
16897
16994
  success: false,
16898
16995
  error: `No channelInstallationId provided and unable to auto-detect.`
16899
16996
  });
16900
16997
  }
16901
- const validation = await validatePublicInstallation(installId, tenantId2, input.channel);
16998
+ const validation = await validatePublicInstallation(
16999
+ installId,
17000
+ tenantId2,
17001
+ input.channel,
17002
+ personalInstallationIds
17003
+ );
16902
17004
  if (validation) return failure(validation);
16903
17005
  const existing = await registry4.findBySubject({
16904
17006
  channel: input.channel,
@@ -16912,17 +17014,25 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
16912
17014
  if (existing.channel === "room") {
16913
17015
  return failure("Internal room bindings cannot be managed");
16914
17016
  }
17017
+ if (personalAssistantId && existing.agentId !== personalAssistantId) {
17018
+ return JSON.stringify({ success: false, error: "Binding not found" });
17019
+ }
16915
17020
  await registry4.delete(tenantId2, existing.id);
16916
17021
  return JSON.stringify({ success: true, message: "Binding deleted" });
16917
17022
  }
16918
17023
  case "list": {
16919
- const bindings = await registry4.list({
17024
+ if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
17025
+ return failure("A personal assistant can only list its own bindings");
17026
+ }
17027
+ const listed = await registry4.list({
16920
17028
  channel: input.channel,
16921
- agentId: input.agentId,
17029
+ agentId: personalAssistantId ?? input.agentId,
16922
17030
  tenantId: tenantId2,
16923
17031
  channelInstallationId: input.channelInstallationId,
16924
- excludeChannels: ["room"]
17032
+ excludeChannels: ["room"],
17033
+ ...personalAssistantId ? { limit: 500 } : {}
16925
17034
  });
17035
+ const bindings = personalInstallationIds ? listed.filter((binding) => personalInstallationIds.has(binding.channelInstallationId)) : listed;
16926
17036
  return JSON.stringify({ success: true, data: bindings });
16927
17037
  }
16928
17038
  default:
@@ -16930,33 +17040,83 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
16930
17040
  }
16931
17041
  }
16932
17042
  );
16933
- async function resolveInstallationId(channel, tenantId2) {
17043
+ async function resolveInstallationId(channel, tenantId2, allowedIds) {
16934
17044
  const store2 = getInstallationStore();
16935
17045
  const installations = await store2.getInstallationsByTenant(tenantId2, channel);
16936
- const publicInstallations = installations.filter(isPublicInstallation);
17046
+ const publicInstallations = installations.filter(isPublicInstallation).filter((installation) => !allowedIds || allowedIds.has(installation.id));
16937
17047
  if (publicInstallations.length === 1) {
16938
17048
  return publicInstallations[0].id;
16939
17049
  }
16940
17050
  return null;
16941
17051
  }
16942
- function getTenantId(config) {
17052
+ function getRunConfig(config) {
16943
17053
  if (typeof config !== "object" || config === null) return null;
16944
17054
  const configurable = config.configurable;
16945
17055
  if (typeof configurable !== "object" || configurable === null) return null;
16946
17056
  const runConfig = configurable.runConfig;
16947
17057
  if (typeof runConfig !== "object" || runConfig === null) return null;
16948
- const tenantId2 = runConfig.tenantId;
16949
- return typeof tenantId2 === "string" && tenantId2 ? tenantId2 : null;
17058
+ return runConfig;
17059
+ }
17060
+ function getString(record, key6) {
17061
+ const value = record?.[key6];
17062
+ return typeof value === "string" && value.length > 0 ? value : null;
17063
+ }
17064
+ function getTenantId(config) {
17065
+ return getString(getRunConfig(config), "tenantId");
17066
+ }
17067
+ async function resolvePersonalAssistantId(tenantId2, config) {
17068
+ const runConfig = getRunConfig(config);
17069
+ const assistantId = getString(runConfig, "assistant_id") ?? getString(runConfig, "assistantId");
17070
+ if (!assistantId) return null;
17071
+ try {
17072
+ const assistant = await getStoreLattice("default", "assistant").store.getAssistantById(tenantId2, assistantId);
17073
+ return assistant?.ownerUserId ? assistantId : null;
17074
+ } catch {
17075
+ return null;
17076
+ }
16950
17077
  }
16951
17078
  function isPublicInstallation(installation) {
16952
17079
  return installation.channel !== "room";
16953
17080
  }
16954
- async function validatePublicInstallation(installationId, tenantId2, channel) {
17081
+ function installationReferencesAssistant(installation, assistantId) {
17082
+ if (installation.fallbackAgentId === assistantId) return true;
17083
+ const config = installation.config;
17084
+ return Boolean(
17085
+ config && typeof config === "object" && !Array.isArray(config) && config.assistantId === assistantId
17086
+ );
17087
+ }
17088
+ async function listPersonalInstallationIds(registry4, tenantId2, assistantId) {
17089
+ const ids = /* @__PURE__ */ new Set();
17090
+ const installations = await getInstallationStore().getInstallationsByTenant(tenantId2);
17091
+ for (const installation of installations) {
17092
+ if (isPublicInstallation(installation) && installationReferencesAssistant(installation, assistantId)) {
17093
+ ids.add(installation.id);
17094
+ }
17095
+ }
17096
+ for (let offset = 0; ; offset += 500) {
17097
+ const bindings = await registry4.list({
17098
+ tenantId: tenantId2,
17099
+ agentId: assistantId,
17100
+ excludeChannels: ["room"],
17101
+ limit: 500,
17102
+ offset
17103
+ });
17104
+ for (const binding of bindings) {
17105
+ if (binding.channelInstallationId) ids.add(binding.channelInstallationId);
17106
+ }
17107
+ if (bindings.length < 500) break;
17108
+ }
17109
+ return ids;
17110
+ }
17111
+ async function validatePublicInstallation(installationId, tenantId2, channel, allowedIds) {
16955
17112
  try {
16956
17113
  const installation = await getInstallationStore().getInstallationById(installationId);
16957
17114
  if (!installation || !isPublicInstallation(installation) || installation.tenantId !== tenantId2 || installation.channel !== channel) {
16958
17115
  return "Invalid public channel installation";
16959
17116
  }
17117
+ if (allowedIds && !allowedIds.has(installationId)) {
17118
+ return "Invalid public channel installation";
17119
+ }
16960
17120
  return null;
16961
17121
  } catch {
16962
17122
  return "Unable to validate public channel installation";
@@ -21064,7 +21224,7 @@ var createBrowserGetInfoTool = ({ vmIsolation }) => {
21064
21224
  var import_messages9 = require("@langchain/core/messages");
21065
21225
 
21066
21226
  // src/agent_lattice/types.ts
21067
- var import_protocols25 = require("@axiom-lattice/protocols");
21227
+ var import_protocols26 = require("@axiom-lattice/protocols");
21068
21228
 
21069
21229
  // src/agent_lattice/AgentLatticeManager.ts
21070
21230
  init_BaseLatticeManager();
@@ -22236,7 +22396,7 @@ async function describeImage(options) {
22236
22396
 
22237
22397
  // src/stt_model_lattice/STTModelLatticeManager.ts
22238
22398
  init_BaseLatticeManager();
22239
- var import_protocols26 = require("@axiom-lattice/protocols");
22399
+ var import_protocols27 = require("@axiom-lattice/protocols");
22240
22400
 
22241
22401
  // src/stt_model_lattice/STTModelLattice.ts
22242
22402
  var import_openai3 = require("@langchain/openai");
@@ -22372,7 +22532,7 @@ var STTModelLatticeManager = class _STTModelLatticeManager extends BaseLatticeMa
22372
22532
  * chat key must never resolve to a speech client.
22373
22533
  */
22374
22534
  async loadItemFromStore(tenantId2, key6) {
22375
- const row = key6 === import_protocols26.ASR_DEFAULT_KEY ? await loadTenantDefaultModelRow(tenantId2, "asr") : await loadTenantModelRow(tenantId2, key6);
22535
+ const row = key6 === import_protocols27.ASR_DEFAULT_KEY ? await loadTenantDefaultModelRow(tenantId2, "asr") : await loadTenantModelRow(tenantId2, key6);
22376
22536
  if (!row || row.model.kind !== "asr") {
22377
22537
  return void 0;
22378
22538
  }
@@ -22500,16 +22660,16 @@ var getSTTClient = (key6) => sttModelLatticeManager.getSTTClient(key6);
22500
22660
  var getSTTClientWithTenant = (tenantId2, key6) => sttModelLatticeManager.getSTTClientWithTenant(tenantId2, key6);
22501
22661
 
22502
22662
  // src/deep_agent_new/backends/transcribeAudio.ts
22503
- var import_protocols27 = require("@axiom-lattice/protocols");
22663
+ var import_protocols28 = require("@axiom-lattice/protocols");
22504
22664
  async function transcribeAudio(options) {
22505
22665
  const { audioBuffer, format, tenantId: tenantId2 = "default", modelKey } = options;
22506
- const requestedKey = modelKey || import_protocols27.ASR_DEFAULT_KEY;
22666
+ const requestedKey = modelKey || import_protocols28.ASR_DEFAULT_KEY;
22507
22667
  const client = await sttModelLatticeManager.getSTTClientWithTenantAsync(
22508
22668
  tenantId2,
22509
22669
  requestedKey
22510
- ) ?? (requestedKey === import_protocols27.ASR_DEFAULT_KEY ? void 0 : await sttModelLatticeManager.getSTTClientWithTenantAsync(
22670
+ ) ?? (requestedKey === import_protocols28.ASR_DEFAULT_KEY ? void 0 : await sttModelLatticeManager.getSTTClientWithTenantAsync(
22511
22671
  tenantId2,
22512
- import_protocols27.ASR_DEFAULT_KEY
22672
+ import_protocols28.ASR_DEFAULT_KEY
22513
22673
  )) ?? await sttModelLatticeManager.getSTTClientWithTenantAsync(
22514
22674
  tenantId2,
22515
22675
  "default"
@@ -27621,7 +27781,7 @@ var import_langgraph5 = require("@langchain/langgraph");
27621
27781
 
27622
27782
  // src/agent_worker/delegation_service.ts
27623
27783
  var import_node_crypto10 = require("crypto");
27624
- var import_protocols31 = require("@axiom-lattice/protocols");
27784
+ var import_protocols32 = require("@axiom-lattice/protocols");
27625
27785
 
27626
27786
  // src/services/Agent.ts
27627
27787
  var import_node_crypto9 = require("crypto");
@@ -27682,7 +27842,7 @@ var import_events = require("events");
27682
27842
 
27683
27843
  // src/queue_lattice/QueueLatticeManager.ts
27684
27844
  init_BaseLatticeManager();
27685
- var import_protocols28 = require("@axiom-lattice/protocols");
27845
+ var import_protocols29 = require("@axiom-lattice/protocols");
27686
27846
 
27687
27847
  // src/queue_lattice/MemoryQueueClient.ts
27688
27848
  var queues = /* @__PURE__ */ new Map();
@@ -27775,7 +27935,7 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
27775
27935
  queueClient = client;
27776
27936
  } else {
27777
27937
  const queueName = config.queueName || process.env.QUEUE_NAME || "tasks";
27778
- if (config.type === import_protocols28.QueueType.REDIS) {
27938
+ if (config.type === import_protocols29.QueueType.REDIS) {
27779
27939
  throw new Error(
27780
27940
  `Redis queue client must be provided. Please install @axiom-lattice/queue-redis and pass the client to registerLattice. Example: registerLattice(key, config, new RedisQueueClient(queueName, options))`
27781
27941
  );
@@ -28239,7 +28399,7 @@ function truncateForJson(value, options = {}) {
28239
28399
  }
28240
28400
 
28241
28401
  // src/services/Agent.ts
28242
- var import_protocols30 = require("@axiom-lattice/protocols");
28402
+ var import_protocols31 = require("@axiom-lattice/protocols");
28243
28403
  var import_langgraph4 = require("@langchain/langgraph");
28244
28404
 
28245
28405
  // src/services/agentInterrupts.ts
@@ -28362,7 +28522,7 @@ var ChunkBuffer = class {
28362
28522
  };
28363
28523
 
28364
28524
  // src/chunk_buffer_lattice/InMemoryChunkBuffer.ts
28365
- var import_protocols29 = require("@axiom-lattice/protocols");
28525
+ var import_protocols30 = require("@axiom-lattice/protocols");
28366
28526
  var import_rxjs = require("rxjs");
28367
28527
  var import_rxjs_for_await = require("rxjs-for-await");
28368
28528
  var import_operators = require("rxjs/operators");
@@ -28450,7 +28610,7 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
28450
28610
  let chunk2;
28451
28611
  if (typeof arg2 === "string" && arg3 !== void 0) {
28452
28612
  chunk2 = {
28453
- type: import_protocols29.MessageChunkTypes.AI,
28613
+ type: import_protocols30.MessageChunkTypes.AI,
28454
28614
  data: {
28455
28615
  id: arg2,
28456
28616
  content: arg3
@@ -28645,8 +28805,8 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
28645
28805
  const buffer2 = this.getBufferIfValid(threadId);
28646
28806
  if (!buffer2) return;
28647
28807
  const defaultStopTypes = [
28648
- import_protocols29.MessageChunkTypes.MESSAGE_COMPLETED,
28649
- import_protocols29.MessageChunkTypes.THREAD_IDLE
28808
+ import_protocols30.MessageChunkTypes.MESSAGE_COMPLETED,
28809
+ import_protocols30.MessageChunkTypes.THREAD_IDLE
28650
28810
  ];
28651
28811
  const typesToStop = stopTypes ?? defaultStopTypes;
28652
28812
  let startIndex = buffer2.status === "active" /* ACTIVE */ ? buffer2.chunks.length : 0;
@@ -30800,7 +30960,7 @@ function cloneRunConfig(value, stripReserved) {
30800
30960
  const clone10 = [];
30801
30961
  for (let index = 0; index < length; index += 1) {
30802
30962
  const key6 = String(index);
30803
- const data = (0, import_protocols30.descriptorDataValue)(descriptors[key6]);
30963
+ const data = (0, import_protocols31.descriptorDataValue)(descriptors[key6]);
30804
30964
  if (!data || data.value === void 0) {
30805
30965
  throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${key6}`);
30806
30966
  }
@@ -30815,7 +30975,7 @@ function cloneRunConfig(value, stripReserved) {
30815
30975
  for (const key6 of keys) {
30816
30976
  if (typeof key6 !== "string") continue;
30817
30977
  const fieldPath = callerRunConfigPath(path8, key6);
30818
- const data = (0, import_protocols30.descriptorDataValue)(descriptors[key6]);
30978
+ const data = (0, import_protocols31.descriptorDataValue)(descriptors[key6]);
30819
30979
  if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
30820
30980
  if (stripReserved && RESERVED_CALLER_RUN_KEYS.has(key6) || data.value === void 0) continue;
30821
30981
  Object.defineProperty(clone9, key6, {
@@ -30851,7 +31011,7 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
30851
31011
  if (Array.isArray(entry)) {
30852
31012
  const descriptors2 = Object.getOwnPropertyDescriptors(entry);
30853
31013
  for (let index = 0; index < entry.length; index += 1) {
30854
- const data = (0, import_protocols30.descriptorDataValue)(descriptors2[String(index)]);
31014
+ const data = (0, import_protocols31.descriptorDataValue)(descriptors2[String(index)]);
30855
31015
  if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${index}`);
30856
31016
  visit(data.value, `${path8}/${index}`);
30857
31017
  }
@@ -30870,7 +31030,7 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
30870
31030
  }
30871
31031
  const fieldPath = callerRunConfigPath(path8, key6);
30872
31032
  const descriptor = descriptors[key6];
30873
- const data = (0, import_protocols30.descriptorDataValue)(descriptor);
31033
+ const data = (0, import_protocols31.descriptorDataValue)(descriptor);
30874
31034
  if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
30875
31035
  if (isCredentialBearingKey(key6)) {
30876
31036
  throw new CapabilityRuntimeResolutionError(
@@ -30894,9 +31054,9 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
30894
31054
  }
30895
31055
  function preserveExecutionBinding(source, target) {
30896
31056
  if (typeof source !== "object" || source === null || Array.isArray(source)) return;
30897
- const execution = (0, import_protocols30.descriptorDataValue)(Object.getOwnPropertyDescriptor(source, "execution"))?.value;
31057
+ const execution = (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(source, "execution"))?.value;
30898
31058
  if (typeof execution !== "object" || execution === null || Array.isArray(execution)) return;
30899
- const taskId = (0, import_protocols30.descriptorDataValue)(Object.getOwnPropertyDescriptor(execution, "taskId"))?.value;
31059
+ const taskId = (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(execution, "taskId"))?.value;
30900
31060
  if (typeof taskId !== "string" || taskId.trim() === "") return;
30901
31061
  Object.defineProperty(target, "execution", {
30902
31062
  value: { taskId },
@@ -30920,7 +31080,7 @@ function cloneExecutionRunConfigBase(value) {
30920
31080
  throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
30921
31081
  }
30922
31082
  const descriptor = descriptors[key6];
30923
- const data = (0, import_protocols30.descriptorDataValue)(descriptor);
31083
+ const data = (0, import_protocols31.descriptorDataValue)(descriptor);
30924
31084
  if (!data) {
30925
31085
  throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
30926
31086
  }
@@ -31171,7 +31331,7 @@ var DelegatedScopeNotQueueableError = class extends Error {
31171
31331
  function ownDataValue(value, key6) {
31172
31332
  if (typeof value !== "object" || value === null) return void 0;
31173
31333
  try {
31174
- return (0, import_protocols30.descriptorDataValue)(Object.getOwnPropertyDescriptor(value, key6))?.value;
31334
+ return (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(value, key6))?.value;
31175
31335
  } catch {
31176
31336
  return void 0;
31177
31337
  }
@@ -34147,7 +34307,7 @@ var DelegationService = class {
34147
34307
  }
34148
34308
  this.reserveChild(context.budgetId, request.thread_id);
34149
34309
  }
34150
- const scope = (0, import_protocols31.resolveRunScope)(request.runConfig);
34310
+ const scope = (0, import_protocols32.resolveRunScope)(request.runConfig);
34151
34311
  const leaseStore = storeLatticeManager.getStoreLattice("default", "lease").store;
34152
34312
  const abortController = new AbortController();
34153
34313
  const cancellation = request.parentThreadId ? delegationCancellationRegistry.register(request.tenantId, request.parentThreadId) : void 0;
@@ -34705,7 +34865,7 @@ function createTaskTool(options) {
34705
34865
  key: assistant_id,
34706
34866
  name: "general-purpose",
34707
34867
  description: DEFAULT_GENERAL_PURPOSE_DESCRIPTION,
34708
- type: import_protocols25.AgentType.REACT,
34868
+ type: import_protocols26.AgentType.REACT,
34709
34869
  prompt: DEFAULT_SUBAGENT_PROMPT
34710
34870
  },
34711
34871
  client
@@ -34960,30 +35120,30 @@ var datePlugin = {
34960
35120
  var import_langchain57 = require("langchain");
34961
35121
  var import_zod52 = require("zod");
34962
35122
  var import_uuid6 = require("uuid");
34963
- var import_protocols32 = require("@axiom-lattice/protocols");
35123
+ var import_protocols33 = require("@axiom-lattice/protocols");
34964
35124
  var SCHEDULE_LATTICE_KEY = "default";
34965
35125
  var AGENT_ADD_MESSAGE_TASK_TYPE = "agent.add_message";
34966
- function getRunConfig(config) {
35126
+ function getRunConfig2(config) {
34967
35127
  const configurable = config;
34968
35128
  return configurable?.configurable?.runConfig ?? {};
34969
35129
  }
34970
35130
  function mapStatusToEnum(status) {
34971
35131
  if (!status) return void 0;
34972
35132
  const statusMap = {
34973
- pending: import_protocols32.ScheduledTaskStatus.PENDING,
34974
- running: import_protocols32.ScheduledTaskStatus.RUNNING,
34975
- completed: import_protocols32.ScheduledTaskStatus.COMPLETED,
34976
- failed: import_protocols32.ScheduledTaskStatus.FAILED,
34977
- cancelled: import_protocols32.ScheduledTaskStatus.CANCELLED,
34978
- paused: import_protocols32.ScheduledTaskStatus.PAUSED
35133
+ pending: import_protocols33.ScheduledTaskStatus.PENDING,
35134
+ running: import_protocols33.ScheduledTaskStatus.RUNNING,
35135
+ completed: import_protocols33.ScheduledTaskStatus.COMPLETED,
35136
+ failed: import_protocols33.ScheduledTaskStatus.FAILED,
35137
+ cancelled: import_protocols33.ScheduledTaskStatus.CANCELLED,
35138
+ paused: import_protocols33.ScheduledTaskStatus.PAUSED
34979
35139
  };
34980
35140
  return statusMap[status];
34981
35141
  }
34982
35142
  function mapExecutionTypeToEnum(executionType) {
34983
35143
  if (!executionType) return void 0;
34984
35144
  const typeMap = {
34985
- once: import_protocols32.ScheduleExecutionType.ONCE,
34986
- cron: import_protocols32.ScheduleExecutionType.CRON
35145
+ once: import_protocols33.ScheduleExecutionType.ONCE,
35146
+ cron: import_protocols33.ScheduleExecutionType.CRON
34987
35147
  };
34988
35148
  return typeMap[executionType];
34989
35149
  }
@@ -35044,7 +35204,7 @@ function createSchedulerMiddleware(options = {}) {
35044
35204
  tools: [
35045
35205
  (0, import_langchain57.tool)(
35046
35206
  async (input, config) => {
35047
- const runConfig = getRunConfig(config);
35207
+ const runConfig = getRunConfig2(config);
35048
35208
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
35049
35209
  const taskId = (0, import_uuid6.v4)();
35050
35210
  const executeAt = input.executeAt;
@@ -35079,7 +35239,7 @@ function createSchedulerMiddleware(options = {}) {
35079
35239
  ),
35080
35240
  (0, import_langchain57.tool)(
35081
35241
  async (input, config) => {
35082
- const runConfig = getRunConfig(config);
35242
+ const runConfig = getRunConfig2(config);
35083
35243
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
35084
35244
  const taskId = (0, import_uuid6.v4)();
35085
35245
  const executeAt = Date.now() + input.delayMs;
@@ -35114,7 +35274,7 @@ function createSchedulerMiddleware(options = {}) {
35114
35274
  ),
35115
35275
  (0, import_langchain57.tool)(
35116
35276
  async (input, config) => {
35117
- const runConfig = getRunConfig(config);
35277
+ const runConfig = getRunConfig2(config);
35118
35278
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
35119
35279
  const taskId = (0, import_uuid6.v4)();
35120
35280
  const success = await scheduleLattice.client.scheduleCron(
@@ -35172,7 +35332,7 @@ function createSchedulerMiddleware(options = {}) {
35172
35332
  ),
35173
35333
  (0, import_langchain57.tool)(
35174
35334
  async (input, config) => {
35175
- const runConfig = getRunConfig(config);
35335
+ const runConfig = getRunConfig2(config);
35176
35336
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
35177
35337
  const storage = scheduleLattice.client.getStorage();
35178
35338
  if (!storage) {
@@ -36904,7 +37064,7 @@ ${BASE_PROMPT}` : BASE_PROMPT;
36904
37064
  }
36905
37065
 
36906
37066
  // src/agent_lattice/builders/DeepAgentGraphBuilder.ts
36907
- var import_protocols33 = require("@axiom-lattice/protocols");
37067
+ var import_protocols34 = require("@axiom-lattice/protocols");
36908
37068
  init_MemoryLatticeManager();
36909
37069
  var DeepAgentGraphBuilder = class {
36910
37070
  /**
@@ -36966,7 +37126,7 @@ var DeepAgentGraphBuilder = class {
36966
37126
  key: generalPurposeKey,
36967
37127
  name: "general-purpose",
36968
37128
  description: DEFAULT_GENERAL_PURPOSE_DESCRIPTION,
36969
- type: import_protocols33.AgentType.REACT,
37129
+ type: import_protocols34.AgentType.REACT,
36970
37130
  prompt: DEFAULT_SUBAGENT_PROMPT,
36971
37131
  tenantId: tenantId2
36972
37132
  },
@@ -37298,7 +37458,7 @@ _A2ARemoteClient.MAX_CACHED_TASKS = 100;
37298
37458
  var A2ARemoteClient = _A2ARemoteClient;
37299
37459
 
37300
37460
  // src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
37301
- var import_protocols34 = require("@axiom-lattice/protocols");
37461
+ var import_protocols35 = require("@axiom-lattice/protocols");
37302
37462
  init_MemoryLatticeManager();
37303
37463
  function resolveA2ARemoteContextId(assistantKey, threadId) {
37304
37464
  return threadId ? `a2a-remote:${assistantKey}:${threadId}` : void 0;
@@ -37308,7 +37468,7 @@ var RemoteAgentGraphBuilder = class {
37308
37468
  this.deps = deps;
37309
37469
  }
37310
37470
  async build(agentLattice, params) {
37311
- if (agentLattice.config.type !== import_protocols34.AgentType.A2A_REMOTE) {
37471
+ if (agentLattice.config.type !== import_protocols35.AgentType.A2A_REMOTE) {
37312
37472
  throw new Error(
37313
37473
  `RemoteAgentGraphBuilder received wrong agent type: ${agentLattice.config.type}`
37314
37474
  );
@@ -37367,7 +37527,7 @@ function extractLastHumanMessage(messages) {
37367
37527
  // src/agent_lattice/builders/WorkflowAgentGraphBuilder.ts
37368
37528
  var import_langchain60 = require("langchain");
37369
37529
  init_MemoryLatticeManager();
37370
- var import_protocols35 = require("@axiom-lattice/protocols");
37530
+ var import_protocols36 = require("@axiom-lattice/protocols");
37371
37531
  init_compile();
37372
37532
 
37373
37533
  // src/agent_lattice/builders/middlewareSanitize.ts
@@ -37406,7 +37566,7 @@ ${configPrompt}` : base;
37406
37566
  }
37407
37567
  var WorkflowAgentGraphBuilder = class {
37408
37568
  async build(agentLattice, params) {
37409
- if (!(0, import_protocols35.isWorkflowAgentConfig)(agentLattice.config)) {
37569
+ if (!(0, import_protocols36.isWorkflowAgentConfig)(agentLattice.config)) {
37410
37570
  throw new Error(
37411
37571
  `WorkflowAgentGraphBuilder received wrong agent type: ${agentLattice.config.type}`
37412
37572
  );
@@ -37529,10 +37689,10 @@ var AgentGraphBuilderFactory = class _AgentGraphBuilderFactory {
37529
37689
  * 注册默认的Builder
37530
37690
  */
37531
37691
  registerDefaultBuilders() {
37532
- this.builders.set(import_protocols25.AgentType.REACT, new ReActAgentGraphBuilder());
37533
- this.builders.set(import_protocols25.AgentType.DEEP_AGENT, new DeepAgentGraphBuilder());
37534
- this.builders.set(import_protocols25.AgentType.A2A_REMOTE, new RemoteAgentGraphBuilder());
37535
- this.builders.set(import_protocols25.AgentType.WORKFLOW, new WorkflowAgentGraphBuilder());
37692
+ this.builders.set(import_protocols26.AgentType.REACT, new ReActAgentGraphBuilder());
37693
+ this.builders.set(import_protocols26.AgentType.DEEP_AGENT, new DeepAgentGraphBuilder());
37694
+ this.builders.set(import_protocols26.AgentType.A2A_REMOTE, new RemoteAgentGraphBuilder());
37695
+ this.builders.set(import_protocols26.AgentType.WORKFLOW, new WorkflowAgentGraphBuilder());
37536
37696
  }
37537
37697
  /**
37538
37698
  * 注册自定义Builder
@@ -37559,7 +37719,7 @@ var AgentGraphBuilderFactory = class _AgentGraphBuilderFactory {
37559
37719
  };
37560
37720
 
37561
37721
  // src/mcp_lattice/personalMcpLifecycle.ts
37562
- var import_protocols36 = require("@axiom-lattice/protocols");
37722
+ var import_protocols37 = require("@axiom-lattice/protocols");
37563
37723
 
37564
37724
  // src/mcp_lattice/McpLatticeManager.ts
37565
37725
  var import_mcp_adapters = require("@langchain/mcp-adapters");
@@ -38455,7 +38615,9 @@ function getPersonalMcpMaxServers() {
38455
38615
  return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : PERSONAL_MCP_MAX_SERVERS;
38456
38616
  }
38457
38617
  function getPersonalMcpSyncBudgetMs() {
38458
- const raw = Number(process.env.PERSONAL_MCP_SYNC_BUDGET_MS);
38618
+ const value = process.env.PERSONAL_MCP_SYNC_BUDGET_MS;
38619
+ if (value === void 0 || value.trim() === "") return PERSONAL_MCP_SYNC_BUDGET_MS;
38620
+ const raw = Number(value);
38459
38621
  return Number.isFinite(raw) && raw >= 0 ? raw : PERSONAL_MCP_SYNC_BUDGET_MS;
38460
38622
  }
38461
38623
  var syncCache = /* @__PURE__ */ new Map();
@@ -38473,7 +38635,7 @@ function errorMessage(error) {
38473
38635
  function getPersonalMcpStore() {
38474
38636
  if (!storeLatticeManager.hasLattice("default", "mcp")) return void 0;
38475
38637
  const store2 = storeLatticeManager.getStoreLattice("default", "mcp").store;
38476
- return (0, import_protocols36.isPersonalMcpServerConfigStore)(store2) ? store2 : void 0;
38638
+ return (0, import_protocols37.isPersonalMcpServerConfigStore)(store2) ? store2 : void 0;
38477
38639
  }
38478
38640
  function invalidatePersonalMcpSync(tenantId2, assistantId) {
38479
38641
  const key6 = syncKey(tenantId2, assistantId);
@@ -38763,7 +38925,7 @@ async function countPersonalMcpServers(tenantId2, assistantId) {
38763
38925
  }
38764
38926
 
38765
38927
  // src/agent_lattice/builders/AgentParamsBuilder.ts
38766
- var import_protocols37 = require("@axiom-lattice/protocols");
38928
+ var import_protocols38 = require("@axiom-lattice/protocols");
38767
38929
  var AgentParamsBuilder = class {
38768
38930
  /**
38769
38931
  * constructor
@@ -38781,7 +38943,7 @@ var AgentParamsBuilder = class {
38781
38943
  * @returns Agent build parameters
38782
38944
  */
38783
38945
  async buildParams(agentLattice, options) {
38784
- const skills = (0, import_protocols37.isDeepAgentConfig)(agentLattice.config) ? agentLattice.config.skillCategories : void 0;
38946
+ const skills = (0, import_protocols38.isDeepAgentConfig)(agentLattice.config) ? agentLattice.config.skillCategories : void 0;
38785
38947
  const tenantId2 = agentLattice.config.tenantId || "default";
38786
38948
  const ownerUserId = agentLattice.config.ownerUserId;
38787
38949
  const assistantId = agentLattice.config.key;
@@ -38789,7 +38951,7 @@ var AgentParamsBuilder = class {
38789
38951
  if (isPersonalAssistant) {
38790
38952
  await ensurePersonalMcpForAssistant({ tenantId: tenantId2, assistantId });
38791
38953
  }
38792
- const configuredKeys = options?.overrideTools || (0, import_protocols37.getToolsFromConfig)(agentLattice.config);
38954
+ const configuredKeys = options?.overrideTools || (0, import_protocols38.getToolsFromConfig)(agentLattice.config);
38793
38955
  const autoKeys = isPersonalAssistant && !options?.overrideTools ? toolLatticeManager.getAssistantToolKeys(tenantId2, assistantId) : [];
38794
38956
  const toolKeys = Array.from(/* @__PURE__ */ new Set([...configuredKeys, ...autoKeys]));
38795
38957
  const tools = toolKeys.map((toolKey) => {
@@ -38814,7 +38976,7 @@ var AgentParamsBuilder = class {
38814
38976
  if (!model) {
38815
38977
  throw new Error(`Model "${resolvedModelKey}" does not exist`);
38816
38978
  }
38817
- const subAgentKeys = (0, import_protocols37.getSubAgentsFromConfig)(agentLattice.config);
38979
+ const subAgentKeys = (0, import_protocols38.getSubAgentsFromConfig)(agentLattice.config);
38818
38980
  const subAgents = await Promise.all(subAgentKeys.map(async (agentKey) => {
38819
38981
  const subAgentLattice = await this.getAgentLatticeFunc(agentKey);
38820
38982
  if (!subAgentLattice) {
@@ -38831,7 +38993,7 @@ var AgentParamsBuilder = class {
38831
38993
  }));
38832
38994
  const resolvedSubAgents = subAgents.filter((s) => s !== null);
38833
38995
  let internalSubAgents = [];
38834
- if ((0, import_protocols37.isDeepAgentConfig)(agentLattice.config)) {
38996
+ if ((0, import_protocols38.isDeepAgentConfig)(agentLattice.config)) {
38835
38997
  internalSubAgents = agentLattice.config.internalSubAgents?.map((i) => ({
38836
38998
  key: i.key,
38837
38999
  config: i
@@ -38874,11 +39036,19 @@ function mergeAgentConfig(parent, child) {
38874
39036
  // src/agent_lattice/agentArchitectTools.ts
38875
39037
  var import_zod54 = __toESM(require("zod"));
38876
39038
  var import_uuid8 = require("uuid");
38877
- var import_protocols38 = require("@axiom-lattice/protocols");
39039
+ var import_protocols39 = require("@axiom-lattice/protocols");
38878
39040
  function getTenantId2(exeConfig) {
38879
39041
  const runConfig = exeConfig?.configurable?.runConfig || {};
38880
39042
  return runConfig.tenantId || "default";
38881
39043
  }
39044
+ function getRuntimeUserId(exeConfig) {
39045
+ const runConfig = exeConfig?.configurable?.runConfig || {};
39046
+ const value = runConfig.user_id ?? runConfig.userId;
39047
+ return typeof value === "string" && value.length > 0 ? value : null;
39048
+ }
39049
+ function canAccessAssistant(assistant, userId) {
39050
+ return !assistant.ownerUserId || userId !== null && assistant.ownerUserId === userId;
39051
+ }
38882
39052
  function getAssistStore() {
38883
39053
  return getStoreLattice("default", "assistant").store;
38884
39054
  }
@@ -38894,7 +39064,7 @@ function getAvailableTools(tenantId2) {
38894
39064
  }
38895
39065
  async function getAvailableModels(tenantId2) {
38896
39066
  await tenantHasOwnModelSupply(tenantId2);
38897
- await tenantHasOwnModelSupply(import_protocols38.PLATFORM_MODEL_TENANT_ID);
39067
+ await tenantHasOwnModelSupply(import_protocols39.PLATFORM_MODEL_TENANT_ID);
38898
39068
  return listModelLatticesForTenant(tenantId2);
38899
39069
  }
38900
39070
  async function getAvailableMiddlewareTypes(tenantId2) {
@@ -38924,7 +39094,7 @@ function getStringMetadata(config) {
38924
39094
  }
38925
39095
  function isUndecidedLearningPlaceholder(config) {
38926
39096
  const metadata = getStringMetadata(config);
38927
- return config.type === import_protocols38.AgentType.REACT && metadata.learningPlaceholder === "true" && metadata.architectureStatus === "undecided";
39097
+ return config.type === import_protocols39.AgentType.REACT && metadata.learningPlaceholder === "true" && metadata.architectureStatus === "undecided";
38928
39098
  }
38929
39099
  function requireSkillDeclaration(skillLoaded) {
38930
39100
  if (skillLoaded !== true) {
@@ -38971,17 +39141,21 @@ async function validateAgentReferences(input, tenantId2) {
38971
39141
  function slugify(name) {
38972
39142
  return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-+/g, "-") || "agent";
38973
39143
  }
39144
+ var MAX_AGENT_ID_ALLOCATION_ATTEMPTS = 1e3;
38974
39145
  async function generateAgentId(tenantId2, name) {
38975
39146
  const store2 = getAssistStore();
38976
39147
  const base = slugify(name);
38977
39148
  let id = base;
38978
39149
  let counter = 2;
38979
- while (true) {
39150
+ for (let attempt = 0; attempt < MAX_AGENT_ID_ALLOCATION_ATTEMPTS; attempt += 1) {
38980
39151
  const existing = await store2.getAssistantById(tenantId2, id);
38981
39152
  if (!existing) return id;
38982
39153
  id = `${base}-${counter}`;
38983
- counter++;
39154
+ counter += 1;
38984
39155
  }
39156
+ throw new Error(
39157
+ `Unable to allocate a unique agent id for "${name}" after ${MAX_AGENT_ID_ALLOCATION_ATTEMPTS} attempts`
39158
+ );
38985
39159
  }
38986
39160
  registerToolLattice(
38987
39161
  "list_agents",
@@ -38993,8 +39167,9 @@ registerToolLattice(
38993
39167
  async (_input, exeConfig) => {
38994
39168
  try {
38995
39169
  const tenantId2 = getTenantId2(exeConfig);
39170
+ const userId = getRuntimeUserId(exeConfig);
38996
39171
  const store2 = getAssistStore();
38997
- const agents = await store2.getAllAssistants(tenantId2);
39172
+ const agents = (await store2.getAllAssistants(tenantId2)).filter((agent) => canAccessAssistant(agent, userId));
38998
39173
  return JSON.stringify({
38999
39174
  agents: agents.map((a) => ({
39000
39175
  id: a.id,
@@ -39024,7 +39199,7 @@ registerToolLattice(
39024
39199
  const tenantId2 = getTenantId2(exeConfig);
39025
39200
  const store2 = getAssistStore();
39026
39201
  const agent = await store2.getAssistantById(tenantId2, input.id);
39027
- if (!agent) {
39202
+ if (!agent || !canAccessAssistant(agent, getRuntimeUserId(exeConfig))) {
39028
39203
  return JSON.stringify({ error: `Agent '${input.id}' not found` });
39029
39204
  }
39030
39205
  return JSON.stringify(agent.graphDefinition);
@@ -39077,7 +39252,7 @@ registerToolLattice(
39077
39252
  key: id,
39078
39253
  name: input.name,
39079
39254
  description: input.description || "",
39080
- type: input.type === "deep_agent" ? import_protocols38.AgentType.DEEP_AGENT : import_protocols38.AgentType.REACT,
39255
+ type: input.type === "deep_agent" ? import_protocols39.AgentType.DEEP_AGENT : import_protocols39.AgentType.REACT,
39081
39256
  prompt: input.prompt,
39082
39257
  ...input.tools && input.tools.length > 0 ? { tools: input.tools } : {},
39083
39258
  ...input.middleware && input.middleware.length > 0 ? { middleware: input.middleware } : {},
@@ -39134,7 +39309,7 @@ registerToolLattice(
39134
39309
  key: id,
39135
39310
  name: input.name,
39136
39311
  description: input.description || "",
39137
- type: import_protocols38.AgentType.WORKFLOW,
39312
+ type: import_protocols39.AgentType.WORKFLOW,
39138
39313
  prompt: input.description || `Workflow: ${input.name}`,
39139
39314
  workflowYaml: input.yaml,
39140
39315
  ...input.tools && input.tools.length > 0 ? { tools: input.tools } : {},
@@ -39171,7 +39346,7 @@ registerToolLattice(
39171
39346
  return JSON.stringify({ error: `Agent '${input.id}' not found` });
39172
39347
  }
39173
39348
  const graphDef = agent.graphDefinition;
39174
- if (!graphDef || graphDef.type !== import_protocols38.AgentType.WORKFLOW) {
39349
+ if (!graphDef || graphDef.type !== import_protocols39.AgentType.WORKFLOW) {
39175
39350
  return JSON.stringify({ error: `Agent '${input.id}' is not a workflow agent` });
39176
39351
  }
39177
39352
  const yaml2 = graphDef.workflowYaml;
@@ -39286,7 +39461,7 @@ registerToolLattice(
39286
39461
  return JSON.stringify({ error: `Agent '${input.id}' not found` });
39287
39462
  }
39288
39463
  const existingConfig = existing.graphDefinition || {};
39289
- const isWorkflow = existingConfig.type === import_protocols38.AgentType.WORKFLOW;
39464
+ const isWorkflow = existingConfig.type === import_protocols39.AgentType.WORKFLOW;
39290
39465
  const isPlaceholder = isUndecidedLearningPlaceholder(existingConfig);
39291
39466
  if (!isWorkflow && !isPlaceholder) {
39292
39467
  console.log(`[update_workflow] ERROR: not a workflow agent: ${input.id}`);
@@ -39302,7 +39477,7 @@ registerToolLattice(
39302
39477
  const mergedConfig = {
39303
39478
  ...existingConfig,
39304
39479
  ...isPlaceholder ? {
39305
- type: import_protocols38.AgentType.WORKFLOW,
39480
+ type: import_protocols39.AgentType.WORKFLOW,
39306
39481
  workflowYaml: input.yaml,
39307
39482
  metadata: {
39308
39483
  ...getStringMetadata(existingConfig),
@@ -39400,7 +39575,7 @@ registerToolLattice(
39400
39575
  const tenantId2 = getTenantId2(exeConfig);
39401
39576
  const store2 = getAssistStore();
39402
39577
  const existing = await store2.getAssistantById(tenantId2, input.id);
39403
- if (!existing) {
39578
+ if (!existing || !canAccessAssistant(existing, getRuntimeUserId(exeConfig))) {
39404
39579
  return JSON.stringify({ error: `Agent '${input.id}' not found` });
39405
39580
  }
39406
39581
  const existingConfig = existing.graphDefinition || {};
@@ -39408,14 +39583,14 @@ registerToolLattice(
39408
39583
  const mergedConfig = { ...existingConfig, ...input.config };
39409
39584
  const isPlaceholder = isUndecidedLearningPlaceholder(existingConfigRecord);
39410
39585
  const materializedType = input.config.type;
39411
- const isMaterializingPlaceholder = isPlaceholder && (materializedType === import_protocols38.AgentType.REACT || materializedType === import_protocols38.AgentType.DEEP_AGENT);
39586
+ const isMaterializingPlaceholder = isPlaceholder && (materializedType === import_protocols39.AgentType.REACT || materializedType === import_protocols39.AgentType.DEEP_AGENT);
39412
39587
  if (isMaterializingPlaceholder) {
39413
39588
  mergedConfig.metadata = {
39414
39589
  ...getStringMetadata(existingConfigRecord),
39415
39590
  ...input.config.metadata ?? {},
39416
39591
  learningPlaceholder: "false",
39417
39592
  architectureStatus: "materialized",
39418
- architectureForm: materializedType === import_protocols38.AgentType.DEEP_AGENT ? "orchestra" : "capability"
39593
+ architectureForm: materializedType === import_protocols39.AgentType.DEEP_AGENT ? "orchestra" : "capability"
39419
39594
  };
39420
39595
  } else if (isPlaceholder && input.config.metadata !== void 0) {
39421
39596
  const metadata = {
@@ -39514,9 +39689,16 @@ registerToolLattice(
39514
39689
  const tenantId2 = getTenantId2(exeConfig);
39515
39690
  const store2 = getAssistStore();
39516
39691
  const existing = await store2.getAssistantById(tenantId2, input.id);
39517
- if (!existing) {
39692
+ if (!existing || !canAccessAssistant(existing, getRuntimeUserId(exeConfig))) {
39518
39693
  return JSON.stringify({ error: `Agent '${input.id}' not found`, success: false });
39519
39694
  }
39695
+ if (existing.ownerUserId) {
39696
+ return JSON.stringify({
39697
+ success: false,
39698
+ code: "PERSONAL_ASSISTANT_DELETE_UNSUPPORTED",
39699
+ error: "Personal assistants must be deleted from the Personal Assistant page"
39700
+ });
39701
+ }
39520
39702
  const success = await store2.deleteAssistant(tenantId2, input.id);
39521
39703
  if (success) {
39522
39704
  try {
@@ -39666,7 +39848,7 @@ registerToolLattice(
39666
39848
  );
39667
39849
 
39668
39850
  // src/agent_lattice/agentArchitectConfig.ts
39669
- var import_protocols39 = require("@axiom-lattice/protocols");
39851
+ var import_protocols40 = require("@axiom-lattice/protocols");
39670
39852
 
39671
39853
  // src/agent_lattice/agentArchitectPrompt.ts
39672
39854
  var AGENT_ARCHITECT_PROMPT = `You are the Agent Architect.
@@ -39692,7 +39874,7 @@ var agentArchitectConfig = {
39692
39874
  key: AGENT_ARCHITECT_KEY,
39693
39875
  name: "Agent Architect",
39694
39876
  description: "Design and manage AI agents through natural language conversation. Use this agent when you want to create a new agent, modify an existing agent, or manage your agent collection (list, view, update, delete).",
39695
- type: import_protocols39.AgentType.DEEP_AGENT,
39877
+ type: import_protocols40.AgentType.DEEP_AGENT,
39696
39878
  prompt: AGENT_ARCHITECT_PROMPT,
39697
39879
  tools: [
39698
39880
  "list_agents",
@@ -39795,7 +39977,7 @@ var agentArchitectConfig = {
39795
39977
  };
39796
39978
 
39797
39979
  // src/agent_lattice/agentReviewerConfig.ts
39798
- var import_protocols40 = require("@axiom-lattice/protocols");
39980
+ var import_protocols41 = require("@axiom-lattice/protocols");
39799
39981
 
39800
39982
  // src/agent_lattice/agentReviewerPrompt.ts
39801
39983
  var AGENT_REVIEWER_PROMPT = `# Agent Reviewer
@@ -39861,7 +40043,7 @@ var agentReviewerConfig = {
39861
40043
  key: AGENT_REVIEWER_KEY,
39862
40044
  name: "Agent Reviewer",
39863
40045
  description: "Review and test AI agents. Use this agent to check agent configurations for correctness and to test agents by invoking them with realistic messages.",
39864
- type: import_protocols40.AgentType.REACT,
40046
+ type: import_protocols41.AgentType.REACT,
39865
40047
  prompt: AGENT_REVIEWER_PROMPT,
39866
40048
  tools: [
39867
40049
  "invoke_agent",
@@ -39882,7 +40064,7 @@ var agentReviewerConfig = {
39882
40064
  };
39883
40065
 
39884
40066
  // src/agent_lattice/roomCoordinatorConfig.ts
39885
- var import_protocols41 = require("@axiom-lattice/protocols");
40067
+ var import_protocols42 = require("@axiom-lattice/protocols");
39886
40068
 
39887
40069
  // src/agent_lattice/roomCoordinatorPrompt.ts
39888
40070
  var ROOM_COORDINATOR_PROMPT = `You are the Room Coordinator. CRITICAL FIRST ACTION: Before any response or other action, call the \`skill\` tool with skill_name: "room-coordination" to load room-coordination and follow it. Never announce the skill load. If it fails, retry once, then stop and explicitly report that the required room-coordination skill could not be loaded.`;
@@ -39893,7 +40075,7 @@ var roomCoordinatorConfig = {
39893
40075
  key: ROOM_COORDINATOR_KEY,
39894
40076
  name: "Room Coordinator",
39895
40077
  description: "Manages project room conversations: replies when no bot is mentioned, coordinates room members, and organizes project work.",
39896
- type: import_protocols41.AgentType.DEEP_AGENT,
40078
+ type: import_protocols42.AgentType.DEEP_AGENT,
39897
40079
  prompt: ROOM_COORDINATOR_PROMPT,
39898
40080
  tools: [],
39899
40081
  middleware: [
@@ -39960,7 +40142,7 @@ function assistantToConfig(assistant) {
39960
40142
  key: assistant.id,
39961
40143
  name: assistant.name ?? graphDef.name ?? assistant.id,
39962
40144
  description: assistant.description ?? graphDef.description ?? "",
39963
- type: import_protocols25.AgentType.REACT,
40145
+ type: import_protocols26.AgentType.REACT,
39964
40146
  prompt: typeof assistant.graphDefinition === "string" ? assistant.graphDefinition : JSON.stringify(assistant.graphDefinition)
39965
40147
  };
39966
40148
  Object.assign(config, graphDef);
@@ -40553,7 +40735,7 @@ function clearAuthProvidersForTests() {
40553
40735
 
40554
40736
  // src/auth_lattice/IdentityMappingService.ts
40555
40737
  var import_node_crypto11 = require("crypto");
40556
- var import_protocols42 = require("@axiom-lattice/protocols");
40738
+ var import_protocols43 = require("@axiom-lattice/protocols");
40557
40739
  var IdentityMappingConfigError = class extends Error {
40558
40740
  /**
40559
40741
  * @param message - Human-readable configuration problem.
@@ -40636,7 +40818,7 @@ var IdentityMappingService = class {
40636
40818
  return { kind: "not_provisioned", reason: "NO_MATCH" };
40637
40819
  }
40638
40820
  if (!email) {
40639
- throw new import_protocols42.AuthError("EMAIL_REQUIRED", 400, "OIDC identity has no email");
40821
+ throw new import_protocols43.AuthError("EMAIL_REQUIRED", 400, "OIDC identity has no email");
40640
40822
  }
40641
40823
  const avatarUrl = avatarUrlFromPrincipal(principal);
40642
40824
  let createdUser;
@@ -40650,7 +40832,7 @@ var IdentityMappingService = class {
40650
40832
  } catch {
40651
40833
  const recovered = await this.recoverJitRace(principal, email);
40652
40834
  if (!recovered) {
40653
- throw new import_protocols42.AuthError(
40835
+ throw new import_protocols43.AuthError(
40654
40836
  "PROVIDER_ERROR",
40655
40837
  502,
40656
40838
  "OIDC JIT provisioning failed"
@@ -40675,7 +40857,7 @@ var IdentityMappingService = class {
40675
40857
  try {
40676
40858
  await this.deps.externalIdentityStore.link(identity);
40677
40859
  } catch (error) {
40678
- if (!(error instanceof import_protocols42.ExternalIdentityConflictError)) {
40860
+ if (!(error instanceof import_protocols43.ExternalIdentityConflictError)) {
40679
40861
  await this.deleteUserQuietly(createdUser.id);
40680
40862
  throw error;
40681
40863
  }
@@ -40705,7 +40887,7 @@ var IdentityMappingService = class {
40705
40887
  } catch (error) {
40706
40888
  await this.unlinkQuietly(providerId, issuer, principal.subject);
40707
40889
  await this.deleteUserQuietly(user.id);
40708
- throw error instanceof import_protocols42.AuthError ? error : new import_protocols42.AuthError(
40890
+ throw error instanceof import_protocols43.AuthError ? error : new import_protocols43.AuthError(
40709
40891
  "PROVIDER_ERROR",
40710
40892
  502,
40711
40893
  "Failed to link the default tenant during JIT provisioning"
@@ -40716,7 +40898,7 @@ var IdentityMappingService = class {
40716
40898
  }
40717
40899
  }
40718
40900
  if (!user) {
40719
- throw new import_protocols42.AuthError("PROVIDER_ERROR", 502, "OIDC JIT provisioning failed");
40901
+ throw new import_protocols43.AuthError("PROVIDER_ERROR", 502, "OIDC JIT provisioning failed");
40720
40902
  }
40721
40903
  user = await this.syncOidcAvatar(user, principal);
40722
40904
  if (user.status === "pending") return { kind: "pending", user, created };
@@ -40730,7 +40912,7 @@ var IdentityMappingService = class {
40730
40912
  principal.subject
40731
40913
  );
40732
40914
  if (!linked) {
40733
- throw new import_protocols42.AuthError("PROVIDER_ERROR", 502, "External identity was not linked");
40915
+ throw new import_protocols43.AuthError("PROVIDER_ERROR", 502, "External identity was not linked");
40734
40916
  }
40735
40917
  return { kind: "authenticated", user, externalIdentity: linked };
40736
40918
  }
@@ -40935,7 +41117,7 @@ var getVectorStoreClient = (key6) => vectorStoreLatticeManager.getVectorStoreCli
40935
41117
 
40936
41118
  // src/logger_lattice/LoggerLatticeManager.ts
40937
41119
  init_BaseLatticeManager();
40938
- var import_protocols43 = require("@axiom-lattice/protocols");
41120
+ var import_protocols44 = require("@axiom-lattice/protocols");
40939
41121
 
40940
41122
  // src/logger_lattice/PinoLoggerClient.ts
40941
41123
  var import_pino2 = __toESM(require("pino"));
@@ -41138,11 +41320,11 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
41138
41320
  if (client) {
41139
41321
  loggerClient = client;
41140
41322
  } else {
41141
- if (config.type === import_protocols43.LoggerType.PINO) {
41323
+ if (config.type === import_protocols44.LoggerType.PINO) {
41142
41324
  loggerClient = new PinoLoggerClient(config);
41143
- } else if (config.type === import_protocols43.LoggerType.CONSOLE) {
41325
+ } else if (config.type === import_protocols44.LoggerType.CONSOLE) {
41144
41326
  loggerClient = new ConsoleLoggerClient(config);
41145
- } else if (config.type === import_protocols43.LoggerType.CUSTOM) {
41327
+ } else if (config.type === import_protocols44.LoggerType.CUSTOM) {
41146
41328
  throw new Error(
41147
41329
  `Custom logger client must be provided. Please pass the client to registerLattice.`
41148
41330
  );
@@ -45290,7 +45472,7 @@ var LatticeEvalSuite = class {
45290
45472
  };
45291
45473
 
45292
45474
  // src/eval_lattice/LatticeEvalProject.ts
45293
- var import_protocols44 = require("@axiom-lattice/protocols");
45475
+ var import_protocols45 = require("@axiom-lattice/protocols");
45294
45476
  var import_messages8 = require("@langchain/core/messages");
45295
45477
  var import_uuid10 = require("uuid");
45296
45478
  var DEFAULT_CALIBRATION_PROBES = [
@@ -45350,7 +45532,7 @@ var LatticeEvalProject = class {
45350
45532
  key: this.judgeAgentKey,
45351
45533
  name: `Judge agent for ${this.project.projectName}`,
45352
45534
  description: "Judge agent for evaluating Lattice test cases",
45353
- type: import_protocols44.AgentType.REACT,
45535
+ type: import_protocols45.AgentType.REACT,
45354
45536
  prompt: "",
45355
45537
  modelKey: judgeModelKey
45356
45538
  };
@@ -45576,7 +45758,7 @@ function getMenuRegistry() {
45576
45758
  }
45577
45759
 
45578
45760
  // src/services/ProjectTaskReassignmentAuthorization.ts
45579
- var import_protocols45 = require("@axiom-lattice/protocols");
45761
+ var import_protocols46 = require("@axiom-lattice/protocols");
45580
45762
  var issued = /* @__PURE__ */ new WeakMap();
45581
45763
  function createProjectTaskReassignmentAuthorizer(policy, threadValidator) {
45582
45764
  return {
@@ -45609,7 +45791,7 @@ function inspectProjectTaskReassignmentAuthorization(authorization) {
45609
45791
  return snapshot ? { ...snapshot } : void 0;
45610
45792
  }
45611
45793
  function snapshotInput(input) {
45612
- const row = (0, import_protocols45.snapshotExactRecord)(input, [
45794
+ const row = (0, import_protocols46.snapshotExactRecord)(input, [
45613
45795
  "tenantId",
45614
45796
  "workspaceId",
45615
45797
  "projectId",
@@ -45652,7 +45834,7 @@ function snapshotInput(input) {
45652
45834
  }
45653
45835
 
45654
45836
  // src/services/TaskLifecycleNotifier.ts
45655
- var import_protocols46 = require("@axiom-lattice/protocols");
45837
+ var import_protocols47 = require("@axiom-lattice/protocols");
45656
45838
  var TaskLifecycleNotifier = class {
45657
45839
  constructor() {
45658
45840
  this.listeners = /* @__PURE__ */ new Set();
@@ -45719,7 +45901,7 @@ var TaskLifecycleNotifier = class {
45719
45901
  };
45720
45902
  var taskLifecycleNotifier = new TaskLifecycleNotifier();
45721
45903
  function snapshotNotification(value) {
45722
- const row = (0, import_protocols46.snapshotExactRecord)(value, [
45904
+ const row = (0, import_protocols47.snapshotExactRecord)(value, [
45723
45905
  "tenantId",
45724
45906
  "workspaceId",
45725
45907
  "projectId",
@@ -45751,7 +45933,7 @@ function nonempty(value) {
45751
45933
  }
45752
45934
 
45753
45935
  // src/services/ProjectTaskAdmissionNotifier.ts
45754
- var import_protocols47 = require("@axiom-lattice/protocols");
45936
+ var import_protocols48 = require("@axiom-lattice/protocols");
45755
45937
  var ProjectTaskAdmissionNotifier = class {
45756
45938
  /**
45757
45939
  * Creates a bounded Project task admission notifier.
@@ -45852,7 +46034,7 @@ var ProjectTaskAdmissionNotifier = class {
45852
46034
  };
45853
46035
  var projectTaskAdmissionNotifier = new ProjectTaskAdmissionNotifier();
45854
46036
  function snapshotNotification2(value) {
45855
- const row = (0, import_protocols47.snapshotExactRecord)(value, [
46037
+ const row = (0, import_protocols48.snapshotExactRecord)(value, [
45856
46038
  "tenantId",
45857
46039
  "workspaceId",
45858
46040
  "projectId",
@@ -45955,7 +46137,7 @@ var OutboxPoller = class {
45955
46137
 
45956
46138
  // src/services/ProjectMutationMutex.ts
45957
46139
  var import_node_async_hooks2 = require("async_hooks");
45958
- var import_protocols48 = require("@axiom-lattice/protocols");
46140
+ var import_protocols49 = require("@axiom-lattice/protocols");
45959
46141
 
45960
46142
  // src/services/coordinationLease.ts
45961
46143
  var configured;
@@ -46014,7 +46196,7 @@ async function withLease(store2, key6, ownerLabel, fn, options = {}) {
46014
46196
  // src/services/ProjectMutationMutex.ts
46015
46197
  var MUTATION_LEASE_OPTIONS = { ttlMs: 6e4, acquireTimeoutMs: 9e4, retryDelayMs: 100 };
46016
46198
  function projectKey(scope) {
46017
- const row = (0, import_protocols48.snapshotExactRecord)(scope, ["tenantId", "projectId"]);
46199
+ const row = (0, import_protocols49.snapshotExactRecord)(scope, ["tenantId", "projectId"]);
46018
46200
  if (!row || typeof row.tenantId !== "string" || !row.tenantId || row.tenantId.includes("\0") || typeof row.projectId !== "string" || !row.projectId || row.projectId.includes("\0")) {
46019
46201
  throw new Error("Invalid Project mutation scope");
46020
46202
  }
@@ -46100,7 +46282,7 @@ function createTrustedAgentMessageDispatcher(resolve4) {
46100
46282
 
46101
46283
  // src/services/RoomAgentMessageService.ts
46102
46284
  var import_crypto10 = require("crypto");
46103
- var import_protocols49 = require("@axiom-lattice/protocols");
46285
+ var import_protocols50 = require("@axiom-lattice/protocols");
46104
46286
  var INPUT_KEYS = [
46105
46287
  "tenantId",
46106
46288
  "workspaceId",
@@ -46265,7 +46447,7 @@ var RoomAgentMessageService = class {
46265
46447
  function exactValues(value, required, optional = []) {
46266
46448
  try {
46267
46449
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
46268
- return (0, import_protocols49.snapshotExactRecord)(value, required, optional);
46450
+ return (0, import_protocols50.snapshotExactRecord)(value, required, optional);
46269
46451
  } catch {
46270
46452
  return void 0;
46271
46453
  }
@@ -46317,7 +46499,7 @@ function sourceOriginMatches(author, source) {
46317
46499
  return false;
46318
46500
  }
46319
46501
  function snapshotMentions(value) {
46320
- const rows = (0, import_protocols49.snapshotExactArray)(value);
46502
+ const rows = (0, import_protocols50.snapshotExactArray)(value);
46321
46503
  if (!rows) return void 0;
46322
46504
  const mentions = [];
46323
46505
  for (const row of rows) {
@@ -46345,7 +46527,7 @@ function snapshotCanonical(value, expected) {
46345
46527
  const author = exactValues(values?.author, ["type", "membershipId", "assistantId"]);
46346
46528
  const content = exactValues(values?.content, ["type", "text"]);
46347
46529
  const createdAt = date(values?.createdAt);
46348
- if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0, import_protocols49.snapshotExactArray)(values.mentions)?.length !== 0 || author?.type !== "bot" || expected.author.type !== "bot" || author.membershipId !== expected.author.membershipId || author.assistantId !== expected.author.assistantId || content?.type !== "text" || content.text !== expected.content.text || values.tenantId !== expected.tenantId || values.workspaceId !== expected.workspaceId || values.projectId !== expected.projectId || values.roomId !== expected.roomId || values.replyToMessageId !== expected.replyToMessageId || values.source !== "agent" || values.sourceId !== expected.sourceId || values.idempotencyKey !== expected.idempotencyKey) return void 0;
46530
+ if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0, import_protocols50.snapshotExactArray)(values.mentions)?.length !== 0 || author?.type !== "bot" || expected.author.type !== "bot" || author.membershipId !== expected.author.membershipId || author.assistantId !== expected.author.assistantId || content?.type !== "text" || content.text !== expected.content.text || values.tenantId !== expected.tenantId || values.workspaceId !== expected.workspaceId || values.projectId !== expected.projectId || values.roomId !== expected.roomId || values.replyToMessageId !== expected.replyToMessageId || values.source !== "agent" || values.sourceId !== expected.sourceId || values.idempotencyKey !== expected.idempotencyKey) return void 0;
46349
46531
  return {
46350
46532
  id: values.id,
46351
46533
  tenantId: expected.tenantId,
@@ -46367,7 +46549,7 @@ function snapshotCanonicalScoped(value, expected) {
46367
46549
  const author = exactValues(values?.author, ["type", "membershipId", "assistantId"]);
46368
46550
  const content = exactValues(values?.content, ["type", "text"]);
46369
46551
  const createdAt = date(values?.createdAt);
46370
- if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0, import_protocols49.snapshotExactArray)(values.mentions)?.length !== 0 || author?.type !== "bot" || expected.author.type !== "bot" || author.membershipId !== expected.author.membershipId || author.assistantId !== expected.author.assistantId || content?.type !== "text" || content.text !== expected.content.text || values.tenantId !== expected.tenantId || values.workspaceId !== expected.workspaceId || values.projectId !== expected.projectId || values.roomId !== expected.roomId || values.source !== "agent" || values.sourceId !== expected.sourceId || values.idempotencyKey !== expected.idempotencyKey) return void 0;
46552
+ if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0, import_protocols50.snapshotExactArray)(values.mentions)?.length !== 0 || author?.type !== "bot" || expected.author.type !== "bot" || author.membershipId !== expected.author.membershipId || author.assistantId !== expected.author.assistantId || content?.type !== "text" || content.text !== expected.content.text || values.tenantId !== expected.tenantId || values.workspaceId !== expected.workspaceId || values.projectId !== expected.projectId || values.roomId !== expected.roomId || values.source !== "agent" || values.sourceId !== expected.sourceId || values.idempotencyKey !== expected.idempotencyKey) return void 0;
46371
46553
  return {
46372
46554
  id: values.id,
46373
46555
  tenantId: expected.tenantId,
@@ -46421,7 +46603,7 @@ var ProjectRoomMessageNotifier = class {
46421
46603
  var projectRoomMessageNotifier = new ProjectRoomMessageNotifier();
46422
46604
 
46423
46605
  // src/services/ProjectTaskOwnerPolicy.ts
46424
- var import_protocols50 = require("@axiom-lattice/protocols");
46606
+ var import_protocols51 = require("@axiom-lattice/protocols");
46425
46607
  var MEMBERSHIP_REQUIRED_KEYS = [
46426
46608
  "id",
46427
46609
  "tenantId",
@@ -46530,7 +46712,7 @@ function sameRosterScope(membership, scope) {
46530
46712
  return membership.tenantId === scope.tenantId && membership.workspaceId === scope.workspaceId && membership.projectId === scope.projectId && membership.roomId === scope.roomId;
46531
46713
  }
46532
46714
  function snapshotScope(value, keys) {
46533
- const values = (0, import_protocols50.snapshotExactRecord)(value, keys);
46715
+ const values = (0, import_protocols51.snapshotExactRecord)(value, keys);
46534
46716
  if (!values || keys.some((key6) => !isNonemptyString(values[key6]))) return void 0;
46535
46717
  return values;
46536
46718
  }
@@ -46542,7 +46724,7 @@ function projectScope(scope, keys) {
46542
46724
  function snapshotMembership2(value) {
46543
46725
  try {
46544
46726
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
46545
- const values = (0, import_protocols50.snapshotExactRecord)(value, MEMBERSHIP_REQUIRED_KEYS, ["responsibility"]);
46727
+ const values = (0, import_protocols51.snapshotExactRecord)(value, MEMBERSHIP_REQUIRED_KEYS, ["responsibility"]);
46546
46728
  if (!values) return void 0;
46547
46729
  const joinedAt = snapshotDate(values.joinedAt);
46548
46730
  const updatedAt = snapshotDate(values.updatedAt);
@@ -46861,7 +47043,7 @@ function describe(error) {
46861
47043
 
46862
47044
  // src/services/TaskLifecycleService.ts
46863
47045
  var import_node_crypto17 = require("crypto");
46864
- var import_protocols51 = require("@axiom-lattice/protocols");
47046
+ var import_protocols52 = require("@axiom-lattice/protocols");
46865
47047
 
46866
47048
  // src/middlewares/taskBelief.ts
46867
47049
  var import_node_crypto16 = require("crypto");
@@ -46934,7 +47116,7 @@ async function applyBeliefImpacts(taskStore, owner3, impacts) {
46934
47116
  if (impacts.length === 0) return { description: owner3.description ?? "" };
46935
47117
  let current = owner3;
46936
47118
  for (let attempt = 0; attempt < BELIEF_OWNER_WRITE_ATTEMPTS; attempt += 1) {
46937
- const parsed = (0, import_protocols51.parseTaskBeliefState)(current.description ?? "");
47119
+ const parsed = (0, import_protocols52.parseTaskBeliefState)(current.description ?? "");
46938
47120
  const existingTable = parsed.success;
46939
47121
  if (!existingTable && parsed.code !== "MISSING_BELIEF_STATE") {
46940
47122
  return { description: current.description ?? "", task: current };
@@ -46951,7 +47133,7 @@ async function applyBeliefImpacts(taskStore, owner3, impacts) {
46951
47133
  changed = true;
46952
47134
  }
46953
47135
  if (!changed) return { description: current.description ?? "", task: current };
46954
- const description = (0, import_protocols51.replaceTaskBeliefState)(current.description ?? "", { entries });
47136
+ const description = (0, import_protocols52.replaceTaskBeliefState)(current.description ?? "", { entries });
46955
47137
  try {
46956
47138
  const updated = await taskStore.updateIfStatusAndUpdatedAt(
46957
47139
  current.tenantId,
@@ -47056,7 +47238,7 @@ function beliefStateOf(value) {
47056
47238
  function sameBeliefOwner(left, right) {
47057
47239
  const leftIdentity = { ...left, beliefState: void 0 };
47058
47240
  const rightIdentity = { ...right, beliefState: void 0 };
47059
- return canonicalJson(leftIdentity) === canonicalJson(rightIdentity) && (0, import_protocols51.taskBeliefStatesEqual)(left.beliefState, right.beliefState);
47241
+ return canonicalJson(leftIdentity) === canonicalJson(rightIdentity) && (0, import_protocols52.taskBeliefStatesEqual)(left.beliefState, right.beliefState);
47060
47242
  }
47061
47243
  function sameBeliefOwnerIdentity(left, right) {
47062
47244
  return canonicalJson({ ...left, beliefState: void 0 }) === canonicalJson({ ...right, beliefState: void 0 });
@@ -47204,7 +47386,7 @@ function changedBeliefKeys(left, right) {
47204
47386
  return [...keys].filter((key6) => {
47205
47387
  const oldEntry = leftByKey.get(key6);
47206
47388
  const newEntry = rightByKey.get(key6);
47207
- return !oldEntry || !newEntry || !(0, import_protocols51.taskBeliefStatesEqual)(
47389
+ return !oldEntry || !newEntry || !(0, import_protocols52.taskBeliefStatesEqual)(
47208
47390
  { entries: [oldEntry] },
47209
47391
  { entries: [newEntry] }
47210
47392
  );
@@ -48306,10 +48488,10 @@ var TaskLifecycleService = class {
48306
48488
  const description = preserveTargetContract(existing.description ?? "", input.description);
48307
48489
  const pending = existing.context?.belief_reconciliation_audit;
48308
48490
  const pendingAudit = pending && typeof pending === "object" ? pending : void 0;
48309
- const oldBelief = (0, import_protocols51.parseTaskBeliefState)(existing.description ?? "");
48310
- const newBelief = (0, import_protocols51.parseTaskBeliefState)(description);
48491
+ const oldBelief = (0, import_protocols52.parseTaskBeliefState)(existing.description ?? "");
48492
+ const newBelief = (0, import_protocols52.parseTaskBeliefState)(description);
48311
48493
  if (!newBelief.success) return failure2("INVALID_BELIEF_TABLE", newBelief.message);
48312
- if (!pendingAudit && description === (existing.description ?? "") && oldBelief.success && (0, import_protocols51.taskBeliefStatesEqual)(oldBelief.state, newBelief.state)) {
48494
+ if (!pendingAudit && description === (existing.description ?? "") && oldBelief.success && (0, import_protocols52.taskBeliefStatesEqual)(oldBelief.state, newBelief.state)) {
48313
48495
  return { success: true, task: existing, mutated: false };
48314
48496
  }
48315
48497
  const canonicalNew = newBelief.state.entries;
@@ -48440,7 +48622,7 @@ var TaskLifecycleService = class {
48440
48622
  }
48441
48623
  beliefOwnerSnapshot(task, parent) {
48442
48624
  const owner3 = parent?.ownerType === "agent" ? parent : task;
48443
- const parsed = (0, import_protocols51.parseTaskBeliefState)(owner3.description ?? "");
48625
+ const parsed = (0, import_protocols52.parseTaskBeliefState)(owner3.description ?? "");
48444
48626
  const beliefState = parsed.success ? parsed.state : { entries: [] };
48445
48627
  if (parent?.ownerType === "agent") {
48446
48628
  return {
@@ -49162,7 +49344,7 @@ function createTaskLifecycleService(deps) {
49162
49344
  // src/services/TaskExecutionService.ts
49163
49345
  var import_node_crypto19 = require("crypto");
49164
49346
  var import_node_util3 = require("util");
49165
- var import_protocols52 = require("@axiom-lattice/protocols");
49347
+ var import_protocols53 = require("@axiom-lattice/protocols");
49166
49348
 
49167
49349
  // src/services/taskErrorMessage.ts
49168
49350
  var MAX_EXECUTION_ERROR_MESSAGE_LENGTH = 1024;
@@ -49958,7 +50140,7 @@ function createTaskExecutionService(deps) {
49958
50140
  };
49959
50141
  }
49960
50142
  const eventKey = runId ? `execution-result:${threadId}:${runId}` : `execution-result:${threadId}`;
49961
- if (!(0, import_protocols52.isExecutionResultEventKey)(eventKey)) {
50143
+ if (!(0, import_protocols53.isExecutionResultEventKey)(eventKey)) {
49962
50144
  return {
49963
50145
  success: false,
49964
50146
  code: "INVALID_EXECUTION_RESULT_ID",
@@ -50930,7 +51112,7 @@ var createListCollectionsTool = ({
50930
51112
  // src/tool_lattice/collection/search_collection.ts
50931
51113
  var import_zod60 = __toESM(require("zod"));
50932
51114
  var import_langchain67 = require("langchain");
50933
- var import_protocols53 = require("@axiom-lattice/protocols");
51115
+ var import_protocols54 = require("@axiom-lattice/protocols");
50934
51116
  var SEARCH_COLLECTION_DESCRIPTION = `Search for content within a specific collection using semantic (vector) similarity. Use the 'filter' parameter to narrow results by metadata fields (e.g., {"category": "cardiovascular"}). Returns the most relevant content entries with similarity scores.`;
50935
51117
  var searchSchema = import_zod60.default.object({
50936
51118
  collection: import_zod60.default.string().describe("The collection name to search in"),
@@ -50950,7 +51132,7 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
50950
51132
  if (!metadata) {
50951
51133
  return `Collection "${collection}" not found. Use list_collections to see available collections.`;
50952
51134
  }
50953
- const embeddingKey = metadata.embeddingKey || import_protocols53.EMBEDDING_DEFAULT_KEY;
51135
+ const embeddingKey = metadata.embeddingKey || import_protocols54.EMBEDDING_DEFAULT_KEY;
50954
51136
  let vectorStore;
50955
51137
  try {
50956
51138
  const storeKey = `${tenantId2}:${collection}`;
@@ -50965,9 +51147,9 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
50965
51147
  const embeddingsClient = await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
50966
51148
  tenantId2,
50967
51149
  embeddingKey
50968
- ) ?? (embeddingKey === import_protocols53.EMBEDDING_DEFAULT_KEY ? void 0 : await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
51150
+ ) ?? (embeddingKey === import_protocols54.EMBEDDING_DEFAULT_KEY ? void 0 : await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
50969
51151
  tenantId2,
50970
- import_protocols53.EMBEDDING_DEFAULT_KEY
51152
+ import_protocols54.EMBEDDING_DEFAULT_KEY
50971
51153
  )) ?? await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
50972
51154
  tenantId2,
50973
51155
  "default"
@@ -51178,7 +51360,7 @@ var import_zod66 = __toESM(require("zod"));
51178
51360
  var import_langchain73 = require("langchain");
51179
51361
  var import_documents = require("@langchain/core/documents");
51180
51362
  var import_uuid11 = require("uuid");
51181
- var import_protocols54 = require("@axiom-lattice/protocols");
51363
+ var import_protocols55 = require("@axiom-lattice/protocols");
51182
51364
  var schema3 = import_zod66.default.object({
51183
51365
  collection: import_zod66.default.string().describe("Collection name"),
51184
51366
  entries: import_zod66.default.array(
@@ -51188,7 +51370,7 @@ var schema3 = import_zod66.default.object({
51188
51370
  }).describe("Entry content text"),
51189
51371
  metadata: import_zod66.default.record(import_zod66.default.string(), import_zod66.default.unknown()).optional().describe("Metadata fields matching the collection schema")
51190
51372
  })
51191
- ).min(1).max(import_protocols54.COLLECTION_ENTRY_BATCH_MAX)
51373
+ ).min(1).max(import_protocols55.COLLECTION_ENTRY_BATCH_MAX)
51192
51374
  });
51193
51375
  function key3(tenantId2, collection) {
51194
51376
  return `${tenantId2}:${collection}`;
@@ -51304,14 +51486,14 @@ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
51304
51486
  // src/tool_lattice/collection/delete_entries.ts
51305
51487
  var import_zod68 = __toESM(require("zod"));
51306
51488
  var import_langchain75 = require("langchain");
51307
- var import_protocols55 = require("@axiom-lattice/protocols");
51489
+ var import_protocols56 = require("@axiom-lattice/protocols");
51308
51490
  var schema5 = import_zod68.default.object({
51309
51491
  collection: import_zod68.default.string().describe("Collection name"),
51310
51492
  entryIds: import_zod68.default.array(
51311
51493
  import_zod68.default.string().refine((value) => value.trim().length > 0, {
51312
51494
  message: "entry id must not be blank"
51313
51495
  }).describe("Entry ID to delete")
51314
- ).min(1).max(import_protocols55.COLLECTION_ENTRY_BATCH_MAX)
51496
+ ).min(1).max(import_protocols56.COLLECTION_ENTRY_BATCH_MAX)
51315
51497
  });
51316
51498
  function key5(tenantId2, collection) {
51317
51499
  return `${tenantId2}:${collection}`;
@@ -52568,15 +52750,15 @@ var widgetPlugin = {
52568
52750
  var import_langchain82 = require("langchain");
52569
52751
  var import_zod72 = require("zod");
52570
52752
  var import_langgraph13 = require("@langchain/langgraph");
52571
- var import_protocols57 = require("@axiom-lattice/protocols");
52753
+ var import_protocols58 = require("@axiom-lattice/protocols");
52572
52754
 
52573
52755
  // src/services/taskWorkerRunConfig.ts
52574
- var import_protocols56 = require("@axiom-lattice/protocols");
52756
+ var import_protocols57 = require("@axiom-lattice/protocols");
52575
52757
  function resolveWorkerRunScope(input) {
52576
- const caller = (0, import_protocols56.resolveRunScope)(input.runConfig);
52758
+ const caller = (0, import_protocols57.resolveRunScope)(input.runConfig);
52577
52759
  return {
52578
- workspaceId: (0, import_protocols56.firstNonEmptyString)(input.invocation.workspaceId) ?? caller.workspaceId,
52579
- projectId: (0, import_protocols56.firstNonEmptyString)(input.invocation.projectId) ?? caller.projectId
52760
+ workspaceId: (0, import_protocols57.firstNonEmptyString)(input.invocation.workspaceId) ?? caller.workspaceId,
52761
+ projectId: (0, import_protocols57.firstNonEmptyString)(input.invocation.projectId) ?? caller.projectId
52580
52762
  };
52581
52763
  }
52582
52764
  function applyWorkerRunScope(runConfig, scope) {
@@ -52593,7 +52775,7 @@ function applyWorkerRunScope(runConfig, scope) {
52593
52775
  }
52594
52776
 
52595
52777
  // src/middlewares/taskMiddleware.ts
52596
- var import_protocols58 = require("@axiom-lattice/protocols");
52778
+ var import_protocols59 = require("@axiom-lattice/protocols");
52597
52779
 
52598
52780
  // src/middlewares/taskResponseSerialization.ts
52599
52781
  var TASK_RESPONSE_SCALAR_MAX_BYTES = 4096;
@@ -52898,7 +53080,7 @@ async function postProcessTaskMutationResponse(input) {
52898
53080
  }
52899
53081
 
52900
53082
  // src/middlewares/taskMiddleware.ts
52901
- function getRunConfig2(config) {
53083
+ function getRunConfig3(config) {
52902
53084
  const c = config;
52903
53085
  return c?.configurable?.runConfig ?? {};
52904
53086
  }
@@ -53082,7 +53264,7 @@ function classifyTaskAuthority(runConfig) {
53082
53264
  return delegatedTaskId ? { kind: "delegated", taskId: delegatedTaskId } : { kind: "ordinary" };
53083
53265
  }
53084
53266
  try {
53085
- const trusted = (0, import_protocols58.parseTrustedRunContext)(hasProjectTask ? { projectTask: runConfig.projectTask } : { projectRoom: runConfig.projectRoom });
53267
+ const trusted = (0, import_protocols59.parseTrustedRunContext)(hasProjectTask ? { projectTask: runConfig.projectTask } : { projectRoom: runConfig.projectRoom });
53086
53268
  return { kind: hasProjectTask ? "projectTask" : "projectRoom", trusted };
53087
53269
  } catch {
53088
53270
  return { kind: "invalid" };
@@ -53430,7 +53612,7 @@ function getTaskWorkItemStore() {
53430
53612
  return getStoreLattice("default", "taskWorkItem").store;
53431
53613
  }
53432
53614
  function getProjectTaskWorkItemStore() {
53433
- return (0, import_protocols58.requireProjectTaskWorkItemStore)(getTaskWorkItemStore());
53615
+ return (0, import_protocols59.requireProjectTaskWorkItemStore)(getTaskWorkItemStore());
53434
53616
  }
53435
53617
  function reviewInterruption(task) {
53436
53618
  const value = task.context?.interruption;
@@ -53481,7 +53663,7 @@ var manageTaskSchema = import_zod72.z.object({
53481
53663
  })).optional().describe("Structured belief reports required when an agent-owned task completes; existing keys update the belief owner's table, and a brand-new key must be declared with isNew: true"),
53482
53664
  content: import_zod72.z.string().optional().describe("Markdown content required for add_activity"),
53483
53665
  summary: import_zod72.z.string().optional().describe("Brief summary of the operation"),
53484
- executionResultId: import_zod72.z.string().refine(import_protocols58.isExecutionResultEventKey, {
53666
+ executionResultId: import_zod72.z.string().refine(import_protocols59.isExecutionResultEventKey, {
53485
53667
  message: "executionResultId must be the execution-result:<threadId> event key returned by task()"
53486
53668
  }).optional().describe(
53487
53669
  "Canonical ASCII `execution-result:<suffix>` event key returned by task(); the nonempty suffix allows only A-Z, a-z, 0-9, period, underscore, colon, and hyphen, and is not a database row ID"
@@ -53546,7 +53728,7 @@ async function getPendingExecutionResultIds(store2, tenantId2, taskId) {
53546
53728
  order: "desc",
53547
53729
  limit: PENDING_EXECUTION_RESULT_LIMIT + 1
53548
53730
  });
53549
- const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0, import_protocols58.isExecutionResultEventKey)(item.eventKey));
53731
+ const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0, import_protocols59.isExecutionResultEventKey)(item.eventKey));
53550
53732
  const reconciliationRows = new Array(canonicalCandidates.length);
53551
53733
  let nextCandidateIndex = 0;
53552
53734
  let firstError;
@@ -53624,14 +53806,14 @@ function updateValuesEqual(field, requested, persisted) {
53624
53806
  }
53625
53807
  function createTaskMiddleware(options = {}) {
53626
53808
  const handleManageTaskAction = async (input, config, validateExecutionResult, markMutation) => {
53627
- const rc = getRunConfig2(config);
53809
+ const rc = getRunConfig3(config);
53628
53810
  const authority = classifyTaskAuthority(rc);
53629
53811
  if (authority.kind === "invalid") return trustedContextError();
53630
53812
  const delegatedTaskId = authority.kind === "delegated" ? authority.taskId : void 0;
53631
53813
  const trustedProject = authority.kind === "projectRoom" || authority.kind === "projectTask" ? authority.trusted : void 0;
53632
53814
  const trustedScope = trustedProject?.projectTask ?? trustedProject?.projectRoom;
53633
53815
  const tenantId2 = trustedScope?.tenantId ?? (rc.tenantId || "default");
53634
- const runScope = (0, import_protocols57.resolveRunScope)(rc);
53816
+ const runScope = (0, import_protocols58.resolveRunScope)(rc);
53635
53817
  const workspaceId = trustedScope?.workspaceId ?? runScope.workspaceId;
53636
53818
  const projectId = trustedScope?.projectId ?? runScope.projectId;
53637
53819
  const revalidateCaller = async () => {
@@ -54205,8 +54387,8 @@ function createTaskMiddleware(options = {}) {
54205
54387
  let reconciliationMetadata = {};
54206
54388
  let descriptionMutated = false;
54207
54389
  if (isAgentTask && input.description !== void 0 && !valuesEqual(input.description, existing.description)) {
54208
- const oldBelief = (0, import_protocols58.parseTaskBeliefState)(existing.description ?? "");
54209
- const newBelief = (0, import_protocols58.parseTaskBeliefState)(input.description);
54390
+ const oldBelief = (0, import_protocols59.parseTaskBeliefState)(existing.description ?? "");
54391
+ const newBelief = (0, import_protocols59.parseTaskBeliefState)(input.description);
54210
54392
  const hasBeliefState = oldBelief.success || newBelief.success;
54211
54393
  if (hasBeliefState) {
54212
54394
  await validateExecutionResult();
@@ -54752,7 +54934,7 @@ function createTaskMiddleware(options = {}) {
54752
54934
  };
54753
54935
  const reconcileExplicitExecutionResult = async (input, config, response, validationError, didMutate) => {
54754
54936
  if (input.action !== "update" && input.action !== "set_status" && input.action !== "add_activity" || !input.id) return response;
54755
- const authority = classifyTaskAuthority(getRunConfig2(config));
54937
+ const authority = classifyTaskAuthority(getRunConfig3(config));
54756
54938
  if (authority.kind === "projectRoom" || authority.kind === "projectTask" || authority.kind === "invalid") {
54757
54939
  return response;
54758
54940
  }
@@ -54765,7 +54947,7 @@ function createTaskMiddleware(options = {}) {
54765
54947
  mutationCommitted: didMutate,
54766
54948
  validationError,
54767
54949
  reconcile: async (parsed) => {
54768
- const rc = getRunConfig2(config);
54950
+ const rc = getRunConfig3(config);
54769
54951
  const tenantId2 = rc.tenantId || "default";
54770
54952
  const workItemStore = getTaskWorkItemStore();
54771
54953
  const task = await getTaskStore().getById(tenantId2, taskId);
@@ -54794,11 +54976,11 @@ function createTaskMiddleware(options = {}) {
54794
54976
  let didMutate = false;
54795
54977
  const validateExecutionResult = async () => {
54796
54978
  if (!input.executionResultId || validationAttempted) return;
54797
- const authority = classifyTaskAuthority(getRunConfig2(config));
54979
+ const authority = classifyTaskAuthority(getRunConfig3(config));
54798
54980
  if (authority.kind === "projectRoom" || authority.kind === "projectTask" || authority.kind === "invalid") return;
54799
54981
  validationAttempted = true;
54800
54982
  try {
54801
- const rc = getRunConfig2(config);
54983
+ const rc = getRunConfig3(config);
54802
54984
  const tenantId2 = rc.tenantId || "default";
54803
54985
  const workItemStore = getTaskWorkItemStore();
54804
54986
  const executionResult = await workItemStore.findByEventKey(
@@ -54848,7 +55030,7 @@ function createTaskMiddleware(options = {}) {
54848
55030
  );
54849
55031
  };
54850
55032
  const handleStartTask = async (input, config) => {
54851
- const rc = getRunConfig2(config);
55033
+ const rc = getRunConfig3(config);
54852
55034
  const authority = classifyTaskAuthority(rc);
54853
55035
  if (authority.kind === "invalid") return trustedContextError();
54854
55036
  if (authority.kind === "delegated") {
@@ -55714,7 +55896,7 @@ function createParseDocumentTool({
55714
55896
  }
55715
55897
 
55716
55898
  // src/middlewares/documentParserMiddleware.ts
55717
- var import_protocols59 = require("@axiom-lattice/protocols");
55899
+ var import_protocols60 = require("@axiom-lattice/protocols");
55718
55900
 
55719
55901
  // src/middlewares/documentBenchmarkWorkflow.ts
55720
55902
  var DOCUMENT_PARSER_BENCHMARK_YAML = `name: document-parser-benchmark
@@ -56256,7 +56438,7 @@ var documentParserPlugin = {
56256
56438
  agents: {
56257
56439
  "document-parser": {
56258
56440
  key: "document-parser",
56259
- type: import_protocols59.AgentType.DEEP_AGENT,
56441
+ type: import_protocols60.AgentType.DEEP_AGENT,
56260
56442
  name: "Document Parser",
56261
56443
  description: "Parse documents (pdf, docx, images, spreadsheets) into clean Markdown. Defaults to local MarkItDown; escalates to remote engines only when quality or format needs it; runs engine benchmarking only on explicit request.",
56262
56444
  prompt: DOCUMENT_PARSER_SYSTEM_PROMPT,
@@ -56306,7 +56488,7 @@ var documentParserPlugin = {
56306
56488
  },
56307
56489
  "document-parser-benchmark": {
56308
56490
  key: "document-parser-benchmark",
56309
- type: import_protocols59.AgentType.WORKFLOW,
56491
+ type: import_protocols60.AgentType.WORKFLOW,
56310
56492
  name: "Document Parser Benchmark",
56311
56493
  description: "Benchmark document parsing engines. Parses a document with 5 engines in parallel, scores results, and produces a ranking report. Use this when you need to evaluate which parsing engine works best for a given document.",
56312
56494
  prompt: "Benchmark document parsing engines: parse with 5 engines, score, and rank results.",
@@ -56343,7 +56525,7 @@ var documentParserPlugin = {
56343
56525
 
56344
56526
  // src/middlewares/projectRoomMiddleware.ts
56345
56527
  var import_crypto11 = require("crypto");
56346
- var import_protocols60 = require("@axiom-lattice/protocols");
56528
+ var import_protocols61 = require("@axiom-lattice/protocols");
56347
56529
  var import_langchain86 = require("langchain");
56348
56530
  var import_zod74 = require("zod");
56349
56531
  var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
@@ -56373,7 +56555,7 @@ function ownDataValue2(record, key6) {
56373
56555
  if (typeof record !== "object" || record === null || Array.isArray(record)) return void 0;
56374
56556
  try {
56375
56557
  const descriptor = Object.getOwnPropertyDescriptor(record, key6);
56376
- return (0, import_protocols60.descriptorDataValue)(descriptor)?.value;
56558
+ return (0, import_protocols61.descriptorDataValue)(descriptor)?.value;
56377
56559
  } catch {
56378
56560
  return void 0;
56379
56561
  }
@@ -56383,14 +56565,14 @@ function readTrustedRoomScope(config) {
56383
56565
  const runConfig = ownDataValue2(configurable, "runConfig");
56384
56566
  const projectRoom = ownDataValue2(runConfig, "projectRoom");
56385
56567
  try {
56386
- return (0, import_protocols60.parseTrustedRunContext)({ projectRoom }).projectRoom;
56568
+ return (0, import_protocols61.parseTrustedRunContext)({ projectRoom }).projectRoom;
56387
56569
  } catch {
56388
56570
  return void 0;
56389
56571
  }
56390
56572
  }
56391
56573
  function exactValues2(value, required, optional = []) {
56392
56574
  try {
56393
- return (0, import_protocols60.snapshotExactRecord)(value, required, optional);
56575
+ return (0, import_protocols61.snapshotExactRecord)(value, required, optional);
56394
56576
  } catch {
56395
56577
  return void 0;
56396
56578
  }
@@ -56426,7 +56608,7 @@ function snapshotMembership3(value) {
56426
56608
  return { ...values, joinedAt, updatedAt };
56427
56609
  }
56428
56610
  function snapshotRows(value) {
56429
- return (0, import_protocols60.snapshotExactArray)(value) ?? [];
56611
+ return (0, import_protocols61.snapshotExactArray)(value) ?? [];
56430
56612
  }
56431
56613
  async function rosterExemptMembershipProjection(scope) {
56432
56614
  const excluded = /* @__PURE__ */ new Set();
@@ -56551,7 +56733,7 @@ var projectRoomPlugin = {
56551
56733
  // src/middlewares/sandboxPluginsMiddleware.ts
56552
56734
  var import_langchain87 = require("langchain");
56553
56735
  var import_zod75 = require("zod");
56554
- var import_protocols61 = require("@axiom-lattice/protocols");
56736
+ var import_protocols62 = require("@axiom-lattice/protocols");
56555
56737
 
56556
56738
  // src/services/PluginUiToolRunner.ts
56557
56739
  var PluginNotFoundError = class extends Error {
@@ -58450,7 +58632,7 @@ var sandboxPluginsPlugin = {
58450
58632
  key: "plugin-builder",
58451
58633
  name: "Plugin Builder",
58452
58634
  description: "Author and manage tenant plugins in the shared sandbox: clarify goal, inputs/outputs, credentials, and whether a UI is needed; then write the manifest and JS handlers, add an optional HTML MCP App UI, and validate/test with the manage_plugin tool.",
58453
- type: import_protocols61.AgentType.DEEP_AGENT,
58635
+ type: import_protocols62.AgentType.DEEP_AGENT,
58454
58636
  prompt: PLUGIN_BUILDER_PROMPT,
58455
58637
  // Read-only discovery of connection identifiers (metadata only — never
58456
58638
  // config/secrets) so the builder can confirm a human configured a
@@ -59575,7 +59757,7 @@ var appSharePlugin = {
59575
59757
  // src/middlewares/longTermStoreMiddleware.ts
59576
59758
  var import_langchain89 = require("langchain");
59577
59759
  var import_zod77 = require("zod");
59578
- var import_protocols62 = require("@axiom-lattice/protocols");
59760
+ var import_protocols63 = require("@axiom-lattice/protocols");
59579
59761
  var DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
59580
59762
  var DEFAULT_SEARCH_LIMIT = 10;
59581
59763
  var MAX_SEARCH_LIMIT = 100;
@@ -59606,7 +59788,7 @@ function runtimeScope(exeConfig) {
59606
59788
  function normalizeSegments(value) {
59607
59789
  if (!Array.isArray(value) || value.length === 0) return void 0;
59608
59790
  const segments = value.map((segment) => typeof segment === "string" ? segment.trim() : "");
59609
- if (!segments.every((segment) => segment.length > 0 && !segment.includes(import_protocols62.STORE_IDENTITY_SEPARATOR))) return void 0;
59791
+ if (!segments.every((segment) => segment.length > 0 && !segment.includes(import_protocols63.STORE_IDENTITY_SEPARATOR))) return void 0;
59610
59792
  return segments;
59611
59793
  }
59612
59794
  function clampLimit2(value, fallback = DEFAULT_SEARCH_LIMIT) {
@@ -59617,7 +59799,7 @@ function failure3(error) {
59617
59799
  return JSON.stringify({ success: false, error });
59618
59800
  }
59619
59801
  function operationFailure(error) {
59620
- if (error instanceof import_protocols62.StoreValidationError) {
59802
+ if (error instanceof import_protocols63.StoreValidationError) {
59621
59803
  return failure3(error.message);
59622
59804
  }
59623
59805
  return failure3("Long-term store operation failed");
@@ -60625,7 +60807,7 @@ function buildUserContent(name) {
60625
60807
  var DEFAULT_CONFIG = {
60626
60808
  name: "Personal Assistant",
60627
60809
  description: "Default template for personal assistants",
60628
- type: import_protocols25.AgentType.DEEP_AGENT,
60810
+ type: import_protocols26.AgentType.DEEP_AGENT,
60629
60811
  modelKey: "default",
60630
60812
  prompt: `\u4F60\u662F\u7528\u6237\u7684\u4E13\u5C5E\u4E2A\u4EBA\u52A9\u7406\u3002\u4F60\u7684\u8EAB\u4EFD\u548C\u6027\u683C\u7531 /agent/IDENTITY.md \u5B9A\u4E49\u3002
60631
60813
  \u4F60\u4F1A\u8BB0\u4F4F\u5BF9\u8BDD\u5386\u53F2\uFF0C\u9010\u6B65\u4E86\u89E3\u7528\u6237\u7684\u504F\u597D\u3001\u4E60\u60EF\u548C\u4FE1\u606F\u3002
@@ -60658,6 +60840,9 @@ var DEFAULT_CONFIG = {
60658
60840
  type: "skill",
60659
60841
  name: "Skills",
60660
60842
  description: "Skill system for specialized instructions and workflows",
60843
+ // Temporary default until skills have a per-PA resource/collection model:
60844
+ // keep dynamic discovery by reading all. Do NOT set `skills: []` here —
60845
+ // load_skills treats an explicit empty list as "no static access".
60661
60846
  enabled: true,
60662
60847
  config: {
60663
60848
  readAll: true
@@ -60702,17 +60887,12 @@ var DEFAULT_CONFIG = {
60702
60887
  description: "Persistent task system for human-agent coordination",
60703
60888
  enabled: true,
60704
60889
  config: {}
60705
- },
60706
- {
60707
- id: "document-parser",
60708
- type: "document-parser",
60709
- name: "Document Parser",
60710
- description: "Parse docx/pdf files into markdown via document service",
60711
- enabled: true,
60712
- config: { connectAll: true }
60713
60890
  }
60714
60891
  ],
60715
- tools: ["list_agents", "list_tools", "get_agent", "create_agent", "invoke_agent", "manage_binding"]
60892
+ // The PA is a user-facing assistant, not a tenant agent builder. It may
60893
+ // discover available agents and dispatch work via `task`, but must not read,
60894
+ // create, or invoke agents directly.
60895
+ tools: ["list_agents", "manage_binding"]
60716
60896
  };
60717
60897
  var PersonalAssistantConfig = class {
60718
60898
  /**
@@ -61109,6 +61289,7 @@ registerBuiltinPlugins();
61109
61289
  InMemoryProjectRoomReadStateStore,
61110
61290
  InMemoryProjectRoomStore,
61111
61291
  InMemoryProjectStore,
61292
+ InMemorySessionStore,
61112
61293
  InMemorySharedResourceStore,
61113
61294
  InMemoryStore,
61114
61295
  InMemoryTaskStore,