@axiom-lattice/core 13.0.2 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +108 -4
- package/dist/index.d.ts +108 -4
- package/dist/index.js +666 -321
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +399 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -280,12 +280,12 @@ var init_BaseLatticeManager = __esm({
|
|
|
280
280
|
});
|
|
281
281
|
|
|
282
282
|
// src/memory_lattice/MemoryLatticeManager.ts
|
|
283
|
-
var
|
|
283
|
+
var import_protocols18, _MemoryLatticeManager, MemoryLatticeManager, getCheckpointSaver, registerCheckpointSaver;
|
|
284
284
|
var init_MemoryLatticeManager = __esm({
|
|
285
285
|
"src/memory_lattice/MemoryLatticeManager.ts"() {
|
|
286
286
|
"use strict";
|
|
287
287
|
init_BaseLatticeManager();
|
|
288
|
-
|
|
288
|
+
import_protocols18 = require("@axiom-lattice/protocols");
|
|
289
289
|
_MemoryLatticeManager = class _MemoryLatticeManager extends BaseLatticeManager {
|
|
290
290
|
/**
|
|
291
291
|
* 私有构造函数,防止外部直接实例化
|
|
@@ -375,7 +375,7 @@ var init_DefaultMemorySaver = __esm({
|
|
|
375
375
|
var memory_lattice_exports = {};
|
|
376
376
|
__export(memory_lattice_exports, {
|
|
377
377
|
MemoryLatticeManager: () => MemoryLatticeManager,
|
|
378
|
-
MemoryType: () =>
|
|
378
|
+
MemoryType: () => import_protocols18.MemoryType,
|
|
379
379
|
getCheckpointSaver: () => getCheckpointSaver,
|
|
380
380
|
registerCheckpointSaver: () => registerCheckpointSaver
|
|
381
381
|
});
|
|
@@ -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,
|
|
@@ -1743,7 +1744,7 @@ __export(index_exports, {
|
|
|
1743
1744
|
MemoryLatticeManager: () => MemoryLatticeManager,
|
|
1744
1745
|
MemoryQueueClient: () => MemoryQueueClient,
|
|
1745
1746
|
MemoryScheduleStorage: () => MemoryScheduleStorage,
|
|
1746
|
-
MemoryType: () =>
|
|
1747
|
+
MemoryType: () => import_protocols18.MemoryType,
|
|
1747
1748
|
MetricsServerManager: () => MetricsServerManager,
|
|
1748
1749
|
MicrosandboxRemoteInstance: () => MicrosandboxRemoteInstance,
|
|
1749
1750
|
MicrosandboxRemoteProvider: () => MicrosandboxRemoteProvider,
|
|
@@ -2068,10 +2069,10 @@ __export(index_exports, {
|
|
|
2068
2069
|
parseHostArgs: () => parseHostArgs,
|
|
2069
2070
|
parseJudgeVerdict: () => parseJudgeVerdict,
|
|
2070
2071
|
parsePackSize: () => parsePackSize,
|
|
2071
|
-
parseQueuedExecutionMode: () =>
|
|
2072
|
+
parseQueuedExecutionMode: () => import_protocols11.parseQueuedExecutionMode,
|
|
2072
2073
|
parseSkillFrontmatter: () => parseSkillFrontmatter,
|
|
2073
2074
|
parseTaskResponse: () => parseTaskResponse,
|
|
2074
|
-
parseTrustedRunContext: () =>
|
|
2075
|
+
parseTrustedRunContext: () => import_protocols11.parseTrustedRunContext,
|
|
2075
2076
|
parseYaml: () => parseYaml,
|
|
2076
2077
|
performStringReplacement: () => performStringReplacement,
|
|
2077
2078
|
pluginHostContentHash: () => pluginHostContentHash,
|
|
@@ -2724,12 +2725,13 @@ var ModelLattice = class extends import_chat_models.BaseChatModel {
|
|
|
2724
2725
|
};
|
|
2725
2726
|
|
|
2726
2727
|
// src/model_lattice/ModelLatticeManager.ts
|
|
2727
|
-
var
|
|
2728
|
+
var import_protocols23 = require("@axiom-lattice/protocols");
|
|
2728
2729
|
|
|
2729
2730
|
// src/store_lattice/StoreLatticeManager.ts
|
|
2730
2731
|
init_BaseLatticeManager();
|
|
2731
2732
|
|
|
2732
2733
|
// src/store_lattice/InMemoryThreadStore.ts
|
|
2734
|
+
var import_protocols = require("@axiom-lattice/protocols");
|
|
2733
2735
|
var InMemoryThreadStore = class {
|
|
2734
2736
|
constructor() {
|
|
2735
2737
|
// Map<tenantId, Map<assistantId, Map<threadId, Thread>>>
|
|
@@ -2757,6 +2759,35 @@ var InMemoryThreadStore = class {
|
|
|
2757
2759
|
}
|
|
2758
2760
|
return threads;
|
|
2759
2761
|
}
|
|
2762
|
+
async listThreadsByTenant(tenantId2, query = {}) {
|
|
2763
|
+
const limit = Math.min(200, Math.max(1, Math.floor(query.limit ?? 50)));
|
|
2764
|
+
const offset = Math.max(0, Math.floor(query.offset ?? 0));
|
|
2765
|
+
const createdAfter = query.createdAfter ? Date.parse(query.createdAfter) : void 0;
|
|
2766
|
+
const tenantThreads = this.threads.get(tenantId2);
|
|
2767
|
+
if (!tenantThreads) return { records: [], total: 0 };
|
|
2768
|
+
const all = [];
|
|
2769
|
+
for (const assistantThreads of tenantThreads.values()) {
|
|
2770
|
+
all.push(...assistantThreads.values());
|
|
2771
|
+
}
|
|
2772
|
+
const filtered = all.filter((thread) => {
|
|
2773
|
+
if (query.assistantId && thread.assistantId !== query.assistantId) {
|
|
2774
|
+
return false;
|
|
2775
|
+
}
|
|
2776
|
+
if (createdAfter !== void 0 && Number.isFinite(createdAfter) && thread.createdAt.getTime() < createdAfter) {
|
|
2777
|
+
return false;
|
|
2778
|
+
}
|
|
2779
|
+
if (query.kind && (0, import_protocols.classifyThreadMetadata)(thread.metadata) !== query.kind) {
|
|
2780
|
+
return false;
|
|
2781
|
+
}
|
|
2782
|
+
return true;
|
|
2783
|
+
}).sort(
|
|
2784
|
+
(left, right) => right.createdAt.getTime() - left.createdAt.getTime() || right.id.localeCompare(left.id)
|
|
2785
|
+
);
|
|
2786
|
+
return {
|
|
2787
|
+
records: filtered.slice(offset, offset + limit).map(import_protocols.toThreadMonitorRecord),
|
|
2788
|
+
total: filtered.length
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2760
2791
|
/**
|
|
2761
2792
|
* Get a thread by ID for a specific tenant
|
|
2762
2793
|
*/
|
|
@@ -2899,8 +2930,8 @@ var InMemoryThreadStore = class {
|
|
|
2899
2930
|
};
|
|
2900
2931
|
|
|
2901
2932
|
// src/store_lattice/InMemoryStore.ts
|
|
2902
|
-
var
|
|
2903
|
-
var NAMESPACE_SEPARATOR =
|
|
2933
|
+
var import_protocols2 = require("@axiom-lattice/protocols");
|
|
2934
|
+
var NAMESPACE_SEPARATOR = import_protocols2.STORE_IDENTITY_SEPARATOR;
|
|
2904
2935
|
function namespacePath(namespace) {
|
|
2905
2936
|
return namespace.join(NAMESPACE_SEPARATOR);
|
|
2906
2937
|
}
|
|
@@ -2941,13 +2972,13 @@ var InMemoryStore = class {
|
|
|
2941
2972
|
this.items = /* @__PURE__ */ new Map();
|
|
2942
2973
|
}
|
|
2943
2974
|
async put(tenantId2, input) {
|
|
2944
|
-
(0,
|
|
2975
|
+
(0, import_protocols2.assertStoreIdentity)(input.namespace, input.key);
|
|
2945
2976
|
const now = /* @__PURE__ */ new Date();
|
|
2946
2977
|
const storageKey = this.pathWithKey(input.namespace, input.key);
|
|
2947
2978
|
const tenant = this.items.get(tenantId2) ?? /* @__PURE__ */ new Map();
|
|
2948
2979
|
this.items.set(tenantId2, tenant);
|
|
2949
2980
|
const existing = tenant.get(storageKey);
|
|
2950
|
-
const expiresAt = (0,
|
|
2981
|
+
const expiresAt = (0, import_protocols2.storeExpiresAt)(input.ttlMinutes, now);
|
|
2951
2982
|
const item = {
|
|
2952
2983
|
namespace: [...input.namespace],
|
|
2953
2984
|
key: input.key,
|
|
@@ -2960,26 +2991,26 @@ var InMemoryStore = class {
|
|
|
2960
2991
|
return cloneItem(item);
|
|
2961
2992
|
}
|
|
2962
2993
|
async get(tenantId2, namespace, key6) {
|
|
2963
|
-
(0,
|
|
2994
|
+
(0, import_protocols2.assertStoreIdentity)(namespace, key6);
|
|
2964
2995
|
const entry = this.items.get(tenantId2)?.get(this.pathWithKey(namespace, key6));
|
|
2965
2996
|
return entry && isVisible(entry, /* @__PURE__ */ new Date()) ? cloneItem(entry) : null;
|
|
2966
2997
|
}
|
|
2967
2998
|
async delete(tenantId2, namespace, key6) {
|
|
2968
|
-
(0,
|
|
2999
|
+
(0, import_protocols2.assertStoreIdentity)(namespace, key6);
|
|
2969
3000
|
return this.items.get(tenantId2)?.delete(this.pathWithKey(namespace, key6)) ?? false;
|
|
2970
3001
|
}
|
|
2971
3002
|
async search(tenantId2, input) {
|
|
2972
3003
|
const now = /* @__PURE__ */ new Date();
|
|
2973
3004
|
const prefix = input.namespacePrefix ?? [];
|
|
2974
|
-
(0,
|
|
3005
|
+
(0, import_protocols2.assertStoreNamespacePrefix)(prefix);
|
|
2975
3006
|
const query = input.query?.toLowerCase();
|
|
2976
|
-
const limit = (0,
|
|
2977
|
-
const offset = (0,
|
|
3007
|
+
const limit = (0, import_protocols2.storePaginationValue)(input.limit, 10);
|
|
3008
|
+
const offset = (0, import_protocols2.storePaginationValue)(input.offset, 0);
|
|
2978
3009
|
const matches = Array.from(this.items.get(tenantId2)?.values() ?? []).filter((item) => isVisible(item, now)).filter((item) => hasPrefix(item.namespace, prefix)).filter((item) => input.filter === void 0 || matchesFilter(item.value, input.filter)).filter((item) => query === void 0 || JSON.stringify(item.value).toLowerCase().includes(query)).sort((left, right) => right.updatedAt.getTime() - left.updatedAt.getTime() || namespacePath(left.namespace).localeCompare(namespacePath(right.namespace)) || left.key.localeCompare(right.key));
|
|
2979
3010
|
return matches.slice(offset, offset + limit).map(cloneItem);
|
|
2980
3011
|
}
|
|
2981
3012
|
async listNamespaces(tenantId2, prefix = [], limit = 100) {
|
|
2982
|
-
(0,
|
|
3013
|
+
(0, import_protocols2.assertStoreNamespacePrefix)(prefix);
|
|
2983
3014
|
const now = /* @__PURE__ */ new Date();
|
|
2984
3015
|
const namespaces = /* @__PURE__ */ new Map();
|
|
2985
3016
|
for (const item of this.items.get(tenantId2)?.values() ?? []) {
|
|
@@ -2987,10 +3018,10 @@ var InMemoryStore = class {
|
|
|
2987
3018
|
namespaces.set(namespacePath(item.namespace), [...item.namespace]);
|
|
2988
3019
|
}
|
|
2989
3020
|
}
|
|
2990
|
-
return Array.from(namespaces.entries()).sort(([left], [right]) => left.localeCompare(right)).slice(0, (0,
|
|
3021
|
+
return Array.from(namespaces.entries()).sort(([left], [right]) => left.localeCompare(right)).slice(0, (0, import_protocols2.storePaginationValue)(limit, 100)).map(([, namespace]) => namespace);
|
|
2991
3022
|
}
|
|
2992
3023
|
async deleteExpired(now, limit) {
|
|
2993
|
-
const bounded = (0,
|
|
3024
|
+
const bounded = (0, import_protocols2.storePaginationValue)(limit, 0);
|
|
2994
3025
|
let deleted = 0;
|
|
2995
3026
|
for (const [tenantId2, tenant] of this.items) {
|
|
2996
3027
|
for (const [path8, item] of tenant) {
|
|
@@ -3322,7 +3353,7 @@ var InMemoryWorkspaceStore = class {
|
|
|
3322
3353
|
};
|
|
3323
3354
|
|
|
3324
3355
|
// src/store_lattice/InMemoryProjectStore.ts
|
|
3325
|
-
var
|
|
3356
|
+
var import_protocols3 = require("@axiom-lattice/protocols");
|
|
3326
3357
|
|
|
3327
3358
|
// src/store_lattice/InMemoryCapabilityBundleCoordinator.ts
|
|
3328
3359
|
var InMemoryCapabilityBundleCoordinator = class {
|
|
@@ -3410,7 +3441,7 @@ var InMemoryProjectStore = class {
|
|
|
3410
3441
|
return this.projects.get(key6) || null;
|
|
3411
3442
|
}
|
|
3412
3443
|
async createProject(tenantId2, workspaceId, id, data) {
|
|
3413
|
-
(0,
|
|
3444
|
+
(0, import_protocols3.assertGenericProjectConfig)(data.config);
|
|
3414
3445
|
return this.capabilityBundles.runProjectUpdate(tenantId2, id, () => {
|
|
3415
3446
|
const now = /* @__PURE__ */ new Date();
|
|
3416
3447
|
const key6 = this.getKey(tenantId2, id);
|
|
@@ -3441,7 +3472,7 @@ var InMemoryProjectStore = class {
|
|
|
3441
3472
|
* overwrites the existing config. To preserve the current config, omit this field.
|
|
3442
3473
|
*/
|
|
3443
3474
|
async updateProject(tenantId2, id, updates) {
|
|
3444
|
-
(0,
|
|
3475
|
+
(0, import_protocols3.assertGenericProjectConfig)(updates.config);
|
|
3445
3476
|
return this.capabilityBundles.runProjectUpdate(tenantId2, id, () => {
|
|
3446
3477
|
const key6 = this.getKey(tenantId2, id);
|
|
3447
3478
|
const existing = this.projects.get(key6);
|
|
@@ -5285,7 +5316,7 @@ function entryKey2(tenantId2, pluginType) {
|
|
|
5285
5316
|
}
|
|
5286
5317
|
|
|
5287
5318
|
// src/store_lattice/InMemoryPlatformSettingsStore.ts
|
|
5288
|
-
var
|
|
5319
|
+
var import_protocols4 = require("@axiom-lattice/protocols");
|
|
5289
5320
|
function cloneRecord(record) {
|
|
5290
5321
|
const cloned = structuredClone(record);
|
|
5291
5322
|
cloned.updatedAt = new Date(record.updatedAt.getTime());
|
|
@@ -5311,7 +5342,7 @@ var InMemoryPlatformSettingsStore = class {
|
|
|
5311
5342
|
async save(document, expectedVersion, updatedBy) {
|
|
5312
5343
|
const current = this.record?.version ?? 0;
|
|
5313
5344
|
if (current !== expectedVersion) {
|
|
5314
|
-
throw new
|
|
5345
|
+
throw new import_protocols4.PlatformSettingsVersionConflictError(expectedVersion, current);
|
|
5315
5346
|
}
|
|
5316
5347
|
this.record = {
|
|
5317
5348
|
...structuredClone(document),
|
|
@@ -5446,11 +5477,13 @@ var InMemoryUserStore = class {
|
|
|
5446
5477
|
if (updates.email !== void 0) {
|
|
5447
5478
|
this.assertEmailAvailable(updates.email, id);
|
|
5448
5479
|
}
|
|
5480
|
+
const authEpoch = updates.authEpoch !== void 0 ? updates.authEpoch : existing.authEpoch;
|
|
5449
5481
|
const updated = {
|
|
5450
5482
|
id: existing.id,
|
|
5451
5483
|
email: updates.email ?? existing.email,
|
|
5452
5484
|
name: updates.name ?? existing.name,
|
|
5453
5485
|
status: updates.status ?? existing.status,
|
|
5486
|
+
...authEpoch !== void 0 ? { authEpoch } : {},
|
|
5454
5487
|
metadata: updates.metadata ?? existing.metadata,
|
|
5455
5488
|
createdAt: existing.createdAt,
|
|
5456
5489
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -5535,7 +5568,7 @@ var InMemoryTenantStore = class {
|
|
|
5535
5568
|
};
|
|
5536
5569
|
|
|
5537
5570
|
// src/store_lattice/InMemoryUserTenantLinkStore.ts
|
|
5538
|
-
var
|
|
5571
|
+
var import_protocols5 = require("@axiom-lattice/protocols");
|
|
5539
5572
|
var InMemoryUserTenantLinkStore = class {
|
|
5540
5573
|
constructor() {
|
|
5541
5574
|
this.links = /* @__PURE__ */ new Map();
|
|
@@ -5558,7 +5591,7 @@ var InMemoryUserTenantLinkStore = class {
|
|
|
5558
5591
|
return this.links.get(key6) || null;
|
|
5559
5592
|
}
|
|
5560
5593
|
async createLink(data) {
|
|
5561
|
-
(0,
|
|
5594
|
+
(0, import_protocols5.assertNotPlatformTenant)(data.tenantId);
|
|
5562
5595
|
const link = {
|
|
5563
5596
|
userId: data.userId,
|
|
5564
5597
|
tenantId: data.tenantId,
|
|
@@ -5596,7 +5629,7 @@ var InMemoryUserTenantLinkStore = class {
|
|
|
5596
5629
|
};
|
|
5597
5630
|
|
|
5598
5631
|
// src/store_lattice/InMemoryUserExternalIdentityStore.ts
|
|
5599
|
-
var
|
|
5632
|
+
var import_protocols6 = require("@axiom-lattice/protocols");
|
|
5600
5633
|
function key2(providerId, issuer, subject) {
|
|
5601
5634
|
return JSON.stringify([providerId, issuer, subject]);
|
|
5602
5635
|
}
|
|
@@ -5622,7 +5655,7 @@ var InMemoryUserExternalIdentityStore = class {
|
|
|
5622
5655
|
const existing = this.entries.get(entryKey3);
|
|
5623
5656
|
if (existing) {
|
|
5624
5657
|
if (existing.userId !== identity.userId) {
|
|
5625
|
-
throw new
|
|
5658
|
+
throw new import_protocols6.ExternalIdentityConflictError(
|
|
5626
5659
|
identity.providerId,
|
|
5627
5660
|
identity.issuer,
|
|
5628
5661
|
identity.subject
|
|
@@ -5646,7 +5679,7 @@ var InMemoryUserExternalIdentityStore = class {
|
|
|
5646
5679
|
};
|
|
5647
5680
|
|
|
5648
5681
|
// src/store_lattice/InMemoryOidcProviderConfigStore.ts
|
|
5649
|
-
var
|
|
5682
|
+
var import_protocols7 = require("@axiom-lattice/protocols");
|
|
5650
5683
|
|
|
5651
5684
|
// src/util/encryption.ts
|
|
5652
5685
|
var import_crypto4 = require("crypto");
|
|
@@ -5778,7 +5811,7 @@ var InMemoryOidcProviderConfigStore = class {
|
|
|
5778
5811
|
}
|
|
5779
5812
|
async create(id, input) {
|
|
5780
5813
|
if (this.entries.has(id)) {
|
|
5781
|
-
throw new
|
|
5814
|
+
throw new import_protocols7.OidcProviderConfigConflictError(id);
|
|
5782
5815
|
}
|
|
5783
5816
|
const now = /* @__PURE__ */ new Date();
|
|
5784
5817
|
const tenantId2 = normalizeTenantId(input.defaultTenantId);
|
|
@@ -5879,7 +5912,7 @@ var InMemoryPlatformMemberStore = class {
|
|
|
5879
5912
|
};
|
|
5880
5913
|
|
|
5881
5914
|
// src/store_lattice/InMemoryPlatformInvitationStore.ts
|
|
5882
|
-
var
|
|
5915
|
+
var import_protocols8 = require("@axiom-lattice/protocols");
|
|
5883
5916
|
function clone6(invitation) {
|
|
5884
5917
|
return {
|
|
5885
5918
|
email: invitation.email,
|
|
@@ -5900,7 +5933,7 @@ var InMemoryPlatformInvitationStore = class {
|
|
|
5900
5933
|
}
|
|
5901
5934
|
/** Returns the invitation for an email, or null. */
|
|
5902
5935
|
async get(email) {
|
|
5903
|
-
const entry = this.entries.get((0,
|
|
5936
|
+
const entry = this.entries.get((0, import_protocols8.normalizePlatformInvitationEmail)(email));
|
|
5904
5937
|
return entry ? clone6(entry) : null;
|
|
5905
5938
|
}
|
|
5906
5939
|
/**
|
|
@@ -5912,14 +5945,14 @@ var InMemoryPlatformInvitationStore = class {
|
|
|
5912
5945
|
async upsert(invitation) {
|
|
5913
5946
|
const next = clone6({
|
|
5914
5947
|
...invitation,
|
|
5915
|
-
email: (0,
|
|
5948
|
+
email: (0, import_protocols8.normalizePlatformInvitationEmail)(invitation.email)
|
|
5916
5949
|
});
|
|
5917
5950
|
this.entries.set(next.email, next);
|
|
5918
5951
|
return clone6(next);
|
|
5919
5952
|
}
|
|
5920
5953
|
/** Deletes an invitation. Returns whether a row was removed. */
|
|
5921
5954
|
async delete(email) {
|
|
5922
|
-
return this.entries.delete((0,
|
|
5955
|
+
return this.entries.delete((0, import_protocols8.normalizePlatformInvitationEmail)(email));
|
|
5923
5956
|
}
|
|
5924
5957
|
/**
|
|
5925
5958
|
* Atomically consumes a pending, unexpired invitation.
|
|
@@ -5928,7 +5961,7 @@ var InMemoryPlatformInvitationStore = class {
|
|
|
5928
5961
|
* consumed, or expired.
|
|
5929
5962
|
*/
|
|
5930
5963
|
async consume(email, at) {
|
|
5931
|
-
const key6 = (0,
|
|
5964
|
+
const key6 = (0, import_protocols8.normalizePlatformInvitationEmail)(email);
|
|
5932
5965
|
const entry = this.entries.get(key6);
|
|
5933
5966
|
if (!entry || entry.consumedAt !== void 0) return null;
|
|
5934
5967
|
if (entry.expiresAt !== void 0 && entry.expiresAt.getTime() <= at.getTime()) {
|
|
@@ -5944,7 +5977,7 @@ var InMemoryPlatformInvitationStore = class {
|
|
|
5944
5977
|
};
|
|
5945
5978
|
|
|
5946
5979
|
// src/store_lattice/InMemoryOidcIdentityClaimStore.ts
|
|
5947
|
-
var
|
|
5980
|
+
var import_protocols9 = require("@axiom-lattice/protocols");
|
|
5948
5981
|
function clone7(claim) {
|
|
5949
5982
|
return {
|
|
5950
5983
|
...claim,
|
|
@@ -5980,7 +6013,7 @@ var InMemoryOidcIdentityClaimStore = class {
|
|
|
5980
6013
|
for (const claim2 of this.claims.values()) {
|
|
5981
6014
|
if (claim2.providerId === input.providerId && claim2.issuer === input.issuer && claim2.subject === input.subject && claim2.status === "pending") {
|
|
5982
6015
|
if (claim2.expiresAt.getTime() > now.getTime()) {
|
|
5983
|
-
throw new
|
|
6016
|
+
throw new import_protocols9.OidcIdentityClaimConflictError(
|
|
5984
6017
|
input.providerId,
|
|
5985
6018
|
input.issuer,
|
|
5986
6019
|
input.subject
|
|
@@ -5992,7 +6025,7 @@ var InMemoryOidcIdentityClaimStore = class {
|
|
|
5992
6025
|
}
|
|
5993
6026
|
const claim = {
|
|
5994
6027
|
...input,
|
|
5995
|
-
email: (0,
|
|
6028
|
+
email: (0, import_protocols9.normalizeOidcIdentityEmail)(input.email),
|
|
5996
6029
|
status: "pending",
|
|
5997
6030
|
createdAt: now,
|
|
5998
6031
|
updatedAt: now,
|
|
@@ -6005,7 +6038,7 @@ var InMemoryOidcIdentityClaimStore = class {
|
|
|
6005
6038
|
const claim = this.claims.get(id);
|
|
6006
6039
|
if (!claim || claim.status !== "pending") return null;
|
|
6007
6040
|
if (updates.email !== void 0) {
|
|
6008
|
-
claim.email = (0,
|
|
6041
|
+
claim.email = (0, import_protocols9.normalizeOidcIdentityEmail)(updates.email);
|
|
6009
6042
|
}
|
|
6010
6043
|
if (updates.name !== void 0) claim.name = updates.name;
|
|
6011
6044
|
if (updates.picture !== void 0) claim.picture = updates.picture;
|
|
@@ -6037,7 +6070,7 @@ var InMemoryOidcIdentityClaimStore = class {
|
|
|
6037
6070
|
};
|
|
6038
6071
|
|
|
6039
6072
|
// src/store_lattice/InMemoryInviteLinkStore.ts
|
|
6040
|
-
var
|
|
6073
|
+
var import_protocols10 = require("@axiom-lattice/protocols");
|
|
6041
6074
|
function clone8(link) {
|
|
6042
6075
|
return {
|
|
6043
6076
|
...link,
|
|
@@ -6068,7 +6101,7 @@ var InMemoryInviteLinkStore = class {
|
|
|
6068
6101
|
const now = /* @__PURE__ */ new Date();
|
|
6069
6102
|
const link = {
|
|
6070
6103
|
...input,
|
|
6071
|
-
...input.email ? { email: (0,
|
|
6104
|
+
...input.email ? { email: (0, import_protocols10.normalizeInviteLinkEmail)(input.email) } : {},
|
|
6072
6105
|
createdAt: now,
|
|
6073
6106
|
updatedAt: now,
|
|
6074
6107
|
expiresAt: new Date(input.expiresAt),
|
|
@@ -6098,7 +6131,7 @@ var InMemoryInviteLinkStore = class {
|
|
|
6098
6131
|
};
|
|
6099
6132
|
|
|
6100
6133
|
// src/services/MessageQueueTypes.ts
|
|
6101
|
-
var
|
|
6134
|
+
var import_protocols11 = require("@axiom-lattice/protocols");
|
|
6102
6135
|
var QueueMode = /* @__PURE__ */ ((QueueMode2) => {
|
|
6103
6136
|
QueueMode2["COLLECT"] = "collect";
|
|
6104
6137
|
QueueMode2["FOLLOWUP"] = "followup";
|
|
@@ -6268,12 +6301,13 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
6268
6301
|
const pending = await this.getPendingMessages(threadId, scope);
|
|
6269
6302
|
return pending.length;
|
|
6270
6303
|
}
|
|
6271
|
-
async getThreadsWithPendingMessages() {
|
|
6304
|
+
async getThreadsWithPendingMessages(tenantId2) {
|
|
6272
6305
|
const result = [];
|
|
6273
6306
|
const seen = /* @__PURE__ */ new Set();
|
|
6274
6307
|
for (const [threadId, messages] of this.messages.entries()) {
|
|
6275
6308
|
const scopes = /* @__PURE__ */ new Map();
|
|
6276
6309
|
for (const message of messages) {
|
|
6310
|
+
if (tenantId2 && (message.tenantId || "default") !== tenantId2) continue;
|
|
6277
6311
|
if (message.status !== "pending" && message.status !== "processing" && message.status) continue;
|
|
6278
6312
|
const scopeKey = JSON.stringify([message.tenantId, message.assistantId, message.workspaceId, message.projectId, threadId]);
|
|
6279
6313
|
const hasPending = message.status === "pending" || !message.status;
|
|
@@ -6347,8 +6381,8 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
6347
6381
|
};
|
|
6348
6382
|
function validateQueueTrust(params) {
|
|
6349
6383
|
return {
|
|
6350
|
-
trustedRunContext: params.trusted_run_context === void 0 ? void 0 : (0,
|
|
6351
|
-
executionMode: params.execution_mode === void 0 ? void 0 : (0,
|
|
6384
|
+
trustedRunContext: params.trusted_run_context === void 0 ? void 0 : (0, import_protocols11.parseTrustedRunContext)(params.trusted_run_context),
|
|
6385
|
+
executionMode: params.execution_mode === void 0 ? void 0 : (0, import_protocols11.parseQueuedExecutionMode)(params.execution_mode)
|
|
6352
6386
|
};
|
|
6353
6387
|
}
|
|
6354
6388
|
function clonePendingMessage(message) {
|
|
@@ -6361,7 +6395,7 @@ function clonePendingMessage(message) {
|
|
|
6361
6395
|
priority: message.priority,
|
|
6362
6396
|
command: message.command,
|
|
6363
6397
|
custom_run_config: message.custom_run_config,
|
|
6364
|
-
trusted_run_context: message.trusted_run_context ? (0,
|
|
6398
|
+
trusted_run_context: message.trusted_run_context ? (0, import_protocols11.parseTrustedRunContext)(message.trusted_run_context) : void 0,
|
|
6365
6399
|
execution_mode: message.execution_mode
|
|
6366
6400
|
};
|
|
6367
6401
|
}
|
|
@@ -6624,7 +6658,7 @@ var InMemoryChannelInstallationStore = class {
|
|
|
6624
6658
|
};
|
|
6625
6659
|
|
|
6626
6660
|
// src/store_lattice/InMemoryBindingStore.ts
|
|
6627
|
-
var
|
|
6661
|
+
var import_protocols12 = require("@axiom-lattice/protocols");
|
|
6628
6662
|
var import_crypto5 = require("crypto");
|
|
6629
6663
|
var InMemoryBindingStore = class {
|
|
6630
6664
|
constructor() {
|
|
@@ -6665,7 +6699,7 @@ var InMemoryBindingStore = class {
|
|
|
6665
6699
|
async create(input) {
|
|
6666
6700
|
const operation = this.createTail.then(() => {
|
|
6667
6701
|
const duplicate = Array.from(this.bindings.values()).some((binding2) => binding2.tenantId === input.tenantId && binding2.channel === input.channel && binding2.channelInstallationId === input.channelInstallationId && binding2.senderId === input.senderId);
|
|
6668
|
-
if (duplicate) throw new
|
|
6702
|
+
if (duplicate) throw new import_protocols12.DuplicateChannelBindingSubjectError();
|
|
6669
6703
|
const now = /* @__PURE__ */ new Date();
|
|
6670
6704
|
const binding = {
|
|
6671
6705
|
id: (0, import_crypto5.randomUUID)(),
|
|
@@ -6896,13 +6930,18 @@ var InMemoryOpenAuditStore = class {
|
|
|
6896
6930
|
async append(record) {
|
|
6897
6931
|
this.records.push({ ...record, id: (0, import_crypto7.randomUUID)(), createdAt: /* @__PURE__ */ new Date() });
|
|
6898
6932
|
}
|
|
6933
|
+
async get(tenantId2, id) {
|
|
6934
|
+
return this.records.find((record) => record.tenantId === tenantId2 && record.id === id) ?? null;
|
|
6935
|
+
}
|
|
6899
6936
|
async query(params) {
|
|
6900
6937
|
const from = params.from ? new Date(params.from).getTime() : void 0;
|
|
6901
6938
|
const to = params.to ? new Date(params.to).getTime() : void 0;
|
|
6902
6939
|
const filtered = this.records.filter((r) => {
|
|
6903
6940
|
if (r.tenantId !== params.tenantId) return false;
|
|
6904
6941
|
if (params.credentialId && r.credentialId !== params.credentialId) return false;
|
|
6942
|
+
if (params.projectId && r.projectId !== params.projectId) return false;
|
|
6905
6943
|
if (params.domain && r.domain !== params.domain) return false;
|
|
6944
|
+
if (params.action && r.action !== params.action) return false;
|
|
6906
6945
|
if (params.status && r.status !== params.status) return false;
|
|
6907
6946
|
const t = r.createdAt.getTime();
|
|
6908
6947
|
if (from !== void 0 && t < from) return false;
|
|
@@ -6921,7 +6960,7 @@ var InMemoryOpenAuditStore = class {
|
|
|
6921
6960
|
};
|
|
6922
6961
|
|
|
6923
6962
|
// src/store_lattice/InMemoryTaskStore.ts
|
|
6924
|
-
var
|
|
6963
|
+
var import_protocols13 = require("@axiom-lattice/protocols");
|
|
6925
6964
|
var import_uuid = require("uuid");
|
|
6926
6965
|
function cloneTaskValue(value) {
|
|
6927
6966
|
if (value instanceof Date) return new Date(value);
|
|
@@ -7086,9 +7125,9 @@ var InMemoryTaskStore = class {
|
|
|
7086
7125
|
if (filter2.sourceId) results = results.filter((t) => t.sourceId === filter2.sourceId);
|
|
7087
7126
|
if (filter2.metadata) {
|
|
7088
7127
|
for (const [key6, value] of Object.entries(filter2.metadata)) {
|
|
7089
|
-
const expected = (0,
|
|
7128
|
+
const expected = (0, import_protocols13.normalizeTaskMetadataScalar)(value);
|
|
7090
7129
|
if (expected === void 0) continue;
|
|
7091
|
-
results = results.filter((task) => (0,
|
|
7130
|
+
results = results.filter((task) => (0, import_protocols13.normalizeTaskMetadataScalar)(task.metadata?.[key6]) === expected);
|
|
7092
7131
|
}
|
|
7093
7132
|
}
|
|
7094
7133
|
results.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime() || b.id.localeCompare(a.id));
|
|
@@ -7214,7 +7253,7 @@ var InMemoryTaskStore = class {
|
|
|
7214
7253
|
|
|
7215
7254
|
// src/store_lattice/InMemoryTaskWorkItemStore.ts
|
|
7216
7255
|
var import_uuid2 = require("uuid");
|
|
7217
|
-
var
|
|
7256
|
+
var import_protocols14 = require("@axiom-lattice/protocols");
|
|
7218
7257
|
var PROJECT_LIFECYCLE_ACTIONS = /* @__PURE__ */ new Set([
|
|
7219
7258
|
"in_progress",
|
|
7220
7259
|
"interrupted",
|
|
@@ -7344,15 +7383,15 @@ var InMemoryTaskWorkItemStore = class {
|
|
|
7344
7383
|
}
|
|
7345
7384
|
/** List a bounded newest-first view of unreconciled execution results. */
|
|
7346
7385
|
async listPendingExecutionResults(params) {
|
|
7347
|
-
if (!Number.isSafeInteger(params.limit) || params.limit < 0 || params.limit >
|
|
7348
|
-
const error = new RangeError(`limit must be a safe integer between 0 and ${
|
|
7386
|
+
if (!Number.isSafeInteger(params.limit) || params.limit < 0 || params.limit > import_protocols14.MAX_PENDING_EXECUTION_RESULTS_LIMIT) {
|
|
7387
|
+
const error = new RangeError(`limit must be a safe integer between 0 and ${import_protocols14.MAX_PENDING_EXECUTION_RESULTS_LIMIT}`);
|
|
7349
7388
|
error.code = "INVALID_LIMIT";
|
|
7350
7389
|
throw error;
|
|
7351
7390
|
}
|
|
7352
7391
|
if (params.limit === 0) return [];
|
|
7353
7392
|
const items = this.store.get(params.tenantId)?.get(params.taskId) ?? [];
|
|
7354
7393
|
const reconciled = new Set(items.filter((item) => item.action === "execution_reconciled").map((item) => item.detail?.executionResultId).filter((value) => typeof value === "string"));
|
|
7355
|
-
return items.filter((item) => item.action === "execution_result" && (0,
|
|
7394
|
+
return items.filter((item) => item.action === "execution_result" && (0, import_protocols14.isExecutionResultEventKey)(item.eventKey) && !reconciled.has(item.eventKey)).sort((left, right) => right.createdAt.getTime() - left.createdAt.getTime() || right.id.localeCompare(left.id)).slice(0, params.limit);
|
|
7356
7395
|
}
|
|
7357
7396
|
/** Lists canonical project lifecycle events with an exclusive cursor. */
|
|
7358
7397
|
async listProjectLifecycleEvents(query) {
|
|
@@ -7757,13 +7796,13 @@ ConnectionRegistry.store = null;
|
|
|
7757
7796
|
|
|
7758
7797
|
// src/schedule_lattice/ScheduleLatticeManager.ts
|
|
7759
7798
|
init_BaseLatticeManager();
|
|
7760
|
-
var
|
|
7799
|
+
var import_protocols17 = require("@axiom-lattice/protocols");
|
|
7761
7800
|
|
|
7762
7801
|
// src/schedule_lattice/DefaultScheduleClient.ts
|
|
7763
|
-
var
|
|
7802
|
+
var import_protocols16 = require("@axiom-lattice/protocols");
|
|
7764
7803
|
|
|
7765
7804
|
// src/schedule_lattice/MemoryScheduleStorage.ts
|
|
7766
|
-
var
|
|
7805
|
+
var import_protocols15 = require("@axiom-lattice/protocols");
|
|
7767
7806
|
var MemoryScheduleStorage = class {
|
|
7768
7807
|
constructor() {
|
|
7769
7808
|
this.tasks = /* @__PURE__ */ new Map();
|
|
@@ -7803,12 +7842,12 @@ var MemoryScheduleStorage = class {
|
|
|
7803
7842
|
*/
|
|
7804
7843
|
async claimScheduledRun(taskId) {
|
|
7805
7844
|
const task = this.tasks.get(taskId);
|
|
7806
|
-
if (!task || task.status !==
|
|
7845
|
+
if (!task || task.status !== import_protocols15.ScheduledTaskStatus.PENDING) {
|
|
7807
7846
|
return false;
|
|
7808
7847
|
}
|
|
7809
7848
|
this.tasks.set(taskId, {
|
|
7810
7849
|
...task,
|
|
7811
|
-
status:
|
|
7850
|
+
status: import_protocols15.ScheduledTaskStatus.RUNNING,
|
|
7812
7851
|
updatedAt: Date.now()
|
|
7813
7852
|
});
|
|
7814
7853
|
return true;
|
|
@@ -7825,10 +7864,10 @@ var MemoryScheduleStorage = class {
|
|
|
7825
7864
|
const cutoff = now - olderThanMs;
|
|
7826
7865
|
let requeued = 0;
|
|
7827
7866
|
for (const [taskId, task] of this.tasks.entries()) {
|
|
7828
|
-
if (task.status ===
|
|
7867
|
+
if (task.status === import_protocols15.ScheduledTaskStatus.RUNNING && task.updatedAt < cutoff) {
|
|
7829
7868
|
this.tasks.set(taskId, {
|
|
7830
7869
|
...task,
|
|
7831
|
-
status:
|
|
7870
|
+
status: import_protocols15.ScheduledTaskStatus.PENDING,
|
|
7832
7871
|
updatedAt: now
|
|
7833
7872
|
});
|
|
7834
7873
|
requeued++;
|
|
@@ -7848,7 +7887,7 @@ var MemoryScheduleStorage = class {
|
|
|
7848
7887
|
async getActiveTasks() {
|
|
7849
7888
|
const result = [];
|
|
7850
7889
|
for (const task of this.tasks.values()) {
|
|
7851
|
-
if (task.status ===
|
|
7890
|
+
if (task.status === import_protocols15.ScheduledTaskStatus.PENDING || task.status === import_protocols15.ScheduledTaskStatus.PAUSED) {
|
|
7852
7891
|
result.push({ ...task });
|
|
7853
7892
|
}
|
|
7854
7893
|
}
|
|
@@ -7991,7 +8030,7 @@ var MemoryScheduleStorage = class {
|
|
|
7991
8030
|
const cutoff = Date.now() - olderThanMs;
|
|
7992
8031
|
let deleted = 0;
|
|
7993
8032
|
for (const [taskId, task] of this.tasks.entries()) {
|
|
7994
|
-
if ((task.status ===
|
|
8033
|
+
if ((task.status === import_protocols15.ScheduledTaskStatus.COMPLETED || task.status === import_protocols15.ScheduledTaskStatus.CANCELLED || task.status === import_protocols15.ScheduledTaskStatus.FAILED) && task.updatedAt < cutoff) {
|
|
7995
8034
|
this.tasks.delete(taskId);
|
|
7996
8035
|
deleted++;
|
|
7997
8036
|
}
|
|
@@ -8382,10 +8421,10 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8382
8421
|
tenantId: options.tenantId ?? "default",
|
|
8383
8422
|
assistantId: options.assistantId,
|
|
8384
8423
|
threadId: options.threadId,
|
|
8385
|
-
executionType:
|
|
8424
|
+
executionType: import_protocols16.ScheduleExecutionType.ONCE,
|
|
8386
8425
|
executeAt,
|
|
8387
8426
|
delayMs: options.delayMs,
|
|
8388
|
-
status:
|
|
8427
|
+
status: import_protocols16.ScheduledTaskStatus.PENDING,
|
|
8389
8428
|
runCount: 0,
|
|
8390
8429
|
retryCount: 0,
|
|
8391
8430
|
maxRetries: options.maxRetries ?? 0,
|
|
@@ -8428,11 +8467,11 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8428
8467
|
tenantId: options.tenantId ?? "default",
|
|
8429
8468
|
assistantId: options.assistantId,
|
|
8430
8469
|
threadId: options.threadId,
|
|
8431
|
-
executionType:
|
|
8470
|
+
executionType: import_protocols16.ScheduleExecutionType.CRON,
|
|
8432
8471
|
cronExpression: options.cronExpression,
|
|
8433
8472
|
timezone: options.timezone,
|
|
8434
8473
|
nextRunAt: nextRunAt.getTime(),
|
|
8435
|
-
status:
|
|
8474
|
+
status: import_protocols16.ScheduledTaskStatus.PENDING,
|
|
8436
8475
|
runCount: 0,
|
|
8437
8476
|
maxRuns: options.maxRuns,
|
|
8438
8477
|
retryCount: 0,
|
|
@@ -8459,7 +8498,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8459
8498
|
const task = await this.storage.get(taskId);
|
|
8460
8499
|
if (task) {
|
|
8461
8500
|
await this.storage.update(taskId, {
|
|
8462
|
-
status:
|
|
8501
|
+
status: import_protocols16.ScheduledTaskStatus.CANCELLED
|
|
8463
8502
|
});
|
|
8464
8503
|
console.log(`[Scheduler] Task cancelled: ${taskId}`);
|
|
8465
8504
|
return true;
|
|
@@ -8468,11 +8507,11 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8468
8507
|
}
|
|
8469
8508
|
async pause(taskId) {
|
|
8470
8509
|
const task = await this.storage.get(taskId);
|
|
8471
|
-
if (!task || task.executionType !==
|
|
8510
|
+
if (!task || task.executionType !== import_protocols16.ScheduleExecutionType.CRON) {
|
|
8472
8511
|
console.error(`[Scheduler] Can only pause CRON tasks: ${taskId}`);
|
|
8473
8512
|
return false;
|
|
8474
8513
|
}
|
|
8475
|
-
if (task.status !==
|
|
8514
|
+
if (task.status !== import_protocols16.ScheduledTaskStatus.PENDING) {
|
|
8476
8515
|
console.error(`[Scheduler] Can only pause PENDING tasks: ${taskId}`);
|
|
8477
8516
|
return false;
|
|
8478
8517
|
}
|
|
@@ -8482,24 +8521,24 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8482
8521
|
this.timers.delete(taskId);
|
|
8483
8522
|
}
|
|
8484
8523
|
await this.storage.update(taskId, {
|
|
8485
|
-
status:
|
|
8524
|
+
status: import_protocols16.ScheduledTaskStatus.PAUSED
|
|
8486
8525
|
});
|
|
8487
8526
|
console.log(`[Scheduler] Task paused: ${taskId}`);
|
|
8488
8527
|
return true;
|
|
8489
8528
|
}
|
|
8490
8529
|
async resume(taskId) {
|
|
8491
8530
|
const task = await this.storage.get(taskId);
|
|
8492
|
-
if (!task || task.executionType !==
|
|
8531
|
+
if (!task || task.executionType !== import_protocols16.ScheduleExecutionType.CRON) {
|
|
8493
8532
|
console.error(`[Scheduler] Can only resume CRON tasks: ${taskId}`);
|
|
8494
8533
|
return false;
|
|
8495
8534
|
}
|
|
8496
|
-
if (task.status !==
|
|
8535
|
+
if (task.status !== import_protocols16.ScheduledTaskStatus.PAUSED) {
|
|
8497
8536
|
console.error(`[Scheduler] Can only resume PAUSED tasks: ${taskId}`);
|
|
8498
8537
|
return false;
|
|
8499
8538
|
}
|
|
8500
8539
|
const nextRunAt = getNextCronTime(task.cronExpression, /* @__PURE__ */ new Date(), task.timezone);
|
|
8501
8540
|
await this.storage.update(taskId, {
|
|
8502
|
-
status:
|
|
8541
|
+
status: import_protocols16.ScheduledTaskStatus.PENDING,
|
|
8503
8542
|
nextRunAt: nextRunAt.getTime()
|
|
8504
8543
|
});
|
|
8505
8544
|
const updatedTask = await this.storage.get(taskId);
|
|
@@ -8521,7 +8560,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8521
8560
|
if (!task) {
|
|
8522
8561
|
return -1;
|
|
8523
8562
|
}
|
|
8524
|
-
const targetTime = task.executionType ===
|
|
8563
|
+
const targetTime = task.executionType === import_protocols16.ScheduleExecutionType.CRON ? task.nextRunAt : task.executeAt;
|
|
8525
8564
|
if (targetTime === void 0) {
|
|
8526
8565
|
return -1;
|
|
8527
8566
|
}
|
|
@@ -8543,7 +8582,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8543
8582
|
const activeTasks = await this.storage.getActiveTasks();
|
|
8544
8583
|
for (const task of activeTasks) {
|
|
8545
8584
|
await this.storage.update(task.taskId, {
|
|
8546
|
-
status:
|
|
8585
|
+
status: import_protocols16.ScheduledTaskStatus.CANCELLED
|
|
8547
8586
|
});
|
|
8548
8587
|
}
|
|
8549
8588
|
console.log(`[Scheduler] All tasks cancelled`);
|
|
@@ -8600,7 +8639,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8600
8639
|
const activeById = new Map(activeTasks.map((task) => [task.taskId, task]));
|
|
8601
8640
|
for (const taskId of [...this.timers.keys()]) {
|
|
8602
8641
|
const task = activeById.get(taskId);
|
|
8603
|
-
if (!task || task.status ===
|
|
8642
|
+
if (!task || task.status === import_protocols16.ScheduledTaskStatus.PAUSED) {
|
|
8604
8643
|
this.clearTimer(taskId);
|
|
8605
8644
|
}
|
|
8606
8645
|
}
|
|
@@ -8613,18 +8652,18 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8613
8652
|
this.clearTimer(task.taskId);
|
|
8614
8653
|
continue;
|
|
8615
8654
|
}
|
|
8616
|
-
if (task.status ===
|
|
8655
|
+
if (task.status === import_protocols16.ScheduledTaskStatus.PAUSED) {
|
|
8617
8656
|
this.clearTimer(task.taskId);
|
|
8618
8657
|
continue;
|
|
8619
8658
|
}
|
|
8620
|
-
if (task.executionType ===
|
|
8659
|
+
if (task.executionType === import_protocols16.ScheduleExecutionType.ONCE) {
|
|
8621
8660
|
if (task.executeAt !== void 0 && task.executeAt <= Date.now()) {
|
|
8622
8661
|
this.clearTimer(task.taskId);
|
|
8623
8662
|
void this.executeTask(task);
|
|
8624
8663
|
} else if (task.executeAt !== void 0) {
|
|
8625
8664
|
this.scheduleTimer(task);
|
|
8626
8665
|
}
|
|
8627
|
-
} else if (task.executionType ===
|
|
8666
|
+
} else if (task.executionType === import_protocols16.ScheduleExecutionType.CRON) {
|
|
8628
8667
|
let nextRunAt = task.nextRunAt;
|
|
8629
8668
|
if (recomputeCronNextRun || nextRunAt === void 0) {
|
|
8630
8669
|
nextRunAt = getNextCronTime(task.cronExpression, /* @__PURE__ */ new Date(), task.timezone).getTime();
|
|
@@ -8658,7 +8697,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8658
8697
|
// ===== Private Methods =====
|
|
8659
8698
|
scheduleTimer(task) {
|
|
8660
8699
|
this.clearTimer(task.taskId);
|
|
8661
|
-
const targetTime = task.executionType ===
|
|
8700
|
+
const targetTime = task.executionType === import_protocols16.ScheduleExecutionType.CRON ? task.nextRunAt : task.executeAt;
|
|
8662
8701
|
if (targetTime === void 0) {
|
|
8663
8702
|
console.error(`[Scheduler] No execution time for task: ${task.taskId}`);
|
|
8664
8703
|
return;
|
|
@@ -8696,7 +8735,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8696
8735
|
`[Scheduler] No handler for task type: ${task.taskType}, task: ${task.taskId}`
|
|
8697
8736
|
);
|
|
8698
8737
|
await this.storage.update(task.taskId, {
|
|
8699
|
-
status:
|
|
8738
|
+
status: import_protocols16.ScheduledTaskStatus.FAILED,
|
|
8700
8739
|
lastError: `No handler registered for task type: ${task.taskType}`
|
|
8701
8740
|
});
|
|
8702
8741
|
return;
|
|
@@ -8710,7 +8749,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8710
8749
|
}
|
|
8711
8750
|
await handler(latestTask.payload, latestTask);
|
|
8712
8751
|
const afterRunTask = await this.storage.get(task.taskId);
|
|
8713
|
-
if (!afterRunTask || afterRunTask.status !==
|
|
8752
|
+
if (!afterRunTask || afterRunTask.status !== import_protocols16.ScheduledTaskStatus.RUNNING) {
|
|
8714
8753
|
this.timers.delete(task.taskId);
|
|
8715
8754
|
console.log(
|
|
8716
8755
|
`[Scheduler] Task ${task.taskId} was ${afterRunTask?.status ?? "removed"} during its run; skipping reschedule`
|
|
@@ -8719,17 +8758,17 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8719
8758
|
}
|
|
8720
8759
|
const newRunCount = afterRunTask.runCount + 1;
|
|
8721
8760
|
console.log(`[Scheduler] Task completed: ${task.taskId}`);
|
|
8722
|
-
if (task.executionType ===
|
|
8761
|
+
if (task.executionType === import_protocols16.ScheduleExecutionType.ONCE) {
|
|
8723
8762
|
await this.storage.update(task.taskId, {
|
|
8724
|
-
status:
|
|
8763
|
+
status: import_protocols16.ScheduledTaskStatus.COMPLETED,
|
|
8725
8764
|
runCount: newRunCount,
|
|
8726
8765
|
lastRunAt: Date.now()
|
|
8727
8766
|
});
|
|
8728
8767
|
this.timers.delete(task.taskId);
|
|
8729
|
-
} else if (task.executionType ===
|
|
8768
|
+
} else if (task.executionType === import_protocols16.ScheduleExecutionType.CRON) {
|
|
8730
8769
|
if (task.maxRuns !== void 0 && newRunCount >= task.maxRuns) {
|
|
8731
8770
|
await this.storage.update(task.taskId, {
|
|
8732
|
-
status:
|
|
8771
|
+
status: import_protocols16.ScheduledTaskStatus.COMPLETED,
|
|
8733
8772
|
runCount: newRunCount,
|
|
8734
8773
|
lastRunAt: Date.now()
|
|
8735
8774
|
});
|
|
@@ -8741,7 +8780,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8741
8780
|
}
|
|
8742
8781
|
if (task.expiresAt !== void 0 && Date.now() >= task.expiresAt) {
|
|
8743
8782
|
await this.storage.update(task.taskId, {
|
|
8744
|
-
status:
|
|
8783
|
+
status: import_protocols16.ScheduledTaskStatus.COMPLETED,
|
|
8745
8784
|
runCount: newRunCount,
|
|
8746
8785
|
lastRunAt: Date.now()
|
|
8747
8786
|
});
|
|
@@ -8753,7 +8792,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8753
8792
|
}
|
|
8754
8793
|
const nextRunAt = getNextCronTime(task.cronExpression, /* @__PURE__ */ new Date(), task.timezone);
|
|
8755
8794
|
await this.storage.update(task.taskId, {
|
|
8756
|
-
status:
|
|
8795
|
+
status: import_protocols16.ScheduledTaskStatus.PENDING,
|
|
8757
8796
|
runCount: newRunCount,
|
|
8758
8797
|
lastRunAt: Date.now(),
|
|
8759
8798
|
nextRunAt: nextRunAt.getTime(),
|
|
@@ -8772,7 +8811,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8772
8811
|
const errorMessage3 = error instanceof Error ? error.message : String(error);
|
|
8773
8812
|
console.error(`[Scheduler] Task failed: ${task.taskId}`, error);
|
|
8774
8813
|
const latestTask = await this.storage.get(task.taskId);
|
|
8775
|
-
if (!latestTask || latestTask.status !==
|
|
8814
|
+
if (!latestTask || latestTask.status !== import_protocols16.ScheduledTaskStatus.RUNNING) {
|
|
8776
8815
|
this.timers.delete(task.taskId);
|
|
8777
8816
|
return;
|
|
8778
8817
|
}
|
|
@@ -8782,7 +8821,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8782
8821
|
`[Scheduler] Retrying task: ${task.taskId} (attempt ${newRetryCount}/${latestTask.maxRetries})`
|
|
8783
8822
|
);
|
|
8784
8823
|
await this.storage.update(task.taskId, {
|
|
8785
|
-
status:
|
|
8824
|
+
status: import_protocols16.ScheduledTaskStatus.PENDING,
|
|
8786
8825
|
retryCount: newRetryCount,
|
|
8787
8826
|
lastError: errorMessage3
|
|
8788
8827
|
});
|
|
@@ -8792,7 +8831,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8792
8831
|
);
|
|
8793
8832
|
const retryTask = await this.storage.get(task.taskId);
|
|
8794
8833
|
if (retryTask) {
|
|
8795
|
-
if (task.executionType ===
|
|
8834
|
+
if (task.executionType === import_protocols16.ScheduleExecutionType.ONCE) {
|
|
8796
8835
|
retryTask.executeAt = Date.now() + retryDelay;
|
|
8797
8836
|
} else {
|
|
8798
8837
|
retryTask.nextRunAt = Date.now() + retryDelay;
|
|
@@ -8805,7 +8844,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
|
|
|
8805
8844
|
}
|
|
8806
8845
|
} else {
|
|
8807
8846
|
await this.storage.update(task.taskId, {
|
|
8808
|
-
status:
|
|
8847
|
+
status: import_protocols16.ScheduledTaskStatus.FAILED,
|
|
8809
8848
|
retryCount: newRetryCount,
|
|
8810
8849
|
lastError: errorMessage3
|
|
8811
8850
|
});
|
|
@@ -8857,9 +8896,9 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
|
|
|
8857
8896
|
} else {
|
|
8858
8897
|
storage = new MemoryScheduleStorage();
|
|
8859
8898
|
}
|
|
8860
|
-
if (config.type ===
|
|
8899
|
+
if (config.type === import_protocols17.ScheduleType.MEMORY) {
|
|
8861
8900
|
scheduleClient = new DefaultScheduleClient(storage);
|
|
8862
|
-
} else if (config.type ===
|
|
8901
|
+
} else if (config.type === import_protocols17.ScheduleType.POSTGRES) {
|
|
8863
8902
|
if (!config.storage) {
|
|
8864
8903
|
throw new Error(
|
|
8865
8904
|
`PostgreSQL schedule storage must be provided. Please install @axiom-lattice/pg-stores and pass the storage in config.storage.`
|
|
@@ -8992,7 +9031,7 @@ init_MemoryLatticeManager();
|
|
|
8992
9031
|
|
|
8993
9032
|
// src/vectorstore_lattice/VectorStoreProviderManager.ts
|
|
8994
9033
|
init_BaseLatticeManager();
|
|
8995
|
-
var
|
|
9034
|
+
var import_protocols21 = require("@axiom-lattice/protocols");
|
|
8996
9035
|
|
|
8997
9036
|
// src/collection_lattice/SimpleMemoryVectorStore.ts
|
|
8998
9037
|
var import_vectorstores = require("@langchain/core/vectorstores");
|
|
@@ -9097,7 +9136,7 @@ var SimpleMemoryVectorStore = class extends import_vectorstores.VectorStore {
|
|
|
9097
9136
|
|
|
9098
9137
|
// src/embeddings_lattice/EmbeddingsLatticeManager.ts
|
|
9099
9138
|
var import_openai2 = require("@langchain/openai");
|
|
9100
|
-
var
|
|
9139
|
+
var import_protocols20 = require("@axiom-lattice/protocols");
|
|
9101
9140
|
init_BaseLatticeManager();
|
|
9102
9141
|
|
|
9103
9142
|
// src/model_lattice/buildModelLlmConfig.ts
|
|
@@ -9249,11 +9288,11 @@ function buildModelConfig(provider2, model) {
|
|
|
9249
9288
|
}
|
|
9250
9289
|
|
|
9251
9290
|
// src/model_lattice/loadTenantModelRow.ts
|
|
9252
|
-
var
|
|
9291
|
+
var import_protocols19 = require("@axiom-lattice/protocols");
|
|
9253
9292
|
async function loadTenantModelRow(tenantId2, key6) {
|
|
9254
9293
|
try {
|
|
9255
9294
|
const { store: store2 } = getStoreLattice("default", "modelProvider");
|
|
9256
|
-
const parsed = (0,
|
|
9295
|
+
const parsed = (0, import_protocols19.parseModelKey)(key6);
|
|
9257
9296
|
if (!parsed) {
|
|
9258
9297
|
return void 0;
|
|
9259
9298
|
}
|
|
@@ -9490,7 +9529,7 @@ var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatti
|
|
|
9490
9529
|
* @param key `${providerId}/${modelId}`
|
|
9491
9530
|
*/
|
|
9492
9531
|
async loadItemFromStore(tenantId2, key6) {
|
|
9493
|
-
const row = key6 ===
|
|
9532
|
+
const row = key6 === import_protocols20.EMBEDDING_DEFAULT_KEY ? await loadTenantDefaultModelRow(tenantId2, "embedding") : await loadTenantModelRow(tenantId2, key6);
|
|
9494
9533
|
if (!row || row.model.kind !== "embedding") {
|
|
9495
9534
|
return void 0;
|
|
9496
9535
|
}
|
|
@@ -9640,13 +9679,13 @@ var getEmbeddingsClient = (key6) => embeddingsLatticeManager.getEmbeddingsClient
|
|
|
9640
9679
|
var MemoryVectorStoreProvider = class {
|
|
9641
9680
|
async create(params) {
|
|
9642
9681
|
const tenantId2 = params.tenantId ?? "default";
|
|
9643
|
-
const requestedKey = params.embeddingKey ||
|
|
9682
|
+
const requestedKey = params.embeddingKey || import_protocols21.EMBEDDING_DEFAULT_KEY;
|
|
9644
9683
|
const embeddings = await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
9645
9684
|
tenantId2,
|
|
9646
9685
|
requestedKey
|
|
9647
|
-
) ?? (requestedKey ===
|
|
9686
|
+
) ?? (requestedKey === import_protocols21.EMBEDDING_DEFAULT_KEY ? void 0 : await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
9648
9687
|
tenantId2,
|
|
9649
|
-
|
|
9688
|
+
import_protocols21.EMBEDDING_DEFAULT_KEY
|
|
9650
9689
|
)) ?? await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
9651
9690
|
tenantId2,
|
|
9652
9691
|
"default"
|
|
@@ -10728,6 +10767,63 @@ var InMemoryAgentRunStore = class {
|
|
|
10728
10767
|
(left, right) => right.record.createdAt - left.record.createdAt || right.sequence - left.sequence
|
|
10729
10768
|
).slice(offset, offset + limit).map(({ record }) => cloneRun(record));
|
|
10730
10769
|
}
|
|
10770
|
+
async listRunsByTenant(tenantId2, query = {}) {
|
|
10771
|
+
const limit = clampLimit(query.limit);
|
|
10772
|
+
const offset = Math.max(0, Math.floor(query.offset ?? 0));
|
|
10773
|
+
const createdAfter = query.createdAfter ? Date.parse(query.createdAfter) : void 0;
|
|
10774
|
+
const matches = [...this.runs.values()].filter(({ record }) => {
|
|
10775
|
+
if (record.tenantId !== tenantId2) return false;
|
|
10776
|
+
if (query.status && record.status !== query.status) return false;
|
|
10777
|
+
if (query.source && (record.source ?? "legacy") !== query.source) {
|
|
10778
|
+
return false;
|
|
10779
|
+
}
|
|
10780
|
+
if (query.assistantId && record.assistantId !== query.assistantId) {
|
|
10781
|
+
return false;
|
|
10782
|
+
}
|
|
10783
|
+
if (createdAfter !== void 0 && Number.isFinite(createdAfter) && record.createdAt < createdAfter) {
|
|
10784
|
+
return false;
|
|
10785
|
+
}
|
|
10786
|
+
return true;
|
|
10787
|
+
}).sort(
|
|
10788
|
+
(left, right) => right.record.createdAt - left.record.createdAt || right.sequence - left.sequence
|
|
10789
|
+
);
|
|
10790
|
+
return {
|
|
10791
|
+
records: matches.slice(offset, offset + limit).map(({ record }) => cloneRun(record)),
|
|
10792
|
+
total: matches.length
|
|
10793
|
+
};
|
|
10794
|
+
}
|
|
10795
|
+
async summaryByTenant(tenantId2, options = {}) {
|
|
10796
|
+
const now = this.now();
|
|
10797
|
+
const since = options.since ? Date.parse(options.since) : now - 24 * 60 * 60 * 1e3;
|
|
10798
|
+
const counts = emptyCounts();
|
|
10799
|
+
let oldestPending = null;
|
|
10800
|
+
let stuckRunning = 0;
|
|
10801
|
+
for (const { record } of this.runs.values()) {
|
|
10802
|
+
if (record.tenantId !== tenantId2) continue;
|
|
10803
|
+
if (record.status === "pending") {
|
|
10804
|
+
counts.pending += 1;
|
|
10805
|
+
if (oldestPending === null || record.createdAt < oldestPending) {
|
|
10806
|
+
oldestPending = record.createdAt;
|
|
10807
|
+
}
|
|
10808
|
+
continue;
|
|
10809
|
+
}
|
|
10810
|
+
if (record.status === "running") {
|
|
10811
|
+
counts.running += 1;
|
|
10812
|
+
if (record.leaseExpiresAt !== null && record.leaseExpiresAt < now) {
|
|
10813
|
+
stuckRunning += 1;
|
|
10814
|
+
}
|
|
10815
|
+
continue;
|
|
10816
|
+
}
|
|
10817
|
+
if (record.createdAt >= since) {
|
|
10818
|
+
counts[record.status] += 1;
|
|
10819
|
+
}
|
|
10820
|
+
}
|
|
10821
|
+
return {
|
|
10822
|
+
counts,
|
|
10823
|
+
oldestPendingAgeMs: oldestPending === null ? null : Math.max(0, now - oldestPending),
|
|
10824
|
+
stuckRunning
|
|
10825
|
+
};
|
|
10826
|
+
}
|
|
10731
10827
|
/** Finds the thread's running run, if any. */
|
|
10732
10828
|
async findRunning(tenantId2, threadId) {
|
|
10733
10829
|
for (const entry of this.runs.values()) {
|
|
@@ -10996,6 +11092,17 @@ function clampLimit(limit) {
|
|
|
10996
11092
|
if (!Number.isFinite(floored)) return DEFAULT_LIST_LIMIT;
|
|
10997
11093
|
return Math.min(MAX_LIST_LIMIT, Math.max(1, floored));
|
|
10998
11094
|
}
|
|
11095
|
+
function emptyCounts() {
|
|
11096
|
+
return {
|
|
11097
|
+
pending: 0,
|
|
11098
|
+
running: 0,
|
|
11099
|
+
success: 0,
|
|
11100
|
+
error: 0,
|
|
11101
|
+
interrupted: 0,
|
|
11102
|
+
cancelled: 0,
|
|
11103
|
+
timeout: 0
|
|
11104
|
+
};
|
|
11105
|
+
}
|
|
10999
11106
|
function terminalTimestamp(record) {
|
|
11000
11107
|
return record.finishedAt ?? record.updatedAt ?? record.createdAt;
|
|
11001
11108
|
}
|
|
@@ -11016,7 +11123,7 @@ function cloneJson(value) {
|
|
|
11016
11123
|
}
|
|
11017
11124
|
|
|
11018
11125
|
// src/store_lattice/InMemoryChannelReplyJobStore.ts
|
|
11019
|
-
var
|
|
11126
|
+
var import_protocols22 = require("@axiom-lattice/protocols");
|
|
11020
11127
|
var InMemoryChannelReplyJobStore = class {
|
|
11021
11128
|
/** @param now Clock override (epoch ms) used by deterministic tests. */
|
|
11022
11129
|
constructor(now = Date.now) {
|
|
@@ -11025,7 +11132,7 @@ var InMemoryChannelReplyJobStore = class {
|
|
|
11025
11132
|
}
|
|
11026
11133
|
/** Creates a pending job. Duplicate run ids are rejected. */
|
|
11027
11134
|
async create(input) {
|
|
11028
|
-
(0,
|
|
11135
|
+
(0, import_protocols22.assertValidCreateChannelReplyJobInput)(input);
|
|
11029
11136
|
const key6 = this.key(input.tenantId, input.runId);
|
|
11030
11137
|
if (this.jobs.has(key6)) {
|
|
11031
11138
|
throw new Error(`ChannelReplyJob ${input.runId} already exists`);
|
|
@@ -11061,10 +11168,10 @@ var InMemoryChannelReplyJobStore = class {
|
|
|
11061
11168
|
return job ? this.copy(job) : null;
|
|
11062
11169
|
}
|
|
11063
11170
|
/** Lists claimable pending jobs that are due at `now`, oldest first. */
|
|
11064
|
-
async listPending(now, limit =
|
|
11171
|
+
async listPending(now, limit = import_protocols22.CHANNEL_REPLY_JOB_LIST_LIMIT_DEFAULT) {
|
|
11065
11172
|
return [...this.jobs.values()].filter((job) => this.isClaimable(job, now)).sort(
|
|
11066
11173
|
(a, b) => a.availableAt - b.availableAt || a.createdAt - b.createdAt || a.runId.localeCompare(b.runId)
|
|
11067
|
-
).slice(0, (0,
|
|
11174
|
+
).slice(0, (0, import_protocols22.normalizeChannelReplyJobListLimit)(limit)).map((job) => this.copy(job));
|
|
11068
11175
|
}
|
|
11069
11176
|
/** Atomically leases a claimable job. */
|
|
11070
11177
|
async claim(tenantId2, runId, owner3, leaseMs, now = this.now()) {
|
|
@@ -11116,8 +11223,8 @@ var InMemoryChannelReplyJobStore = class {
|
|
|
11116
11223
|
return this.jobs.delete(this.key(tenantId2, runId));
|
|
11117
11224
|
}
|
|
11118
11225
|
/** Deletes terminal jobs whose last update is older than `before`. */
|
|
11119
|
-
async deleteTerminalBefore(before, limit =
|
|
11120
|
-
const batch = Math.max(1, (0,
|
|
11226
|
+
async deleteTerminalBefore(before, limit = import_protocols22.CHANNEL_REPLY_JOB_LIST_LIMIT_DEFAULT) {
|
|
11227
|
+
const batch = Math.max(1, (0, import_protocols22.normalizeChannelReplyJobListLimit)(limit));
|
|
11121
11228
|
const candidates = [...this.jobs.values()].filter(
|
|
11122
11229
|
(job) => (job.status === "delivered" || job.status === "failed") && job.updatedAt < before
|
|
11123
11230
|
).sort((a, b) => a.updatedAt - b.updatedAt || a.runId.localeCompare(b.runId)).slice(0, batch);
|
|
@@ -11147,11 +11254,62 @@ var InMemoryChannelReplyJobStore = class {
|
|
|
11147
11254
|
}
|
|
11148
11255
|
};
|
|
11149
11256
|
|
|
11257
|
+
// src/store_lattice/InMemorySessionStore.ts
|
|
11258
|
+
var InMemorySessionStore = class {
|
|
11259
|
+
constructor() {
|
|
11260
|
+
this.byId = /* @__PURE__ */ new Map();
|
|
11261
|
+
this.byHash = /* @__PURE__ */ new Map();
|
|
11262
|
+
}
|
|
11263
|
+
async create(record) {
|
|
11264
|
+
this.byId.set(record.id, { ...record });
|
|
11265
|
+
this.byHash.set(record.refreshTokenHash, record.id);
|
|
11266
|
+
}
|
|
11267
|
+
async findByRefreshTokenHash(hash) {
|
|
11268
|
+
const id = this.byHash.get(hash);
|
|
11269
|
+
return id ? { ...this.byId.get(id) } : null;
|
|
11270
|
+
}
|
|
11271
|
+
async findByFamilyId(familyId) {
|
|
11272
|
+
const rows = [...this.byId.values()].filter((row) => row.familyId === familyId);
|
|
11273
|
+
const active = rows.filter((row) => !row.replacedBy && !row.revokedAt);
|
|
11274
|
+
const pool = active.length > 0 ? active : rows;
|
|
11275
|
+
pool.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
11276
|
+
return pool[0] ? { ...pool[0] } : null;
|
|
11277
|
+
}
|
|
11278
|
+
async rotate(oldId, next) {
|
|
11279
|
+
const old = this.byId.get(oldId);
|
|
11280
|
+
if (!old) return;
|
|
11281
|
+
old.replacedBy = next.id;
|
|
11282
|
+
old.lastUsedAt = next.createdAt;
|
|
11283
|
+
this.byId.set(oldId, old);
|
|
11284
|
+
await this.create(next);
|
|
11285
|
+
}
|
|
11286
|
+
async revokeFamily(familyId, _reason) {
|
|
11287
|
+
const now = /* @__PURE__ */ new Date();
|
|
11288
|
+
for (const row of this.byId.values()) {
|
|
11289
|
+
if (row.familyId === familyId && !row.revokedAt) row.revokedAt = now;
|
|
11290
|
+
}
|
|
11291
|
+
}
|
|
11292
|
+
async revokeAllForUser(userId, _reason) {
|
|
11293
|
+
const now = /* @__PURE__ */ new Date();
|
|
11294
|
+
for (const row of this.byId.values()) {
|
|
11295
|
+
if (row.userId === userId && !row.revokedAt) row.revokedAt = now;
|
|
11296
|
+
}
|
|
11297
|
+
}
|
|
11298
|
+
async touch(id, lastUsedAt) {
|
|
11299
|
+
const row = this.byId.get(id);
|
|
11300
|
+
if (row) row.lastUsedAt = lastUsedAt;
|
|
11301
|
+
}
|
|
11302
|
+
async listForUser(userId) {
|
|
11303
|
+
return [...this.byId.values()].filter((row) => row.userId === userId).map((row) => ({ ...row }));
|
|
11304
|
+
}
|
|
11305
|
+
};
|
|
11306
|
+
|
|
11150
11307
|
// src/store_lattice/configureStores.ts
|
|
11151
11308
|
var _disposables = [];
|
|
11152
11309
|
var _cleanupRegistered = false;
|
|
11153
11310
|
var _inMemoryAgentRunWarningEmitted = false;
|
|
11154
11311
|
var _inMemoryChannelReplyJobWarningEmitted = false;
|
|
11312
|
+
var _inMemorySessionWarningEmitted = false;
|
|
11155
11313
|
function registerSignalCleanup() {
|
|
11156
11314
|
if (_cleanupRegistered) return;
|
|
11157
11315
|
_cleanupRegistered = true;
|
|
@@ -11211,6 +11369,20 @@ async function configureStores(stores, options = {}) {
|
|
|
11211
11369
|
}
|
|
11212
11370
|
storeLatticeManager.registerLattice("default", "channelReplyJob", channelReplyJob);
|
|
11213
11371
|
}
|
|
11372
|
+
if (stores.session === void 0 && options.customStores?.session === void 0) {
|
|
11373
|
+
if (!_inMemorySessionWarningEmitted) {
|
|
11374
|
+
_inMemorySessionWarningEmitted = true;
|
|
11375
|
+
console.warn(
|
|
11376
|
+
"[configureStores] session is using InMemorySessionStore: sessions are non-durable and lost on restart. Configure a PostgreSQL session store for production."
|
|
11377
|
+
);
|
|
11378
|
+
}
|
|
11379
|
+
const session = new InMemorySessionStore();
|
|
11380
|
+
await initAndRegister(session, localDisposables);
|
|
11381
|
+
if (storeLatticeManager.hasLattice("default", "session")) {
|
|
11382
|
+
storeLatticeManager.removeLattice("default", "session");
|
|
11383
|
+
}
|
|
11384
|
+
storeLatticeManager.registerLattice("default", "session", session);
|
|
11385
|
+
}
|
|
11214
11386
|
if (storeLatticeManager.hasLattice("default", "connection")) {
|
|
11215
11387
|
const connectionStore = storeLatticeManager.getStoreLattice("default", "connection").store;
|
|
11216
11388
|
ConnectionRegistry.setStore(connectionStore);
|
|
@@ -15981,7 +16153,7 @@ var ModelLatticeManager = class _ModelLatticeManager extends BaseLatticeManager
|
|
|
15981
16153
|
* @param key Lattice键名(`${providerId}/${modelId}`)
|
|
15982
16154
|
*/
|
|
15983
16155
|
async loadItemFromStore(tenantId2, key6) {
|
|
15984
|
-
if (key6 ===
|
|
16156
|
+
if (key6 === import_protocols23.DEFAULT_MODEL_KEY) {
|
|
15985
16157
|
try {
|
|
15986
16158
|
const { store: store2 } = getStoreLattice("default", "modelProvider");
|
|
15987
16159
|
return await this.loadTenantDefault(store2, tenantId2);
|
|
@@ -16046,7 +16218,7 @@ var ModelLatticeManager = class _ModelLatticeManager extends BaseLatticeManager
|
|
|
16046
16218
|
}
|
|
16047
16219
|
this.tenantDefaultMissAt.delete(tenantId2);
|
|
16048
16220
|
return {
|
|
16049
|
-
key:
|
|
16221
|
+
key: import_protocols23.DEFAULT_MODEL_KEY,
|
|
16050
16222
|
client: new ModelLattice(buildModelLlmConfig(provider2, marked))
|
|
16051
16223
|
};
|
|
16052
16224
|
}
|
|
@@ -16103,7 +16275,7 @@ var ModelLatticeManager = class _ModelLatticeManager extends BaseLatticeManager
|
|
|
16103
16275
|
}
|
|
16104
16276
|
}
|
|
16105
16277
|
}
|
|
16106
|
-
this.removeWithTenant(tenantId2,
|
|
16278
|
+
this.removeWithTenant(tenantId2, import_protocols23.DEFAULT_MODEL_KEY);
|
|
16107
16279
|
this.forgetTenantDefaultMiss(tenantId2);
|
|
16108
16280
|
}
|
|
16109
16281
|
};
|
|
@@ -16113,10 +16285,10 @@ var registerModelLatticeForTenant = (tenantId2, key6, config) => modelLatticeMan
|
|
|
16113
16285
|
var getModelLattice = (key6) => modelLatticeManager.getModelLattice(key6);
|
|
16114
16286
|
|
|
16115
16287
|
// src/model_lattice/resolveModelLattice.ts
|
|
16116
|
-
var
|
|
16288
|
+
var import_protocols24 = require("@axiom-lattice/protocols");
|
|
16117
16289
|
var DEPLOYMENT_MODEL_TENANT_ID = "default";
|
|
16118
16290
|
function mayUsePlatformCatalog(tenantId2) {
|
|
16119
|
-
return tenantId2 !==
|
|
16291
|
+
return tenantId2 !== import_protocols24.PLATFORM_MODEL_TENANT_ID && tenantId2 !== DEPLOYMENT_MODEL_TENANT_ID;
|
|
16120
16292
|
}
|
|
16121
16293
|
async function resolveModelLatticeForTenant(tenantId2, modelKey) {
|
|
16122
16294
|
const own = await modelLatticeManager.getModelLatticeOrLoad(
|
|
@@ -16131,13 +16303,13 @@ async function resolveModelLatticeForTenant(tenantId2, modelKey) {
|
|
|
16131
16303
|
}
|
|
16132
16304
|
if (mayUsePlatformCatalog(tenantId2)) {
|
|
16133
16305
|
const platform = await modelLatticeManager.getModelLatticeOrLoad(
|
|
16134
|
-
|
|
16306
|
+
import_protocols24.PLATFORM_MODEL_TENANT_ID,
|
|
16135
16307
|
modelKey
|
|
16136
16308
|
);
|
|
16137
16309
|
if (platform) {
|
|
16138
16310
|
return platform;
|
|
16139
16311
|
}
|
|
16140
|
-
if (await tenantHasOwnModelSupply(
|
|
16312
|
+
if (await tenantHasOwnModelSupply(import_protocols24.PLATFORM_MODEL_TENANT_ID)) {
|
|
16141
16313
|
return void 0;
|
|
16142
16314
|
}
|
|
16143
16315
|
}
|
|
@@ -16155,12 +16327,12 @@ async function hasModelLatticeForTenant(tenantId2, modelKey) {
|
|
|
16155
16327
|
}
|
|
16156
16328
|
if (mayUsePlatformCatalog(tenantId2)) {
|
|
16157
16329
|
if (await modelLatticeManager.hasModelLatticeOrLoad(
|
|
16158
|
-
|
|
16330
|
+
import_protocols24.PLATFORM_MODEL_TENANT_ID,
|
|
16159
16331
|
modelKey
|
|
16160
16332
|
)) {
|
|
16161
16333
|
return true;
|
|
16162
16334
|
}
|
|
16163
|
-
if (await tenantHasOwnModelSupply(
|
|
16335
|
+
if (await tenantHasOwnModelSupply(import_protocols24.PLATFORM_MODEL_TENANT_ID)) {
|
|
16164
16336
|
return false;
|
|
16165
16337
|
}
|
|
16166
16338
|
}
|
|
@@ -16177,10 +16349,10 @@ function hasModelLatticeForTenantSync(tenantId2, modelKey) {
|
|
|
16177
16349
|
return false;
|
|
16178
16350
|
}
|
|
16179
16351
|
if (mayUsePlatformCatalog(tenantId2)) {
|
|
16180
|
-
if (modelLatticeManager.hasLatticeWithTenant(
|
|
16352
|
+
if (modelLatticeManager.hasLatticeWithTenant(import_protocols24.PLATFORM_MODEL_TENANT_ID, modelKey)) {
|
|
16181
16353
|
return true;
|
|
16182
16354
|
}
|
|
16183
|
-
if (tenantHasOwnModelSupplySync(
|
|
16355
|
+
if (tenantHasOwnModelSupplySync(import_protocols24.PLATFORM_MODEL_TENANT_ID)) {
|
|
16184
16356
|
return false;
|
|
16185
16357
|
}
|
|
16186
16358
|
}
|
|
@@ -16194,11 +16366,11 @@ function listModelLatticesForTenant(tenantId2) {
|
|
|
16194
16366
|
const showFallbacks = !tenantHasOwnModelSupplySync(tenantId2) && tenantId2 !== DEPLOYMENT_MODEL_TENANT_ID;
|
|
16195
16367
|
if (showFallbacks) {
|
|
16196
16368
|
for (const lattice of modelLatticeManager.getAllLatticesByTenant(
|
|
16197
|
-
|
|
16369
|
+
import_protocols24.PLATFORM_MODEL_TENANT_ID
|
|
16198
16370
|
)) {
|
|
16199
16371
|
byKey.set(lattice.key, lattice);
|
|
16200
16372
|
}
|
|
16201
|
-
if (!tenantHasOwnModelSupplySync(
|
|
16373
|
+
if (!tenantHasOwnModelSupplySync(import_protocols24.PLATFORM_MODEL_TENANT_ID)) {
|
|
16202
16374
|
for (const lattice of modelLatticeManager.getAllLatticesByTenant(
|
|
16203
16375
|
DEPLOYMENT_MODEL_TENANT_ID
|
|
16204
16376
|
)) {
|
|
@@ -16682,6 +16854,7 @@ function getBindingRegistry() {
|
|
|
16682
16854
|
}
|
|
16683
16855
|
|
|
16684
16856
|
// src/tool_lattice/manage_binding/index.ts
|
|
16857
|
+
var import_protocols25 = require("@axiom-lattice/protocols");
|
|
16685
16858
|
function getInstallationStore() {
|
|
16686
16859
|
return getStoreLattice("default", "channelInstallation").store;
|
|
16687
16860
|
}
|
|
@@ -16718,6 +16891,8 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16718
16891
|
const tenantId2 = getTenantId(config);
|
|
16719
16892
|
if (!tenantId2) return failure("manage_binding requires tenant execution context");
|
|
16720
16893
|
if (input.channel === "room") return failure("Internal room bindings cannot be managed");
|
|
16894
|
+
const personalAssistantId = await resolvePersonalAssistantId(tenantId2, config);
|
|
16895
|
+
const personalInstallationIds = personalAssistantId ? await listPersonalInstallationIds(registry4, tenantId2, personalAssistantId) : null;
|
|
16721
16896
|
switch (input.action) {
|
|
16722
16897
|
case "list_installations": {
|
|
16723
16898
|
const store2 = getInstallationStore();
|
|
@@ -16725,27 +16900,42 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16725
16900
|
tenantId2,
|
|
16726
16901
|
input.channel
|
|
16727
16902
|
);
|
|
16728
|
-
return JSON.stringify({
|
|
16903
|
+
return JSON.stringify({
|
|
16904
|
+
success: true,
|
|
16905
|
+
data: installations.filter(isPublicInstallation).filter((installation) => !personalInstallationIds || personalInstallationIds.has(installation.id)).map(import_protocols25.maskChannelInstallationSecrets)
|
|
16906
|
+
});
|
|
16729
16907
|
}
|
|
16730
16908
|
case "create": {
|
|
16731
|
-
if (!input.channel || !input.senderId
|
|
16909
|
+
if (!input.channel || !input.senderId) {
|
|
16910
|
+
return JSON.stringify({ success: false, error: "create requires channel, senderId, and agentId" });
|
|
16911
|
+
}
|
|
16912
|
+
if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
|
|
16913
|
+
return failure("A personal assistant can only bind senders to itself");
|
|
16914
|
+
}
|
|
16915
|
+
const agentId = personalAssistantId ?? input.agentId;
|
|
16916
|
+
if (!agentId) {
|
|
16732
16917
|
return JSON.stringify({ success: false, error: "create requires channel, senderId, and agentId" });
|
|
16733
16918
|
}
|
|
16734
|
-
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2);
|
|
16919
|
+
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
|
|
16735
16920
|
if (!installId) {
|
|
16736
16921
|
return JSON.stringify({
|
|
16737
16922
|
success: false,
|
|
16738
16923
|
error: `No channelInstallationId provided and unable to auto-detect. Use action=list_installations to find available installations for channel "${input.channel}".`
|
|
16739
16924
|
});
|
|
16740
16925
|
}
|
|
16741
|
-
const validation = await validatePublicInstallation(
|
|
16926
|
+
const validation = await validatePublicInstallation(
|
|
16927
|
+
installId,
|
|
16928
|
+
tenantId2,
|
|
16929
|
+
input.channel,
|
|
16930
|
+
personalInstallationIds
|
|
16931
|
+
);
|
|
16742
16932
|
if (validation) return failure(validation);
|
|
16743
16933
|
const binding = await registry4.create({
|
|
16744
16934
|
channel: input.channel,
|
|
16745
16935
|
channelInstallationId: installId,
|
|
16746
16936
|
tenantId: tenantId2,
|
|
16747
16937
|
senderId: input.senderId,
|
|
16748
|
-
agentId
|
|
16938
|
+
agentId,
|
|
16749
16939
|
threadMode: input.threadMode,
|
|
16750
16940
|
senderDisplayName: input.senderDisplayName
|
|
16751
16941
|
});
|
|
@@ -16755,14 +16945,22 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16755
16945
|
if (!input.channel || !input.senderId) {
|
|
16756
16946
|
return JSON.stringify({ success: false, error: "update requires channel and senderId" });
|
|
16757
16947
|
}
|
|
16758
|
-
|
|
16948
|
+
if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
|
|
16949
|
+
return failure("A personal assistant can only bind senders to itself");
|
|
16950
|
+
}
|
|
16951
|
+
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
|
|
16759
16952
|
if (!installId) {
|
|
16760
16953
|
return JSON.stringify({
|
|
16761
16954
|
success: false,
|
|
16762
16955
|
error: `No channelInstallationId provided and unable to auto-detect. Use action=list_installations first.`
|
|
16763
16956
|
});
|
|
16764
16957
|
}
|
|
16765
|
-
const validation = await validatePublicInstallation(
|
|
16958
|
+
const validation = await validatePublicInstallation(
|
|
16959
|
+
installId,
|
|
16960
|
+
tenantId2,
|
|
16961
|
+
input.channel,
|
|
16962
|
+
personalInstallationIds
|
|
16963
|
+
);
|
|
16766
16964
|
if (validation) return failure(validation);
|
|
16767
16965
|
const existing = await registry4.findBySubject({
|
|
16768
16966
|
channel: input.channel,
|
|
@@ -16776,8 +16974,11 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16776
16974
|
if (existing.channel === "room") {
|
|
16777
16975
|
return failure("Internal room bindings cannot be managed");
|
|
16778
16976
|
}
|
|
16977
|
+
if (personalAssistantId && existing.agentId !== personalAssistantId) {
|
|
16978
|
+
return JSON.stringify({ success: false, error: "Binding not found" });
|
|
16979
|
+
}
|
|
16779
16980
|
const updated = await registry4.update(tenantId2, existing.id, {
|
|
16780
|
-
agentId: input.agentId,
|
|
16981
|
+
agentId: personalAssistantId ?? input.agentId,
|
|
16781
16982
|
threadMode: input.threadMode,
|
|
16782
16983
|
senderDisplayName: input.senderDisplayName
|
|
16783
16984
|
});
|
|
@@ -16787,14 +16988,19 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16787
16988
|
if (!input.channel || !input.senderId) {
|
|
16788
16989
|
return JSON.stringify({ success: false, error: "delete requires channel and senderId" });
|
|
16789
16990
|
}
|
|
16790
|
-
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2);
|
|
16991
|
+
const installId = input.channelInstallationId || await resolveInstallationId(input.channel, tenantId2, personalInstallationIds);
|
|
16791
16992
|
if (!installId) {
|
|
16792
16993
|
return JSON.stringify({
|
|
16793
16994
|
success: false,
|
|
16794
16995
|
error: `No channelInstallationId provided and unable to auto-detect.`
|
|
16795
16996
|
});
|
|
16796
16997
|
}
|
|
16797
|
-
const validation = await validatePublicInstallation(
|
|
16998
|
+
const validation = await validatePublicInstallation(
|
|
16999
|
+
installId,
|
|
17000
|
+
tenantId2,
|
|
17001
|
+
input.channel,
|
|
17002
|
+
personalInstallationIds
|
|
17003
|
+
);
|
|
16798
17004
|
if (validation) return failure(validation);
|
|
16799
17005
|
const existing = await registry4.findBySubject({
|
|
16800
17006
|
channel: input.channel,
|
|
@@ -16808,17 +17014,25 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16808
17014
|
if (existing.channel === "room") {
|
|
16809
17015
|
return failure("Internal room bindings cannot be managed");
|
|
16810
17016
|
}
|
|
17017
|
+
if (personalAssistantId && existing.agentId !== personalAssistantId) {
|
|
17018
|
+
return JSON.stringify({ success: false, error: "Binding not found" });
|
|
17019
|
+
}
|
|
16811
17020
|
await registry4.delete(tenantId2, existing.id);
|
|
16812
17021
|
return JSON.stringify({ success: true, message: "Binding deleted" });
|
|
16813
17022
|
}
|
|
16814
17023
|
case "list": {
|
|
16815
|
-
|
|
17024
|
+
if (personalAssistantId && input.agentId && input.agentId !== personalAssistantId) {
|
|
17025
|
+
return failure("A personal assistant can only list its own bindings");
|
|
17026
|
+
}
|
|
17027
|
+
const listed = await registry4.list({
|
|
16816
17028
|
channel: input.channel,
|
|
16817
|
-
agentId: input.agentId,
|
|
17029
|
+
agentId: personalAssistantId ?? input.agentId,
|
|
16818
17030
|
tenantId: tenantId2,
|
|
16819
17031
|
channelInstallationId: input.channelInstallationId,
|
|
16820
|
-
excludeChannels: ["room"]
|
|
17032
|
+
excludeChannels: ["room"],
|
|
17033
|
+
...personalAssistantId ? { limit: 500 } : {}
|
|
16821
17034
|
});
|
|
17035
|
+
const bindings = personalInstallationIds ? listed.filter((binding) => personalInstallationIds.has(binding.channelInstallationId)) : listed;
|
|
16822
17036
|
return JSON.stringify({ success: true, data: bindings });
|
|
16823
17037
|
}
|
|
16824
17038
|
default:
|
|
@@ -16826,33 +17040,83 @@ A sender can only be bound to ONE agent per channel+installation combination.`,
|
|
|
16826
17040
|
}
|
|
16827
17041
|
}
|
|
16828
17042
|
);
|
|
16829
|
-
async function resolveInstallationId(channel, tenantId2) {
|
|
17043
|
+
async function resolveInstallationId(channel, tenantId2, allowedIds) {
|
|
16830
17044
|
const store2 = getInstallationStore();
|
|
16831
17045
|
const installations = await store2.getInstallationsByTenant(tenantId2, channel);
|
|
16832
|
-
const publicInstallations = installations.filter(isPublicInstallation);
|
|
17046
|
+
const publicInstallations = installations.filter(isPublicInstallation).filter((installation) => !allowedIds || allowedIds.has(installation.id));
|
|
16833
17047
|
if (publicInstallations.length === 1) {
|
|
16834
17048
|
return publicInstallations[0].id;
|
|
16835
17049
|
}
|
|
16836
17050
|
return null;
|
|
16837
17051
|
}
|
|
16838
|
-
function
|
|
17052
|
+
function getRunConfig(config) {
|
|
16839
17053
|
if (typeof config !== "object" || config === null) return null;
|
|
16840
17054
|
const configurable = config.configurable;
|
|
16841
17055
|
if (typeof configurable !== "object" || configurable === null) return null;
|
|
16842
17056
|
const runConfig = configurable.runConfig;
|
|
16843
17057
|
if (typeof runConfig !== "object" || runConfig === null) return null;
|
|
16844
|
-
|
|
16845
|
-
|
|
17058
|
+
return runConfig;
|
|
17059
|
+
}
|
|
17060
|
+
function getString(record, key6) {
|
|
17061
|
+
const value = record?.[key6];
|
|
17062
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
17063
|
+
}
|
|
17064
|
+
function getTenantId(config) {
|
|
17065
|
+
return getString(getRunConfig(config), "tenantId");
|
|
17066
|
+
}
|
|
17067
|
+
async function resolvePersonalAssistantId(tenantId2, config) {
|
|
17068
|
+
const runConfig = getRunConfig(config);
|
|
17069
|
+
const assistantId = getString(runConfig, "assistant_id") ?? getString(runConfig, "assistantId");
|
|
17070
|
+
if (!assistantId) return null;
|
|
17071
|
+
try {
|
|
17072
|
+
const assistant = await getStoreLattice("default", "assistant").store.getAssistantById(tenantId2, assistantId);
|
|
17073
|
+
return assistant?.ownerUserId ? assistantId : null;
|
|
17074
|
+
} catch {
|
|
17075
|
+
return null;
|
|
17076
|
+
}
|
|
16846
17077
|
}
|
|
16847
17078
|
function isPublicInstallation(installation) {
|
|
16848
17079
|
return installation.channel !== "room";
|
|
16849
17080
|
}
|
|
16850
|
-
|
|
17081
|
+
function installationReferencesAssistant(installation, assistantId) {
|
|
17082
|
+
if (installation.fallbackAgentId === assistantId) return true;
|
|
17083
|
+
const config = installation.config;
|
|
17084
|
+
return Boolean(
|
|
17085
|
+
config && typeof config === "object" && !Array.isArray(config) && config.assistantId === assistantId
|
|
17086
|
+
);
|
|
17087
|
+
}
|
|
17088
|
+
async function listPersonalInstallationIds(registry4, tenantId2, assistantId) {
|
|
17089
|
+
const ids = /* @__PURE__ */ new Set();
|
|
17090
|
+
const installations = await getInstallationStore().getInstallationsByTenant(tenantId2);
|
|
17091
|
+
for (const installation of installations) {
|
|
17092
|
+
if (isPublicInstallation(installation) && installationReferencesAssistant(installation, assistantId)) {
|
|
17093
|
+
ids.add(installation.id);
|
|
17094
|
+
}
|
|
17095
|
+
}
|
|
17096
|
+
for (let offset = 0; ; offset += 500) {
|
|
17097
|
+
const bindings = await registry4.list({
|
|
17098
|
+
tenantId: tenantId2,
|
|
17099
|
+
agentId: assistantId,
|
|
17100
|
+
excludeChannels: ["room"],
|
|
17101
|
+
limit: 500,
|
|
17102
|
+
offset
|
|
17103
|
+
});
|
|
17104
|
+
for (const binding of bindings) {
|
|
17105
|
+
if (binding.channelInstallationId) ids.add(binding.channelInstallationId);
|
|
17106
|
+
}
|
|
17107
|
+
if (bindings.length < 500) break;
|
|
17108
|
+
}
|
|
17109
|
+
return ids;
|
|
17110
|
+
}
|
|
17111
|
+
async function validatePublicInstallation(installationId, tenantId2, channel, allowedIds) {
|
|
16851
17112
|
try {
|
|
16852
17113
|
const installation = await getInstallationStore().getInstallationById(installationId);
|
|
16853
17114
|
if (!installation || !isPublicInstallation(installation) || installation.tenantId !== tenantId2 || installation.channel !== channel) {
|
|
16854
17115
|
return "Invalid public channel installation";
|
|
16855
17116
|
}
|
|
17117
|
+
if (allowedIds && !allowedIds.has(installationId)) {
|
|
17118
|
+
return "Invalid public channel installation";
|
|
17119
|
+
}
|
|
16856
17120
|
return null;
|
|
16857
17121
|
} catch {
|
|
16858
17122
|
return "Unable to validate public channel installation";
|
|
@@ -20960,7 +21224,7 @@ var createBrowserGetInfoTool = ({ vmIsolation }) => {
|
|
|
20960
21224
|
var import_messages9 = require("@langchain/core/messages");
|
|
20961
21225
|
|
|
20962
21226
|
// src/agent_lattice/types.ts
|
|
20963
|
-
var
|
|
21227
|
+
var import_protocols26 = require("@axiom-lattice/protocols");
|
|
20964
21228
|
|
|
20965
21229
|
// src/agent_lattice/AgentLatticeManager.ts
|
|
20966
21230
|
init_BaseLatticeManager();
|
|
@@ -22132,7 +22396,7 @@ async function describeImage(options) {
|
|
|
22132
22396
|
|
|
22133
22397
|
// src/stt_model_lattice/STTModelLatticeManager.ts
|
|
22134
22398
|
init_BaseLatticeManager();
|
|
22135
|
-
var
|
|
22399
|
+
var import_protocols27 = require("@axiom-lattice/protocols");
|
|
22136
22400
|
|
|
22137
22401
|
// src/stt_model_lattice/STTModelLattice.ts
|
|
22138
22402
|
var import_openai3 = require("@langchain/openai");
|
|
@@ -22268,7 +22532,7 @@ var STTModelLatticeManager = class _STTModelLatticeManager extends BaseLatticeMa
|
|
|
22268
22532
|
* chat key must never resolve to a speech client.
|
|
22269
22533
|
*/
|
|
22270
22534
|
async loadItemFromStore(tenantId2, key6) {
|
|
22271
|
-
const row = key6 ===
|
|
22535
|
+
const row = key6 === import_protocols27.ASR_DEFAULT_KEY ? await loadTenantDefaultModelRow(tenantId2, "asr") : await loadTenantModelRow(tenantId2, key6);
|
|
22272
22536
|
if (!row || row.model.kind !== "asr") {
|
|
22273
22537
|
return void 0;
|
|
22274
22538
|
}
|
|
@@ -22396,16 +22660,16 @@ var getSTTClient = (key6) => sttModelLatticeManager.getSTTClient(key6);
|
|
|
22396
22660
|
var getSTTClientWithTenant = (tenantId2, key6) => sttModelLatticeManager.getSTTClientWithTenant(tenantId2, key6);
|
|
22397
22661
|
|
|
22398
22662
|
// src/deep_agent_new/backends/transcribeAudio.ts
|
|
22399
|
-
var
|
|
22663
|
+
var import_protocols28 = require("@axiom-lattice/protocols");
|
|
22400
22664
|
async function transcribeAudio(options) {
|
|
22401
22665
|
const { audioBuffer, format, tenantId: tenantId2 = "default", modelKey } = options;
|
|
22402
|
-
const requestedKey = modelKey ||
|
|
22666
|
+
const requestedKey = modelKey || import_protocols28.ASR_DEFAULT_KEY;
|
|
22403
22667
|
const client = await sttModelLatticeManager.getSTTClientWithTenantAsync(
|
|
22404
22668
|
tenantId2,
|
|
22405
22669
|
requestedKey
|
|
22406
|
-
) ?? (requestedKey ===
|
|
22670
|
+
) ?? (requestedKey === import_protocols28.ASR_DEFAULT_KEY ? void 0 : await sttModelLatticeManager.getSTTClientWithTenantAsync(
|
|
22407
22671
|
tenantId2,
|
|
22408
|
-
|
|
22672
|
+
import_protocols28.ASR_DEFAULT_KEY
|
|
22409
22673
|
)) ?? await sttModelLatticeManager.getSTTClientWithTenantAsync(
|
|
22410
22674
|
tenantId2,
|
|
22411
22675
|
"default"
|
|
@@ -27517,7 +27781,7 @@ var import_langgraph5 = require("@langchain/langgraph");
|
|
|
27517
27781
|
|
|
27518
27782
|
// src/agent_worker/delegation_service.ts
|
|
27519
27783
|
var import_node_crypto10 = require("crypto");
|
|
27520
|
-
var
|
|
27784
|
+
var import_protocols32 = require("@axiom-lattice/protocols");
|
|
27521
27785
|
|
|
27522
27786
|
// src/services/Agent.ts
|
|
27523
27787
|
var import_node_crypto9 = require("crypto");
|
|
@@ -27578,7 +27842,7 @@ var import_events = require("events");
|
|
|
27578
27842
|
|
|
27579
27843
|
// src/queue_lattice/QueueLatticeManager.ts
|
|
27580
27844
|
init_BaseLatticeManager();
|
|
27581
|
-
var
|
|
27845
|
+
var import_protocols29 = require("@axiom-lattice/protocols");
|
|
27582
27846
|
|
|
27583
27847
|
// src/queue_lattice/MemoryQueueClient.ts
|
|
27584
27848
|
var queues = /* @__PURE__ */ new Map();
|
|
@@ -27671,7 +27935,7 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
|
|
|
27671
27935
|
queueClient = client;
|
|
27672
27936
|
} else {
|
|
27673
27937
|
const queueName = config.queueName || process.env.QUEUE_NAME || "tasks";
|
|
27674
|
-
if (config.type ===
|
|
27938
|
+
if (config.type === import_protocols29.QueueType.REDIS) {
|
|
27675
27939
|
throw new Error(
|
|
27676
27940
|
`Redis queue client must be provided. Please install @axiom-lattice/queue-redis and pass the client to registerLattice. Example: registerLattice(key, config, new RedisQueueClient(queueName, options))`
|
|
27677
27941
|
);
|
|
@@ -28135,7 +28399,7 @@ function truncateForJson(value, options = {}) {
|
|
|
28135
28399
|
}
|
|
28136
28400
|
|
|
28137
28401
|
// src/services/Agent.ts
|
|
28138
|
-
var
|
|
28402
|
+
var import_protocols31 = require("@axiom-lattice/protocols");
|
|
28139
28403
|
var import_langgraph4 = require("@langchain/langgraph");
|
|
28140
28404
|
|
|
28141
28405
|
// src/services/agentInterrupts.ts
|
|
@@ -28258,7 +28522,7 @@ var ChunkBuffer = class {
|
|
|
28258
28522
|
};
|
|
28259
28523
|
|
|
28260
28524
|
// src/chunk_buffer_lattice/InMemoryChunkBuffer.ts
|
|
28261
|
-
var
|
|
28525
|
+
var import_protocols30 = require("@axiom-lattice/protocols");
|
|
28262
28526
|
var import_rxjs = require("rxjs");
|
|
28263
28527
|
var import_rxjs_for_await = require("rxjs-for-await");
|
|
28264
28528
|
var import_operators = require("rxjs/operators");
|
|
@@ -28346,7 +28610,7 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
|
|
|
28346
28610
|
let chunk2;
|
|
28347
28611
|
if (typeof arg2 === "string" && arg3 !== void 0) {
|
|
28348
28612
|
chunk2 = {
|
|
28349
|
-
type:
|
|
28613
|
+
type: import_protocols30.MessageChunkTypes.AI,
|
|
28350
28614
|
data: {
|
|
28351
28615
|
id: arg2,
|
|
28352
28616
|
content: arg3
|
|
@@ -28541,8 +28805,8 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
|
|
|
28541
28805
|
const buffer2 = this.getBufferIfValid(threadId);
|
|
28542
28806
|
if (!buffer2) return;
|
|
28543
28807
|
const defaultStopTypes = [
|
|
28544
|
-
|
|
28545
|
-
|
|
28808
|
+
import_protocols30.MessageChunkTypes.MESSAGE_COMPLETED,
|
|
28809
|
+
import_protocols30.MessageChunkTypes.THREAD_IDLE
|
|
28546
28810
|
];
|
|
28547
28811
|
const typesToStop = stopTypes ?? defaultStopTypes;
|
|
28548
28812
|
let startIndex = buffer2.status === "active" /* ACTIVE */ ? buffer2.chunks.length : 0;
|
|
@@ -30696,7 +30960,7 @@ function cloneRunConfig(value, stripReserved) {
|
|
|
30696
30960
|
const clone10 = [];
|
|
30697
30961
|
for (let index = 0; index < length; index += 1) {
|
|
30698
30962
|
const key6 = String(index);
|
|
30699
|
-
const data = (0,
|
|
30963
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptors[key6]);
|
|
30700
30964
|
if (!data || data.value === void 0) {
|
|
30701
30965
|
throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${key6}`);
|
|
30702
30966
|
}
|
|
@@ -30711,7 +30975,7 @@ function cloneRunConfig(value, stripReserved) {
|
|
|
30711
30975
|
for (const key6 of keys) {
|
|
30712
30976
|
if (typeof key6 !== "string") continue;
|
|
30713
30977
|
const fieldPath = callerRunConfigPath(path8, key6);
|
|
30714
|
-
const data = (0,
|
|
30978
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptors[key6]);
|
|
30715
30979
|
if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
|
|
30716
30980
|
if (stripReserved && RESERVED_CALLER_RUN_KEYS.has(key6) || data.value === void 0) continue;
|
|
30717
30981
|
Object.defineProperty(clone9, key6, {
|
|
@@ -30747,7 +31011,7 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
|
|
|
30747
31011
|
if (Array.isArray(entry)) {
|
|
30748
31012
|
const descriptors2 = Object.getOwnPropertyDescriptors(entry);
|
|
30749
31013
|
for (let index = 0; index < entry.length; index += 1) {
|
|
30750
|
-
const data = (0,
|
|
31014
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptors2[String(index)]);
|
|
30751
31015
|
if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${index}`);
|
|
30752
31016
|
visit(data.value, `${path8}/${index}`);
|
|
30753
31017
|
}
|
|
@@ -30766,7 +31030,7 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
|
|
|
30766
31030
|
}
|
|
30767
31031
|
const fieldPath = callerRunConfigPath(path8, key6);
|
|
30768
31032
|
const descriptor = descriptors[key6];
|
|
30769
|
-
const data = (0,
|
|
31033
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptor);
|
|
30770
31034
|
if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
|
|
30771
31035
|
if (isCredentialBearingKey(key6)) {
|
|
30772
31036
|
throw new CapabilityRuntimeResolutionError(
|
|
@@ -30790,9 +31054,9 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
|
|
|
30790
31054
|
}
|
|
30791
31055
|
function preserveExecutionBinding(source, target) {
|
|
30792
31056
|
if (typeof source !== "object" || source === null || Array.isArray(source)) return;
|
|
30793
|
-
const execution = (0,
|
|
31057
|
+
const execution = (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(source, "execution"))?.value;
|
|
30794
31058
|
if (typeof execution !== "object" || execution === null || Array.isArray(execution)) return;
|
|
30795
|
-
const taskId = (0,
|
|
31059
|
+
const taskId = (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(execution, "taskId"))?.value;
|
|
30796
31060
|
if (typeof taskId !== "string" || taskId.trim() === "") return;
|
|
30797
31061
|
Object.defineProperty(target, "execution", {
|
|
30798
31062
|
value: { taskId },
|
|
@@ -30816,7 +31080,7 @@ function cloneExecutionRunConfigBase(value) {
|
|
|
30816
31080
|
throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
|
|
30817
31081
|
}
|
|
30818
31082
|
const descriptor = descriptors[key6];
|
|
30819
|
-
const data = (0,
|
|
31083
|
+
const data = (0, import_protocols31.descriptorDataValue)(descriptor);
|
|
30820
31084
|
if (!data) {
|
|
30821
31085
|
throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
|
|
30822
31086
|
}
|
|
@@ -31067,7 +31331,7 @@ var DelegatedScopeNotQueueableError = class extends Error {
|
|
|
31067
31331
|
function ownDataValue(value, key6) {
|
|
31068
31332
|
if (typeof value !== "object" || value === null) return void 0;
|
|
31069
31333
|
try {
|
|
31070
|
-
return (0,
|
|
31334
|
+
return (0, import_protocols31.descriptorDataValue)(Object.getOwnPropertyDescriptor(value, key6))?.value;
|
|
31071
31335
|
} catch {
|
|
31072
31336
|
return void 0;
|
|
31073
31337
|
}
|
|
@@ -31737,7 +32001,7 @@ var Agent = class {
|
|
|
31737
32001
|
}
|
|
31738
32002
|
}
|
|
31739
32003
|
validateTrustedRunContext(context, inputMessageId) {
|
|
31740
|
-
const parsed = (0,
|
|
32004
|
+
const parsed = (0, import_protocols11.parseTrustedRunContext)(context);
|
|
31741
32005
|
const trusted = parsed.projectRoom ?? parsed.projectTask;
|
|
31742
32006
|
if (!trusted || trusted.tenantId !== this.tenant_id || trusted.workspaceId !== this.workspace_id || trusted.projectId !== this.project_id || trusted.assistantId !== this.assistant_id || trusted.inputMessageId !== inputMessageId || parsed.projectTask !== void 0 && parsed.projectTask.threadId !== this.thread_id) {
|
|
31743
32007
|
throw invalidTrustedRunContext();
|
|
@@ -31773,7 +32037,7 @@ var Agent = class {
|
|
|
31773
32037
|
}
|
|
31774
32038
|
let trustedRunContext;
|
|
31775
32039
|
try {
|
|
31776
|
-
trustedRunContext = (0,
|
|
32040
|
+
trustedRunContext = (0, import_protocols11.parseTrustedRunContext)(row.trusted_run_context);
|
|
31777
32041
|
this.validateTrustedRunContext(trustedRunContext, row.id);
|
|
31778
32042
|
} catch {
|
|
31779
32043
|
throw new TrustedRunContextRecoveryError("Trusted processing context is invalid");
|
|
@@ -31815,7 +32079,7 @@ var Agent = class {
|
|
|
31815
32079
|
delete base.projectRoom;
|
|
31816
32080
|
delete base.projectTask;
|
|
31817
32081
|
if (trustedRunContext === void 0) return base;
|
|
31818
|
-
const parsed = (0,
|
|
32082
|
+
const parsed = (0, import_protocols11.parseTrustedRunContext)(trustedRunContext);
|
|
31819
32083
|
const branch = parsed.projectRoom ? "projectRoom" : "projectTask";
|
|
31820
32084
|
Object.defineProperty(base, branch, {
|
|
31821
32085
|
value: parsed.projectRoom ?? parsed.projectTask,
|
|
@@ -34043,7 +34307,7 @@ var DelegationService = class {
|
|
|
34043
34307
|
}
|
|
34044
34308
|
this.reserveChild(context.budgetId, request.thread_id);
|
|
34045
34309
|
}
|
|
34046
|
-
const scope = (0,
|
|
34310
|
+
const scope = (0, import_protocols32.resolveRunScope)(request.runConfig);
|
|
34047
34311
|
const leaseStore = storeLatticeManager.getStoreLattice("default", "lease").store;
|
|
34048
34312
|
const abortController = new AbortController();
|
|
34049
34313
|
const cancellation = request.parentThreadId ? delegationCancellationRegistry.register(request.tenantId, request.parentThreadId) : void 0;
|
|
@@ -34601,7 +34865,7 @@ function createTaskTool(options) {
|
|
|
34601
34865
|
key: assistant_id,
|
|
34602
34866
|
name: "general-purpose",
|
|
34603
34867
|
description: DEFAULT_GENERAL_PURPOSE_DESCRIPTION,
|
|
34604
|
-
type:
|
|
34868
|
+
type: import_protocols26.AgentType.REACT,
|
|
34605
34869
|
prompt: DEFAULT_SUBAGENT_PROMPT
|
|
34606
34870
|
},
|
|
34607
34871
|
client
|
|
@@ -34856,30 +35120,30 @@ var datePlugin = {
|
|
|
34856
35120
|
var import_langchain57 = require("langchain");
|
|
34857
35121
|
var import_zod52 = require("zod");
|
|
34858
35122
|
var import_uuid6 = require("uuid");
|
|
34859
|
-
var
|
|
35123
|
+
var import_protocols33 = require("@axiom-lattice/protocols");
|
|
34860
35124
|
var SCHEDULE_LATTICE_KEY = "default";
|
|
34861
35125
|
var AGENT_ADD_MESSAGE_TASK_TYPE = "agent.add_message";
|
|
34862
|
-
function
|
|
35126
|
+
function getRunConfig2(config) {
|
|
34863
35127
|
const configurable = config;
|
|
34864
35128
|
return configurable?.configurable?.runConfig ?? {};
|
|
34865
35129
|
}
|
|
34866
35130
|
function mapStatusToEnum(status) {
|
|
34867
35131
|
if (!status) return void 0;
|
|
34868
35132
|
const statusMap = {
|
|
34869
|
-
pending:
|
|
34870
|
-
running:
|
|
34871
|
-
completed:
|
|
34872
|
-
failed:
|
|
34873
|
-
cancelled:
|
|
34874
|
-
paused:
|
|
35133
|
+
pending: import_protocols33.ScheduledTaskStatus.PENDING,
|
|
35134
|
+
running: import_protocols33.ScheduledTaskStatus.RUNNING,
|
|
35135
|
+
completed: import_protocols33.ScheduledTaskStatus.COMPLETED,
|
|
35136
|
+
failed: import_protocols33.ScheduledTaskStatus.FAILED,
|
|
35137
|
+
cancelled: import_protocols33.ScheduledTaskStatus.CANCELLED,
|
|
35138
|
+
paused: import_protocols33.ScheduledTaskStatus.PAUSED
|
|
34875
35139
|
};
|
|
34876
35140
|
return statusMap[status];
|
|
34877
35141
|
}
|
|
34878
35142
|
function mapExecutionTypeToEnum(executionType) {
|
|
34879
35143
|
if (!executionType) return void 0;
|
|
34880
35144
|
const typeMap = {
|
|
34881
|
-
once:
|
|
34882
|
-
cron:
|
|
35145
|
+
once: import_protocols33.ScheduleExecutionType.ONCE,
|
|
35146
|
+
cron: import_protocols33.ScheduleExecutionType.CRON
|
|
34883
35147
|
};
|
|
34884
35148
|
return typeMap[executionType];
|
|
34885
35149
|
}
|
|
@@ -34940,7 +35204,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
34940
35204
|
tools: [
|
|
34941
35205
|
(0, import_langchain57.tool)(
|
|
34942
35206
|
async (input, config) => {
|
|
34943
|
-
const runConfig =
|
|
35207
|
+
const runConfig = getRunConfig2(config);
|
|
34944
35208
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
34945
35209
|
const taskId = (0, import_uuid6.v4)();
|
|
34946
35210
|
const executeAt = input.executeAt;
|
|
@@ -34975,7 +35239,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
34975
35239
|
),
|
|
34976
35240
|
(0, import_langchain57.tool)(
|
|
34977
35241
|
async (input, config) => {
|
|
34978
|
-
const runConfig =
|
|
35242
|
+
const runConfig = getRunConfig2(config);
|
|
34979
35243
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
34980
35244
|
const taskId = (0, import_uuid6.v4)();
|
|
34981
35245
|
const executeAt = Date.now() + input.delayMs;
|
|
@@ -35010,7 +35274,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
35010
35274
|
),
|
|
35011
35275
|
(0, import_langchain57.tool)(
|
|
35012
35276
|
async (input, config) => {
|
|
35013
|
-
const runConfig =
|
|
35277
|
+
const runConfig = getRunConfig2(config);
|
|
35014
35278
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
35015
35279
|
const taskId = (0, import_uuid6.v4)();
|
|
35016
35280
|
const success = await scheduleLattice.client.scheduleCron(
|
|
@@ -35068,7 +35332,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
35068
35332
|
),
|
|
35069
35333
|
(0, import_langchain57.tool)(
|
|
35070
35334
|
async (input, config) => {
|
|
35071
|
-
const runConfig =
|
|
35335
|
+
const runConfig = getRunConfig2(config);
|
|
35072
35336
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
35073
35337
|
const storage = scheduleLattice.client.getStorage();
|
|
35074
35338
|
if (!storage) {
|
|
@@ -36800,7 +37064,7 @@ ${BASE_PROMPT}` : BASE_PROMPT;
|
|
|
36800
37064
|
}
|
|
36801
37065
|
|
|
36802
37066
|
// src/agent_lattice/builders/DeepAgentGraphBuilder.ts
|
|
36803
|
-
var
|
|
37067
|
+
var import_protocols34 = require("@axiom-lattice/protocols");
|
|
36804
37068
|
init_MemoryLatticeManager();
|
|
36805
37069
|
var DeepAgentGraphBuilder = class {
|
|
36806
37070
|
/**
|
|
@@ -36862,7 +37126,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
36862
37126
|
key: generalPurposeKey,
|
|
36863
37127
|
name: "general-purpose",
|
|
36864
37128
|
description: DEFAULT_GENERAL_PURPOSE_DESCRIPTION,
|
|
36865
|
-
type:
|
|
37129
|
+
type: import_protocols34.AgentType.REACT,
|
|
36866
37130
|
prompt: DEFAULT_SUBAGENT_PROMPT,
|
|
36867
37131
|
tenantId: tenantId2
|
|
36868
37132
|
},
|
|
@@ -37194,7 +37458,7 @@ _A2ARemoteClient.MAX_CACHED_TASKS = 100;
|
|
|
37194
37458
|
var A2ARemoteClient = _A2ARemoteClient;
|
|
37195
37459
|
|
|
37196
37460
|
// src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
|
|
37197
|
-
var
|
|
37461
|
+
var import_protocols35 = require("@axiom-lattice/protocols");
|
|
37198
37462
|
init_MemoryLatticeManager();
|
|
37199
37463
|
function resolveA2ARemoteContextId(assistantKey, threadId) {
|
|
37200
37464
|
return threadId ? `a2a-remote:${assistantKey}:${threadId}` : void 0;
|
|
@@ -37204,7 +37468,7 @@ var RemoteAgentGraphBuilder = class {
|
|
|
37204
37468
|
this.deps = deps;
|
|
37205
37469
|
}
|
|
37206
37470
|
async build(agentLattice, params) {
|
|
37207
|
-
if (agentLattice.config.type !==
|
|
37471
|
+
if (agentLattice.config.type !== import_protocols35.AgentType.A2A_REMOTE) {
|
|
37208
37472
|
throw new Error(
|
|
37209
37473
|
`RemoteAgentGraphBuilder received wrong agent type: ${agentLattice.config.type}`
|
|
37210
37474
|
);
|
|
@@ -37263,7 +37527,7 @@ function extractLastHumanMessage(messages) {
|
|
|
37263
37527
|
// src/agent_lattice/builders/WorkflowAgentGraphBuilder.ts
|
|
37264
37528
|
var import_langchain60 = require("langchain");
|
|
37265
37529
|
init_MemoryLatticeManager();
|
|
37266
|
-
var
|
|
37530
|
+
var import_protocols36 = require("@axiom-lattice/protocols");
|
|
37267
37531
|
init_compile();
|
|
37268
37532
|
|
|
37269
37533
|
// src/agent_lattice/builders/middlewareSanitize.ts
|
|
@@ -37302,7 +37566,7 @@ ${configPrompt}` : base;
|
|
|
37302
37566
|
}
|
|
37303
37567
|
var WorkflowAgentGraphBuilder = class {
|
|
37304
37568
|
async build(agentLattice, params) {
|
|
37305
|
-
if (!(0,
|
|
37569
|
+
if (!(0, import_protocols36.isWorkflowAgentConfig)(agentLattice.config)) {
|
|
37306
37570
|
throw new Error(
|
|
37307
37571
|
`WorkflowAgentGraphBuilder received wrong agent type: ${agentLattice.config.type}`
|
|
37308
37572
|
);
|
|
@@ -37425,10 +37689,10 @@ var AgentGraphBuilderFactory = class _AgentGraphBuilderFactory {
|
|
|
37425
37689
|
* 注册默认的Builder
|
|
37426
37690
|
*/
|
|
37427
37691
|
registerDefaultBuilders() {
|
|
37428
|
-
this.builders.set(
|
|
37429
|
-
this.builders.set(
|
|
37430
|
-
this.builders.set(
|
|
37431
|
-
this.builders.set(
|
|
37692
|
+
this.builders.set(import_protocols26.AgentType.REACT, new ReActAgentGraphBuilder());
|
|
37693
|
+
this.builders.set(import_protocols26.AgentType.DEEP_AGENT, new DeepAgentGraphBuilder());
|
|
37694
|
+
this.builders.set(import_protocols26.AgentType.A2A_REMOTE, new RemoteAgentGraphBuilder());
|
|
37695
|
+
this.builders.set(import_protocols26.AgentType.WORKFLOW, new WorkflowAgentGraphBuilder());
|
|
37432
37696
|
}
|
|
37433
37697
|
/**
|
|
37434
37698
|
* 注册自定义Builder
|
|
@@ -37455,7 +37719,7 @@ var AgentGraphBuilderFactory = class _AgentGraphBuilderFactory {
|
|
|
37455
37719
|
};
|
|
37456
37720
|
|
|
37457
37721
|
// src/mcp_lattice/personalMcpLifecycle.ts
|
|
37458
|
-
var
|
|
37722
|
+
var import_protocols37 = require("@axiom-lattice/protocols");
|
|
37459
37723
|
|
|
37460
37724
|
// src/mcp_lattice/McpLatticeManager.ts
|
|
37461
37725
|
var import_mcp_adapters = require("@langchain/mcp-adapters");
|
|
@@ -38351,7 +38615,9 @@ function getPersonalMcpMaxServers() {
|
|
|
38351
38615
|
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : PERSONAL_MCP_MAX_SERVERS;
|
|
38352
38616
|
}
|
|
38353
38617
|
function getPersonalMcpSyncBudgetMs() {
|
|
38354
|
-
const
|
|
38618
|
+
const value = process.env.PERSONAL_MCP_SYNC_BUDGET_MS;
|
|
38619
|
+
if (value === void 0 || value.trim() === "") return PERSONAL_MCP_SYNC_BUDGET_MS;
|
|
38620
|
+
const raw = Number(value);
|
|
38355
38621
|
return Number.isFinite(raw) && raw >= 0 ? raw : PERSONAL_MCP_SYNC_BUDGET_MS;
|
|
38356
38622
|
}
|
|
38357
38623
|
var syncCache = /* @__PURE__ */ new Map();
|
|
@@ -38369,7 +38635,7 @@ function errorMessage(error) {
|
|
|
38369
38635
|
function getPersonalMcpStore() {
|
|
38370
38636
|
if (!storeLatticeManager.hasLattice("default", "mcp")) return void 0;
|
|
38371
38637
|
const store2 = storeLatticeManager.getStoreLattice("default", "mcp").store;
|
|
38372
|
-
return (0,
|
|
38638
|
+
return (0, import_protocols37.isPersonalMcpServerConfigStore)(store2) ? store2 : void 0;
|
|
38373
38639
|
}
|
|
38374
38640
|
function invalidatePersonalMcpSync(tenantId2, assistantId) {
|
|
38375
38641
|
const key6 = syncKey(tenantId2, assistantId);
|
|
@@ -38659,7 +38925,7 @@ async function countPersonalMcpServers(tenantId2, assistantId) {
|
|
|
38659
38925
|
}
|
|
38660
38926
|
|
|
38661
38927
|
// src/agent_lattice/builders/AgentParamsBuilder.ts
|
|
38662
|
-
var
|
|
38928
|
+
var import_protocols38 = require("@axiom-lattice/protocols");
|
|
38663
38929
|
var AgentParamsBuilder = class {
|
|
38664
38930
|
/**
|
|
38665
38931
|
* constructor
|
|
@@ -38677,7 +38943,7 @@ var AgentParamsBuilder = class {
|
|
|
38677
38943
|
* @returns Agent build parameters
|
|
38678
38944
|
*/
|
|
38679
38945
|
async buildParams(agentLattice, options) {
|
|
38680
|
-
const skills = (0,
|
|
38946
|
+
const skills = (0, import_protocols38.isDeepAgentConfig)(agentLattice.config) ? agentLattice.config.skillCategories : void 0;
|
|
38681
38947
|
const tenantId2 = agentLattice.config.tenantId || "default";
|
|
38682
38948
|
const ownerUserId = agentLattice.config.ownerUserId;
|
|
38683
38949
|
const assistantId = agentLattice.config.key;
|
|
@@ -38685,7 +38951,7 @@ var AgentParamsBuilder = class {
|
|
|
38685
38951
|
if (isPersonalAssistant) {
|
|
38686
38952
|
await ensurePersonalMcpForAssistant({ tenantId: tenantId2, assistantId });
|
|
38687
38953
|
}
|
|
38688
|
-
const configuredKeys = options?.overrideTools || (0,
|
|
38954
|
+
const configuredKeys = options?.overrideTools || (0, import_protocols38.getToolsFromConfig)(agentLattice.config);
|
|
38689
38955
|
const autoKeys = isPersonalAssistant && !options?.overrideTools ? toolLatticeManager.getAssistantToolKeys(tenantId2, assistantId) : [];
|
|
38690
38956
|
const toolKeys = Array.from(/* @__PURE__ */ new Set([...configuredKeys, ...autoKeys]));
|
|
38691
38957
|
const tools = toolKeys.map((toolKey) => {
|
|
@@ -38710,7 +38976,7 @@ var AgentParamsBuilder = class {
|
|
|
38710
38976
|
if (!model) {
|
|
38711
38977
|
throw new Error(`Model "${resolvedModelKey}" does not exist`);
|
|
38712
38978
|
}
|
|
38713
|
-
const subAgentKeys = (0,
|
|
38979
|
+
const subAgentKeys = (0, import_protocols38.getSubAgentsFromConfig)(agentLattice.config);
|
|
38714
38980
|
const subAgents = await Promise.all(subAgentKeys.map(async (agentKey) => {
|
|
38715
38981
|
const subAgentLattice = await this.getAgentLatticeFunc(agentKey);
|
|
38716
38982
|
if (!subAgentLattice) {
|
|
@@ -38727,7 +38993,7 @@ var AgentParamsBuilder = class {
|
|
|
38727
38993
|
}));
|
|
38728
38994
|
const resolvedSubAgents = subAgents.filter((s) => s !== null);
|
|
38729
38995
|
let internalSubAgents = [];
|
|
38730
|
-
if ((0,
|
|
38996
|
+
if ((0, import_protocols38.isDeepAgentConfig)(agentLattice.config)) {
|
|
38731
38997
|
internalSubAgents = agentLattice.config.internalSubAgents?.map((i) => ({
|
|
38732
38998
|
key: i.key,
|
|
38733
38999
|
config: i
|
|
@@ -38770,11 +39036,19 @@ function mergeAgentConfig(parent, child) {
|
|
|
38770
39036
|
// src/agent_lattice/agentArchitectTools.ts
|
|
38771
39037
|
var import_zod54 = __toESM(require("zod"));
|
|
38772
39038
|
var import_uuid8 = require("uuid");
|
|
38773
|
-
var
|
|
39039
|
+
var import_protocols39 = require("@axiom-lattice/protocols");
|
|
38774
39040
|
function getTenantId2(exeConfig) {
|
|
38775
39041
|
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
38776
39042
|
return runConfig.tenantId || "default";
|
|
38777
39043
|
}
|
|
39044
|
+
function getRuntimeUserId(exeConfig) {
|
|
39045
|
+
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
39046
|
+
const value = runConfig.user_id ?? runConfig.userId;
|
|
39047
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
39048
|
+
}
|
|
39049
|
+
function canAccessAssistant(assistant, userId) {
|
|
39050
|
+
return !assistant.ownerUserId || userId !== null && assistant.ownerUserId === userId;
|
|
39051
|
+
}
|
|
38778
39052
|
function getAssistStore() {
|
|
38779
39053
|
return getStoreLattice("default", "assistant").store;
|
|
38780
39054
|
}
|
|
@@ -38790,7 +39064,7 @@ function getAvailableTools(tenantId2) {
|
|
|
38790
39064
|
}
|
|
38791
39065
|
async function getAvailableModels(tenantId2) {
|
|
38792
39066
|
await tenantHasOwnModelSupply(tenantId2);
|
|
38793
|
-
await tenantHasOwnModelSupply(
|
|
39067
|
+
await tenantHasOwnModelSupply(import_protocols39.PLATFORM_MODEL_TENANT_ID);
|
|
38794
39068
|
return listModelLatticesForTenant(tenantId2);
|
|
38795
39069
|
}
|
|
38796
39070
|
async function getAvailableMiddlewareTypes(tenantId2) {
|
|
@@ -38820,7 +39094,7 @@ function getStringMetadata(config) {
|
|
|
38820
39094
|
}
|
|
38821
39095
|
function isUndecidedLearningPlaceholder(config) {
|
|
38822
39096
|
const metadata = getStringMetadata(config);
|
|
38823
|
-
return config.type ===
|
|
39097
|
+
return config.type === import_protocols39.AgentType.REACT && metadata.learningPlaceholder === "true" && metadata.architectureStatus === "undecided";
|
|
38824
39098
|
}
|
|
38825
39099
|
function requireSkillDeclaration(skillLoaded) {
|
|
38826
39100
|
if (skillLoaded !== true) {
|
|
@@ -38867,17 +39141,21 @@ async function validateAgentReferences(input, tenantId2) {
|
|
|
38867
39141
|
function slugify(name) {
|
|
38868
39142
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-+/g, "-") || "agent";
|
|
38869
39143
|
}
|
|
39144
|
+
var MAX_AGENT_ID_ALLOCATION_ATTEMPTS = 1e3;
|
|
38870
39145
|
async function generateAgentId(tenantId2, name) {
|
|
38871
39146
|
const store2 = getAssistStore();
|
|
38872
39147
|
const base = slugify(name);
|
|
38873
39148
|
let id = base;
|
|
38874
39149
|
let counter = 2;
|
|
38875
|
-
|
|
39150
|
+
for (let attempt = 0; attempt < MAX_AGENT_ID_ALLOCATION_ATTEMPTS; attempt += 1) {
|
|
38876
39151
|
const existing = await store2.getAssistantById(tenantId2, id);
|
|
38877
39152
|
if (!existing) return id;
|
|
38878
39153
|
id = `${base}-${counter}`;
|
|
38879
|
-
counter
|
|
39154
|
+
counter += 1;
|
|
38880
39155
|
}
|
|
39156
|
+
throw new Error(
|
|
39157
|
+
`Unable to allocate a unique agent id for "${name}" after ${MAX_AGENT_ID_ALLOCATION_ATTEMPTS} attempts`
|
|
39158
|
+
);
|
|
38881
39159
|
}
|
|
38882
39160
|
registerToolLattice(
|
|
38883
39161
|
"list_agents",
|
|
@@ -38889,8 +39167,9 @@ registerToolLattice(
|
|
|
38889
39167
|
async (_input, exeConfig) => {
|
|
38890
39168
|
try {
|
|
38891
39169
|
const tenantId2 = getTenantId2(exeConfig);
|
|
39170
|
+
const userId = getRuntimeUserId(exeConfig);
|
|
38892
39171
|
const store2 = getAssistStore();
|
|
38893
|
-
const agents = await store2.getAllAssistants(tenantId2);
|
|
39172
|
+
const agents = (await store2.getAllAssistants(tenantId2)).filter((agent) => canAccessAssistant(agent, userId));
|
|
38894
39173
|
return JSON.stringify({
|
|
38895
39174
|
agents: agents.map((a) => ({
|
|
38896
39175
|
id: a.id,
|
|
@@ -38920,7 +39199,7 @@ registerToolLattice(
|
|
|
38920
39199
|
const tenantId2 = getTenantId2(exeConfig);
|
|
38921
39200
|
const store2 = getAssistStore();
|
|
38922
39201
|
const agent = await store2.getAssistantById(tenantId2, input.id);
|
|
38923
|
-
if (!agent) {
|
|
39202
|
+
if (!agent || !canAccessAssistant(agent, getRuntimeUserId(exeConfig))) {
|
|
38924
39203
|
return JSON.stringify({ error: `Agent '${input.id}' not found` });
|
|
38925
39204
|
}
|
|
38926
39205
|
return JSON.stringify(agent.graphDefinition);
|
|
@@ -38973,7 +39252,7 @@ registerToolLattice(
|
|
|
38973
39252
|
key: id,
|
|
38974
39253
|
name: input.name,
|
|
38975
39254
|
description: input.description || "",
|
|
38976
|
-
type: input.type === "deep_agent" ?
|
|
39255
|
+
type: input.type === "deep_agent" ? import_protocols39.AgentType.DEEP_AGENT : import_protocols39.AgentType.REACT,
|
|
38977
39256
|
prompt: input.prompt,
|
|
38978
39257
|
...input.tools && input.tools.length > 0 ? { tools: input.tools } : {},
|
|
38979
39258
|
...input.middleware && input.middleware.length > 0 ? { middleware: input.middleware } : {},
|
|
@@ -39030,7 +39309,7 @@ registerToolLattice(
|
|
|
39030
39309
|
key: id,
|
|
39031
39310
|
name: input.name,
|
|
39032
39311
|
description: input.description || "",
|
|
39033
|
-
type:
|
|
39312
|
+
type: import_protocols39.AgentType.WORKFLOW,
|
|
39034
39313
|
prompt: input.description || `Workflow: ${input.name}`,
|
|
39035
39314
|
workflowYaml: input.yaml,
|
|
39036
39315
|
...input.tools && input.tools.length > 0 ? { tools: input.tools } : {},
|
|
@@ -39067,7 +39346,7 @@ registerToolLattice(
|
|
|
39067
39346
|
return JSON.stringify({ error: `Agent '${input.id}' not found` });
|
|
39068
39347
|
}
|
|
39069
39348
|
const graphDef = agent.graphDefinition;
|
|
39070
|
-
if (!graphDef || graphDef.type !==
|
|
39349
|
+
if (!graphDef || graphDef.type !== import_protocols39.AgentType.WORKFLOW) {
|
|
39071
39350
|
return JSON.stringify({ error: `Agent '${input.id}' is not a workflow agent` });
|
|
39072
39351
|
}
|
|
39073
39352
|
const yaml2 = graphDef.workflowYaml;
|
|
@@ -39182,7 +39461,7 @@ registerToolLattice(
|
|
|
39182
39461
|
return JSON.stringify({ error: `Agent '${input.id}' not found` });
|
|
39183
39462
|
}
|
|
39184
39463
|
const existingConfig = existing.graphDefinition || {};
|
|
39185
|
-
const isWorkflow = existingConfig.type ===
|
|
39464
|
+
const isWorkflow = existingConfig.type === import_protocols39.AgentType.WORKFLOW;
|
|
39186
39465
|
const isPlaceholder = isUndecidedLearningPlaceholder(existingConfig);
|
|
39187
39466
|
if (!isWorkflow && !isPlaceholder) {
|
|
39188
39467
|
console.log(`[update_workflow] ERROR: not a workflow agent: ${input.id}`);
|
|
@@ -39198,7 +39477,7 @@ registerToolLattice(
|
|
|
39198
39477
|
const mergedConfig = {
|
|
39199
39478
|
...existingConfig,
|
|
39200
39479
|
...isPlaceholder ? {
|
|
39201
|
-
type:
|
|
39480
|
+
type: import_protocols39.AgentType.WORKFLOW,
|
|
39202
39481
|
workflowYaml: input.yaml,
|
|
39203
39482
|
metadata: {
|
|
39204
39483
|
...getStringMetadata(existingConfig),
|
|
@@ -39296,7 +39575,7 @@ registerToolLattice(
|
|
|
39296
39575
|
const tenantId2 = getTenantId2(exeConfig);
|
|
39297
39576
|
const store2 = getAssistStore();
|
|
39298
39577
|
const existing = await store2.getAssistantById(tenantId2, input.id);
|
|
39299
|
-
if (!existing) {
|
|
39578
|
+
if (!existing || !canAccessAssistant(existing, getRuntimeUserId(exeConfig))) {
|
|
39300
39579
|
return JSON.stringify({ error: `Agent '${input.id}' not found` });
|
|
39301
39580
|
}
|
|
39302
39581
|
const existingConfig = existing.graphDefinition || {};
|
|
@@ -39304,14 +39583,14 @@ registerToolLattice(
|
|
|
39304
39583
|
const mergedConfig = { ...existingConfig, ...input.config };
|
|
39305
39584
|
const isPlaceholder = isUndecidedLearningPlaceholder(existingConfigRecord);
|
|
39306
39585
|
const materializedType = input.config.type;
|
|
39307
|
-
const isMaterializingPlaceholder = isPlaceholder && (materializedType ===
|
|
39586
|
+
const isMaterializingPlaceholder = isPlaceholder && (materializedType === import_protocols39.AgentType.REACT || materializedType === import_protocols39.AgentType.DEEP_AGENT);
|
|
39308
39587
|
if (isMaterializingPlaceholder) {
|
|
39309
39588
|
mergedConfig.metadata = {
|
|
39310
39589
|
...getStringMetadata(existingConfigRecord),
|
|
39311
39590
|
...input.config.metadata ?? {},
|
|
39312
39591
|
learningPlaceholder: "false",
|
|
39313
39592
|
architectureStatus: "materialized",
|
|
39314
|
-
architectureForm: materializedType ===
|
|
39593
|
+
architectureForm: materializedType === import_protocols39.AgentType.DEEP_AGENT ? "orchestra" : "capability"
|
|
39315
39594
|
};
|
|
39316
39595
|
} else if (isPlaceholder && input.config.metadata !== void 0) {
|
|
39317
39596
|
const metadata = {
|
|
@@ -39410,9 +39689,16 @@ registerToolLattice(
|
|
|
39410
39689
|
const tenantId2 = getTenantId2(exeConfig);
|
|
39411
39690
|
const store2 = getAssistStore();
|
|
39412
39691
|
const existing = await store2.getAssistantById(tenantId2, input.id);
|
|
39413
|
-
if (!existing) {
|
|
39692
|
+
if (!existing || !canAccessAssistant(existing, getRuntimeUserId(exeConfig))) {
|
|
39414
39693
|
return JSON.stringify({ error: `Agent '${input.id}' not found`, success: false });
|
|
39415
39694
|
}
|
|
39695
|
+
if (existing.ownerUserId) {
|
|
39696
|
+
return JSON.stringify({
|
|
39697
|
+
success: false,
|
|
39698
|
+
code: "PERSONAL_ASSISTANT_DELETE_UNSUPPORTED",
|
|
39699
|
+
error: "Personal assistants must be deleted from the Personal Assistant page"
|
|
39700
|
+
});
|
|
39701
|
+
}
|
|
39416
39702
|
const success = await store2.deleteAssistant(tenantId2, input.id);
|
|
39417
39703
|
if (success) {
|
|
39418
39704
|
try {
|
|
@@ -39562,7 +39848,7 @@ registerToolLattice(
|
|
|
39562
39848
|
);
|
|
39563
39849
|
|
|
39564
39850
|
// src/agent_lattice/agentArchitectConfig.ts
|
|
39565
|
-
var
|
|
39851
|
+
var import_protocols40 = require("@axiom-lattice/protocols");
|
|
39566
39852
|
|
|
39567
39853
|
// src/agent_lattice/agentArchitectPrompt.ts
|
|
39568
39854
|
var AGENT_ARCHITECT_PROMPT = `You are the Agent Architect.
|
|
@@ -39588,7 +39874,7 @@ var agentArchitectConfig = {
|
|
|
39588
39874
|
key: AGENT_ARCHITECT_KEY,
|
|
39589
39875
|
name: "Agent Architect",
|
|
39590
39876
|
description: "Design and manage AI agents through natural language conversation. Use this agent when you want to create a new agent, modify an existing agent, or manage your agent collection (list, view, update, delete).",
|
|
39591
|
-
type:
|
|
39877
|
+
type: import_protocols40.AgentType.DEEP_AGENT,
|
|
39592
39878
|
prompt: AGENT_ARCHITECT_PROMPT,
|
|
39593
39879
|
tools: [
|
|
39594
39880
|
"list_agents",
|
|
@@ -39691,7 +39977,7 @@ var agentArchitectConfig = {
|
|
|
39691
39977
|
};
|
|
39692
39978
|
|
|
39693
39979
|
// src/agent_lattice/agentReviewerConfig.ts
|
|
39694
|
-
var
|
|
39980
|
+
var import_protocols41 = require("@axiom-lattice/protocols");
|
|
39695
39981
|
|
|
39696
39982
|
// src/agent_lattice/agentReviewerPrompt.ts
|
|
39697
39983
|
var AGENT_REVIEWER_PROMPT = `# Agent Reviewer
|
|
@@ -39757,7 +40043,7 @@ var agentReviewerConfig = {
|
|
|
39757
40043
|
key: AGENT_REVIEWER_KEY,
|
|
39758
40044
|
name: "Agent Reviewer",
|
|
39759
40045
|
description: "Review and test AI agents. Use this agent to check agent configurations for correctness and to test agents by invoking them with realistic messages.",
|
|
39760
|
-
type:
|
|
40046
|
+
type: import_protocols41.AgentType.REACT,
|
|
39761
40047
|
prompt: AGENT_REVIEWER_PROMPT,
|
|
39762
40048
|
tools: [
|
|
39763
40049
|
"invoke_agent",
|
|
@@ -39778,7 +40064,7 @@ var agentReviewerConfig = {
|
|
|
39778
40064
|
};
|
|
39779
40065
|
|
|
39780
40066
|
// src/agent_lattice/roomCoordinatorConfig.ts
|
|
39781
|
-
var
|
|
40067
|
+
var import_protocols42 = require("@axiom-lattice/protocols");
|
|
39782
40068
|
|
|
39783
40069
|
// src/agent_lattice/roomCoordinatorPrompt.ts
|
|
39784
40070
|
var ROOM_COORDINATOR_PROMPT = `You are the Room Coordinator. CRITICAL FIRST ACTION: Before any response or other action, call the \`skill\` tool with skill_name: "room-coordination" to load room-coordination and follow it. Never announce the skill load. If it fails, retry once, then stop and explicitly report that the required room-coordination skill could not be loaded.`;
|
|
@@ -39789,7 +40075,7 @@ var roomCoordinatorConfig = {
|
|
|
39789
40075
|
key: ROOM_COORDINATOR_KEY,
|
|
39790
40076
|
name: "Room Coordinator",
|
|
39791
40077
|
description: "Manages project room conversations: replies when no bot is mentioned, coordinates room members, and organizes project work.",
|
|
39792
|
-
type:
|
|
40078
|
+
type: import_protocols42.AgentType.DEEP_AGENT,
|
|
39793
40079
|
prompt: ROOM_COORDINATOR_PROMPT,
|
|
39794
40080
|
tools: [],
|
|
39795
40081
|
middleware: [
|
|
@@ -39856,7 +40142,7 @@ function assistantToConfig(assistant) {
|
|
|
39856
40142
|
key: assistant.id,
|
|
39857
40143
|
name: assistant.name ?? graphDef.name ?? assistant.id,
|
|
39858
40144
|
description: assistant.description ?? graphDef.description ?? "",
|
|
39859
|
-
type:
|
|
40145
|
+
type: import_protocols26.AgentType.REACT,
|
|
39860
40146
|
prompt: typeof assistant.graphDefinition === "string" ? assistant.graphDefinition : JSON.stringify(assistant.graphDefinition)
|
|
39861
40147
|
};
|
|
39862
40148
|
Object.assign(config, graphDef);
|
|
@@ -40449,7 +40735,7 @@ function clearAuthProvidersForTests() {
|
|
|
40449
40735
|
|
|
40450
40736
|
// src/auth_lattice/IdentityMappingService.ts
|
|
40451
40737
|
var import_node_crypto11 = require("crypto");
|
|
40452
|
-
var
|
|
40738
|
+
var import_protocols43 = require("@axiom-lattice/protocols");
|
|
40453
40739
|
var IdentityMappingConfigError = class extends Error {
|
|
40454
40740
|
/**
|
|
40455
40741
|
* @param message - Human-readable configuration problem.
|
|
@@ -40532,7 +40818,7 @@ var IdentityMappingService = class {
|
|
|
40532
40818
|
return { kind: "not_provisioned", reason: "NO_MATCH" };
|
|
40533
40819
|
}
|
|
40534
40820
|
if (!email) {
|
|
40535
|
-
throw new
|
|
40821
|
+
throw new import_protocols43.AuthError("EMAIL_REQUIRED", 400, "OIDC identity has no email");
|
|
40536
40822
|
}
|
|
40537
40823
|
const avatarUrl = avatarUrlFromPrincipal(principal);
|
|
40538
40824
|
let createdUser;
|
|
@@ -40546,7 +40832,7 @@ var IdentityMappingService = class {
|
|
|
40546
40832
|
} catch {
|
|
40547
40833
|
const recovered = await this.recoverJitRace(principal, email);
|
|
40548
40834
|
if (!recovered) {
|
|
40549
|
-
throw new
|
|
40835
|
+
throw new import_protocols43.AuthError(
|
|
40550
40836
|
"PROVIDER_ERROR",
|
|
40551
40837
|
502,
|
|
40552
40838
|
"OIDC JIT provisioning failed"
|
|
@@ -40571,7 +40857,7 @@ var IdentityMappingService = class {
|
|
|
40571
40857
|
try {
|
|
40572
40858
|
await this.deps.externalIdentityStore.link(identity);
|
|
40573
40859
|
} catch (error) {
|
|
40574
|
-
if (!(error instanceof
|
|
40860
|
+
if (!(error instanceof import_protocols43.ExternalIdentityConflictError)) {
|
|
40575
40861
|
await this.deleteUserQuietly(createdUser.id);
|
|
40576
40862
|
throw error;
|
|
40577
40863
|
}
|
|
@@ -40601,7 +40887,7 @@ var IdentityMappingService = class {
|
|
|
40601
40887
|
} catch (error) {
|
|
40602
40888
|
await this.unlinkQuietly(providerId, issuer, principal.subject);
|
|
40603
40889
|
await this.deleteUserQuietly(user.id);
|
|
40604
|
-
throw error instanceof
|
|
40890
|
+
throw error instanceof import_protocols43.AuthError ? error : new import_protocols43.AuthError(
|
|
40605
40891
|
"PROVIDER_ERROR",
|
|
40606
40892
|
502,
|
|
40607
40893
|
"Failed to link the default tenant during JIT provisioning"
|
|
@@ -40612,7 +40898,7 @@ var IdentityMappingService = class {
|
|
|
40612
40898
|
}
|
|
40613
40899
|
}
|
|
40614
40900
|
if (!user) {
|
|
40615
|
-
throw new
|
|
40901
|
+
throw new import_protocols43.AuthError("PROVIDER_ERROR", 502, "OIDC JIT provisioning failed");
|
|
40616
40902
|
}
|
|
40617
40903
|
user = await this.syncOidcAvatar(user, principal);
|
|
40618
40904
|
if (user.status === "pending") return { kind: "pending", user, created };
|
|
@@ -40626,7 +40912,7 @@ var IdentityMappingService = class {
|
|
|
40626
40912
|
principal.subject
|
|
40627
40913
|
);
|
|
40628
40914
|
if (!linked) {
|
|
40629
|
-
throw new
|
|
40915
|
+
throw new import_protocols43.AuthError("PROVIDER_ERROR", 502, "External identity was not linked");
|
|
40630
40916
|
}
|
|
40631
40917
|
return { kind: "authenticated", user, externalIdentity: linked };
|
|
40632
40918
|
}
|
|
@@ -40831,7 +41117,7 @@ var getVectorStoreClient = (key6) => vectorStoreLatticeManager.getVectorStoreCli
|
|
|
40831
41117
|
|
|
40832
41118
|
// src/logger_lattice/LoggerLatticeManager.ts
|
|
40833
41119
|
init_BaseLatticeManager();
|
|
40834
|
-
var
|
|
41120
|
+
var import_protocols44 = require("@axiom-lattice/protocols");
|
|
40835
41121
|
|
|
40836
41122
|
// src/logger_lattice/PinoLoggerClient.ts
|
|
40837
41123
|
var import_pino2 = __toESM(require("pino"));
|
|
@@ -41034,11 +41320,11 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
|
|
|
41034
41320
|
if (client) {
|
|
41035
41321
|
loggerClient = client;
|
|
41036
41322
|
} else {
|
|
41037
|
-
if (config.type ===
|
|
41323
|
+
if (config.type === import_protocols44.LoggerType.PINO) {
|
|
41038
41324
|
loggerClient = new PinoLoggerClient(config);
|
|
41039
|
-
} else if (config.type ===
|
|
41325
|
+
} else if (config.type === import_protocols44.LoggerType.CONSOLE) {
|
|
41040
41326
|
loggerClient = new ConsoleLoggerClient(config);
|
|
41041
|
-
} else if (config.type ===
|
|
41327
|
+
} else if (config.type === import_protocols44.LoggerType.CUSTOM) {
|
|
41042
41328
|
throw new Error(
|
|
41043
41329
|
`Custom logger client must be provided. Please pass the client to registerLattice.`
|
|
41044
41330
|
);
|
|
@@ -41857,10 +42143,23 @@ var MicrosandboxRemoteInstance = class {
|
|
|
41857
42143
|
);
|
|
41858
42144
|
},
|
|
41859
42145
|
downloadFile: async (params) => {
|
|
41860
|
-
const
|
|
41861
|
-
|
|
41862
|
-
|
|
41863
|
-
|
|
42146
|
+
const normalized = normalizeExternalSandboxPath(params.file);
|
|
42147
|
+
const rawClient = this.client;
|
|
42148
|
+
if (typeof rawClient.downloadFileRaw === "function") {
|
|
42149
|
+
try {
|
|
42150
|
+
return await rawClient.downloadFileRaw(this.name, normalized);
|
|
42151
|
+
} catch (err) {
|
|
42152
|
+
const statusCode = err.statusCode;
|
|
42153
|
+
const code = err.code;
|
|
42154
|
+
if (statusCode !== 404 && statusCode !== 405) {
|
|
42155
|
+
throw err;
|
|
42156
|
+
}
|
|
42157
|
+
if (code) {
|
|
42158
|
+
throw err;
|
|
42159
|
+
}
|
|
42160
|
+
}
|
|
42161
|
+
}
|
|
42162
|
+
const result = await this.client.downloadFile(this.name, normalized);
|
|
41864
42163
|
if (result.contentBase64) {
|
|
41865
42164
|
return Buffer.from(result.contentBase64, "base64");
|
|
41866
42165
|
}
|
|
@@ -42052,6 +42351,45 @@ var MicrosandboxServiceClient = class {
|
|
|
42052
42351
|
method: "GET"
|
|
42053
42352
|
});
|
|
42054
42353
|
}
|
|
42354
|
+
/**
|
|
42355
|
+
* Download file bytes using the binary route.
|
|
42356
|
+
*
|
|
42357
|
+
* Avoids the base64/JSON envelope (2-3x memory amplification). Callers should
|
|
42358
|
+
* fall back to {@link downloadFile} when this route is unavailable (older
|
|
42359
|
+
* gateway).
|
|
42360
|
+
*/
|
|
42361
|
+
async downloadFileRaw(sandboxName, path8) {
|
|
42362
|
+
const query = new URLSearchParams({ sandboxName, path: path8 });
|
|
42363
|
+
const headers = {};
|
|
42364
|
+
if (this.apiKey) {
|
|
42365
|
+
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
42366
|
+
}
|
|
42367
|
+
const response = await fetch(`${this.baseURL}/api/files/download/raw?${query.toString()}`, {
|
|
42368
|
+
headers
|
|
42369
|
+
});
|
|
42370
|
+
if (!response.ok) {
|
|
42371
|
+
let detail = `${response.status} ${response.statusText}`;
|
|
42372
|
+
let code;
|
|
42373
|
+
try {
|
|
42374
|
+
const errorBody = await response.json();
|
|
42375
|
+
const responseError = errorBody.error;
|
|
42376
|
+
if (typeof responseError === "object" && responseError) {
|
|
42377
|
+
detail = responseError.message ?? detail;
|
|
42378
|
+
code = responseError.code;
|
|
42379
|
+
} else if (responseError) {
|
|
42380
|
+
detail = responseError;
|
|
42381
|
+
}
|
|
42382
|
+
} catch {
|
|
42383
|
+
}
|
|
42384
|
+
const error = new Error(`Microsandbox service request failed: ${detail}`);
|
|
42385
|
+
error.statusCode = response.status;
|
|
42386
|
+
if (code) {
|
|
42387
|
+
error.code = code;
|
|
42388
|
+
}
|
|
42389
|
+
throw error;
|
|
42390
|
+
}
|
|
42391
|
+
return Buffer.from(await response.arrayBuffer());
|
|
42392
|
+
}
|
|
42055
42393
|
async execCommand(input) {
|
|
42056
42394
|
return this.request("/api/shell/exec", {
|
|
42057
42395
|
method: "POST",
|
|
@@ -42270,6 +42608,14 @@ var MicrosandboxRemoteProvider = class {
|
|
|
42270
42608
|
image,
|
|
42271
42609
|
cpus: this.config.cpus ?? defaultMicrosandboxRemoteConfig.cpus,
|
|
42272
42610
|
memoryMib: this.config.memoryMib ?? defaultMicrosandboxRemoteConfig.memoryMib,
|
|
42611
|
+
requests: config.requests,
|
|
42612
|
+
snapshotId: config.snapshotId,
|
|
42613
|
+
secureAccess: config.secureAccess,
|
|
42614
|
+
networkPolicy: config.networkPolicy,
|
|
42615
|
+
credentialProxy: config.credentialProxy,
|
|
42616
|
+
extensions: config.extensions,
|
|
42617
|
+
platform: config.platform,
|
|
42618
|
+
metadata: config.metadata,
|
|
42273
42619
|
env: {
|
|
42274
42620
|
...this.config.env,
|
|
42275
42621
|
...buildSandboxMetadataEnv(config)
|
|
@@ -45126,7 +45472,7 @@ var LatticeEvalSuite = class {
|
|
|
45126
45472
|
};
|
|
45127
45473
|
|
|
45128
45474
|
// src/eval_lattice/LatticeEvalProject.ts
|
|
45129
|
-
var
|
|
45475
|
+
var import_protocols45 = require("@axiom-lattice/protocols");
|
|
45130
45476
|
var import_messages8 = require("@langchain/core/messages");
|
|
45131
45477
|
var import_uuid10 = require("uuid");
|
|
45132
45478
|
var DEFAULT_CALIBRATION_PROBES = [
|
|
@@ -45186,7 +45532,7 @@ var LatticeEvalProject = class {
|
|
|
45186
45532
|
key: this.judgeAgentKey,
|
|
45187
45533
|
name: `Judge agent for ${this.project.projectName}`,
|
|
45188
45534
|
description: "Judge agent for evaluating Lattice test cases",
|
|
45189
|
-
type:
|
|
45535
|
+
type: import_protocols45.AgentType.REACT,
|
|
45190
45536
|
prompt: "",
|
|
45191
45537
|
modelKey: judgeModelKey
|
|
45192
45538
|
};
|
|
@@ -45412,7 +45758,7 @@ function getMenuRegistry() {
|
|
|
45412
45758
|
}
|
|
45413
45759
|
|
|
45414
45760
|
// src/services/ProjectTaskReassignmentAuthorization.ts
|
|
45415
|
-
var
|
|
45761
|
+
var import_protocols46 = require("@axiom-lattice/protocols");
|
|
45416
45762
|
var issued = /* @__PURE__ */ new WeakMap();
|
|
45417
45763
|
function createProjectTaskReassignmentAuthorizer(policy, threadValidator) {
|
|
45418
45764
|
return {
|
|
@@ -45445,7 +45791,7 @@ function inspectProjectTaskReassignmentAuthorization(authorization) {
|
|
|
45445
45791
|
return snapshot ? { ...snapshot } : void 0;
|
|
45446
45792
|
}
|
|
45447
45793
|
function snapshotInput(input) {
|
|
45448
|
-
const row = (0,
|
|
45794
|
+
const row = (0, import_protocols46.snapshotExactRecord)(input, [
|
|
45449
45795
|
"tenantId",
|
|
45450
45796
|
"workspaceId",
|
|
45451
45797
|
"projectId",
|
|
@@ -45488,7 +45834,7 @@ function snapshotInput(input) {
|
|
|
45488
45834
|
}
|
|
45489
45835
|
|
|
45490
45836
|
// src/services/TaskLifecycleNotifier.ts
|
|
45491
|
-
var
|
|
45837
|
+
var import_protocols47 = require("@axiom-lattice/protocols");
|
|
45492
45838
|
var TaskLifecycleNotifier = class {
|
|
45493
45839
|
constructor() {
|
|
45494
45840
|
this.listeners = /* @__PURE__ */ new Set();
|
|
@@ -45555,7 +45901,7 @@ var TaskLifecycleNotifier = class {
|
|
|
45555
45901
|
};
|
|
45556
45902
|
var taskLifecycleNotifier = new TaskLifecycleNotifier();
|
|
45557
45903
|
function snapshotNotification(value) {
|
|
45558
|
-
const row = (0,
|
|
45904
|
+
const row = (0, import_protocols47.snapshotExactRecord)(value, [
|
|
45559
45905
|
"tenantId",
|
|
45560
45906
|
"workspaceId",
|
|
45561
45907
|
"projectId",
|
|
@@ -45587,7 +45933,7 @@ function nonempty(value) {
|
|
|
45587
45933
|
}
|
|
45588
45934
|
|
|
45589
45935
|
// src/services/ProjectTaskAdmissionNotifier.ts
|
|
45590
|
-
var
|
|
45936
|
+
var import_protocols48 = require("@axiom-lattice/protocols");
|
|
45591
45937
|
var ProjectTaskAdmissionNotifier = class {
|
|
45592
45938
|
/**
|
|
45593
45939
|
* Creates a bounded Project task admission notifier.
|
|
@@ -45688,7 +46034,7 @@ var ProjectTaskAdmissionNotifier = class {
|
|
|
45688
46034
|
};
|
|
45689
46035
|
var projectTaskAdmissionNotifier = new ProjectTaskAdmissionNotifier();
|
|
45690
46036
|
function snapshotNotification2(value) {
|
|
45691
|
-
const row = (0,
|
|
46037
|
+
const row = (0, import_protocols48.snapshotExactRecord)(value, [
|
|
45692
46038
|
"tenantId",
|
|
45693
46039
|
"workspaceId",
|
|
45694
46040
|
"projectId",
|
|
@@ -45791,7 +46137,7 @@ var OutboxPoller = class {
|
|
|
45791
46137
|
|
|
45792
46138
|
// src/services/ProjectMutationMutex.ts
|
|
45793
46139
|
var import_node_async_hooks2 = require("async_hooks");
|
|
45794
|
-
var
|
|
46140
|
+
var import_protocols49 = require("@axiom-lattice/protocols");
|
|
45795
46141
|
|
|
45796
46142
|
// src/services/coordinationLease.ts
|
|
45797
46143
|
var configured;
|
|
@@ -45850,7 +46196,7 @@ async function withLease(store2, key6, ownerLabel, fn, options = {}) {
|
|
|
45850
46196
|
// src/services/ProjectMutationMutex.ts
|
|
45851
46197
|
var MUTATION_LEASE_OPTIONS = { ttlMs: 6e4, acquireTimeoutMs: 9e4, retryDelayMs: 100 };
|
|
45852
46198
|
function projectKey(scope) {
|
|
45853
|
-
const row = (0,
|
|
46199
|
+
const row = (0, import_protocols49.snapshotExactRecord)(scope, ["tenantId", "projectId"]);
|
|
45854
46200
|
if (!row || typeof row.tenantId !== "string" || !row.tenantId || row.tenantId.includes("\0") || typeof row.projectId !== "string" || !row.projectId || row.projectId.includes("\0")) {
|
|
45855
46201
|
throw new Error("Invalid Project mutation scope");
|
|
45856
46202
|
}
|
|
@@ -45936,7 +46282,7 @@ function createTrustedAgentMessageDispatcher(resolve4) {
|
|
|
45936
46282
|
|
|
45937
46283
|
// src/services/RoomAgentMessageService.ts
|
|
45938
46284
|
var import_crypto10 = require("crypto");
|
|
45939
|
-
var
|
|
46285
|
+
var import_protocols50 = require("@axiom-lattice/protocols");
|
|
45940
46286
|
var INPUT_KEYS = [
|
|
45941
46287
|
"tenantId",
|
|
45942
46288
|
"workspaceId",
|
|
@@ -46101,7 +46447,7 @@ var RoomAgentMessageService = class {
|
|
|
46101
46447
|
function exactValues(value, required, optional = []) {
|
|
46102
46448
|
try {
|
|
46103
46449
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
46104
|
-
return (0,
|
|
46450
|
+
return (0, import_protocols50.snapshotExactRecord)(value, required, optional);
|
|
46105
46451
|
} catch {
|
|
46106
46452
|
return void 0;
|
|
46107
46453
|
}
|
|
@@ -46153,7 +46499,7 @@ function sourceOriginMatches(author, source) {
|
|
|
46153
46499
|
return false;
|
|
46154
46500
|
}
|
|
46155
46501
|
function snapshotMentions(value) {
|
|
46156
|
-
const rows = (0,
|
|
46502
|
+
const rows = (0, import_protocols50.snapshotExactArray)(value);
|
|
46157
46503
|
if (!rows) return void 0;
|
|
46158
46504
|
const mentions = [];
|
|
46159
46505
|
for (const row of rows) {
|
|
@@ -46181,7 +46527,7 @@ function snapshotCanonical(value, expected) {
|
|
|
46181
46527
|
const author = exactValues(values?.author, ["type", "membershipId", "assistantId"]);
|
|
46182
46528
|
const content = exactValues(values?.content, ["type", "text"]);
|
|
46183
46529
|
const createdAt = date(values?.createdAt);
|
|
46184
|
-
if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0,
|
|
46530
|
+
if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0, import_protocols50.snapshotExactArray)(values.mentions)?.length !== 0 || author?.type !== "bot" || expected.author.type !== "bot" || author.membershipId !== expected.author.membershipId || author.assistantId !== expected.author.assistantId || content?.type !== "text" || content.text !== expected.content.text || values.tenantId !== expected.tenantId || values.workspaceId !== expected.workspaceId || values.projectId !== expected.projectId || values.roomId !== expected.roomId || values.replyToMessageId !== expected.replyToMessageId || values.source !== "agent" || values.sourceId !== expected.sourceId || values.idempotencyKey !== expected.idempotencyKey) return void 0;
|
|
46185
46531
|
return {
|
|
46186
46532
|
id: values.id,
|
|
46187
46533
|
tenantId: expected.tenantId,
|
|
@@ -46203,7 +46549,7 @@ function snapshotCanonicalScoped(value, expected) {
|
|
|
46203
46549
|
const author = exactValues(values?.author, ["type", "membershipId", "assistantId"]);
|
|
46204
46550
|
const content = exactValues(values?.content, ["type", "text"]);
|
|
46205
46551
|
const createdAt = date(values?.createdAt);
|
|
46206
|
-
if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0,
|
|
46552
|
+
if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0, import_protocols50.snapshotExactArray)(values.mentions)?.length !== 0 || author?.type !== "bot" || expected.author.type !== "bot" || author.membershipId !== expected.author.membershipId || author.assistantId !== expected.author.assistantId || content?.type !== "text" || content.text !== expected.content.text || values.tenantId !== expected.tenantId || values.workspaceId !== expected.workspaceId || values.projectId !== expected.projectId || values.roomId !== expected.roomId || values.source !== "agent" || values.sourceId !== expected.sourceId || values.idempotencyKey !== expected.idempotencyKey) return void 0;
|
|
46207
46553
|
return {
|
|
46208
46554
|
id: values.id,
|
|
46209
46555
|
tenantId: expected.tenantId,
|
|
@@ -46257,7 +46603,7 @@ var ProjectRoomMessageNotifier = class {
|
|
|
46257
46603
|
var projectRoomMessageNotifier = new ProjectRoomMessageNotifier();
|
|
46258
46604
|
|
|
46259
46605
|
// src/services/ProjectTaskOwnerPolicy.ts
|
|
46260
|
-
var
|
|
46606
|
+
var import_protocols51 = require("@axiom-lattice/protocols");
|
|
46261
46607
|
var MEMBERSHIP_REQUIRED_KEYS = [
|
|
46262
46608
|
"id",
|
|
46263
46609
|
"tenantId",
|
|
@@ -46366,7 +46712,7 @@ function sameRosterScope(membership, scope) {
|
|
|
46366
46712
|
return membership.tenantId === scope.tenantId && membership.workspaceId === scope.workspaceId && membership.projectId === scope.projectId && membership.roomId === scope.roomId;
|
|
46367
46713
|
}
|
|
46368
46714
|
function snapshotScope(value, keys) {
|
|
46369
|
-
const values = (0,
|
|
46715
|
+
const values = (0, import_protocols51.snapshotExactRecord)(value, keys);
|
|
46370
46716
|
if (!values || keys.some((key6) => !isNonemptyString(values[key6]))) return void 0;
|
|
46371
46717
|
return values;
|
|
46372
46718
|
}
|
|
@@ -46378,7 +46724,7 @@ function projectScope(scope, keys) {
|
|
|
46378
46724
|
function snapshotMembership2(value) {
|
|
46379
46725
|
try {
|
|
46380
46726
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
46381
|
-
const values = (0,
|
|
46727
|
+
const values = (0, import_protocols51.snapshotExactRecord)(value, MEMBERSHIP_REQUIRED_KEYS, ["responsibility"]);
|
|
46382
46728
|
if (!values) return void 0;
|
|
46383
46729
|
const joinedAt = snapshotDate(values.joinedAt);
|
|
46384
46730
|
const updatedAt = snapshotDate(values.updatedAt);
|
|
@@ -46697,7 +47043,7 @@ function describe(error) {
|
|
|
46697
47043
|
|
|
46698
47044
|
// src/services/TaskLifecycleService.ts
|
|
46699
47045
|
var import_node_crypto17 = require("crypto");
|
|
46700
|
-
var
|
|
47046
|
+
var import_protocols52 = require("@axiom-lattice/protocols");
|
|
46701
47047
|
|
|
46702
47048
|
// src/middlewares/taskBelief.ts
|
|
46703
47049
|
var import_node_crypto16 = require("crypto");
|
|
@@ -46770,7 +47116,7 @@ async function applyBeliefImpacts(taskStore, owner3, impacts) {
|
|
|
46770
47116
|
if (impacts.length === 0) return { description: owner3.description ?? "" };
|
|
46771
47117
|
let current = owner3;
|
|
46772
47118
|
for (let attempt = 0; attempt < BELIEF_OWNER_WRITE_ATTEMPTS; attempt += 1) {
|
|
46773
|
-
const parsed = (0,
|
|
47119
|
+
const parsed = (0, import_protocols52.parseTaskBeliefState)(current.description ?? "");
|
|
46774
47120
|
const existingTable = parsed.success;
|
|
46775
47121
|
if (!existingTable && parsed.code !== "MISSING_BELIEF_STATE") {
|
|
46776
47122
|
return { description: current.description ?? "", task: current };
|
|
@@ -46787,7 +47133,7 @@ async function applyBeliefImpacts(taskStore, owner3, impacts) {
|
|
|
46787
47133
|
changed = true;
|
|
46788
47134
|
}
|
|
46789
47135
|
if (!changed) return { description: current.description ?? "", task: current };
|
|
46790
|
-
const description = (0,
|
|
47136
|
+
const description = (0, import_protocols52.replaceTaskBeliefState)(current.description ?? "", { entries });
|
|
46791
47137
|
try {
|
|
46792
47138
|
const updated = await taskStore.updateIfStatusAndUpdatedAt(
|
|
46793
47139
|
current.tenantId,
|
|
@@ -46892,7 +47238,7 @@ function beliefStateOf(value) {
|
|
|
46892
47238
|
function sameBeliefOwner(left, right) {
|
|
46893
47239
|
const leftIdentity = { ...left, beliefState: void 0 };
|
|
46894
47240
|
const rightIdentity = { ...right, beliefState: void 0 };
|
|
46895
|
-
return canonicalJson(leftIdentity) === canonicalJson(rightIdentity) && (0,
|
|
47241
|
+
return canonicalJson(leftIdentity) === canonicalJson(rightIdentity) && (0, import_protocols52.taskBeliefStatesEqual)(left.beliefState, right.beliefState);
|
|
46896
47242
|
}
|
|
46897
47243
|
function sameBeliefOwnerIdentity(left, right) {
|
|
46898
47244
|
return canonicalJson({ ...left, beliefState: void 0 }) === canonicalJson({ ...right, beliefState: void 0 });
|
|
@@ -47040,7 +47386,7 @@ function changedBeliefKeys(left, right) {
|
|
|
47040
47386
|
return [...keys].filter((key6) => {
|
|
47041
47387
|
const oldEntry = leftByKey.get(key6);
|
|
47042
47388
|
const newEntry = rightByKey.get(key6);
|
|
47043
|
-
return !oldEntry || !newEntry || !(0,
|
|
47389
|
+
return !oldEntry || !newEntry || !(0, import_protocols52.taskBeliefStatesEqual)(
|
|
47044
47390
|
{ entries: [oldEntry] },
|
|
47045
47391
|
{ entries: [newEntry] }
|
|
47046
47392
|
);
|
|
@@ -48142,10 +48488,10 @@ var TaskLifecycleService = class {
|
|
|
48142
48488
|
const description = preserveTargetContract(existing.description ?? "", input.description);
|
|
48143
48489
|
const pending = existing.context?.belief_reconciliation_audit;
|
|
48144
48490
|
const pendingAudit = pending && typeof pending === "object" ? pending : void 0;
|
|
48145
|
-
const oldBelief = (0,
|
|
48146
|
-
const newBelief = (0,
|
|
48491
|
+
const oldBelief = (0, import_protocols52.parseTaskBeliefState)(existing.description ?? "");
|
|
48492
|
+
const newBelief = (0, import_protocols52.parseTaskBeliefState)(description);
|
|
48147
48493
|
if (!newBelief.success) return failure2("INVALID_BELIEF_TABLE", newBelief.message);
|
|
48148
|
-
if (!pendingAudit && description === (existing.description ?? "") && oldBelief.success && (0,
|
|
48494
|
+
if (!pendingAudit && description === (existing.description ?? "") && oldBelief.success && (0, import_protocols52.taskBeliefStatesEqual)(oldBelief.state, newBelief.state)) {
|
|
48149
48495
|
return { success: true, task: existing, mutated: false };
|
|
48150
48496
|
}
|
|
48151
48497
|
const canonicalNew = newBelief.state.entries;
|
|
@@ -48276,7 +48622,7 @@ var TaskLifecycleService = class {
|
|
|
48276
48622
|
}
|
|
48277
48623
|
beliefOwnerSnapshot(task, parent) {
|
|
48278
48624
|
const owner3 = parent?.ownerType === "agent" ? parent : task;
|
|
48279
|
-
const parsed = (0,
|
|
48625
|
+
const parsed = (0, import_protocols52.parseTaskBeliefState)(owner3.description ?? "");
|
|
48280
48626
|
const beliefState = parsed.success ? parsed.state : { entries: [] };
|
|
48281
48627
|
if (parent?.ownerType === "agent") {
|
|
48282
48628
|
return {
|
|
@@ -48998,7 +49344,7 @@ function createTaskLifecycleService(deps) {
|
|
|
48998
49344
|
// src/services/TaskExecutionService.ts
|
|
48999
49345
|
var import_node_crypto19 = require("crypto");
|
|
49000
49346
|
var import_node_util3 = require("util");
|
|
49001
|
-
var
|
|
49347
|
+
var import_protocols53 = require("@axiom-lattice/protocols");
|
|
49002
49348
|
|
|
49003
49349
|
// src/services/taskErrorMessage.ts
|
|
49004
49350
|
var MAX_EXECUTION_ERROR_MESSAGE_LENGTH = 1024;
|
|
@@ -49794,7 +50140,7 @@ function createTaskExecutionService(deps) {
|
|
|
49794
50140
|
};
|
|
49795
50141
|
}
|
|
49796
50142
|
const eventKey = runId ? `execution-result:${threadId}:${runId}` : `execution-result:${threadId}`;
|
|
49797
|
-
if (!(0,
|
|
50143
|
+
if (!(0, import_protocols53.isExecutionResultEventKey)(eventKey)) {
|
|
49798
50144
|
return {
|
|
49799
50145
|
success: false,
|
|
49800
50146
|
code: "INVALID_EXECUTION_RESULT_ID",
|
|
@@ -50766,7 +51112,7 @@ var createListCollectionsTool = ({
|
|
|
50766
51112
|
// src/tool_lattice/collection/search_collection.ts
|
|
50767
51113
|
var import_zod60 = __toESM(require("zod"));
|
|
50768
51114
|
var import_langchain67 = require("langchain");
|
|
50769
|
-
var
|
|
51115
|
+
var import_protocols54 = require("@axiom-lattice/protocols");
|
|
50770
51116
|
var SEARCH_COLLECTION_DESCRIPTION = `Search for content within a specific collection using semantic (vector) similarity. Use the 'filter' parameter to narrow results by metadata fields (e.g., {"category": "cardiovascular"}). Returns the most relevant content entries with similarity scores.`;
|
|
50771
51117
|
var searchSchema = import_zod60.default.object({
|
|
50772
51118
|
collection: import_zod60.default.string().describe("The collection name to search in"),
|
|
@@ -50786,7 +51132,7 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
|
|
|
50786
51132
|
if (!metadata) {
|
|
50787
51133
|
return `Collection "${collection}" not found. Use list_collections to see available collections.`;
|
|
50788
51134
|
}
|
|
50789
|
-
const embeddingKey = metadata.embeddingKey ||
|
|
51135
|
+
const embeddingKey = metadata.embeddingKey || import_protocols54.EMBEDDING_DEFAULT_KEY;
|
|
50790
51136
|
let vectorStore;
|
|
50791
51137
|
try {
|
|
50792
51138
|
const storeKey = `${tenantId2}:${collection}`;
|
|
@@ -50801,9 +51147,9 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
|
|
|
50801
51147
|
const embeddingsClient = await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
50802
51148
|
tenantId2,
|
|
50803
51149
|
embeddingKey
|
|
50804
|
-
) ?? (embeddingKey ===
|
|
51150
|
+
) ?? (embeddingKey === import_protocols54.EMBEDDING_DEFAULT_KEY ? void 0 : await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
50805
51151
|
tenantId2,
|
|
50806
|
-
|
|
51152
|
+
import_protocols54.EMBEDDING_DEFAULT_KEY
|
|
50807
51153
|
)) ?? await embeddingsLatticeManager.getEmbeddingsClientWithTenant(
|
|
50808
51154
|
tenantId2,
|
|
50809
51155
|
"default"
|
|
@@ -51014,7 +51360,7 @@ var import_zod66 = __toESM(require("zod"));
|
|
|
51014
51360
|
var import_langchain73 = require("langchain");
|
|
51015
51361
|
var import_documents = require("@langchain/core/documents");
|
|
51016
51362
|
var import_uuid11 = require("uuid");
|
|
51017
|
-
var
|
|
51363
|
+
var import_protocols55 = require("@axiom-lattice/protocols");
|
|
51018
51364
|
var schema3 = import_zod66.default.object({
|
|
51019
51365
|
collection: import_zod66.default.string().describe("Collection name"),
|
|
51020
51366
|
entries: import_zod66.default.array(
|
|
@@ -51024,7 +51370,7 @@ var schema3 = import_zod66.default.object({
|
|
|
51024
51370
|
}).describe("Entry content text"),
|
|
51025
51371
|
metadata: import_zod66.default.record(import_zod66.default.string(), import_zod66.default.unknown()).optional().describe("Metadata fields matching the collection schema")
|
|
51026
51372
|
})
|
|
51027
|
-
).min(1).max(
|
|
51373
|
+
).min(1).max(import_protocols55.COLLECTION_ENTRY_BATCH_MAX)
|
|
51028
51374
|
});
|
|
51029
51375
|
function key3(tenantId2, collection) {
|
|
51030
51376
|
return `${tenantId2}:${collection}`;
|
|
@@ -51140,14 +51486,14 @@ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
|
|
|
51140
51486
|
// src/tool_lattice/collection/delete_entries.ts
|
|
51141
51487
|
var import_zod68 = __toESM(require("zod"));
|
|
51142
51488
|
var import_langchain75 = require("langchain");
|
|
51143
|
-
var
|
|
51489
|
+
var import_protocols56 = require("@axiom-lattice/protocols");
|
|
51144
51490
|
var schema5 = import_zod68.default.object({
|
|
51145
51491
|
collection: import_zod68.default.string().describe("Collection name"),
|
|
51146
51492
|
entryIds: import_zod68.default.array(
|
|
51147
51493
|
import_zod68.default.string().refine((value) => value.trim().length > 0, {
|
|
51148
51494
|
message: "entry id must not be blank"
|
|
51149
51495
|
}).describe("Entry ID to delete")
|
|
51150
|
-
).min(1).max(
|
|
51496
|
+
).min(1).max(import_protocols56.COLLECTION_ENTRY_BATCH_MAX)
|
|
51151
51497
|
});
|
|
51152
51498
|
function key5(tenantId2, collection) {
|
|
51153
51499
|
return `${tenantId2}:${collection}`;
|
|
@@ -52404,15 +52750,15 @@ var widgetPlugin = {
|
|
|
52404
52750
|
var import_langchain82 = require("langchain");
|
|
52405
52751
|
var import_zod72 = require("zod");
|
|
52406
52752
|
var import_langgraph13 = require("@langchain/langgraph");
|
|
52407
|
-
var
|
|
52753
|
+
var import_protocols58 = require("@axiom-lattice/protocols");
|
|
52408
52754
|
|
|
52409
52755
|
// src/services/taskWorkerRunConfig.ts
|
|
52410
|
-
var
|
|
52756
|
+
var import_protocols57 = require("@axiom-lattice/protocols");
|
|
52411
52757
|
function resolveWorkerRunScope(input) {
|
|
52412
|
-
const caller = (0,
|
|
52758
|
+
const caller = (0, import_protocols57.resolveRunScope)(input.runConfig);
|
|
52413
52759
|
return {
|
|
52414
|
-
workspaceId: (0,
|
|
52415
|
-
projectId: (0,
|
|
52760
|
+
workspaceId: (0, import_protocols57.firstNonEmptyString)(input.invocation.workspaceId) ?? caller.workspaceId,
|
|
52761
|
+
projectId: (0, import_protocols57.firstNonEmptyString)(input.invocation.projectId) ?? caller.projectId
|
|
52416
52762
|
};
|
|
52417
52763
|
}
|
|
52418
52764
|
function applyWorkerRunScope(runConfig, scope) {
|
|
@@ -52429,7 +52775,7 @@ function applyWorkerRunScope(runConfig, scope) {
|
|
|
52429
52775
|
}
|
|
52430
52776
|
|
|
52431
52777
|
// src/middlewares/taskMiddleware.ts
|
|
52432
|
-
var
|
|
52778
|
+
var import_protocols59 = require("@axiom-lattice/protocols");
|
|
52433
52779
|
|
|
52434
52780
|
// src/middlewares/taskResponseSerialization.ts
|
|
52435
52781
|
var TASK_RESPONSE_SCALAR_MAX_BYTES = 4096;
|
|
@@ -52734,7 +53080,7 @@ async function postProcessTaskMutationResponse(input) {
|
|
|
52734
53080
|
}
|
|
52735
53081
|
|
|
52736
53082
|
// src/middlewares/taskMiddleware.ts
|
|
52737
|
-
function
|
|
53083
|
+
function getRunConfig3(config) {
|
|
52738
53084
|
const c = config;
|
|
52739
53085
|
return c?.configurable?.runConfig ?? {};
|
|
52740
53086
|
}
|
|
@@ -52918,7 +53264,7 @@ function classifyTaskAuthority(runConfig) {
|
|
|
52918
53264
|
return delegatedTaskId ? { kind: "delegated", taskId: delegatedTaskId } : { kind: "ordinary" };
|
|
52919
53265
|
}
|
|
52920
53266
|
try {
|
|
52921
|
-
const trusted = (0,
|
|
53267
|
+
const trusted = (0, import_protocols59.parseTrustedRunContext)(hasProjectTask ? { projectTask: runConfig.projectTask } : { projectRoom: runConfig.projectRoom });
|
|
52922
53268
|
return { kind: hasProjectTask ? "projectTask" : "projectRoom", trusted };
|
|
52923
53269
|
} catch {
|
|
52924
53270
|
return { kind: "invalid" };
|
|
@@ -53266,7 +53612,7 @@ function getTaskWorkItemStore() {
|
|
|
53266
53612
|
return getStoreLattice("default", "taskWorkItem").store;
|
|
53267
53613
|
}
|
|
53268
53614
|
function getProjectTaskWorkItemStore() {
|
|
53269
|
-
return (0,
|
|
53615
|
+
return (0, import_protocols59.requireProjectTaskWorkItemStore)(getTaskWorkItemStore());
|
|
53270
53616
|
}
|
|
53271
53617
|
function reviewInterruption(task) {
|
|
53272
53618
|
const value = task.context?.interruption;
|
|
@@ -53317,7 +53663,7 @@ var manageTaskSchema = import_zod72.z.object({
|
|
|
53317
53663
|
})).optional().describe("Structured belief reports required when an agent-owned task completes; existing keys update the belief owner's table, and a brand-new key must be declared with isNew: true"),
|
|
53318
53664
|
content: import_zod72.z.string().optional().describe("Markdown content required for add_activity"),
|
|
53319
53665
|
summary: import_zod72.z.string().optional().describe("Brief summary of the operation"),
|
|
53320
|
-
executionResultId: import_zod72.z.string().refine(
|
|
53666
|
+
executionResultId: import_zod72.z.string().refine(import_protocols59.isExecutionResultEventKey, {
|
|
53321
53667
|
message: "executionResultId must be the execution-result:<threadId> event key returned by task()"
|
|
53322
53668
|
}).optional().describe(
|
|
53323
53669
|
"Canonical ASCII `execution-result:<suffix>` event key returned by task(); the nonempty suffix allows only A-Z, a-z, 0-9, period, underscore, colon, and hyphen, and is not a database row ID"
|
|
@@ -53382,7 +53728,7 @@ async function getPendingExecutionResultIds(store2, tenantId2, taskId) {
|
|
|
53382
53728
|
order: "desc",
|
|
53383
53729
|
limit: PENDING_EXECUTION_RESULT_LIMIT + 1
|
|
53384
53730
|
});
|
|
53385
|
-
const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0,
|
|
53731
|
+
const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0, import_protocols59.isExecutionResultEventKey)(item.eventKey));
|
|
53386
53732
|
const reconciliationRows = new Array(canonicalCandidates.length);
|
|
53387
53733
|
let nextCandidateIndex = 0;
|
|
53388
53734
|
let firstError;
|
|
@@ -53460,14 +53806,14 @@ function updateValuesEqual(field, requested, persisted) {
|
|
|
53460
53806
|
}
|
|
53461
53807
|
function createTaskMiddleware(options = {}) {
|
|
53462
53808
|
const handleManageTaskAction = async (input, config, validateExecutionResult, markMutation) => {
|
|
53463
|
-
const rc =
|
|
53809
|
+
const rc = getRunConfig3(config);
|
|
53464
53810
|
const authority = classifyTaskAuthority(rc);
|
|
53465
53811
|
if (authority.kind === "invalid") return trustedContextError();
|
|
53466
53812
|
const delegatedTaskId = authority.kind === "delegated" ? authority.taskId : void 0;
|
|
53467
53813
|
const trustedProject = authority.kind === "projectRoom" || authority.kind === "projectTask" ? authority.trusted : void 0;
|
|
53468
53814
|
const trustedScope = trustedProject?.projectTask ?? trustedProject?.projectRoom;
|
|
53469
53815
|
const tenantId2 = trustedScope?.tenantId ?? (rc.tenantId || "default");
|
|
53470
|
-
const runScope = (0,
|
|
53816
|
+
const runScope = (0, import_protocols58.resolveRunScope)(rc);
|
|
53471
53817
|
const workspaceId = trustedScope?.workspaceId ?? runScope.workspaceId;
|
|
53472
53818
|
const projectId = trustedScope?.projectId ?? runScope.projectId;
|
|
53473
53819
|
const revalidateCaller = async () => {
|
|
@@ -54041,8 +54387,8 @@ function createTaskMiddleware(options = {}) {
|
|
|
54041
54387
|
let reconciliationMetadata = {};
|
|
54042
54388
|
let descriptionMutated = false;
|
|
54043
54389
|
if (isAgentTask && input.description !== void 0 && !valuesEqual(input.description, existing.description)) {
|
|
54044
|
-
const oldBelief = (0,
|
|
54045
|
-
const newBelief = (0,
|
|
54390
|
+
const oldBelief = (0, import_protocols59.parseTaskBeliefState)(existing.description ?? "");
|
|
54391
|
+
const newBelief = (0, import_protocols59.parseTaskBeliefState)(input.description);
|
|
54046
54392
|
const hasBeliefState = oldBelief.success || newBelief.success;
|
|
54047
54393
|
if (hasBeliefState) {
|
|
54048
54394
|
await validateExecutionResult();
|
|
@@ -54588,7 +54934,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
54588
54934
|
};
|
|
54589
54935
|
const reconcileExplicitExecutionResult = async (input, config, response, validationError, didMutate) => {
|
|
54590
54936
|
if (input.action !== "update" && input.action !== "set_status" && input.action !== "add_activity" || !input.id) return response;
|
|
54591
|
-
const authority = classifyTaskAuthority(
|
|
54937
|
+
const authority = classifyTaskAuthority(getRunConfig3(config));
|
|
54592
54938
|
if (authority.kind === "projectRoom" || authority.kind === "projectTask" || authority.kind === "invalid") {
|
|
54593
54939
|
return response;
|
|
54594
54940
|
}
|
|
@@ -54601,7 +54947,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
54601
54947
|
mutationCommitted: didMutate,
|
|
54602
54948
|
validationError,
|
|
54603
54949
|
reconcile: async (parsed) => {
|
|
54604
|
-
const rc =
|
|
54950
|
+
const rc = getRunConfig3(config);
|
|
54605
54951
|
const tenantId2 = rc.tenantId || "default";
|
|
54606
54952
|
const workItemStore = getTaskWorkItemStore();
|
|
54607
54953
|
const task = await getTaskStore().getById(tenantId2, taskId);
|
|
@@ -54630,11 +54976,11 @@ function createTaskMiddleware(options = {}) {
|
|
|
54630
54976
|
let didMutate = false;
|
|
54631
54977
|
const validateExecutionResult = async () => {
|
|
54632
54978
|
if (!input.executionResultId || validationAttempted) return;
|
|
54633
|
-
const authority = classifyTaskAuthority(
|
|
54979
|
+
const authority = classifyTaskAuthority(getRunConfig3(config));
|
|
54634
54980
|
if (authority.kind === "projectRoom" || authority.kind === "projectTask" || authority.kind === "invalid") return;
|
|
54635
54981
|
validationAttempted = true;
|
|
54636
54982
|
try {
|
|
54637
|
-
const rc =
|
|
54983
|
+
const rc = getRunConfig3(config);
|
|
54638
54984
|
const tenantId2 = rc.tenantId || "default";
|
|
54639
54985
|
const workItemStore = getTaskWorkItemStore();
|
|
54640
54986
|
const executionResult = await workItemStore.findByEventKey(
|
|
@@ -54684,7 +55030,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
54684
55030
|
);
|
|
54685
55031
|
};
|
|
54686
55032
|
const handleStartTask = async (input, config) => {
|
|
54687
|
-
const rc =
|
|
55033
|
+
const rc = getRunConfig3(config);
|
|
54688
55034
|
const authority = classifyTaskAuthority(rc);
|
|
54689
55035
|
if (authority.kind === "invalid") return trustedContextError();
|
|
54690
55036
|
if (authority.kind === "delegated") {
|
|
@@ -55550,7 +55896,7 @@ function createParseDocumentTool({
|
|
|
55550
55896
|
}
|
|
55551
55897
|
|
|
55552
55898
|
// src/middlewares/documentParserMiddleware.ts
|
|
55553
|
-
var
|
|
55899
|
+
var import_protocols60 = require("@axiom-lattice/protocols");
|
|
55554
55900
|
|
|
55555
55901
|
// src/middlewares/documentBenchmarkWorkflow.ts
|
|
55556
55902
|
var DOCUMENT_PARSER_BENCHMARK_YAML = `name: document-parser-benchmark
|
|
@@ -56092,7 +56438,7 @@ var documentParserPlugin = {
|
|
|
56092
56438
|
agents: {
|
|
56093
56439
|
"document-parser": {
|
|
56094
56440
|
key: "document-parser",
|
|
56095
|
-
type:
|
|
56441
|
+
type: import_protocols60.AgentType.DEEP_AGENT,
|
|
56096
56442
|
name: "Document Parser",
|
|
56097
56443
|
description: "Parse documents (pdf, docx, images, spreadsheets) into clean Markdown. Defaults to local MarkItDown; escalates to remote engines only when quality or format needs it; runs engine benchmarking only on explicit request.",
|
|
56098
56444
|
prompt: DOCUMENT_PARSER_SYSTEM_PROMPT,
|
|
@@ -56142,7 +56488,7 @@ var documentParserPlugin = {
|
|
|
56142
56488
|
},
|
|
56143
56489
|
"document-parser-benchmark": {
|
|
56144
56490
|
key: "document-parser-benchmark",
|
|
56145
|
-
type:
|
|
56491
|
+
type: import_protocols60.AgentType.WORKFLOW,
|
|
56146
56492
|
name: "Document Parser Benchmark",
|
|
56147
56493
|
description: "Benchmark document parsing engines. Parses a document with 5 engines in parallel, scores results, and produces a ranking report. Use this when you need to evaluate which parsing engine works best for a given document.",
|
|
56148
56494
|
prompt: "Benchmark document parsing engines: parse with 5 engines, score, and rank results.",
|
|
@@ -56179,7 +56525,7 @@ var documentParserPlugin = {
|
|
|
56179
56525
|
|
|
56180
56526
|
// src/middlewares/projectRoomMiddleware.ts
|
|
56181
56527
|
var import_crypto11 = require("crypto");
|
|
56182
|
-
var
|
|
56528
|
+
var import_protocols61 = require("@axiom-lattice/protocols");
|
|
56183
56529
|
var import_langchain86 = require("langchain");
|
|
56184
56530
|
var import_zod74 = require("zod");
|
|
56185
56531
|
var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
|
|
@@ -56209,7 +56555,7 @@ function ownDataValue2(record, key6) {
|
|
|
56209
56555
|
if (typeof record !== "object" || record === null || Array.isArray(record)) return void 0;
|
|
56210
56556
|
try {
|
|
56211
56557
|
const descriptor = Object.getOwnPropertyDescriptor(record, key6);
|
|
56212
|
-
return (0,
|
|
56558
|
+
return (0, import_protocols61.descriptorDataValue)(descriptor)?.value;
|
|
56213
56559
|
} catch {
|
|
56214
56560
|
return void 0;
|
|
56215
56561
|
}
|
|
@@ -56219,14 +56565,14 @@ function readTrustedRoomScope(config) {
|
|
|
56219
56565
|
const runConfig = ownDataValue2(configurable, "runConfig");
|
|
56220
56566
|
const projectRoom = ownDataValue2(runConfig, "projectRoom");
|
|
56221
56567
|
try {
|
|
56222
|
-
return (0,
|
|
56568
|
+
return (0, import_protocols61.parseTrustedRunContext)({ projectRoom }).projectRoom;
|
|
56223
56569
|
} catch {
|
|
56224
56570
|
return void 0;
|
|
56225
56571
|
}
|
|
56226
56572
|
}
|
|
56227
56573
|
function exactValues2(value, required, optional = []) {
|
|
56228
56574
|
try {
|
|
56229
|
-
return (0,
|
|
56575
|
+
return (0, import_protocols61.snapshotExactRecord)(value, required, optional);
|
|
56230
56576
|
} catch {
|
|
56231
56577
|
return void 0;
|
|
56232
56578
|
}
|
|
@@ -56262,7 +56608,7 @@ function snapshotMembership3(value) {
|
|
|
56262
56608
|
return { ...values, joinedAt, updatedAt };
|
|
56263
56609
|
}
|
|
56264
56610
|
function snapshotRows(value) {
|
|
56265
|
-
return (0,
|
|
56611
|
+
return (0, import_protocols61.snapshotExactArray)(value) ?? [];
|
|
56266
56612
|
}
|
|
56267
56613
|
async function rosterExemptMembershipProjection(scope) {
|
|
56268
56614
|
const excluded = /* @__PURE__ */ new Set();
|
|
@@ -56387,7 +56733,7 @@ var projectRoomPlugin = {
|
|
|
56387
56733
|
// src/middlewares/sandboxPluginsMiddleware.ts
|
|
56388
56734
|
var import_langchain87 = require("langchain");
|
|
56389
56735
|
var import_zod75 = require("zod");
|
|
56390
|
-
var
|
|
56736
|
+
var import_protocols62 = require("@axiom-lattice/protocols");
|
|
56391
56737
|
|
|
56392
56738
|
// src/services/PluginUiToolRunner.ts
|
|
56393
56739
|
var PluginNotFoundError = class extends Error {
|
|
@@ -58286,7 +58632,7 @@ var sandboxPluginsPlugin = {
|
|
|
58286
58632
|
key: "plugin-builder",
|
|
58287
58633
|
name: "Plugin Builder",
|
|
58288
58634
|
description: "Author and manage tenant plugins in the shared sandbox: clarify goal, inputs/outputs, credentials, and whether a UI is needed; then write the manifest and JS handlers, add an optional HTML MCP App UI, and validate/test with the manage_plugin tool.",
|
|
58289
|
-
type:
|
|
58635
|
+
type: import_protocols62.AgentType.DEEP_AGENT,
|
|
58290
58636
|
prompt: PLUGIN_BUILDER_PROMPT,
|
|
58291
58637
|
// Read-only discovery of connection identifiers (metadata only — never
|
|
58292
58638
|
// config/secrets) so the builder can confirm a human configured a
|
|
@@ -59411,7 +59757,7 @@ var appSharePlugin = {
|
|
|
59411
59757
|
// src/middlewares/longTermStoreMiddleware.ts
|
|
59412
59758
|
var import_langchain89 = require("langchain");
|
|
59413
59759
|
var import_zod77 = require("zod");
|
|
59414
|
-
var
|
|
59760
|
+
var import_protocols63 = require("@axiom-lattice/protocols");
|
|
59415
59761
|
var DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
|
|
59416
59762
|
var DEFAULT_SEARCH_LIMIT = 10;
|
|
59417
59763
|
var MAX_SEARCH_LIMIT = 100;
|
|
@@ -59442,7 +59788,7 @@ function runtimeScope(exeConfig) {
|
|
|
59442
59788
|
function normalizeSegments(value) {
|
|
59443
59789
|
if (!Array.isArray(value) || value.length === 0) return void 0;
|
|
59444
59790
|
const segments = value.map((segment) => typeof segment === "string" ? segment.trim() : "");
|
|
59445
|
-
if (!segments.every((segment) => segment.length > 0 && !segment.includes(
|
|
59791
|
+
if (!segments.every((segment) => segment.length > 0 && !segment.includes(import_protocols63.STORE_IDENTITY_SEPARATOR))) return void 0;
|
|
59446
59792
|
return segments;
|
|
59447
59793
|
}
|
|
59448
59794
|
function clampLimit2(value, fallback = DEFAULT_SEARCH_LIMIT) {
|
|
@@ -59453,7 +59799,7 @@ function failure3(error) {
|
|
|
59453
59799
|
return JSON.stringify({ success: false, error });
|
|
59454
59800
|
}
|
|
59455
59801
|
function operationFailure(error) {
|
|
59456
|
-
if (error instanceof
|
|
59802
|
+
if (error instanceof import_protocols63.StoreValidationError) {
|
|
59457
59803
|
return failure3(error.message);
|
|
59458
59804
|
}
|
|
59459
59805
|
return failure3("Long-term store operation failed");
|
|
@@ -60461,7 +60807,7 @@ function buildUserContent(name) {
|
|
|
60461
60807
|
var DEFAULT_CONFIG = {
|
|
60462
60808
|
name: "Personal Assistant",
|
|
60463
60809
|
description: "Default template for personal assistants",
|
|
60464
|
-
type:
|
|
60810
|
+
type: import_protocols26.AgentType.DEEP_AGENT,
|
|
60465
60811
|
modelKey: "default",
|
|
60466
60812
|
prompt: `\u4F60\u662F\u7528\u6237\u7684\u4E13\u5C5E\u4E2A\u4EBA\u52A9\u7406\u3002\u4F60\u7684\u8EAB\u4EFD\u548C\u6027\u683C\u7531 /agent/IDENTITY.md \u5B9A\u4E49\u3002
|
|
60467
60813
|
\u4F60\u4F1A\u8BB0\u4F4F\u5BF9\u8BDD\u5386\u53F2\uFF0C\u9010\u6B65\u4E86\u89E3\u7528\u6237\u7684\u504F\u597D\u3001\u4E60\u60EF\u548C\u4FE1\u606F\u3002
|
|
@@ -60494,6 +60840,9 @@ var DEFAULT_CONFIG = {
|
|
|
60494
60840
|
type: "skill",
|
|
60495
60841
|
name: "Skills",
|
|
60496
60842
|
description: "Skill system for specialized instructions and workflows",
|
|
60843
|
+
// Temporary default until skills have a per-PA resource/collection model:
|
|
60844
|
+
// keep dynamic discovery by reading all. Do NOT set `skills: []` here —
|
|
60845
|
+
// load_skills treats an explicit empty list as "no static access".
|
|
60497
60846
|
enabled: true,
|
|
60498
60847
|
config: {
|
|
60499
60848
|
readAll: true
|
|
@@ -60538,17 +60887,12 @@ var DEFAULT_CONFIG = {
|
|
|
60538
60887
|
description: "Persistent task system for human-agent coordination",
|
|
60539
60888
|
enabled: true,
|
|
60540
60889
|
config: {}
|
|
60541
|
-
},
|
|
60542
|
-
{
|
|
60543
|
-
id: "document-parser",
|
|
60544
|
-
type: "document-parser",
|
|
60545
|
-
name: "Document Parser",
|
|
60546
|
-
description: "Parse docx/pdf files into markdown via document service",
|
|
60547
|
-
enabled: true,
|
|
60548
|
-
config: { connectAll: true }
|
|
60549
60890
|
}
|
|
60550
60891
|
],
|
|
60551
|
-
|
|
60892
|
+
// The PA is a user-facing assistant, not a tenant agent builder. It may
|
|
60893
|
+
// discover available agents and dispatch work via `task`, but must not read,
|
|
60894
|
+
// create, or invoke agents directly.
|
|
60895
|
+
tools: ["list_agents", "manage_binding"]
|
|
60552
60896
|
};
|
|
60553
60897
|
var PersonalAssistantConfig = class {
|
|
60554
60898
|
/**
|
|
@@ -60945,6 +61289,7 @@ registerBuiltinPlugins();
|
|
|
60945
61289
|
InMemoryProjectRoomReadStateStore,
|
|
60946
61290
|
InMemoryProjectRoomStore,
|
|
60947
61291
|
InMemoryProjectStore,
|
|
61292
|
+
InMemorySessionStore,
|
|
60948
61293
|
InMemorySharedResourceStore,
|
|
60949
61294
|
InMemoryStore,
|
|
60950
61295
|
InMemoryTaskStore,
|