@axiom-lattice/core 13.1.0 → 13.3.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.d.mts +21 -5
- package/dist/index.d.ts +21 -5
- package/dist/index.js +434 -250
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +289 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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: () =>
|
|
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()
|
|
@@ -5683,6 +5686,7 @@ var import_crypto4 = require("crypto");
|
|
|
5683
5686
|
var ALGORITHM = "aes-256-gcm";
|
|
5684
5687
|
var IV_LENGTH = 16;
|
|
5685
5688
|
var SALT_LENGTH = 32;
|
|
5689
|
+
var AUTH_TAG_LENGTH = 16;
|
|
5686
5690
|
var ITERATIONS = 1e5;
|
|
5687
5691
|
var DEFAULT_ENCRYPTION_KEY = "lattice-default-encryption-key-dev-only-32b!";
|
|
5688
5692
|
var cachedKey = null;
|
|
@@ -5704,7 +5708,7 @@ function encrypt(plaintext, key6) {
|
|
|
5704
5708
|
const salt = (0, import_crypto4.randomBytes)(SALT_LENGTH);
|
|
5705
5709
|
const iv = (0, import_crypto4.randomBytes)(IV_LENGTH);
|
|
5706
5710
|
const derivedKey = (0, import_crypto4.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
|
|
5707
|
-
const cipher = (0, import_crypto4.createCipheriv)(ALGORITHM, derivedKey, iv);
|
|
5711
|
+
const cipher = (0, import_crypto4.createCipheriv)(ALGORITHM, derivedKey, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
5708
5712
|
const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
5709
5713
|
const authTag = cipher.getAuthTag();
|
|
5710
5714
|
return Buffer.concat([salt, iv, encrypted, authTag]).toString("base64");
|
|
@@ -5714,10 +5718,10 @@ function decrypt(encrypted, key6) {
|
|
|
5714
5718
|
const data = Buffer.from(encrypted, "base64");
|
|
5715
5719
|
const salt = data.subarray(0, SALT_LENGTH);
|
|
5716
5720
|
const iv = data.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);
|
|
5717
|
-
const authTag = data.subarray(-
|
|
5718
|
-
const ciphertext = data.subarray(SALT_LENGTH + IV_LENGTH, -
|
|
5721
|
+
const authTag = data.subarray(-AUTH_TAG_LENGTH);
|
|
5722
|
+
const ciphertext = data.subarray(SALT_LENGTH + IV_LENGTH, -AUTH_TAG_LENGTH);
|
|
5719
5723
|
const derivedKey = (0, import_crypto4.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
|
|
5720
|
-
const decipher = (0, import_crypto4.createDecipheriv)(ALGORITHM, derivedKey, iv);
|
|
5724
|
+
const decipher = (0, import_crypto4.createDecipheriv)(ALGORITHM, derivedKey, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
5721
5725
|
decipher.setAuthTag(authTag);
|
|
5722
5726
|
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
5723
5727
|
}
|
|
@@ -9818,7 +9822,7 @@ function serializePluginMeta(plugin) {
|
|
|
9818
9822
|
}
|
|
9819
9823
|
|
|
9820
9824
|
// src/sandbox_lattice/sandboxPaths.ts
|
|
9821
|
-
var NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.
|
|
9825
|
+
var NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.1";
|
|
9822
9826
|
var LEGACY_ROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.1.0";
|
|
9823
9827
|
function normalizeSandboxHome(value) {
|
|
9824
9828
|
const trimmed = value.trim();
|
|
@@ -11251,11 +11255,62 @@ var InMemoryChannelReplyJobStore = class {
|
|
|
11251
11255
|
}
|
|
11252
11256
|
};
|
|
11253
11257
|
|
|
11258
|
+
// src/store_lattice/InMemorySessionStore.ts
|
|
11259
|
+
var InMemorySessionStore = class {
|
|
11260
|
+
constructor() {
|
|
11261
|
+
this.byId = /* @__PURE__ */ new Map();
|
|
11262
|
+
this.byHash = /* @__PURE__ */ new Map();
|
|
11263
|
+
}
|
|
11264
|
+
async create(record) {
|
|
11265
|
+
this.byId.set(record.id, { ...record });
|
|
11266
|
+
this.byHash.set(record.refreshTokenHash, record.id);
|
|
11267
|
+
}
|
|
11268
|
+
async findByRefreshTokenHash(hash) {
|
|
11269
|
+
const id = this.byHash.get(hash);
|
|
11270
|
+
return id ? { ...this.byId.get(id) } : null;
|
|
11271
|
+
}
|
|
11272
|
+
async findByFamilyId(familyId) {
|
|
11273
|
+
const rows = [...this.byId.values()].filter((row) => row.familyId === familyId);
|
|
11274
|
+
const active = rows.filter((row) => !row.replacedBy && !row.revokedAt);
|
|
11275
|
+
const pool = active.length > 0 ? active : rows;
|
|
11276
|
+
pool.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
11277
|
+
return pool[0] ? { ...pool[0] } : null;
|
|
11278
|
+
}
|
|
11279
|
+
async rotate(oldId, next) {
|
|
11280
|
+
const old = this.byId.get(oldId);
|
|
11281
|
+
if (!old) return;
|
|
11282
|
+
old.replacedBy = next.id;
|
|
11283
|
+
old.lastUsedAt = next.createdAt;
|
|
11284
|
+
this.byId.set(oldId, old);
|
|
11285
|
+
await this.create(next);
|
|
11286
|
+
}
|
|
11287
|
+
async revokeFamily(familyId, _reason) {
|
|
11288
|
+
const now = /* @__PURE__ */ new Date();
|
|
11289
|
+
for (const row of this.byId.values()) {
|
|
11290
|
+
if (row.familyId === familyId && !row.revokedAt) row.revokedAt = now;
|
|
11291
|
+
}
|
|
11292
|
+
}
|
|
11293
|
+
async revokeAllForUser(userId, _reason) {
|
|
11294
|
+
const now = /* @__PURE__ */ new Date();
|
|
11295
|
+
for (const row of this.byId.values()) {
|
|
11296
|
+
if (row.userId === userId && !row.revokedAt) row.revokedAt = now;
|
|
11297
|
+
}
|
|
11298
|
+
}
|
|
11299
|
+
async touch(id, lastUsedAt) {
|
|
11300
|
+
const row = this.byId.get(id);
|
|
11301
|
+
if (row) row.lastUsedAt = lastUsedAt;
|
|
11302
|
+
}
|
|
11303
|
+
async listForUser(userId) {
|
|
11304
|
+
return [...this.byId.values()].filter((row) => row.userId === userId).map((row) => ({ ...row }));
|
|
11305
|
+
}
|
|
11306
|
+
};
|
|
11307
|
+
|
|
11254
11308
|
// src/store_lattice/configureStores.ts
|
|
11255
11309
|
var _disposables = [];
|
|
11256
11310
|
var _cleanupRegistered = false;
|
|
11257
11311
|
var _inMemoryAgentRunWarningEmitted = false;
|
|
11258
11312
|
var _inMemoryChannelReplyJobWarningEmitted = false;
|
|
11313
|
+
var _inMemorySessionWarningEmitted = false;
|
|
11259
11314
|
function registerSignalCleanup() {
|
|
11260
11315
|
if (_cleanupRegistered) return;
|
|
11261
11316
|
_cleanupRegistered = true;
|
|
@@ -11315,6 +11370,20 @@ async function configureStores(stores, options = {}) {
|
|
|
11315
11370
|
}
|
|
11316
11371
|
storeLatticeManager.registerLattice("default", "channelReplyJob", channelReplyJob);
|
|
11317
11372
|
}
|
|
11373
|
+
if (stores.session === void 0 && options.customStores?.session === void 0) {
|
|
11374
|
+
if (!_inMemorySessionWarningEmitted) {
|
|
11375
|
+
_inMemorySessionWarningEmitted = true;
|
|
11376
|
+
console.warn(
|
|
11377
|
+
"[configureStores] session is using InMemorySessionStore: sessions are non-durable and lost on restart. Configure a PostgreSQL session store for production."
|
|
11378
|
+
);
|
|
11379
|
+
}
|
|
11380
|
+
const session = new InMemorySessionStore();
|
|
11381
|
+
await initAndRegister(session, localDisposables);
|
|
11382
|
+
if (storeLatticeManager.hasLattice("default", "session")) {
|
|
11383
|
+
storeLatticeManager.removeLattice("default", "session");
|
|
11384
|
+
}
|
|
11385
|
+
storeLatticeManager.registerLattice("default", "session", session);
|
|
11386
|
+
}
|
|
11318
11387
|
if (storeLatticeManager.hasLattice("default", "connection")) {
|
|
11319
11388
|
const connectionStore = storeLatticeManager.getStoreLattice("default", "connection").store;
|
|
11320
11389
|
ConnectionRegistry.setStore(connectionStore);
|
|
@@ -16786,6 +16855,7 @@ function getBindingRegistry() {
|
|
|
16786
16855
|
}
|
|
16787
16856
|
|
|
16788
16857
|
// src/tool_lattice/manage_binding/index.ts
|
|
16858
|
+
var import_protocols25 = require("@axiom-lattice/protocols");
|
|
16789
16859
|
function getInstallationStore() {
|
|
16790
16860
|
return getStoreLattice("default", "channelInstallation").store;
|
|
16791
16861
|
}
|
|
@@ -16822,6 +16892,8 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16822
16892
|
const tenantId2 = getTenantId(config);
|
|
16823
16893
|
if (!tenantId2) return failure("manage_binding requires tenant execution context");
|
|
16824
16894
|
if (input.channel === "room") return failure("Internal room bindings cannot be managed");
|
|
16895
|
+
const personalAssistantId = await resolvePersonalAssistantId(tenantId2, config);
|
|
16896
|
+
const personalInstallationIds = personalAssistantId ? await listPersonalInstallationIds(registry4, tenantId2, personalAssistantId) : null;
|
|
16825
16897
|
switch (input.action) {
|
|
16826
16898
|
case "list_installations": {
|
|
16827
16899
|
const store2 = getInstallationStore();
|
|
@@ -16829,27 +16901,42 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16829
16901
|
tenantId2,
|
|
16830
16902
|
input.channel
|
|
16831
16903
|
);
|
|
16832
|
-
return JSON.stringify({
|
|
16904
|
+
return JSON.stringify({
|
|
16905
|
+
success: true,
|
|
16906
|
+
data: installations.filter(isPublicInstallation).filter((installation) => !personalInstallationIds || personalInstallationIds.has(installation.id)).map(import_protocols25.maskChannelInstallationSecrets)
|
|
16907
|
+
});
|
|
16833
16908
|
}
|
|
16834
16909
|
case "create": {
|
|
16835
|
-
if (!input.channel || !input.senderId
|
|
16910
|
+
if (!input.channel || !input.senderId) {
|
|
16911
|
+
return JSON.stringify({ success: false, error: "create requires channel, senderId, and agentId" });
|
|
16912
|
+
}
|
|
16913
|
+
if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
|
|
16914
|
+
return failure("A personal assistant can only bind senders to itself");
|
|
16915
|
+
}
|
|
16916
|
+
const agentId = personalAssistantId ?? input.agentId;
|
|
16917
|
+
if (!agentId) {
|
|
16836
16918
|
return JSON.stringify({ success: false, error: "create requires channel, senderId, and agentId" });
|
|
16837
16919
|
}
|
|
16838
|
-
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2);
|
|
16920
|
+
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
|
|
16839
16921
|
if (!installId) {
|
|
16840
16922
|
return JSON.stringify({
|
|
16841
16923
|
success: false,
|
|
16842
16924
|
error: `No channelInstallationId provided and unable to auto-detect. Use action=list_installations to find available installations for channel "${input.channel}".`
|
|
16843
16925
|
});
|
|
16844
16926
|
}
|
|
16845
|
-
const validation = await validatePublicInstallation(
|
|
16927
|
+
const validation = await validatePublicInstallation(
|
|
16928
|
+
installId,
|
|
16929
|
+
tenantId2,
|
|
16930
|
+
input.channel,
|
|
16931
|
+
personalInstallationIds
|
|
16932
|
+
);
|
|
16846
16933
|
if (validation) return failure(validation);
|
|
16847
16934
|
const binding = await registry4.create({
|
|
16848
16935
|
channel: input.channel,
|
|
16849
16936
|
channelInstallationId: installId,
|
|
16850
16937
|
tenantId: tenantId2,
|
|
16851
16938
|
senderId: input.senderId,
|
|
16852
|
-
agentId
|
|
16939
|
+
agentId,
|
|
16853
16940
|
threadMode: input.threadMode,
|
|
16854
16941
|
senderDisplayName: input.senderDisplayName
|
|
16855
16942
|
});
|
|
@@ -16859,14 +16946,22 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16859
16946
|
if (!input.channel || !input.senderId) {
|
|
16860
16947
|
return JSON.stringify({ success: false, error: "update requires channel and senderId" });
|
|
16861
16948
|
}
|
|
16862
|
-
|
|
16949
|
+
if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
|
|
16950
|
+
return failure("A personal assistant can only bind senders to itself");
|
|
16951
|
+
}
|
|
16952
|
+
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
|
|
16863
16953
|
if (!installId) {
|
|
16864
16954
|
return JSON.stringify({
|
|
16865
16955
|
success: false,
|
|
16866
16956
|
error: `No channelInstallationId provided and unable to auto-detect. Use action=list_installations first.`
|
|
16867
16957
|
});
|
|
16868
16958
|
}
|
|
16869
|
-
const validation = await validatePublicInstallation(
|
|
16959
|
+
const validation = await validatePublicInstallation(
|
|
16960
|
+
installId,
|
|
16961
|
+
tenantId2,
|
|
16962
|
+
input.channel,
|
|
16963
|
+
personalInstallationIds
|
|
16964
|
+
);
|
|
16870
16965
|
if (validation) return failure(validation);
|
|
16871
16966
|
const existing = await registry4.findBySubject({
|
|
16872
16967
|
channel: input.channel,
|
|
@@ -16880,8 +16975,11 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16880
16975
|
if (existing.channel === "room") {
|
|
16881
16976
|
return failure("Internal room bindings cannot be managed");
|
|
16882
16977
|
}
|
|
16978
|
+
if (personalAssistantId && existing.agentId !== personalAssistantId) {
|
|
16979
|
+
return JSON.stringify({ success: false, error: "Binding not found" });
|
|
16980
|
+
}
|
|
16883
16981
|
const updated = await registry4.update(tenantId2, existing.id, {
|
|
16884
|
-
agentId: input.agentId,
|
|
16982
|
+
agentId: personalAssistantId ?? input.agentId,
|
|
16885
16983
|
threadMode: input.threadMode,
|
|
16886
16984
|
senderDisplayName: input.senderDisplayName
|
|
16887
16985
|
});
|
|
@@ -16891,14 +16989,19 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16891
16989
|
if (!input.channel || !input.senderId) {
|
|
16892
16990
|
return JSON.stringify({ success: false, error: "delete requires channel and senderId" });
|
|
16893
16991
|
}
|
|
16894
|
-
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2);
|
|
16992
|
+
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
|
|
16895
16993
|
if (!installId) {
|
|
16896
16994
|
return JSON.stringify({
|
|
16897
16995
|
success: false,
|
|
16898
16996
|
error: `No channelInstallationId provided and unable to auto-detect.`
|
|
16899
16997
|
});
|
|
16900
16998
|
}
|
|
16901
|
-
const validation = await validatePublicInstallation(
|
|
16999
|
+
const validation = await validatePublicInstallation(
|
|
17000
|
+
installId,
|
|
17001
|
+
tenantId2,
|
|
17002
|
+
input.channel,
|
|
17003
|
+
personalInstallationIds
|
|
17004
|
+
);
|
|
16902
17005
|
if (validation) return failure(validation);
|
|
16903
17006
|
const existing = await registry4.findBySubject({
|
|
16904
17007
|
channel: input.channel,
|
|
@@ -16912,17 +17015,25 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16912
17015
|
if (existing.channel === "room") {
|
|
16913
17016
|
return failure("Internal room bindings cannot be managed");
|
|
16914
17017
|
}
|
|
17018
|
+
if (personalAssistantId && existing.agentId !== personalAssistantId) {
|
|
17019
|
+
return JSON.stringify({ success: false, error: "Binding not found" });
|
|
17020
|
+
}
|
|
16915
17021
|
await registry4.delete(tenantId2, existing.id);
|
|
16916
17022
|
return JSON.stringify({ success: true, message: "Binding deleted" });
|
|
16917
17023
|
}
|
|
16918
17024
|
case "list": {
|
|
16919
|
-
|
|
17025
|
+
if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
|
|
17026
|
+
return failure("A personal assistant can only list its own bindings");
|
|
17027
|
+
}
|
|
17028
|
+
const listed = await registry4.list({
|
|
16920
17029
|
channel: input.channel,
|
|
16921
|
-
agentId: input.agentId,
|
|
17030
|
+
agentId: personalAssistantId ?? input.agentId,
|
|
16922
17031
|
tenantId: tenantId2,
|
|
16923
17032
|
channelInstallationId: input.channelInstallationId,
|
|
16924
|
-
excludeChannels: ["room"]
|
|
17033
|
+
excludeChannels: ["room"],
|
|
17034
|
+
...personalAssistantId ? { limit: 500 } : {}
|
|
16925
17035
|
});
|
|
17036
|
+
const bindings = personalInstallationIds ? listed.filter((binding) => personalInstallationIds.has(binding.channelInstallationId)) : listed;
|
|
16926
17037
|
return JSON.stringify({ success: true, data: bindings });
|
|
16927
17038
|
}
|
|
16928
17039
|
default:
|
|
@@ -16930,33 +17041,83 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16930
17041
|
}
|
|
16931
17042
|
}
|
|
16932
17043
|
);
|
|
16933
|
-
async function resolveInstallationId(channel, tenantId2) {
|
|
17044
|
+
async function resolveInstallationId(channel, tenantId2, allowedIds) {
|
|
16934
17045
|
const store2 = getInstallationStore();
|
|
16935
17046
|
const installations = await store2.getInstallationsByTenant(tenantId2, channel);
|
|
16936
|
-
const publicInstallations = installations.filter(isPublicInstallation);
|
|
17047
|
+
const publicInstallations = installations.filter(isPublicInstallation).filter((installation) => !allowedIds || allowedIds.has(installation.id));
|
|
16937
17048
|
if (publicInstallations.length === 1) {
|
|
16938
17049
|
return publicInstallations[0].id;
|
|
16939
17050
|
}
|
|
16940
17051
|
return null;
|
|
16941
17052
|
}
|
|
16942
|
-
function
|
|
17053
|
+
function getRunConfig(config) {
|
|
16943
17054
|
if (typeof config !== "object" || config === null) return null;
|
|
16944
17055
|
const configurable = config.configurable;
|
|
16945
17056
|
if (typeof configurable !== "object" || configurable === null) return null;
|
|
16946
17057
|
const runConfig = configurable.runConfig;
|
|
16947
17058
|
if (typeof runConfig !== "object" || runConfig === null) return null;
|
|
16948
|
-
|
|
16949
|
-
|
|
17059
|
+
return runConfig;
|
|
17060
|
+
}
|
|
17061
|
+
function getString(record, key6) {
|
|
17062
|
+
const value = record?.[key6];
|
|
17063
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
17064
|
+
}
|
|
17065
|
+
function getTenantId(config) {
|
|
17066
|
+
return getString(getRunConfig(config), "tenantId");
|
|
17067
|
+
}
|
|
17068
|
+
async function resolvePersonalAssistantId(tenantId2, config) {
|
|
17069
|
+
const runConfig = getRunConfig(config);
|
|
17070
|
+
const assistantId = getString(runConfig, "assistant_id") ?? getString(runConfig, "assistantId");
|
|
17071
|
+
if (!assistantId) return null;
|
|
17072
|
+
try {
|
|
17073
|
+
const assistant = await getStoreLattice("default", "assistant").store.getAssistantById(tenantId2, assistantId);
|
|
17074
|
+
return assistant?.ownerUserId ? assistantId : null;
|
|
17075
|
+
} catch {
|
|
17076
|
+
return null;
|
|
17077
|
+
}
|
|
16950
17078
|
}
|
|
16951
17079
|
function isPublicInstallation(installation) {
|
|
16952
17080
|
return installation.channel !== "room";
|
|
16953
17081
|
}
|
|
16954
|
-
|
|
17082
|
+
function installationReferencesAssistant(installation, assistantId) {
|
|
17083
|
+
if (installation.fallbackAgentId === assistantId) return true;
|
|
17084
|
+
const config = installation.config;
|
|
17085
|
+
return Boolean(
|
|
17086
|
+
config && typeof config === "object" && !Array.isArray(config) && config.assistantId === assistantId
|
|
17087
|
+
);
|
|
17088
|
+
}
|
|
17089
|
+
async function listPersonalInstallationIds(registry4, tenantId2, assistantId) {
|
|
17090
|
+
const ids = /* @__PURE__ */ new Set();
|
|
17091
|
+
const installations = await getInstallationStore().getInstallationsByTenant(tenantId2);
|
|
17092
|
+
for (const installation of installations) {
|
|
17093
|
+
if (isPublicInstallation(installation) && installationReferencesAssistant(installation, assistantId)) {
|
|
17094
|
+
ids.add(installation.id);
|
|
17095
|
+
}
|
|
17096
|
+
}
|
|
17097
|
+
for (let offset = 0; ; offset += 500) {
|
|
17098
|
+
const bindings = await registry4.list({
|
|
17099
|
+
tenantId: tenantId2,
|
|
17100
|
+
agentId: assistantId,
|
|
17101
|
+
excludeChannels: ["room"],
|
|
17102
|
+
limit: 500,
|
|
17103
|
+
offset
|
|
17104
|
+
});
|
|
17105
|
+
for (const binding of bindings) {
|
|
17106
|
+
if (binding.channelInstallationId) ids.add(binding.channelInstallationId);
|
|
17107
|
+
}
|
|
17108
|
+
if (bindings.length < 500) break;
|
|
17109
|
+
}
|
|
17110
|
+
return ids;
|
|
17111
|
+
}
|
|
17112
|
+
async function validatePublicInstallation(installationId, tenantId2, channel, allowedIds) {
|
|
16955
17113
|
try {
|
|
16956
17114
|
const installation = await getInstallationStore().getInstallationById(installationId);
|
|
16957
17115
|
if (!installation || !isPublicInstallation(installation) || installation.tenantId !== tenantId2 || installation.channel !== channel) {
|
|
16958
17116
|
return "Invalid public channel installation";
|
|
16959
17117
|
}
|
|
17118
|
+
if (allowedIds && !allowedIds.has(installationId)) {
|
|
17119
|
+
return "Invalid public channel installation";
|
|
17120
|
+
}
|
|
16960
17121
|
return null;
|
|
16961
17122
|
} catch {
|
|
16962
17123
|
return "Unable to validate public channel installation";
|
|
@@ -16966,6 +17127,60 @@ function failure(error) {
|
|
|
16966
17127
|
return JSON.stringify({ success: false, error });
|
|
16967
17128
|
}
|
|
16968
17129
|
|
|
17130
|
+
// src/capability/CapabilityRuntimeAccessor.ts
|
|
17131
|
+
function getRuntimeCapabilityConfig(executionConfig, capabilityType) {
|
|
17132
|
+
return readRecordProperty(getRuntimeCapabilityPolicy(executionConfig, capabilityType), "config");
|
|
17133
|
+
}
|
|
17134
|
+
function hasRuntimeCapabilityPolicy(executionConfig, capabilityType) {
|
|
17135
|
+
return getRuntimeCapabilityPolicy(executionConfig, capabilityType) !== void 0;
|
|
17136
|
+
}
|
|
17137
|
+
function getRuntimeCapabilityPolicy(executionConfig, capabilityType) {
|
|
17138
|
+
const configurable = readRecordProperty(executionConfig, "configurable");
|
|
17139
|
+
const context = readRecordProperty(executionConfig, "context");
|
|
17140
|
+
const runConfig = readRecordProperty(configurable, "runConfig") ?? readRecordProperty(context, "runConfig");
|
|
17141
|
+
const runtime = readRecordProperty(runConfig, "capabilityRuntime");
|
|
17142
|
+
const middleware = readRecordProperty(runtime, "middleware");
|
|
17143
|
+
return readRecordProperty(middleware, capabilityType);
|
|
17144
|
+
}
|
|
17145
|
+
function getRuntimeSkillSelection(executionConfig) {
|
|
17146
|
+
const policy = getRuntimeCapabilityPolicy(executionConfig, "skill");
|
|
17147
|
+
if (!policy) return { hasPolicy: false, enabled: true, readAll: false };
|
|
17148
|
+
const config = readRecordProperty(policy, "config") ?? {};
|
|
17149
|
+
const skills = config.skills;
|
|
17150
|
+
return {
|
|
17151
|
+
hasPolicy: true,
|
|
17152
|
+
enabled: policy.enabled !== false,
|
|
17153
|
+
...Array.isArray(skills) && skills.every((skill) => typeof skill === "string") ? { skills: [...skills] } : {},
|
|
17154
|
+
readAll: config.readAll === true
|
|
17155
|
+
};
|
|
17156
|
+
}
|
|
17157
|
+
function readRecordProperty(value, property) {
|
|
17158
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
17159
|
+
const propertyValue = value[property];
|
|
17160
|
+
return typeof propertyValue === "object" && propertyValue !== null && !Array.isArray(propertyValue) ? propertyValue : void 0;
|
|
17161
|
+
}
|
|
17162
|
+
|
|
17163
|
+
// src/tool_lattice/sql/utils.ts
|
|
17164
|
+
function getEffectiveDatabaseKeys(exeConfig, staticDatabaseKeys) {
|
|
17165
|
+
const runtimeConfig = getRuntimeCapabilityConfig(exeConfig, "sql");
|
|
17166
|
+
if (runtimeConfig && Object.prototype.hasOwnProperty.call(runtimeConfig, "databaseKeys")) {
|
|
17167
|
+
const databaseKeys = runtimeConfig.databaseKeys;
|
|
17168
|
+
if (Array.isArray(databaseKeys) && databaseKeys.every((key6) => typeof key6 === "string")) {
|
|
17169
|
+
return databaseKeys;
|
|
17170
|
+
}
|
|
17171
|
+
return [];
|
|
17172
|
+
}
|
|
17173
|
+
return staticDatabaseKeys;
|
|
17174
|
+
}
|
|
17175
|
+
function getTenantIdFromConfig(exeConfig, getTenantId3) {
|
|
17176
|
+
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
17177
|
+
return runConfig.tenantId || (getTenantId3 ? getTenantId3() : "default");
|
|
17178
|
+
}
|
|
17179
|
+
function buildSslConfig(ssl, rejectUnauthorized) {
|
|
17180
|
+
if (!ssl) return void 0;
|
|
17181
|
+
return { rejectUnauthorized: rejectUnauthorized !== false };
|
|
17182
|
+
}
|
|
17183
|
+
|
|
16969
17184
|
// src/tool_lattice/sql/SqlDatabaseManager.ts
|
|
16970
17185
|
function splitQualifiedTableName(qualifiedName) {
|
|
16971
17186
|
const parts = [];
|
|
@@ -17019,7 +17234,7 @@ var PostgresDatabase = class {
|
|
|
17019
17234
|
database: this.config.database,
|
|
17020
17235
|
user: this.config.user,
|
|
17021
17236
|
password: this.config.password,
|
|
17022
|
-
ssl: this.config.ssl
|
|
17237
|
+
ssl: buildSslConfig(this.config.ssl, this.config.sslRejectUnauthorized)
|
|
17023
17238
|
};
|
|
17024
17239
|
this.pool = new Pool(poolConfig);
|
|
17025
17240
|
const client = await this.pool.connect();
|
|
@@ -17179,7 +17394,7 @@ var MysqlDatabase = class {
|
|
|
17179
17394
|
database: this.config.database,
|
|
17180
17395
|
user: this.config.user,
|
|
17181
17396
|
password: this.config.password,
|
|
17182
|
-
ssl: this.config.ssl
|
|
17397
|
+
ssl: buildSslConfig(this.config.ssl, this.config.sslRejectUnauthorized)
|
|
17183
17398
|
};
|
|
17184
17399
|
this.pool = mysql.createPool({
|
|
17185
17400
|
...poolConfig,
|
|
@@ -17543,58 +17758,6 @@ var sqlDatabaseManager = SqlDatabaseManager.getInstance();
|
|
|
17543
17758
|
// src/tool_lattice/sql/list_tables_sql.ts
|
|
17544
17759
|
var import_zod4 = __toESM(require("zod"));
|
|
17545
17760
|
var import_langchain = require("langchain");
|
|
17546
|
-
|
|
17547
|
-
// src/capability/CapabilityRuntimeAccessor.ts
|
|
17548
|
-
function getRuntimeCapabilityConfig(executionConfig, capabilityType) {
|
|
17549
|
-
return readRecordProperty(getRuntimeCapabilityPolicy(executionConfig, capabilityType), "config");
|
|
17550
|
-
}
|
|
17551
|
-
function hasRuntimeCapabilityPolicy(executionConfig, capabilityType) {
|
|
17552
|
-
return getRuntimeCapabilityPolicy(executionConfig, capabilityType) !== void 0;
|
|
17553
|
-
}
|
|
17554
|
-
function getRuntimeCapabilityPolicy(executionConfig, capabilityType) {
|
|
17555
|
-
const configurable = readRecordProperty(executionConfig, "configurable");
|
|
17556
|
-
const context = readRecordProperty(executionConfig, "context");
|
|
17557
|
-
const runConfig = readRecordProperty(configurable, "runConfig") ?? readRecordProperty(context, "runConfig");
|
|
17558
|
-
const runtime = readRecordProperty(runConfig, "capabilityRuntime");
|
|
17559
|
-
const middleware = readRecordProperty(runtime, "middleware");
|
|
17560
|
-
return readRecordProperty(middleware, capabilityType);
|
|
17561
|
-
}
|
|
17562
|
-
function getRuntimeSkillSelection(executionConfig) {
|
|
17563
|
-
const policy = getRuntimeCapabilityPolicy(executionConfig, "skill");
|
|
17564
|
-
if (!policy) return { hasPolicy: false, enabled: true, readAll: false };
|
|
17565
|
-
const config = readRecordProperty(policy, "config") ?? {};
|
|
17566
|
-
const skills = config.skills;
|
|
17567
|
-
return {
|
|
17568
|
-
hasPolicy: true,
|
|
17569
|
-
enabled: policy.enabled !== false,
|
|
17570
|
-
...Array.isArray(skills) && skills.every((skill) => typeof skill === "string") ? { skills: [...skills] } : {},
|
|
17571
|
-
readAll: config.readAll === true
|
|
17572
|
-
};
|
|
17573
|
-
}
|
|
17574
|
-
function readRecordProperty(value, property) {
|
|
17575
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
17576
|
-
const propertyValue = value[property];
|
|
17577
|
-
return typeof propertyValue === "object" && propertyValue !== null && !Array.isArray(propertyValue) ? propertyValue : void 0;
|
|
17578
|
-
}
|
|
17579
|
-
|
|
17580
|
-
// src/tool_lattice/sql/utils.ts
|
|
17581
|
-
function getEffectiveDatabaseKeys(exeConfig, staticDatabaseKeys) {
|
|
17582
|
-
const runtimeConfig = getRuntimeCapabilityConfig(exeConfig, "sql");
|
|
17583
|
-
if (runtimeConfig && Object.prototype.hasOwnProperty.call(runtimeConfig, "databaseKeys")) {
|
|
17584
|
-
const databaseKeys = runtimeConfig.databaseKeys;
|
|
17585
|
-
if (Array.isArray(databaseKeys) && databaseKeys.every((key6) => typeof key6 === "string")) {
|
|
17586
|
-
return databaseKeys;
|
|
17587
|
-
}
|
|
17588
|
-
return [];
|
|
17589
|
-
}
|
|
17590
|
-
return staticDatabaseKeys;
|
|
17591
|
-
}
|
|
17592
|
-
function getTenantIdFromConfig(exeConfig, getTenantId3) {
|
|
17593
|
-
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
17594
|
-
return runConfig.tenantId || (getTenantId3 ? getTenantId3() : "default");
|
|
17595
|
-
}
|
|
17596
|
-
|
|
17597
|
-
// src/tool_lattice/sql/list_tables_sql.ts
|
|
17598
17761
|
var LIST_TABLES_SQL_DESCRIPTION = `List all tables in the connected SQL database. Returns a comma-separated list of table names. Use this tool first to understand what tables are available before querying the database.`;
|
|
17599
17762
|
var SIMPLE_IDENTIFIER = /^[a-z_][a-z0-9_]*$/;
|
|
17600
17763
|
function formatIdentifier(identifier) {
|
|
@@ -21064,7 +21227,7 @@ var createBrowserGetInfoTool = ({ vmIsolation }) => {
|
|
|
21064
21227
|
var import_messages9 = require("@langchain/core/messages");
|
|
21065
21228
|
|
|
21066
21229
|
// src/agent_lattice/types.ts
|
|
21067
|
-
var
|
|
21230
|
+
var import_protocols26 = require("@axiom-lattice/protocols");
|
|
21068
21231
|
|
|
21069
21232
|
// src/agent_lattice/AgentLatticeManager.ts
|
|
21070
21233
|
init_BaseLatticeManager();
|
|
@@ -22236,7 +22399,7 @@ async function describeImage(options) {
|
|
|
22236
22399
|
|
|
22237
22400
|
// src/stt_model_lattice/STTModelLatticeManager.ts
|
|
22238
22401
|
init_BaseLatticeManager();
|
|
22239
|
-
var
|
|
22402
|
+
var import_protocols27 = require("@axiom-lattice/protocols");
|
|
22240
22403
|
|
|
22241
22404
|
// src/stt_model_lattice/STTModelLattice.ts
|
|
22242
22405
|
var import_openai3 = require("@langchain/openai");
|
|
@@ -22372,7 +22535,7 @@ var STTModelLatticeManager = class _STTModelLatticeManager extends BaseLatticeMa
|
|
|
22372
22535
|
* chat key must never resolve to a speech client.
|
|
22373
22536
|
*/
|
|
22374
22537
|
async loadItemFromStore(tenantId2, key6) {
|
|
22375
|
-
const row = key6 ===
|
|
22538
|
+
const row = key6 === import_protocols27.ASR_DEFAULT_KEY ? await loadTenantDefaultModelRow(tenantId2, "asr") : await loadTenantModelRow(tenantId2, key6);
|
|
22376
22539
|
if (!row || row.model.kind !== "asr") {
|
|
22377
22540
|
return void 0;
|
|
22378
22541
|
}
|
|
@@ -22500,16 +22663,16 @@ var getSTTClient = (key6) => sttModelLatticeManager.getSTTClient(key6);
|
|
|
22500
22663
|
var getSTTClientWithTenant = (tenantId2, key6) => sttModelLatticeManager.getSTTClientWithTenant(tenantId2, key6);
|
|
22501
22664
|
|
|
22502
22665
|
// src/deep_agent_new/backends/transcribeAudio.ts
|
|
22503
|
-
var
|
|
22666
|
+
var import_protocols28 = require("@axiom-lattice/protocols");
|
|
22504
22667
|
async function transcribeAudio(options) {
|
|
22505
22668
|
const { audioBuffer, format, tenantId: tenantId2 = "default", modelKey } = options;
|
|
22506
|
-
const requestedKey = modelKey ||
|
|
22669
|
+
const requestedKey = modelKey || import_protocols28.ASR_DEFAULT_KEY;
|
|
22507
22670
|
const client = await sttModelLatticeManager.getSTTClientWithTenantAsync(
|
|
22508
22671
|
tenantId2,
|
|
22509
22672
|
requestedKey
|
|
22510
|
-
) ?? (requestedKey ===
|
|
22673
|
+
) ?? (requestedKey === import_protocols28.ASR_DEFAULT_KEY ? void 0 : await sttModelLatticeManager.getSTTClientWithTenantAsync(
|
|
22511
22674
|
tenantId2,
|
|
22512
|
-
|
|
22675
|
+
import_protocols28.ASR_DEFAULT_KEY
|
|
22513
22676
|
)) ?? await sttModelLatticeManager.getSTTClientWithTenantAsync(
|
|
22514
22677
|
tenantId2,
|
|
22515
22678
|
"default"
|
|
@@ -27621,7 +27784,7 @@ var import_langgraph5 = require("@langchain/langgraph");
|
|
|
27621
27784
|
|
|
27622
27785
|
// src/agent_worker/delegation_service.ts
|
|
27623
27786
|
var import_node_crypto10 = require("crypto");
|
|
27624
|
-
var
|
|
27787
|
+
var import_protocols32 = require("@axiom-lattice/protocols");
|
|
27625
27788
|
|
|
27626
27789
|
// src/services/Agent.ts
|
|
27627
27790
|
var import_node_crypto9 = require("crypto");
|
|
@@ -27682,7 +27845,7 @@ var import_events = require("events");
|
|
|
27682
27845
|
|
|
27683
27846
|
// src/queue_lattice/QueueLatticeManager.ts
|
|
27684
27847
|
init_BaseLatticeManager();
|
|
27685
|
-
var
|
|
27848
|
+
var import_protocols29 = require("@axiom-lattice/protocols");
|
|
27686
27849
|
|
|
27687
27850
|
// src/queue_lattice/MemoryQueueClient.ts
|
|
27688
27851
|
var queues = /* @__PURE__ */ new Map();
|
|
@@ -27775,7 +27938,7 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
|
|
|
27775
27938
|
queueClient = client;
|
|
27776
27939
|
} else {
|
|
27777
27940
|
const queueName = config.queueName || process.env.QUEUE_NAME || "tasks";
|
|
27778
|
-
if (config.type ===
|
|
27941
|
+
if (config.type === import_protocols29.QueueType.REDIS) {
|
|
27779
27942
|
throw new Error(
|
|
27780
27943
|
`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
27944
|
);
|
|
@@ -28239,7 +28402,7 @@ function truncateForJson(value, options = {}) {
|
|
|
28239
28402
|
}
|
|
28240
28403
|
|
|
28241
28404
|
// src/services/Agent.ts
|
|
28242
|
-
var
|
|
28405
|
+
var import_protocols31 = require("@axiom-lattice/protocols");
|
|
28243
28406
|
var import_langgraph4 = require("@langchain/langgraph");
|
|
28244
28407
|
|
|
28245
28408
|
// src/services/agentInterrupts.ts
|
|
@@ -28362,7 +28525,7 @@ var ChunkBuffer = class {
|
|
|
28362
28525
|
};
|
|
28363
28526
|
|
|
28364
28527
|
// src/chunk_buffer_lattice/InMemoryChunkBuffer.ts
|
|
28365
|
-
var
|
|
28528
|
+
var import_protocols30 = require("@axiom-lattice/protocols");
|
|
28366
28529
|
var import_rxjs = require("rxjs");
|
|
28367
28530
|
var import_rxjs_for_await = require("rxjs-for-await");
|
|
28368
28531
|
var import_operators = require("rxjs/operators");
|
|
@@ -28450,7 +28613,7 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
|
|
|
28450
28613
|
let chunk2;
|
|
28451
28614
|
if (typeof arg2 === "string" && arg3 !== void 0) {
|
|
28452
28615
|
chunk2 = {
|
|
28453
|
-
type:
|
|
28616
|
+
type: import_protocols30.MessageChunkTypes.AI,
|
|
28454
28617
|
data: {
|
|
28455
28618
|
id: arg2,
|
|
28456
28619
|
content: arg3
|
|
@@ -28645,8 +28808,8 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
|
|
|
28645
28808
|
const buffer2 = this.getBufferIfValid(threadId);
|
|
28646
28809
|
if (!buffer2) return;
|
|
28647
28810
|
const defaultStopTypes = [
|
|
28648
|
-
|
|
28649
|
-
|
|
28811
|
+
import_protocols30.MessageChunkTypes.MESSAGE_COMPLETED,
|
|
28812
|
+
import_protocols30.MessageChunkTypes.THREAD_IDLE
|
|
28650
28813
|
];
|
|
28651
28814
|
const typesToStop = stopTypes ?? defaultStopTypes;
|
|
28652
28815
|
let startIndex = buffer2.status === "active" /* ACTIVE */ ? buffer2.chunks.length : 0;
|
|
@@ -30800,7 +30963,7 @@ function cloneRunConfig(value, stripReserved) {
|
|
|
30800
30963
|
const clone10 = [];
|
|
30801
30964
|
for (let index = 0; index < length; index += 1) {
|
|
30802
30965
|
const key6 = String(index);
|
|
30803
|
-
const data = (0,
|
|
30966
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptors[key6]);
|
|
30804
30967
|
if (!data || data.value === void 0) {
|
|
30805
30968
|
throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${key6}`);
|
|
30806
30969
|
}
|
|
@@ -30815,7 +30978,7 @@ function cloneRunConfig(value, stripReserved) {
|
|
|
30815
30978
|
for (const key6 of keys) {
|
|
30816
30979
|
if (typeof key6 !== "string") continue;
|
|
30817
30980
|
const fieldPath = callerRunConfigPath(path8, key6);
|
|
30818
|
-
const data = (0,
|
|
30981
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptors[key6]);
|
|
30819
30982
|
if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
|
|
30820
30983
|
if (stripReserved && RESERVED_CALLER_RUN_KEYS.has(key6) || data.value === void 0) continue;
|
|
30821
30984
|
Object.defineProperty(clone9, key6, {
|
|
@@ -30851,7 +31014,7 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
|
|
|
30851
31014
|
if (Array.isArray(entry)) {
|
|
30852
31015
|
const descriptors2 = Object.getOwnPropertyDescriptors(entry);
|
|
30853
31016
|
for (let index = 0; index < entry.length; index += 1) {
|
|
30854
|
-
const data = (0,
|
|
31017
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptors2[String(index)]);
|
|
30855
31018
|
if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${index}`);
|
|
30856
31019
|
visit(data.value, `${path8}/${index}`);
|
|
30857
31020
|
}
|
|
@@ -30870,7 +31033,7 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
|
|
|
30870
31033
|
}
|
|
30871
31034
|
const fieldPath = callerRunConfigPath(path8, key6);
|
|
30872
31035
|
const descriptor = descriptors[key6];
|
|
30873
|
-
const data = (0,
|
|
31036
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptor);
|
|
30874
31037
|
if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
|
|
30875
31038
|
if (isCredentialBearingKey(key6)) {
|
|
30876
31039
|
throw new CapabilityRuntimeResolutionError(
|
|
@@ -30894,9 +31057,9 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
|
|
|
30894
31057
|
}
|
|
30895
31058
|
function preserveExecutionBinding(source, target) {
|
|
30896
31059
|
if (typeof source !== "object" || source === null || Array.isArray(source)) return;
|
|
30897
|
-
const execution = (0,
|
|
31060
|
+
const execution = (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(source, "execution"))?.value;
|
|
30898
31061
|
if (typeof execution !== "object" || execution === null || Array.isArray(execution)) return;
|
|
30899
|
-
const taskId = (0,
|
|
31062
|
+
const taskId = (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(execution, "taskId"))?.value;
|
|
30900
31063
|
if (typeof taskId !== "string" || taskId.trim() === "") return;
|
|
30901
31064
|
Object.defineProperty(target, "execution", {
|
|
30902
31065
|
value: { taskId },
|
|
@@ -30920,7 +31083,7 @@ function cloneExecutionRunConfigBase(value) {
|
|
|
30920
31083
|
throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
|
|
30921
31084
|
}
|
|
30922
31085
|
const descriptor = descriptors[key6];
|
|
30923
|
-
const data = (0,
|
|
31086
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptor);
|
|
30924
31087
|
if (!data) {
|
|
30925
31088
|
throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
|
|
30926
31089
|
}
|
|
@@ -31171,7 +31334,7 @@ var DelegatedScopeNotQueueableError = class extends Error {
|
|
|
31171
31334
|
function ownDataValue(value, key6) {
|
|
31172
31335
|
if (typeof value !== "object" || value === null) return void 0;
|
|
31173
31336
|
try {
|
|
31174
|
-
return (0,
|
|
31337
|
+
return (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(value, key6))?.value;
|
|
31175
31338
|
} catch {
|
|
31176
31339
|
return void 0;
|
|
31177
31340
|
}
|
|
@@ -34147,7 +34310,7 @@ var DelegationService = class {
|
|
|
34147
34310
|
}
|
|
34148
34311
|
this.reserveChild(context.budgetId, request.thread_id);
|
|
34149
34312
|
}
|
|
34150
|
-
const scope = (0,
|
|
34313
|
+
const scope = (0, import_protocols32.resolveRunScope)(request.runConfig);
|
|
34151
34314
|
const leaseStore = storeLatticeManager.getStoreLattice("default", "lease").store;
|
|
34152
34315
|
const abortController = new AbortController();
|
|
34153
34316
|
const cancellation = request.parentThreadId ? delegationCancellationRegistry.register(request.tenantId, request.parentThreadId) : void 0;
|
|
@@ -34705,7 +34868,7 @@ function createTaskTool(options) {
|
|
|
34705
34868
|
key: assistant_id,
|
|
34706
34869
|
name: "general-purpose",
|
|
34707
34870
|
description: DEFAULT_GENERAL_PURPOSE_DESCRIPTION,
|
|
34708
|
-
type:
|
|
34871
|
+
type: import_protocols26.AgentType.REACT,
|
|
34709
34872
|
prompt: DEFAULT_SUBAGENT_PROMPT
|
|
34710
34873
|
},
|
|
34711
34874
|
client
|
|
@@ -34960,30 +35123,30 @@ var datePlugin = {
|
|
|
34960
35123
|
var import_langchain57 = require("langchain");
|
|
34961
35124
|
var import_zod52 = require("zod");
|
|
34962
35125
|
var import_uuid6 = require("uuid");
|
|
34963
|
-
var
|
|
35126
|
+
var import_protocols33 = require("@axiom-lattice/protocols");
|
|
34964
35127
|
var SCHEDULE_LATTICE_KEY = "default";
|
|
34965
35128
|
var AGENT_ADD_MESSAGE_TASK_TYPE = "agent.add_message";
|
|
34966
|
-
function
|
|
35129
|
+
function getRunConfig2(config) {
|
|
34967
35130
|
const configurable = config;
|
|
34968
35131
|
return configurable?.configurable?.runConfig ?? {};
|
|
34969
35132
|
}
|
|
34970
35133
|
function mapStatusToEnum(status) {
|
|
34971
35134
|
if (!status) return void 0;
|
|
34972
35135
|
const statusMap = {
|
|
34973
|
-
pending:
|
|
34974
|
-
running:
|
|
34975
|
-
completed:
|
|
34976
|
-
failed:
|
|
34977
|
-
cancelled:
|
|
34978
|
-
paused:
|
|
35136
|
+
pending: import_protocols33.ScheduledTaskStatus.PENDING,
|
|
35137
|
+
running: import_protocols33.ScheduledTaskStatus.RUNNING,
|
|
35138
|
+
completed: import_protocols33.ScheduledTaskStatus.COMPLETED,
|
|
35139
|
+
failed: import_protocols33.ScheduledTaskStatus.FAILED,
|
|
35140
|
+
cancelled: import_protocols33.ScheduledTaskStatus.CANCELLED,
|
|
35141
|
+
paused: import_protocols33.ScheduledTaskStatus.PAUSED
|
|
34979
35142
|
};
|
|
34980
35143
|
return statusMap[status];
|
|
34981
35144
|
}
|
|
34982
35145
|
function mapExecutionTypeToEnum(executionType) {
|
|
34983
35146
|
if (!executionType) return void 0;
|
|
34984
35147
|
const typeMap = {
|
|
34985
|
-
once:
|
|
34986
|
-
cron:
|
|
35148
|
+
once: import_protocols33.ScheduleExecutionType.ONCE,
|
|
35149
|
+
cron: import_protocols33.ScheduleExecutionType.CRON
|
|
34987
35150
|
};
|
|
34988
35151
|
return typeMap[executionType];
|
|
34989
35152
|
}
|
|
@@ -35044,7 +35207,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
35044
35207
|
tools: [
|
|
35045
35208
|
(0, import_langchain57.tool)(
|
|
35046
35209
|
async (input, config) => {
|
|
35047
|
-
const runConfig =
|
|
35210
|
+
const runConfig = getRunConfig2(config);
|
|
35048
35211
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
35049
35212
|
const taskId = (0, import_uuid6.v4)();
|
|
35050
35213
|
const executeAt = input.executeAt;
|
|
@@ -35079,7 +35242,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
35079
35242
|
),
|
|
35080
35243
|
(0, import_langchain57.tool)(
|
|
35081
35244
|
async (input, config) => {
|
|
35082
|
-
const runConfig =
|
|
35245
|
+
const runConfig = getRunConfig2(config);
|
|
35083
35246
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
35084
35247
|
const taskId = (0, import_uuid6.v4)();
|
|
35085
35248
|
const executeAt = Date.now() + input.delayMs;
|
|
@@ -35114,7 +35277,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
35114
35277
|
),
|
|
35115
35278
|
(0, import_langchain57.tool)(
|
|
35116
35279
|
async (input, config) => {
|
|
35117
|
-
const runConfig =
|
|
35280
|
+
const runConfig = getRunConfig2(config);
|
|
35118
35281
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
35119
35282
|
const taskId = (0, import_uuid6.v4)();
|
|
35120
35283
|
const success = await scheduleLattice.client.scheduleCron(
|
|
@@ -35172,7 +35335,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
35172
35335
|
),
|
|
35173
35336
|
(0, import_langchain57.tool)(
|
|
35174
35337
|
async (input, config) => {
|
|
35175
|
-
const runConfig =
|
|
35338
|
+
const runConfig = getRunConfig2(config);
|
|
35176
35339
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
35177
35340
|
const storage = scheduleLattice.client.getStorage();
|
|
35178
35341
|
if (!storage) {
|
|
@@ -36904,7 +37067,7 @@ ${BASE_PROMPT}` : BASE_PROMPT;
|
|
|
36904
37067
|
}
|
|
36905
37068
|
|
|
36906
37069
|
// src/agent_lattice/builders/DeepAgentGraphBuilder.ts
|
|
36907
|
-
var
|
|
37070
|
+
var import_protocols34 = require("@axiom-lattice/protocols");
|
|
36908
37071
|
init_MemoryLatticeManager();
|
|
36909
37072
|
var DeepAgentGraphBuilder = class {
|
|
36910
37073
|
/**
|
|
@@ -36966,7 +37129,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
36966
37129
|
key: generalPurposeKey,
|
|
36967
37130
|
name: "general-purpose",
|
|
36968
37131
|
description: DEFAULT_GENERAL_PURPOSE_DESCRIPTION,
|
|
36969
|
-
type:
|
|
37132
|
+
type: import_protocols34.AgentType.REACT,
|
|
36970
37133
|
prompt: DEFAULT_SUBAGENT_PROMPT,
|
|
36971
37134
|
tenantId: tenantId2
|
|
36972
37135
|
},
|
|
@@ -37298,7 +37461,7 @@ _A2ARemoteClient.MAX_CACHED_TASKS = 100;
|
|
|
37298
37461
|
var A2ARemoteClient = _A2ARemoteClient;
|
|
37299
37462
|
|
|
37300
37463
|
// src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
|
|
37301
|
-
var
|
|
37464
|
+
var import_protocols35 = require("@axiom-lattice/protocols");
|
|
37302
37465
|
init_MemoryLatticeManager();
|
|
37303
37466
|
function resolveA2ARemoteContextId(assistantKey, threadId) {
|
|
37304
37467
|
return threadId ? `a2a-remote:${assistantKey}:${threadId}` : void 0;
|
|
@@ -37308,7 +37471,7 @@ var RemoteAgentGraphBuilder = class {
|
|
|
37308
37471
|
this.deps = deps;
|
|
37309
37472
|
}
|
|
37310
37473
|
async build(agentLattice, params) {
|
|
37311
|
-
if (agentLattice.config.type !==
|
|
37474
|
+
if (agentLattice.config.type !== import_protocols35.AgentType.A2A_REMOTE) {
|
|
37312
37475
|
throw new Error(
|
|
37313
37476
|
`RemoteAgentGraphBuilder received wrong agent type: ${agentLattice.config.type}`
|
|
37314
37477
|
);
|
|
@@ -37367,7 +37530,7 @@ function extractLastHumanMessage(messages) {
|
|
|
37367
37530
|
// src/agent_lattice/builders/WorkflowAgentGraphBuilder.ts
|
|
37368
37531
|
var import_langchain60 = require("langchain");
|
|
37369
37532
|
init_MemoryLatticeManager();
|
|
37370
|
-
var
|
|
37533
|
+
var import_protocols36 = require("@axiom-lattice/protocols");
|
|
37371
37534
|
init_compile();
|
|
37372
37535
|
|
|
37373
37536
|
// src/agent_lattice/builders/middlewareSanitize.ts
|
|
@@ -37406,7 +37569,7 @@ ${configPrompt}` : base;
|
|
|
37406
37569
|
}
|
|
37407
37570
|
var WorkflowAgentGraphBuilder = class {
|
|
37408
37571
|
async build(agentLattice, params) {
|
|
37409
|
-
if (!(0,
|
|
37572
|
+
if (!(0, import_protocols36.isWorkflowAgentConfig)(agentLattice.config)) {
|
|
37410
37573
|
throw new Error(
|
|
37411
37574
|
`WorkflowAgentGraphBuilder received wrong agent type: ${agentLattice.config.type}`
|
|
37412
37575
|
);
|
|
@@ -37529,10 +37692,10 @@ var AgentGraphBuilderFactory = class _AgentGraphBuilderFactory {
|
|
|
37529
37692
|
* 注册默认的Builder
|
|
37530
37693
|
*/
|
|
37531
37694
|
registerDefaultBuilders() {
|
|
37532
|
-
this.builders.set(
|
|
37533
|
-
this.builders.set(
|
|
37534
|
-
this.builders.set(
|
|
37535
|
-
this.builders.set(
|
|
37695
|
+
this.builders.set(import_protocols26.AgentType.REACT, new ReActAgentGraphBuilder());
|
|
37696
|
+
this.builders.set(import_protocols26.AgentType.DEEP_AGENT, new DeepAgentGraphBuilder());
|
|
37697
|
+
this.builders.set(import_protocols26.AgentType.A2A_REMOTE, new RemoteAgentGraphBuilder());
|
|
37698
|
+
this.builders.set(import_protocols26.AgentType.WORKFLOW, new WorkflowAgentGraphBuilder());
|
|
37536
37699
|
}
|
|
37537
37700
|
/**
|
|
37538
37701
|
* 注册自定义Builder
|
|
@@ -37559,7 +37722,7 @@ var AgentGraphBuilderFactory = class _AgentGraphBuilderFactory {
|
|
|
37559
37722
|
};
|
|
37560
37723
|
|
|
37561
37724
|
// src/mcp_lattice/personalMcpLifecycle.ts
|
|
37562
|
-
var
|
|
37725
|
+
var import_protocols37 = require("@axiom-lattice/protocols");
|
|
37563
37726
|
|
|
37564
37727
|
// src/mcp_lattice/McpLatticeManager.ts
|
|
37565
37728
|
var import_mcp_adapters = require("@langchain/mcp-adapters");
|
|
@@ -38455,7 +38618,9 @@ function getPersonalMcpMaxServers() {
|
|
|
38455
38618
|
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : PERSONAL_MCP_MAX_SERVERS;
|
|
38456
38619
|
}
|
|
38457
38620
|
function getPersonalMcpSyncBudgetMs() {
|
|
38458
|
-
const
|
|
38621
|
+
const value = process.env.PERSONAL_MCP_SYNC_BUDGET_MS;
|
|
38622
|
+
if (value === void 0 || value.trim() === "") return PERSONAL_MCP_SYNC_BUDGET_MS;
|
|
38623
|
+
const raw = Number(value);
|
|
38459
38624
|
return Number.isFinite(raw) && raw >= 0 ? raw : PERSONAL_MCP_SYNC_BUDGET_MS;
|
|
38460
38625
|
}
|
|
38461
38626
|
var syncCache = /* @__PURE__ */ new Map();
|
|
@@ -38473,7 +38638,7 @@ function errorMessage(error) {
|
|
|
38473
38638
|
function getPersonalMcpStore() {
|
|
38474
38639
|
if (!storeLatticeManager.hasLattice("default", "mcp")) return void 0;
|
|
38475
38640
|
const store2 = storeLatticeManager.getStoreLattice("default", "mcp").store;
|
|
38476
|
-
return (0,
|
|
38641
|
+
return (0, import_protocols37.isPersonalMcpServerConfigStore)(store2) ? store2 : void 0;
|
|
38477
38642
|
}
|
|
38478
38643
|
function invalidatePersonalMcpSync(tenantId2, assistantId) {
|
|
38479
38644
|
const key6 = syncKey(tenantId2, assistantId);
|
|
@@ -38763,7 +38928,7 @@ async function countPersonalMcpServers(tenantId2, assistantId) {
|
|
|
38763
38928
|
}
|
|
38764
38929
|
|
|
38765
38930
|
// src/agent_lattice/builders/AgentParamsBuilder.ts
|
|
38766
|
-
var
|
|
38931
|
+
var import_protocols38 = require("@axiom-lattice/protocols");
|
|
38767
38932
|
var AgentParamsBuilder = class {
|
|
38768
38933
|
/**
|
|
38769
38934
|
* constructor
|
|
@@ -38781,7 +38946,7 @@ var AgentParamsBuilder = class {
|
|
|
38781
38946
|
* @returns Agent build parameters
|
|
38782
38947
|
*/
|
|
38783
38948
|
async buildParams(agentLattice, options) {
|
|
38784
|
-
const skills = (0,
|
|
38949
|
+
const skills = (0, import_protocols38.isDeepAgentConfig)(agentLattice.config) ? agentLattice.config.skillCategories : void 0;
|
|
38785
38950
|
const tenantId2 = agentLattice.config.tenantId || "default";
|
|
38786
38951
|
const ownerUserId = agentLattice.config.ownerUserId;
|
|
38787
38952
|
const assistantId = agentLattice.config.key;
|
|
@@ -38789,7 +38954,7 @@ var AgentParamsBuilder = class {
|
|
|
38789
38954
|
if (isPersonalAssistant) {
|
|
38790
38955
|
await ensurePersonalMcpForAssistant({ tenantId: tenantId2, assistantId });
|
|
38791
38956
|
}
|
|
38792
|
-
const configuredKeys = options?.overrideTools || (0,
|
|
38957
|
+
const configuredKeys = options?.overrideTools || (0, import_protocols38.getToolsFromConfig)(agentLattice.config);
|
|
38793
38958
|
const autoKeys = isPersonalAssistant && !options?.overrideTools ? toolLatticeManager.getAssistantToolKeys(tenantId2, assistantId) : [];
|
|
38794
38959
|
const toolKeys = Array.from(/* @__PURE__ */ new Set([...configuredKeys, ...autoKeys]));
|
|
38795
38960
|
const tools = toolKeys.map((toolKey) => {
|
|
@@ -38814,7 +38979,7 @@ var AgentParamsBuilder = class {
|
|
|
38814
38979
|
if (!model) {
|
|
38815
38980
|
throw new Error(`Model "${resolvedModelKey}" does not exist`);
|
|
38816
38981
|
}
|
|
38817
|
-
const subAgentKeys = (0,
|
|
38982
|
+
const subAgentKeys = (0, import_protocols38.getSubAgentsFromConfig)(agentLattice.config);
|
|
38818
38983
|
const subAgents = await Promise.all(subAgentKeys.map(async (agentKey) => {
|
|
38819
38984
|
const subAgentLattice = await this.getAgentLatticeFunc(agentKey);
|
|
38820
38985
|
if (!subAgentLattice) {
|
|
@@ -38831,7 +38996,7 @@ var AgentParamsBuilder = class {
|
|
|
38831
38996
|
}));
|
|
38832
38997
|
const resolvedSubAgents = subAgents.filter((s) => s !== null);
|
|
38833
38998
|
let internalSubAgents = [];
|
|
38834
|
-
if ((0,
|
|
38999
|
+
if ((0, import_protocols38.isDeepAgentConfig)(agentLattice.config)) {
|
|
38835
39000
|
internalSubAgents = agentLattice.config.internalSubAgents?.map((i) => ({
|
|
38836
39001
|
key: i.key,
|
|
38837
39002
|
config: i
|
|
@@ -38874,11 +39039,19 @@ function mergeAgentConfig(parent, child) {
|
|
|
38874
39039
|
// src/agent_lattice/agentArchitectTools.ts
|
|
38875
39040
|
var import_zod54 = __toESM(require("zod"));
|
|
38876
39041
|
var import_uuid8 = require("uuid");
|
|
38877
|
-
var
|
|
39042
|
+
var import_protocols39 = require("@axiom-lattice/protocols");
|
|
38878
39043
|
function getTenantId2(exeConfig) {
|
|
38879
39044
|
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
38880
39045
|
return runConfig.tenantId || "default";
|
|
38881
39046
|
}
|
|
39047
|
+
function getRuntimeUserId(exeConfig) {
|
|
39048
|
+
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
39049
|
+
const value = runConfig.user_id ?? runConfig.userId;
|
|
39050
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
39051
|
+
}
|
|
39052
|
+
function canAccessAssistant(assistant, userId) {
|
|
39053
|
+
return !assistant.ownerUserId || userId !== null && assistant.ownerUserId === userId;
|
|
39054
|
+
}
|
|
38882
39055
|
function getAssistStore() {
|
|
38883
39056
|
return getStoreLattice("default", "assistant").store;
|
|
38884
39057
|
}
|
|
@@ -38894,7 +39067,7 @@ function getAvailableTools(tenantId2) {
|
|
|
38894
39067
|
}
|
|
38895
39068
|
async function getAvailableModels(tenantId2) {
|
|
38896
39069
|
await tenantHasOwnModelSupply(tenantId2);
|
|
38897
|
-
await tenantHasOwnModelSupply(
|
|
39070
|
+
await tenantHasOwnModelSupply(import_protocols39.PLATFORM_MODEL_TENANT_ID);
|
|
38898
39071
|
return listModelLatticesForTenant(tenantId2);
|
|
38899
39072
|
}
|
|
38900
39073
|
async function getAvailableMiddlewareTypes(tenantId2) {
|
|
@@ -38924,7 +39097,7 @@ function getStringMetadata(config) {
|
|
|
38924
39097
|
}
|
|
38925
39098
|
function isUndecidedLearningPlaceholder(config) {
|
|
38926
39099
|
const metadata = getStringMetadata(config);
|
|
38927
|
-
return config.type ===
|
|
39100
|
+
return config.type === import_protocols39.AgentType.REACT && metadata.learningPlaceholder === "true" && metadata.architectureStatus === "undecided";
|
|
38928
39101
|
}
|
|
38929
39102
|
function requireSkillDeclaration(skillLoaded) {
|
|
38930
39103
|
if (skillLoaded !== true) {
|
|
@@ -38971,17 +39144,21 @@ async function validateAgentReferences(input, tenantId2) {
|
|
|
38971
39144
|
function slugify(name) {
|
|
38972
39145
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-+/g, "-") || "agent";
|
|
38973
39146
|
}
|
|
39147
|
+
var MAX_AGENT_ID_ALLOCATION_ATTEMPTS = 1e3;
|
|
38974
39148
|
async function generateAgentId(tenantId2, name) {
|
|
38975
39149
|
const store2 = getAssistStore();
|
|
38976
39150
|
const base = slugify(name);
|
|
38977
39151
|
let id = base;
|
|
38978
39152
|
let counter = 2;
|
|
38979
|
-
|
|
39153
|
+
for (let attempt = 0; attempt < MAX_AGENT_ID_ALLOCATION_ATTEMPTS; attempt += 1) {
|
|
38980
39154
|
const existing = await store2.getAssistantById(tenantId2, id);
|
|
38981
39155
|
if (!existing) return id;
|
|
38982
39156
|
id = `${base}-${counter}`;
|
|
38983
|
-
counter
|
|
39157
|
+
counter += 1;
|
|
38984
39158
|
}
|
|
39159
|
+
throw new Error(
|
|
39160
|
+
`Unable to allocate a unique agent id for "${name}" after ${MAX_AGENT_ID_ALLOCATION_ATTEMPTS} attempts`
|
|
39161
|
+
);
|
|
38985
39162
|
}
|
|
38986
39163
|
registerToolLattice(
|
|
38987
39164
|
"list_agents",
|
|
@@ -38993,8 +39170,9 @@ registerToolLattice(
|
|
|
38993
39170
|
async (_input, exeConfig) => {
|
|
38994
39171
|
try {
|
|
38995
39172
|
const tenantId2 = getTenantId2(exeConfig);
|
|
39173
|
+
const userId = getRuntimeUserId(exeConfig);
|
|
38996
39174
|
const store2 = getAssistStore();
|
|
38997
|
-
const agents = await store2.getAllAssistants(tenantId2);
|
|
39175
|
+
const agents = (await store2.getAllAssistants(tenantId2)).filter((agent) => canAccessAssistant(agent, userId));
|
|
38998
39176
|
return JSON.stringify({
|
|
38999
39177
|
agents: agents.map((a) => ({
|
|
39000
39178
|
id: a.id,
|
|
@@ -39024,7 +39202,7 @@ registerToolLattice(
|
|
|
39024
39202
|
const tenantId2 = getTenantId2(exeConfig);
|
|
39025
39203
|
const store2 = getAssistStore();
|
|
39026
39204
|
const agent = await store2.getAssistantById(tenantId2, input.id);
|
|
39027
|
-
if (!agent) {
|
|
39205
|
+
if (!agent || !canAccessAssistant(agent, getRuntimeUserId(exeConfig))) {
|
|
39028
39206
|
return JSON.stringify({ error: `Agent '${input.id}' not found` });
|
|
39029
39207
|
}
|
|
39030
39208
|
return JSON.stringify(agent.graphDefinition);
|
|
@@ -39077,7 +39255,7 @@ registerToolLattice(
|
|
|
39077
39255
|
key: id,
|
|
39078
39256
|
name: input.name,
|
|
39079
39257
|
description: input.description || "",
|
|
39080
|
-
type: input.type === "deep_agent" ?
|
|
39258
|
+
type: input.type === "deep_agent" ? import_protocols39.AgentType.DEEP_AGENT : import_protocols39.AgentType.REACT,
|
|
39081
39259
|
prompt: input.prompt,
|
|
39082
39260
|
...input.tools && input.tools.length > 0 ? { tools: input.tools } : {},
|
|
39083
39261
|
...input.middleware && input.middleware.length > 0 ? { middleware: input.middleware } : {},
|
|
@@ -39134,7 +39312,7 @@ registerToolLattice(
|
|
|
39134
39312
|
key: id,
|
|
39135
39313
|
name: input.name,
|
|
39136
39314
|
description: input.description || "",
|
|
39137
|
-
type:
|
|
39315
|
+
type: import_protocols39.AgentType.WORKFLOW,
|
|
39138
39316
|
prompt: input.description || `Workflow: ${input.name}`,
|
|
39139
39317
|
workflowYaml: input.yaml,
|
|
39140
39318
|
...input.tools && input.tools.length > 0 ? { tools: input.tools } : {},
|
|
@@ -39171,7 +39349,7 @@ registerToolLattice(
|
|
|
39171
39349
|
return JSON.stringify({ error: `Agent '${input.id}' not found` });
|
|
39172
39350
|
}
|
|
39173
39351
|
const graphDef = agent.graphDefinition;
|
|
39174
|
-
if (!graphDef || graphDef.type !==
|
|
39352
|
+
if (!graphDef || graphDef.type !== import_protocols39.AgentType.WORKFLOW) {
|
|
39175
39353
|
return JSON.stringify({ error: `Agent '${input.id}' is not a workflow agent` });
|
|
39176
39354
|
}
|
|
39177
39355
|
const yaml2 = graphDef.workflowYaml;
|
|
@@ -39286,7 +39464,7 @@ registerToolLattice(
|
|
|
39286
39464
|
return JSON.stringify({ error: `Agent '${input.id}' not found` });
|
|
39287
39465
|
}
|
|
39288
39466
|
const existingConfig = existing.graphDefinition || {};
|
|
39289
|
-
const isWorkflow = existingConfig.type ===
|
|
39467
|
+
const isWorkflow = existingConfig.type === import_protocols39.AgentType.WORKFLOW;
|
|
39290
39468
|
const isPlaceholder = isUndecidedLearningPlaceholder(existingConfig);
|
|
39291
39469
|
if (!isWorkflow && !isPlaceholder) {
|
|
39292
39470
|
console.log(`[update_workflow] ERROR: not a workflow agent: ${input.id}`);
|
|
@@ -39302,7 +39480,7 @@ registerToolLattice(
|
|
|
39302
39480
|
const mergedConfig = {
|
|
39303
39481
|
...existingConfig,
|
|
39304
39482
|
...isPlaceholder ? {
|
|
39305
|
-
type:
|
|
39483
|
+
type: import_protocols39.AgentType.WORKFLOW,
|
|
39306
39484
|
workflowYaml: input.yaml,
|
|
39307
39485
|
metadata: {
|
|
39308
39486
|
...getStringMetadata(existingConfig),
|
|
@@ -39400,7 +39578,7 @@ registerToolLattice(
|
|
|
39400
39578
|
const tenantId2 = getTenantId2(exeConfig);
|
|
39401
39579
|
const store2 = getAssistStore();
|
|
39402
39580
|
const existing = await store2.getAssistantById(tenantId2, input.id);
|
|
39403
|
-
if (!existing) {
|
|
39581
|
+
if (!existing || !canAccessAssistant(existing, getRuntimeUserId(exeConfig))) {
|
|
39404
39582
|
return JSON.stringify({ error: `Agent '${input.id}' not found` });
|
|
39405
39583
|
}
|
|
39406
39584
|
const existingConfig = existing.graphDefinition || {};
|
|
@@ -39408,14 +39586,14 @@ registerToolLattice(
|
|
|
39408
39586
|
const mergedConfig = { ...existingConfig, ...input.config };
|
|
39409
39587
|
const isPlaceholder = isUndecidedLearningPlaceholder(existingConfigRecord);
|
|
39410
39588
|
const materializedType = input.config.type;
|
|
39411
|
-
const isMaterializingPlaceholder = isPlaceholder && (materializedType ===
|
|
39589
|
+
const isMaterializingPlaceholder = isPlaceholder && (materializedType === import_protocols39.AgentType.REACT || materializedType === import_protocols39.AgentType.DEEP_AGENT);
|
|
39412
39590
|
if (isMaterializingPlaceholder) {
|
|
39413
39591
|
mergedConfig.metadata = {
|
|
39414
39592
|
...getStringMetadata(existingConfigRecord),
|
|
39415
39593
|
...input.config.metadata ?? {},
|
|
39416
39594
|
learningPlaceholder: "false",
|
|
39417
39595
|
architectureStatus: "materialized",
|
|
39418
|
-
architectureForm: materializedType ===
|
|
39596
|
+
architectureForm: materializedType === import_protocols39.AgentType.DEEP_AGENT ? "orchestra" : "capability"
|
|
39419
39597
|
};
|
|
39420
39598
|
} else if (isPlaceholder && input.config.metadata !== void 0) {
|
|
39421
39599
|
const metadata = {
|
|
@@ -39514,9 +39692,16 @@ registerToolLattice(
|
|
|
39514
39692
|
const tenantId2 = getTenantId2(exeConfig);
|
|
39515
39693
|
const store2 = getAssistStore();
|
|
39516
39694
|
const existing = await store2.getAssistantById(tenantId2, input.id);
|
|
39517
|
-
if (!existing) {
|
|
39695
|
+
if (!existing || !canAccessAssistant(existing, getRuntimeUserId(exeConfig))) {
|
|
39518
39696
|
return JSON.stringify({ error: `Agent '${input.id}' not found`, success: false });
|
|
39519
39697
|
}
|
|
39698
|
+
if (existing.ownerUserId) {
|
|
39699
|
+
return JSON.stringify({
|
|
39700
|
+
success: false,
|
|
39701
|
+
code: "PERSONAL_ASSISTANT_DELETE_UNSUPPORTED",
|
|
39702
|
+
error: "Personal assistants must be deleted from the Personal Assistant page"
|
|
39703
|
+
});
|
|
39704
|
+
}
|
|
39520
39705
|
const success = await store2.deleteAssistant(tenantId2, input.id);
|
|
39521
39706
|
if (success) {
|
|
39522
39707
|
try {
|
|
@@ -39666,7 +39851,7 @@ registerToolLattice(
|
|
|
39666
39851
|
);
|
|
39667
39852
|
|
|
39668
39853
|
// src/agent_lattice/agentArchitectConfig.ts
|
|
39669
|
-
var
|
|
39854
|
+
var import_protocols40 = require("@axiom-lattice/protocols");
|
|
39670
39855
|
|
|
39671
39856
|
// src/agent_lattice/agentArchitectPrompt.ts
|
|
39672
39857
|
var AGENT_ARCHITECT_PROMPT = `You are the Agent Architect.
|
|
@@ -39692,7 +39877,7 @@ var agentArchitectConfig = {
|
|
|
39692
39877
|
key: AGENT_ARCHITECT_KEY,
|
|
39693
39878
|
name: "Agent Architect",
|
|
39694
39879
|
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:
|
|
39880
|
+
type: import_protocols40.AgentType.DEEP_AGENT,
|
|
39696
39881
|
prompt: AGENT_ARCHITECT_PROMPT,
|
|
39697
39882
|
tools: [
|
|
39698
39883
|
"list_agents",
|
|
@@ -39795,7 +39980,7 @@ var agentArchitectConfig = {
|
|
|
39795
39980
|
};
|
|
39796
39981
|
|
|
39797
39982
|
// src/agent_lattice/agentReviewerConfig.ts
|
|
39798
|
-
var
|
|
39983
|
+
var import_protocols41 = require("@axiom-lattice/protocols");
|
|
39799
39984
|
|
|
39800
39985
|
// src/agent_lattice/agentReviewerPrompt.ts
|
|
39801
39986
|
var AGENT_REVIEWER_PROMPT = `# Agent Reviewer
|
|
@@ -39861,7 +40046,7 @@ var agentReviewerConfig = {
|
|
|
39861
40046
|
key: AGENT_REVIEWER_KEY,
|
|
39862
40047
|
name: "Agent Reviewer",
|
|
39863
40048
|
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:
|
|
40049
|
+
type: import_protocols41.AgentType.REACT,
|
|
39865
40050
|
prompt: AGENT_REVIEWER_PROMPT,
|
|
39866
40051
|
tools: [
|
|
39867
40052
|
"invoke_agent",
|
|
@@ -39882,7 +40067,7 @@ var agentReviewerConfig = {
|
|
|
39882
40067
|
};
|
|
39883
40068
|
|
|
39884
40069
|
// src/agent_lattice/roomCoordinatorConfig.ts
|
|
39885
|
-
var
|
|
40070
|
+
var import_protocols42 = require("@axiom-lattice/protocols");
|
|
39886
40071
|
|
|
39887
40072
|
// src/agent_lattice/roomCoordinatorPrompt.ts
|
|
39888
40073
|
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 +40078,7 @@ var roomCoordinatorConfig = {
|
|
|
39893
40078
|
key: ROOM_COORDINATOR_KEY,
|
|
39894
40079
|
name: "Room Coordinator",
|
|
39895
40080
|
description: "Manages project room conversations: replies when no bot is mentioned, coordinates room members, and organizes project work.",
|
|
39896
|
-
type:
|
|
40081
|
+
type: import_protocols42.AgentType.DEEP_AGENT,
|
|
39897
40082
|
prompt: ROOM_COORDINATOR_PROMPT,
|
|
39898
40083
|
tools: [],
|
|
39899
40084
|
middleware: [
|
|
@@ -39960,7 +40145,7 @@ function assistantToConfig(assistant) {
|
|
|
39960
40145
|
key: assistant.id,
|
|
39961
40146
|
name: assistant.name ?? graphDef.name ?? assistant.id,
|
|
39962
40147
|
description: assistant.description ?? graphDef.description ?? "",
|
|
39963
|
-
type:
|
|
40148
|
+
type: import_protocols26.AgentType.REACT,
|
|
39964
40149
|
prompt: typeof assistant.graphDefinition === "string" ? assistant.graphDefinition : JSON.stringify(assistant.graphDefinition)
|
|
39965
40150
|
};
|
|
39966
40151
|
Object.assign(config, graphDef);
|
|
@@ -40553,7 +40738,7 @@ function clearAuthProvidersForTests() {
|
|
|
40553
40738
|
|
|
40554
40739
|
// src/auth_lattice/IdentityMappingService.ts
|
|
40555
40740
|
var import_node_crypto11 = require("crypto");
|
|
40556
|
-
var
|
|
40741
|
+
var import_protocols43 = require("@axiom-lattice/protocols");
|
|
40557
40742
|
var IdentityMappingConfigError = class extends Error {
|
|
40558
40743
|
/**
|
|
40559
40744
|
* @param message - Human-readable configuration problem.
|
|
@@ -40636,7 +40821,7 @@ var IdentityMappingService = class {
|
|
|
40636
40821
|
return { kind: "not_provisioned", reason: "NO_MATCH" };
|
|
40637
40822
|
}
|
|
40638
40823
|
if (!email) {
|
|
40639
|
-
throw new
|
|
40824
|
+
throw new import_protocols43.AuthError("EMAIL_REQUIRED", 400, "OIDC identity has no email");
|
|
40640
40825
|
}
|
|
40641
40826
|
const avatarUrl = avatarUrlFromPrincipal(principal);
|
|
40642
40827
|
let createdUser;
|
|
@@ -40650,7 +40835,7 @@ var IdentityMappingService = class {
|
|
|
40650
40835
|
} catch {
|
|
40651
40836
|
const recovered = await this.recoverJitRace(principal, email);
|
|
40652
40837
|
if (!recovered) {
|
|
40653
|
-
throw new
|
|
40838
|
+
throw new import_protocols43.AuthError(
|
|
40654
40839
|
"PROVIDER_ERROR",
|
|
40655
40840
|
502,
|
|
40656
40841
|
"OIDC JIT provisioning failed"
|
|
@@ -40675,7 +40860,7 @@ var IdentityMappingService = class {
|
|
|
40675
40860
|
try {
|
|
40676
40861
|
await this.deps.externalIdentityStore.link(identity);
|
|
40677
40862
|
} catch (error) {
|
|
40678
|
-
if (!(error instanceof
|
|
40863
|
+
if (!(error instanceof import_protocols43.ExternalIdentityConflictError)) {
|
|
40679
40864
|
await this.deleteUserQuietly(createdUser.id);
|
|
40680
40865
|
throw error;
|
|
40681
40866
|
}
|
|
@@ -40705,7 +40890,7 @@ var IdentityMappingService = class {
|
|
|
40705
40890
|
} catch (error) {
|
|
40706
40891
|
await this.unlinkQuietly(providerId, issuer, principal.subject);
|
|
40707
40892
|
await this.deleteUserQuietly(user.id);
|
|
40708
|
-
throw error instanceof
|
|
40893
|
+
throw error instanceof import_protocols43.AuthError ? error : new import_protocols43.AuthError(
|
|
40709
40894
|
"PROVIDER_ERROR",
|
|
40710
40895
|
502,
|
|
40711
40896
|
"Failed to link the default tenant during JIT provisioning"
|
|
@@ -40716,7 +40901,7 @@ var IdentityMappingService = class {
|
|
|
40716
40901
|
}
|
|
40717
40902
|
}
|
|
40718
40903
|
if (!user) {
|
|
40719
|
-
throw new
|
|
40904
|
+
throw new import_protocols43.AuthError("PROVIDER_ERROR", 502, "OIDC JIT provisioning failed");
|
|
40720
40905
|
}
|
|
40721
40906
|
user = await this.syncOidcAvatar(user, principal);
|
|
40722
40907
|
if (user.status === "pending") return { kind: "pending", user, created };
|
|
@@ -40730,7 +40915,7 @@ var IdentityMappingService = class {
|
|
|
40730
40915
|
principal.subject
|
|
40731
40916
|
);
|
|
40732
40917
|
if (!linked) {
|
|
40733
|
-
throw new
|
|
40918
|
+
throw new import_protocols43.AuthError("PROVIDER_ERROR", 502, "External identity was not linked");
|
|
40734
40919
|
}
|
|
40735
40920
|
return { kind: "authenticated", user, externalIdentity: linked };
|
|
40736
40921
|
}
|
|
@@ -40935,7 +41120,7 @@ var getVectorStoreClient = (key6) => vectorStoreLatticeManager.getVectorStoreCli
|
|
|
40935
41120
|
|
|
40936
41121
|
// src/logger_lattice/LoggerLatticeManager.ts
|
|
40937
41122
|
init_BaseLatticeManager();
|
|
40938
|
-
var
|
|
41123
|
+
var import_protocols44 = require("@axiom-lattice/protocols");
|
|
40939
41124
|
|
|
40940
41125
|
// src/logger_lattice/PinoLoggerClient.ts
|
|
40941
41126
|
var import_pino2 = __toESM(require("pino"));
|
|
@@ -41138,11 +41323,11 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
|
|
|
41138
41323
|
if (client) {
|
|
41139
41324
|
loggerClient = client;
|
|
41140
41325
|
} else {
|
|
41141
|
-
if (config.type ===
|
|
41326
|
+
if (config.type === import_protocols44.LoggerType.PINO) {
|
|
41142
41327
|
loggerClient = new PinoLoggerClient(config);
|
|
41143
|
-
} else if (config.type ===
|
|
41328
|
+
} else if (config.type === import_protocols44.LoggerType.CONSOLE) {
|
|
41144
41329
|
loggerClient = new ConsoleLoggerClient(config);
|
|
41145
|
-
} else if (config.type ===
|
|
41330
|
+
} else if (config.type === import_protocols44.LoggerType.CUSTOM) {
|
|
41146
41331
|
throw new Error(
|
|
41147
41332
|
`Custom logger client must be provided. Please pass the client to registerLattice.`
|
|
41148
41333
|
);
|
|
@@ -45290,7 +45475,7 @@ var LatticeEvalSuite = class {
|
|
|
45290
45475
|
};
|
|
45291
45476
|
|
|
45292
45477
|
// src/eval_lattice/LatticeEvalProject.ts
|
|
45293
|
-
var
|
|
45478
|
+
var import_protocols45 = require("@axiom-lattice/protocols");
|
|
45294
45479
|
var import_messages8 = require("@langchain/core/messages");
|
|
45295
45480
|
var import_uuid10 = require("uuid");
|
|
45296
45481
|
var DEFAULT_CALIBRATION_PROBES = [
|
|
@@ -45350,7 +45535,7 @@ var LatticeEvalProject = class {
|
|
|
45350
45535
|
key: this.judgeAgentKey,
|
|
45351
45536
|
name: `Judge agent for ${this.project.projectName}`,
|
|
45352
45537
|
description: "Judge agent for evaluating Lattice test cases",
|
|
45353
|
-
type:
|
|
45538
|
+
type: import_protocols45.AgentType.REACT,
|
|
45354
45539
|
prompt: "",
|
|
45355
45540
|
modelKey: judgeModelKey
|
|
45356
45541
|
};
|
|
@@ -45576,7 +45761,7 @@ function getMenuRegistry() {
|
|
|
45576
45761
|
}
|
|
45577
45762
|
|
|
45578
45763
|
// src/services/ProjectTaskReassignmentAuthorization.ts
|
|
45579
|
-
var
|
|
45764
|
+
var import_protocols46 = require("@axiom-lattice/protocols");
|
|
45580
45765
|
var issued = /* @__PURE__ */ new WeakMap();
|
|
45581
45766
|
function createProjectTaskReassignmentAuthorizer(policy, threadValidator) {
|
|
45582
45767
|
return {
|
|
@@ -45609,7 +45794,7 @@ function inspectProjectTaskReassignmentAuthorization(authorization) {
|
|
|
45609
45794
|
return snapshot ? { ...snapshot } : void 0;
|
|
45610
45795
|
}
|
|
45611
45796
|
function snapshotInput(input) {
|
|
45612
|
-
const row = (0,
|
|
45797
|
+
const row = (0, import_protocols46.snapshotExactRecord)(input, [
|
|
45613
45798
|
"tenantId",
|
|
45614
45799
|
"workspaceId",
|
|
45615
45800
|
"projectId",
|
|
@@ -45652,7 +45837,7 @@ function snapshotInput(input) {
|
|
|
45652
45837
|
}
|
|
45653
45838
|
|
|
45654
45839
|
// src/services/TaskLifecycleNotifier.ts
|
|
45655
|
-
var
|
|
45840
|
+
var import_protocols47 = require("@axiom-lattice/protocols");
|
|
45656
45841
|
var TaskLifecycleNotifier = class {
|
|
45657
45842
|
constructor() {
|
|
45658
45843
|
this.listeners = /* @__PURE__ */ new Set();
|
|
@@ -45719,7 +45904,7 @@ var TaskLifecycleNotifier = class {
|
|
|
45719
45904
|
};
|
|
45720
45905
|
var taskLifecycleNotifier = new TaskLifecycleNotifier();
|
|
45721
45906
|
function snapshotNotification(value) {
|
|
45722
|
-
const row = (0,
|
|
45907
|
+
const row = (0, import_protocols47.snapshotExactRecord)(value, [
|
|
45723
45908
|
"tenantId",
|
|
45724
45909
|
"workspaceId",
|
|
45725
45910
|
"projectId",
|
|
@@ -45751,7 +45936,7 @@ function nonempty(value) {
|
|
|
45751
45936
|
}
|
|
45752
45937
|
|
|
45753
45938
|
// src/services/ProjectTaskAdmissionNotifier.ts
|
|
45754
|
-
var
|
|
45939
|
+
var import_protocols48 = require("@axiom-lattice/protocols");
|
|
45755
45940
|
var ProjectTaskAdmissionNotifier = class {
|
|
45756
45941
|
/**
|
|
45757
45942
|
* Creates a bounded Project task admission notifier.
|
|
@@ -45852,7 +46037,7 @@ var ProjectTaskAdmissionNotifier = class {
|
|
|
45852
46037
|
};
|
|
45853
46038
|
var projectTaskAdmissionNotifier = new ProjectTaskAdmissionNotifier();
|
|
45854
46039
|
function snapshotNotification2(value) {
|
|
45855
|
-
const row = (0,
|
|
46040
|
+
const row = (0, import_protocols48.snapshotExactRecord)(value, [
|
|
45856
46041
|
"tenantId",
|
|
45857
46042
|
"workspaceId",
|
|
45858
46043
|
"projectId",
|
|
@@ -45955,7 +46140,7 @@ var OutboxPoller = class {
|
|
|
45955
46140
|
|
|
45956
46141
|
// src/services/ProjectMutationMutex.ts
|
|
45957
46142
|
var import_node_async_hooks2 = require("async_hooks");
|
|
45958
|
-
var
|
|
46143
|
+
var import_protocols49 = require("@axiom-lattice/protocols");
|
|
45959
46144
|
|
|
45960
46145
|
// src/services/coordinationLease.ts
|
|
45961
46146
|
var configured;
|
|
@@ -46014,7 +46199,7 @@ async function withLease(store2, key6, ownerLabel, fn, options = {}) {
|
|
|
46014
46199
|
// src/services/ProjectMutationMutex.ts
|
|
46015
46200
|
var MUTATION_LEASE_OPTIONS = { ttlMs: 6e4, acquireTimeoutMs: 9e4, retryDelayMs: 100 };
|
|
46016
46201
|
function projectKey(scope) {
|
|
46017
|
-
const row = (0,
|
|
46202
|
+
const row = (0, import_protocols49.snapshotExactRecord)(scope, ["tenantId", "projectId"]);
|
|
46018
46203
|
if (!row || typeof row.tenantId !== "string" || !row.tenantId || row.tenantId.includes("\0") || typeof row.projectId !== "string" || !row.projectId || row.projectId.includes("\0")) {
|
|
46019
46204
|
throw new Error("Invalid Project mutation scope");
|
|
46020
46205
|
}
|
|
@@ -46100,7 +46285,7 @@ function createTrustedAgentMessageDispatcher(resolve4) {
|
|
|
46100
46285
|
|
|
46101
46286
|
// src/services/RoomAgentMessageService.ts
|
|
46102
46287
|
var import_crypto10 = require("crypto");
|
|
46103
|
-
var
|
|
46288
|
+
var import_protocols50 = require("@axiom-lattice/protocols");
|
|
46104
46289
|
var INPUT_KEYS = [
|
|
46105
46290
|
"tenantId",
|
|
46106
46291
|
"workspaceId",
|
|
@@ -46265,7 +46450,7 @@ var RoomAgentMessageService = class {
|
|
|
46265
46450
|
function exactValues(value, required, optional = []) {
|
|
46266
46451
|
try {
|
|
46267
46452
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
46268
|
-
return (0,
|
|
46453
|
+
return (0, import_protocols50.snapshotExactRecord)(value, required, optional);
|
|
46269
46454
|
} catch {
|
|
46270
46455
|
return void 0;
|
|
46271
46456
|
}
|
|
@@ -46317,7 +46502,7 @@ function sourceOriginMatches(author, source) {
|
|
|
46317
46502
|
return false;
|
|
46318
46503
|
}
|
|
46319
46504
|
function snapshotMentions(value) {
|
|
46320
|
-
const rows = (0,
|
|
46505
|
+
const rows = (0, import_protocols50.snapshotExactArray)(value);
|
|
46321
46506
|
if (!rows) return void 0;
|
|
46322
46507
|
const mentions = [];
|
|
46323
46508
|
for (const row of rows) {
|
|
@@ -46345,7 +46530,7 @@ function snapshotCanonical(value, expected) {
|
|
|
46345
46530
|
const author = exactValues(values?.author, ["type", "membershipId", "assistantId"]);
|
|
46346
46531
|
const content = exactValues(values?.content, ["type", "text"]);
|
|
46347
46532
|
const createdAt = date(values?.createdAt);
|
|
46348
|
-
if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0,
|
|
46533
|
+
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
46534
|
return {
|
|
46350
46535
|
id: values.id,
|
|
46351
46536
|
tenantId: expected.tenantId,
|
|
@@ -46367,7 +46552,7 @@ function snapshotCanonicalScoped(value, expected) {
|
|
|
46367
46552
|
const author = exactValues(values?.author, ["type", "membershipId", "assistantId"]);
|
|
46368
46553
|
const content = exactValues(values?.content, ["type", "text"]);
|
|
46369
46554
|
const createdAt = date(values?.createdAt);
|
|
46370
|
-
if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0,
|
|
46555
|
+
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
46556
|
return {
|
|
46372
46557
|
id: values.id,
|
|
46373
46558
|
tenantId: expected.tenantId,
|
|
@@ -46421,7 +46606,7 @@ var ProjectRoomMessageNotifier = class {
|
|
|
46421
46606
|
var projectRoomMessageNotifier = new ProjectRoomMessageNotifier();
|
|
46422
46607
|
|
|
46423
46608
|
// src/services/ProjectTaskOwnerPolicy.ts
|
|
46424
|
-
var
|
|
46609
|
+
var import_protocols51 = require("@axiom-lattice/protocols");
|
|
46425
46610
|
var MEMBERSHIP_REQUIRED_KEYS = [
|
|
46426
46611
|
"id",
|
|
46427
46612
|
"tenantId",
|
|
@@ -46530,7 +46715,7 @@ function sameRosterScope(membership, scope) {
|
|
|
46530
46715
|
return membership.tenantId === scope.tenantId && membership.workspaceId === scope.workspaceId && membership.projectId === scope.projectId && membership.roomId === scope.roomId;
|
|
46531
46716
|
}
|
|
46532
46717
|
function snapshotScope(value, keys) {
|
|
46533
|
-
const values = (0,
|
|
46718
|
+
const values = (0, import_protocols51.snapshotExactRecord)(value, keys);
|
|
46534
46719
|
if (!values || keys.some((key6) => !isNonemptyString(values[key6]))) return void 0;
|
|
46535
46720
|
return values;
|
|
46536
46721
|
}
|
|
@@ -46542,7 +46727,7 @@ function projectScope(scope, keys) {
|
|
|
46542
46727
|
function snapshotMembership2(value) {
|
|
46543
46728
|
try {
|
|
46544
46729
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
46545
|
-
const values = (0,
|
|
46730
|
+
const values = (0, import_protocols51.snapshotExactRecord)(value, MEMBERSHIP_REQUIRED_KEYS, ["responsibility"]);
|
|
46546
46731
|
if (!values) return void 0;
|
|
46547
46732
|
const joinedAt = snapshotDate(values.joinedAt);
|
|
46548
46733
|
const updatedAt = snapshotDate(values.updatedAt);
|
|
@@ -46861,7 +47046,7 @@ function describe(error) {
|
|
|
46861
47046
|
|
|
46862
47047
|
// src/services/TaskLifecycleService.ts
|
|
46863
47048
|
var import_node_crypto17 = require("crypto");
|
|
46864
|
-
var
|
|
47049
|
+
var import_protocols52 = require("@axiom-lattice/protocols");
|
|
46865
47050
|
|
|
46866
47051
|
// src/middlewares/taskBelief.ts
|
|
46867
47052
|
var import_node_crypto16 = require("crypto");
|
|
@@ -46934,7 +47119,7 @@ async function applyBeliefImpacts(taskStore, owner3, impacts) {
|
|
|
46934
47119
|
if (impacts.length === 0) return { description: owner3.description ?? "" };
|
|
46935
47120
|
let current = owner3;
|
|
46936
47121
|
for (let attempt = 0; attempt < BELIEF_OWNER_WRITE_ATTEMPTS; attempt += 1) {
|
|
46937
|
-
const parsed = (0,
|
|
47122
|
+
const parsed = (0, import_protocols52.parseTaskBeliefState)(current.description ?? "");
|
|
46938
47123
|
const existingTable = parsed.success;
|
|
46939
47124
|
if (!existingTable && parsed.code !== "MISSING_BELIEF_STATE") {
|
|
46940
47125
|
return { description: current.description ?? "", task: current };
|
|
@@ -46951,7 +47136,7 @@ async function applyBeliefImpacts(taskStore, owner3, impacts) {
|
|
|
46951
47136
|
changed = true;
|
|
46952
47137
|
}
|
|
46953
47138
|
if (!changed) return { description: current.description ?? "", task: current };
|
|
46954
|
-
const description = (0,
|
|
47139
|
+
const description = (0, import_protocols52.replaceTaskBeliefState)(current.description ?? "", { entries });
|
|
46955
47140
|
try {
|
|
46956
47141
|
const updated = await taskStore.updateIfStatusAndUpdatedAt(
|
|
46957
47142
|
current.tenantId,
|
|
@@ -47056,7 +47241,7 @@ function beliefStateOf(value) {
|
|
|
47056
47241
|
function sameBeliefOwner(left, right) {
|
|
47057
47242
|
const leftIdentity = { ...left, beliefState: void 0 };
|
|
47058
47243
|
const rightIdentity = { ...right, beliefState: void 0 };
|
|
47059
|
-
return canonicalJson(leftIdentity) === canonicalJson(rightIdentity) && (0,
|
|
47244
|
+
return canonicalJson(leftIdentity) === canonicalJson(rightIdentity) && (0, import_protocols52.taskBeliefStatesEqual)(left.beliefState, right.beliefState);
|
|
47060
47245
|
}
|
|
47061
47246
|
function sameBeliefOwnerIdentity(left, right) {
|
|
47062
47247
|
return canonicalJson({ ...left, beliefState: void 0 }) === canonicalJson({ ...right, beliefState: void 0 });
|
|
@@ -47204,7 +47389,7 @@ function changedBeliefKeys(left, right) {
|
|
|
47204
47389
|
return [...keys].filter((key6) => {
|
|
47205
47390
|
const oldEntry = leftByKey.get(key6);
|
|
47206
47391
|
const newEntry = rightByKey.get(key6);
|
|
47207
|
-
return !oldEntry || !newEntry || !(0,
|
|
47392
|
+
return !oldEntry || !newEntry || !(0, import_protocols52.taskBeliefStatesEqual)(
|
|
47208
47393
|
{ entries: [oldEntry] },
|
|
47209
47394
|
{ entries: [newEntry] }
|
|
47210
47395
|
);
|
|
@@ -48306,10 +48491,10 @@ var TaskLifecycleService = class {
|
|
|
48306
48491
|
const description = preserveTargetContract(existing.description ?? "", input.description);
|
|
48307
48492
|
const pending = existing.context?.belief_reconciliation_audit;
|
|
48308
48493
|
const pendingAudit = pending && typeof pending === "object" ? pending : void 0;
|
|
48309
|
-
const oldBelief = (0,
|
|
48310
|
-
const newBelief = (0,
|
|
48494
|
+
const oldBelief = (0, import_protocols52.parseTaskBeliefState)(existing.description ?? "");
|
|
48495
|
+
const newBelief = (0, import_protocols52.parseTaskBeliefState)(description);
|
|
48311
48496
|
if (!newBelief.success) return failure2("INVALID_BELIEF_TABLE", newBelief.message);
|
|
48312
|
-
if (!pendingAudit && description === (existing.description ?? "") && oldBelief.success && (0,
|
|
48497
|
+
if (!pendingAudit && description === (existing.description ?? "") && oldBelief.success && (0, import_protocols52.taskBeliefStatesEqual)(oldBelief.state, newBelief.state)) {
|
|
48313
48498
|
return { success: true, task: existing, mutated: false };
|
|
48314
48499
|
}
|
|
48315
48500
|
const canonicalNew = newBelief.state.entries;
|
|
@@ -48440,7 +48625,7 @@ var TaskLifecycleService = class {
|
|
|
48440
48625
|
}
|
|
48441
48626
|
beliefOwnerSnapshot(task, parent) {
|
|
48442
48627
|
const owner3 = parent?.ownerType === "agent" ? parent : task;
|
|
48443
|
-
const parsed = (0,
|
|
48628
|
+
const parsed = (0, import_protocols52.parseTaskBeliefState)(owner3.description ?? "");
|
|
48444
48629
|
const beliefState = parsed.success ? parsed.state : { entries: [] };
|
|
48445
48630
|
if (parent?.ownerType === "agent") {
|
|
48446
48631
|
return {
|
|
@@ -49162,7 +49347,7 @@ function createTaskLifecycleService(deps) {
|
|
|
49162
49347
|
// src/services/TaskExecutionService.ts
|
|
49163
49348
|
var import_node_crypto19 = require("crypto");
|
|
49164
49349
|
var import_node_util3 = require("util");
|
|
49165
|
-
var
|
|
49350
|
+
var import_protocols53 = require("@axiom-lattice/protocols");
|
|
49166
49351
|
|
|
49167
49352
|
// src/services/taskErrorMessage.ts
|
|
49168
49353
|
var MAX_EXECUTION_ERROR_MESSAGE_LENGTH = 1024;
|
|
@@ -49958,7 +50143,7 @@ function createTaskExecutionService(deps) {
|
|
|
49958
50143
|
};
|
|
49959
50144
|
}
|
|
49960
50145
|
const eventKey = runId ? `execution-result:${threadId}:${runId}` : `execution-result:${threadId}`;
|
|
49961
|
-
if (!(0,
|
|
50146
|
+
if (!(0, import_protocols53.isExecutionResultEventKey)(eventKey)) {
|
|
49962
50147
|
return {
|
|
49963
50148
|
success: false,
|
|
49964
50149
|
code: "INVALID_EXECUTION_RESULT_ID",
|
|
@@ -50930,7 +51115,7 @@ var createListCollectionsTool = ({
|
|
|
50930
51115
|
// src/tool_lattice/collection/search_collection.ts
|
|
50931
51116
|
var import_zod60 = __toESM(require("zod"));
|
|
50932
51117
|
var import_langchain67 = require("langchain");
|
|
50933
|
-
var
|
|
51118
|
+
var import_protocols54 = require("@axiom-lattice/protocols");
|
|
50934
51119
|
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
51120
|
var searchSchema = import_zod60.default.object({
|
|
50936
51121
|
collection: import_zod60.default.string().describe("The collection name to search in"),
|
|
@@ -50950,7 +51135,7 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
|
|
|
50950
51135
|
if (!metadata) {
|
|
50951
51136
|
return `Collection "${collection}" not found. Use list_collections to see available collections.`;
|
|
50952
51137
|
}
|
|
50953
|
-
const embeddingKey = metadata.embeddingKey ||
|
|
51138
|
+
const embeddingKey = metadata.embeddingKey || import_protocols54.EMBEDDING_DEFAULT_KEY;
|
|
50954
51139
|
let vectorStore;
|
|
50955
51140
|
try {
|
|
50956
51141
|
const storeKey = `${tenantId2}:${collection}`;
|
|
@@ -50965,9 +51150,9 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
|
|
|
50965
51150
|
const embeddingsClient = await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
50966
51151
|
tenantId2,
|
|
50967
51152
|
embeddingKey
|
|
50968
|
-
) ?? (embeddingKey ===
|
|
51153
|
+
) ?? (embeddingKey === import_protocols54.EMBEDDING_DEFAULT_KEY ? void 0 : await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
50969
51154
|
tenantId2,
|
|
50970
|
-
|
|
51155
|
+
import_protocols54.EMBEDDING_DEFAULT_KEY
|
|
50971
51156
|
)) ?? await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
50972
51157
|
tenantId2,
|
|
50973
51158
|
"default"
|
|
@@ -51178,7 +51363,7 @@ var import_zod66 = __toESM(require("zod"));
|
|
|
51178
51363
|
var import_langchain73 = require("langchain");
|
|
51179
51364
|
var import_documents = require("@langchain/core/documents");
|
|
51180
51365
|
var import_uuid11 = require("uuid");
|
|
51181
|
-
var
|
|
51366
|
+
var import_protocols55 = require("@axiom-lattice/protocols");
|
|
51182
51367
|
var schema3 = import_zod66.default.object({
|
|
51183
51368
|
collection: import_zod66.default.string().describe("Collection name"),
|
|
51184
51369
|
entries: import_zod66.default.array(
|
|
@@ -51188,7 +51373,7 @@ var schema3 = import_zod66.default.object({
|
|
|
51188
51373
|
}).describe("Entry content text"),
|
|
51189
51374
|
metadata: import_zod66.default.record(import_zod66.default.string(), import_zod66.default.unknown()).optional().describe("Metadata fields matching the collection schema")
|
|
51190
51375
|
})
|
|
51191
|
-
).min(1).max(
|
|
51376
|
+
).min(1).max(import_protocols55.COLLECTION_ENTRY_BATCH_MAX)
|
|
51192
51377
|
});
|
|
51193
51378
|
function key3(tenantId2, collection) {
|
|
51194
51379
|
return `${tenantId2}:${collection}`;
|
|
@@ -51304,14 +51489,14 @@ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
|
|
|
51304
51489
|
// src/tool_lattice/collection/delete_entries.ts
|
|
51305
51490
|
var import_zod68 = __toESM(require("zod"));
|
|
51306
51491
|
var import_langchain75 = require("langchain");
|
|
51307
|
-
var
|
|
51492
|
+
var import_protocols56 = require("@axiom-lattice/protocols");
|
|
51308
51493
|
var schema5 = import_zod68.default.object({
|
|
51309
51494
|
collection: import_zod68.default.string().describe("Collection name"),
|
|
51310
51495
|
entryIds: import_zod68.default.array(
|
|
51311
51496
|
import_zod68.default.string().refine((value) => value.trim().length > 0, {
|
|
51312
51497
|
message: "entry id must not be blank"
|
|
51313
51498
|
}).describe("Entry ID to delete")
|
|
51314
|
-
).min(1).max(
|
|
51499
|
+
).min(1).max(import_protocols56.COLLECTION_ENTRY_BATCH_MAX)
|
|
51315
51500
|
});
|
|
51316
51501
|
function key5(tenantId2, collection) {
|
|
51317
51502
|
return `${tenantId2}:${collection}`;
|
|
@@ -52568,15 +52753,15 @@ var widgetPlugin = {
|
|
|
52568
52753
|
var import_langchain82 = require("langchain");
|
|
52569
52754
|
var import_zod72 = require("zod");
|
|
52570
52755
|
var import_langgraph13 = require("@langchain/langgraph");
|
|
52571
|
-
var
|
|
52756
|
+
var import_protocols58 = require("@axiom-lattice/protocols");
|
|
52572
52757
|
|
|
52573
52758
|
// src/services/taskWorkerRunConfig.ts
|
|
52574
|
-
var
|
|
52759
|
+
var import_protocols57 = require("@axiom-lattice/protocols");
|
|
52575
52760
|
function resolveWorkerRunScope(input) {
|
|
52576
|
-
const caller = (0,
|
|
52761
|
+
const caller = (0, import_protocols57.resolveRunScope)(input.runConfig);
|
|
52577
52762
|
return {
|
|
52578
|
-
workspaceId: (0,
|
|
52579
|
-
projectId: (0,
|
|
52763
|
+
workspaceId: (0, import_protocols57.firstNonEmptyString)(input.invocation.workspaceId) ?? caller.workspaceId,
|
|
52764
|
+
projectId: (0, import_protocols57.firstNonEmptyString)(input.invocation.projectId) ?? caller.projectId
|
|
52580
52765
|
};
|
|
52581
52766
|
}
|
|
52582
52767
|
function applyWorkerRunScope(runConfig, scope) {
|
|
@@ -52593,7 +52778,7 @@ function applyWorkerRunScope(runConfig, scope) {
|
|
|
52593
52778
|
}
|
|
52594
52779
|
|
|
52595
52780
|
// src/middlewares/taskMiddleware.ts
|
|
52596
|
-
var
|
|
52781
|
+
var import_protocols59 = require("@axiom-lattice/protocols");
|
|
52597
52782
|
|
|
52598
52783
|
// src/middlewares/taskResponseSerialization.ts
|
|
52599
52784
|
var TASK_RESPONSE_SCALAR_MAX_BYTES = 4096;
|
|
@@ -52898,7 +53083,7 @@ async function postProcessTaskMutationResponse(input) {
|
|
|
52898
53083
|
}
|
|
52899
53084
|
|
|
52900
53085
|
// src/middlewares/taskMiddleware.ts
|
|
52901
|
-
function
|
|
53086
|
+
function getRunConfig3(config) {
|
|
52902
53087
|
const c = config;
|
|
52903
53088
|
return c?.configurable?.runConfig ?? {};
|
|
52904
53089
|
}
|
|
@@ -53082,7 +53267,7 @@ function classifyTaskAuthority(runConfig) {
|
|
|
53082
53267
|
return delegatedTaskId ? { kind: "delegated", taskId: delegatedTaskId } : { kind: "ordinary" };
|
|
53083
53268
|
}
|
|
53084
53269
|
try {
|
|
53085
|
-
const trusted = (0,
|
|
53270
|
+
const trusted = (0, import_protocols59.parseTrustedRunContext)(hasProjectTask ? { projectTask: runConfig.projectTask } : { projectRoom: runConfig.projectRoom });
|
|
53086
53271
|
return { kind: hasProjectTask ? "projectTask" : "projectRoom", trusted };
|
|
53087
53272
|
} catch {
|
|
53088
53273
|
return { kind: "invalid" };
|
|
@@ -53430,7 +53615,7 @@ function getTaskWorkItemStore() {
|
|
|
53430
53615
|
return getStoreLattice("default", "taskWorkItem").store;
|
|
53431
53616
|
}
|
|
53432
53617
|
function getProjectTaskWorkItemStore() {
|
|
53433
|
-
return (0,
|
|
53618
|
+
return (0, import_protocols59.requireProjectTaskWorkItemStore)(getTaskWorkItemStore());
|
|
53434
53619
|
}
|
|
53435
53620
|
function reviewInterruption(task) {
|
|
53436
53621
|
const value = task.context?.interruption;
|
|
@@ -53481,7 +53666,7 @@ var manageTaskSchema = import_zod72.z.object({
|
|
|
53481
53666
|
})).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
53667
|
content: import_zod72.z.string().optional().describe("Markdown content required for add_activity"),
|
|
53483
53668
|
summary: import_zod72.z.string().optional().describe("Brief summary of the operation"),
|
|
53484
|
-
executionResultId: import_zod72.z.string().refine(
|
|
53669
|
+
executionResultId: import_zod72.z.string().refine(import_protocols59.isExecutionResultEventKey, {
|
|
53485
53670
|
message: "executionResultId must be the execution-result:<threadId> event key returned by task()"
|
|
53486
53671
|
}).optional().describe(
|
|
53487
53672
|
"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 +53731,7 @@ async function getPendingExecutionResultIds(store2, tenantId2, taskId) {
|
|
|
53546
53731
|
order: "desc",
|
|
53547
53732
|
limit: PENDING_EXECUTION_RESULT_LIMIT + 1
|
|
53548
53733
|
});
|
|
53549
|
-
const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0,
|
|
53734
|
+
const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0, import_protocols59.isExecutionResultEventKey)(item.eventKey));
|
|
53550
53735
|
const reconciliationRows = new Array(canonicalCandidates.length);
|
|
53551
53736
|
let nextCandidateIndex = 0;
|
|
53552
53737
|
let firstError;
|
|
@@ -53624,14 +53809,14 @@ function updateValuesEqual(field, requested, persisted) {
|
|
|
53624
53809
|
}
|
|
53625
53810
|
function createTaskMiddleware(options = {}) {
|
|
53626
53811
|
const handleManageTaskAction = async (input, config, validateExecutionResult, markMutation) => {
|
|
53627
|
-
const rc =
|
|
53812
|
+
const rc = getRunConfig3(config);
|
|
53628
53813
|
const authority = classifyTaskAuthority(rc);
|
|
53629
53814
|
if (authority.kind === "invalid") return trustedContextError();
|
|
53630
53815
|
const delegatedTaskId = authority.kind === "delegated" ? authority.taskId : void 0;
|
|
53631
53816
|
const trustedProject = authority.kind === "projectRoom" || authority.kind === "projectTask" ? authority.trusted : void 0;
|
|
53632
53817
|
const trustedScope = trustedProject?.projectTask ?? trustedProject?.projectRoom;
|
|
53633
53818
|
const tenantId2 = trustedScope?.tenantId ?? (rc.tenantId || "default");
|
|
53634
|
-
const runScope = (0,
|
|
53819
|
+
const runScope = (0, import_protocols58.resolveRunScope)(rc);
|
|
53635
53820
|
const workspaceId = trustedScope?.workspaceId ?? runScope.workspaceId;
|
|
53636
53821
|
const projectId = trustedScope?.projectId ?? runScope.projectId;
|
|
53637
53822
|
const revalidateCaller = async () => {
|
|
@@ -54205,8 +54390,8 @@ function createTaskMiddleware(options = {}) {
|
|
|
54205
54390
|
let reconciliationMetadata = {};
|
|
54206
54391
|
let descriptionMutated = false;
|
|
54207
54392
|
if (isAgentTask && input.description !== void 0 && !valuesEqual(input.description, existing.description)) {
|
|
54208
|
-
const oldBelief = (0,
|
|
54209
|
-
const newBelief = (0,
|
|
54393
|
+
const oldBelief = (0, import_protocols59.parseTaskBeliefState)(existing.description ?? "");
|
|
54394
|
+
const newBelief = (0, import_protocols59.parseTaskBeliefState)(input.description);
|
|
54210
54395
|
const hasBeliefState = oldBelief.success || newBelief.success;
|
|
54211
54396
|
if (hasBeliefState) {
|
|
54212
54397
|
await validateExecutionResult();
|
|
@@ -54752,7 +54937,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
54752
54937
|
};
|
|
54753
54938
|
const reconcileExplicitExecutionResult = async (input, config, response, validationError, didMutate) => {
|
|
54754
54939
|
if (input.action !== "update" && input.action !== "set_status" && input.action !== "add_activity" || !input.id) return response;
|
|
54755
|
-
const authority = classifyTaskAuthority(
|
|
54940
|
+
const authority = classifyTaskAuthority(getRunConfig3(config));
|
|
54756
54941
|
if (authority.kind === "projectRoom" || authority.kind === "projectTask" || authority.kind === "invalid") {
|
|
54757
54942
|
return response;
|
|
54758
54943
|
}
|
|
@@ -54765,7 +54950,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
54765
54950
|
mutationCommitted: didMutate,
|
|
54766
54951
|
validationError,
|
|
54767
54952
|
reconcile: async (parsed) => {
|
|
54768
|
-
const rc =
|
|
54953
|
+
const rc = getRunConfig3(config);
|
|
54769
54954
|
const tenantId2 = rc.tenantId || "default";
|
|
54770
54955
|
const workItemStore = getTaskWorkItemStore();
|
|
54771
54956
|
const task = await getTaskStore().getById(tenantId2, taskId);
|
|
@@ -54794,11 +54979,11 @@ function createTaskMiddleware(options = {}) {
|
|
|
54794
54979
|
let didMutate = false;
|
|
54795
54980
|
const validateExecutionResult = async () => {
|
|
54796
54981
|
if (!input.executionResultId || validationAttempted) return;
|
|
54797
|
-
const authority = classifyTaskAuthority(
|
|
54982
|
+
const authority = classifyTaskAuthority(getRunConfig3(config));
|
|
54798
54983
|
if (authority.kind === "projectRoom" || authority.kind === "projectTask" || authority.kind === "invalid") return;
|
|
54799
54984
|
validationAttempted = true;
|
|
54800
54985
|
try {
|
|
54801
|
-
const rc =
|
|
54986
|
+
const rc = getRunConfig3(config);
|
|
54802
54987
|
const tenantId2 = rc.tenantId || "default";
|
|
54803
54988
|
const workItemStore = getTaskWorkItemStore();
|
|
54804
54989
|
const executionResult = await workItemStore.findByEventKey(
|
|
@@ -54848,7 +55033,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
54848
55033
|
);
|
|
54849
55034
|
};
|
|
54850
55035
|
const handleStartTask = async (input, config) => {
|
|
54851
|
-
const rc =
|
|
55036
|
+
const rc = getRunConfig3(config);
|
|
54852
55037
|
const authority = classifyTaskAuthority(rc);
|
|
54853
55038
|
if (authority.kind === "invalid") return trustedContextError();
|
|
54854
55039
|
if (authority.kind === "delegated") {
|
|
@@ -55714,7 +55899,7 @@ function createParseDocumentTool({
|
|
|
55714
55899
|
}
|
|
55715
55900
|
|
|
55716
55901
|
// src/middlewares/documentParserMiddleware.ts
|
|
55717
|
-
var
|
|
55902
|
+
var import_protocols60 = require("@axiom-lattice/protocols");
|
|
55718
55903
|
|
|
55719
55904
|
// src/middlewares/documentBenchmarkWorkflow.ts
|
|
55720
55905
|
var DOCUMENT_PARSER_BENCHMARK_YAML = `name: document-parser-benchmark
|
|
@@ -56256,7 +56441,7 @@ var documentParserPlugin = {
|
|
|
56256
56441
|
agents: {
|
|
56257
56442
|
"document-parser": {
|
|
56258
56443
|
key: "document-parser",
|
|
56259
|
-
type:
|
|
56444
|
+
type: import_protocols60.AgentType.DEEP_AGENT,
|
|
56260
56445
|
name: "Document Parser",
|
|
56261
56446
|
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
56447
|
prompt: DOCUMENT_PARSER_SYSTEM_PROMPT,
|
|
@@ -56306,7 +56491,7 @@ var documentParserPlugin = {
|
|
|
56306
56491
|
},
|
|
56307
56492
|
"document-parser-benchmark": {
|
|
56308
56493
|
key: "document-parser-benchmark",
|
|
56309
|
-
type:
|
|
56494
|
+
type: import_protocols60.AgentType.WORKFLOW,
|
|
56310
56495
|
name: "Document Parser Benchmark",
|
|
56311
56496
|
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
56497
|
prompt: "Benchmark document parsing engines: parse with 5 engines, score, and rank results.",
|
|
@@ -56343,7 +56528,7 @@ var documentParserPlugin = {
|
|
|
56343
56528
|
|
|
56344
56529
|
// src/middlewares/projectRoomMiddleware.ts
|
|
56345
56530
|
var import_crypto11 = require("crypto");
|
|
56346
|
-
var
|
|
56531
|
+
var import_protocols61 = require("@axiom-lattice/protocols");
|
|
56347
56532
|
var import_langchain86 = require("langchain");
|
|
56348
56533
|
var import_zod74 = require("zod");
|
|
56349
56534
|
var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
|
|
@@ -56373,7 +56558,7 @@ function ownDataValue2(record, key6) {
|
|
|
56373
56558
|
if (typeof record !== "object" || record === null || Array.isArray(record)) return void 0;
|
|
56374
56559
|
try {
|
|
56375
56560
|
const descriptor = Object.getOwnPropertyDescriptor(record, key6);
|
|
56376
|
-
return (0,
|
|
56561
|
+
return (0, import_protocols61.descriptorDataValue)(descriptor)?.value;
|
|
56377
56562
|
} catch {
|
|
56378
56563
|
return void 0;
|
|
56379
56564
|
}
|
|
@@ -56383,14 +56568,14 @@ function readTrustedRoomScope(config) {
|
|
|
56383
56568
|
const runConfig = ownDataValue2(configurable, "runConfig");
|
|
56384
56569
|
const projectRoom = ownDataValue2(runConfig, "projectRoom");
|
|
56385
56570
|
try {
|
|
56386
|
-
return (0,
|
|
56571
|
+
return (0, import_protocols61.parseTrustedRunContext)({ projectRoom }).projectRoom;
|
|
56387
56572
|
} catch {
|
|
56388
56573
|
return void 0;
|
|
56389
56574
|
}
|
|
56390
56575
|
}
|
|
56391
56576
|
function exactValues2(value, required, optional = []) {
|
|
56392
56577
|
try {
|
|
56393
|
-
return (0,
|
|
56578
|
+
return (0, import_protocols61.snapshotExactRecord)(value, required, optional);
|
|
56394
56579
|
} catch {
|
|
56395
56580
|
return void 0;
|
|
56396
56581
|
}
|
|
@@ -56426,7 +56611,7 @@ function snapshotMembership3(value) {
|
|
|
56426
56611
|
return { ...values, joinedAt, updatedAt };
|
|
56427
56612
|
}
|
|
56428
56613
|
function snapshotRows(value) {
|
|
56429
|
-
return (0,
|
|
56614
|
+
return (0, import_protocols61.snapshotExactArray)(value) ?? [];
|
|
56430
56615
|
}
|
|
56431
56616
|
async function rosterExemptMembershipProjection(scope) {
|
|
56432
56617
|
const excluded = /* @__PURE__ */ new Set();
|
|
@@ -56551,7 +56736,7 @@ var projectRoomPlugin = {
|
|
|
56551
56736
|
// src/middlewares/sandboxPluginsMiddleware.ts
|
|
56552
56737
|
var import_langchain87 = require("langchain");
|
|
56553
56738
|
var import_zod75 = require("zod");
|
|
56554
|
-
var
|
|
56739
|
+
var import_protocols62 = require("@axiom-lattice/protocols");
|
|
56555
56740
|
|
|
56556
56741
|
// src/services/PluginUiToolRunner.ts
|
|
56557
56742
|
var PluginNotFoundError = class extends Error {
|
|
@@ -58450,7 +58635,7 @@ var sandboxPluginsPlugin = {
|
|
|
58450
58635
|
key: "plugin-builder",
|
|
58451
58636
|
name: "Plugin Builder",
|
|
58452
58637
|
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:
|
|
58638
|
+
type: import_protocols62.AgentType.DEEP_AGENT,
|
|
58454
58639
|
prompt: PLUGIN_BUILDER_PROMPT,
|
|
58455
58640
|
// Read-only discovery of connection identifiers (metadata only — never
|
|
58456
58641
|
// config/secrets) so the builder can confirm a human configured a
|
|
@@ -59575,7 +59760,7 @@ var appSharePlugin = {
|
|
|
59575
59760
|
// src/middlewares/longTermStoreMiddleware.ts
|
|
59576
59761
|
var import_langchain89 = require("langchain");
|
|
59577
59762
|
var import_zod77 = require("zod");
|
|
59578
|
-
var
|
|
59763
|
+
var import_protocols63 = require("@axiom-lattice/protocols");
|
|
59579
59764
|
var DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
|
|
59580
59765
|
var DEFAULT_SEARCH_LIMIT = 10;
|
|
59581
59766
|
var MAX_SEARCH_LIMIT = 100;
|
|
@@ -59606,7 +59791,7 @@ function runtimeScope(exeConfig) {
|
|
|
59606
59791
|
function normalizeSegments(value) {
|
|
59607
59792
|
if (!Array.isArray(value) || value.length === 0) return void 0;
|
|
59608
59793
|
const segments = value.map((segment) => typeof segment === "string" ? segment.trim() : "");
|
|
59609
|
-
if (!segments.every((segment) => segment.length > 0 && !segment.includes(
|
|
59794
|
+
if (!segments.every((segment) => segment.length > 0 && !segment.includes(import_protocols63.STORE_IDENTITY_SEPARATOR))) return void 0;
|
|
59610
59795
|
return segments;
|
|
59611
59796
|
}
|
|
59612
59797
|
function clampLimit2(value, fallback = DEFAULT_SEARCH_LIMIT) {
|
|
@@ -59617,7 +59802,7 @@ function failure3(error) {
|
|
|
59617
59802
|
return JSON.stringify({ success: false, error });
|
|
59618
59803
|
}
|
|
59619
59804
|
function operationFailure(error) {
|
|
59620
|
-
if (error instanceof
|
|
59805
|
+
if (error instanceof import_protocols63.StoreValidationError) {
|
|
59621
59806
|
return failure3(error.message);
|
|
59622
59807
|
}
|
|
59623
59808
|
return failure3("Long-term store operation failed");
|
|
@@ -60625,7 +60810,7 @@ function buildUserContent(name) {
|
|
|
60625
60810
|
var DEFAULT_CONFIG = {
|
|
60626
60811
|
name: "Personal Assistant",
|
|
60627
60812
|
description: "Default template for personal assistants",
|
|
60628
|
-
type:
|
|
60813
|
+
type: import_protocols26.AgentType.DEEP_AGENT,
|
|
60629
60814
|
modelKey: "default",
|
|
60630
60815
|
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
60816
|
\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 +60843,9 @@ var DEFAULT_CONFIG = {
|
|
|
60658
60843
|
type: "skill",
|
|
60659
60844
|
name: "Skills",
|
|
60660
60845
|
description: "Skill system for specialized instructions and workflows",
|
|
60846
|
+
// Temporary default until skills have a per-PA resource/collection model:
|
|
60847
|
+
// keep dynamic discovery by reading all. Do NOT set `skills: []` here —
|
|
60848
|
+
// load_skills treats an explicit empty list as "no static access".
|
|
60661
60849
|
enabled: true,
|
|
60662
60850
|
config: {
|
|
60663
60851
|
readAll: true
|
|
@@ -60702,17 +60890,12 @@ var DEFAULT_CONFIG = {
|
|
|
60702
60890
|
description: "Persistent task system for human-agent coordination",
|
|
60703
60891
|
enabled: true,
|
|
60704
60892
|
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
60893
|
}
|
|
60714
60894
|
],
|
|
60715
|
-
|
|
60895
|
+
// The PA is a user-facing assistant, not a tenant agent builder. It may
|
|
60896
|
+
// discover available agents and dispatch work via `task`, but must not read,
|
|
60897
|
+
// create, or invoke agents directly.
|
|
60898
|
+
tools: ["list_agents", "manage_binding"]
|
|
60716
60899
|
};
|
|
60717
60900
|
var PersonalAssistantConfig = class {
|
|
60718
60901
|
/**
|
|
@@ -61109,6 +61292,7 @@ registerBuiltinPlugins();
|
|
|
61109
61292
|
InMemoryProjectRoomReadStateStore,
|
|
61110
61293
|
InMemoryProjectRoomStore,
|
|
61111
61294
|
InMemoryProjectStore,
|
|
61295
|
+
InMemorySessionStore,
|
|
61112
61296
|
InMemorySharedResourceStore,
|
|
61113
61297
|
InMemoryStore,
|
|
61114
61298
|
InMemoryTaskStore,
|