@axiom-lattice/core 12.3.1 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1930,6 +1930,7 @@ __export(index_exports, {
1930
1930
  decrypt: () => decrypt,
1931
1931
  decryptConfigFields: () => decryptConfigFields,
1932
1932
  delegationService: () => delegationService,
1933
+ deleteCollectionEntryIds: () => deleteCollectionEntryIds,
1933
1934
  describeCronExpression: () => describeCronExpression,
1934
1935
  disconnectAllChannels: () => disconnectAllChannels,
1935
1936
  documentLearningPlugin: () => documentLearningPlugin,
@@ -8995,6 +8996,20 @@ var import_protocols20 = require("@axiom-lattice/protocols");
8995
8996
 
8996
8997
  // src/collection_lattice/SimpleMemoryVectorStore.ts
8997
8998
  var import_vectorstores = require("@langchain/core/vectorstores");
8999
+ function matchesMetadataFilter(metadata, filter2) {
9000
+ return Object.entries(filter2).every(([key6, expected]) => {
9001
+ if (expected && typeof expected === "object" && !Array.isArray(expected)) {
9002
+ const operator = expected;
9003
+ if (Array.isArray(operator.in)) {
9004
+ return operator.in.includes(metadata[key6]);
9005
+ }
9006
+ if (Array.isArray(operator.notIn)) {
9007
+ return !operator.notIn.includes(metadata[key6]);
9008
+ }
9009
+ }
9010
+ return metadata[key6] === expected;
9011
+ });
9012
+ }
8998
9013
  function cosineSimilarity(a, b) {
8999
9014
  let dotProduct = 0;
9000
9015
  let normA = 0;
@@ -9044,11 +9059,9 @@ var SimpleMemoryVectorStore = class extends import_vectorstores.VectorStore {
9044
9059
  this.vectors = [];
9045
9060
  return;
9046
9061
  }
9047
- this.vectors = this.vectors.filter((v) => {
9048
- return !Object.entries(filter2).every(([k, expected]) => {
9049
- return v.document.metadata[k] === expected;
9050
- });
9051
- });
9062
+ this.vectors = this.vectors.filter(
9063
+ (v) => !matchesMetadataFilter(v.document.metadata, filter2)
9064
+ );
9052
9065
  }
9053
9066
  /**
9054
9067
  * Similarity search with vector and scores.
@@ -9057,11 +9070,9 @@ var SimpleMemoryVectorStore = class extends import_vectorstores.VectorStore {
9057
9070
  let candidates = this.vectors;
9058
9071
  if (filter2 && typeof filter2 === "object") {
9059
9072
  const filterObj = filter2;
9060
- candidates = candidates.filter((v) => {
9061
- return Object.entries(filterObj).every(([k2, expected]) => {
9062
- return v.document.metadata[k2] === expected;
9063
- });
9064
- });
9073
+ candidates = candidates.filter(
9074
+ (v) => matchesMetadataFilter(v.document.metadata, filterObj)
9075
+ );
9065
9076
  }
9066
9077
  const scored = candidates.map((v) => ({
9067
9078
  document: v.document,
@@ -9728,6 +9739,23 @@ function tryExtractTools(plugin) {
9728
9739
  }
9729
9740
  return [];
9730
9741
  }
9742
+ function mergeToolMeta(extracted, declared) {
9743
+ if (!declared || declared.length === 0) return extracted;
9744
+ const remaining = new Map(declared.map((tool68) => [tool68.name, tool68]));
9745
+ const merged = extracted.map((tool68) => {
9746
+ const override = remaining.get(tool68.name);
9747
+ if (!override) return tool68;
9748
+ remaining.delete(tool68.name);
9749
+ return { ...tool68, ...override };
9750
+ });
9751
+ for (const tool68 of declared) {
9752
+ if (remaining.has(tool68.name)) {
9753
+ merged.push(tool68);
9754
+ remaining.delete(tool68.name);
9755
+ }
9756
+ }
9757
+ return merged;
9758
+ }
9731
9759
  function serializePluginMeta(plugin) {
9732
9760
  const meta = {
9733
9761
  type: plugin.meta.type,
@@ -9736,7 +9764,7 @@ function serializePluginMeta(plugin) {
9736
9764
  version: plugin.meta.version,
9737
9765
  source: plugin.meta.source,
9738
9766
  icon: plugin.meta.icon,
9739
- tools: plugin.meta.tools ?? tryExtractTools(plugin),
9767
+ tools: mergeToolMeta(tryExtractTools(plugin), plugin.meta.tools),
9740
9768
  configSchema: plugin.meta.configSchema,
9741
9769
  defaultConfig: plugin.meta.defaultConfig,
9742
9770
  category: plugin.meta.category,
@@ -14321,7 +14349,8 @@ Ask the user to clarify:
14321
14349
  3. **What should I search for to verify it works?** Give 2-3 example queries you'll use to test retrieval.
14322
14350
  4. **Existing knowledge base \u2014 update or replace?** If entries already exist, confirm:
14323
14351
  - **Update** \u2014 add new entries alongside existing ones, or
14324
- - **Replace** \u2014 delete old entries first, then add new ones.
14352
+ - **Replace** \u2014 delete old entries first with \`delete_entries\` (up to 50 IDs
14353
+ per call), then add new ones.
14325
14354
 
14326
14355
  Present the plan as a summary before starting. Do NOT begin building until the user confirms.
14327
14356
 
@@ -14333,7 +14362,8 @@ Present the plan as a summary before starting. Do NOT begin building until the u
14333
14362
  - No collection yet \u2192 \`create_collection(name: "{domain}-knowledge")\`
14334
14363
  (one per domain)
14335
14364
  3. Use \`add_entries\` in batches of up to 50 knowledge entries per batch.
14336
- Extract one self-contained fact or answer per entry. Keep each entry focused \u2014
14365
+ Include every extracted chunk when splitting across calls \u2014 never omit
14366
+ content. Extract one self-contained fact or answer per entry. Keep each entry focused \u2014
14337
14367
  one topic, one question, one answer. Avoid dumping large paragraphs.
14338
14368
  4. Verify retrievability: run the 2-3 example queries from step 3 with
14339
14369
  \`search_collection\` \u2014 entries must return with reasonable relevance scores.
@@ -14844,7 +14874,7 @@ injected with two environment variables:
14844
14874
 
14845
14875
  The token already encodes this agent's authority: the platform reflects the agent's
14846
14876
  own configured middleware into Open grants, plus a small always-on baseline
14847
- (\`kb\` read-only and \`sandbox:self\`). So the callable set = that baseline \u222A the
14877
+ (\`collection\` read-only search and \`sandbox:self\`). So the callable set = that baseline \u222A the
14848
14878
  domains your configured middleware exposes \u2014 and nothing beyond it.
14849
14879
 
14850
14880
  ## Client
@@ -14885,7 +14915,7 @@ CLI equivalents (config comes from the same env vars):
14885
14915
 
14886
14916
  \`\`\`bash
14887
14917
  open-mcp tools list --json
14888
- open-mcp tools call kb_search --json '{"query":"refund policy"}'
14918
+ open-mcp tools call collection_search_collection --json '{"collection":"docs","query":"refund policy"}'
14889
14919
  \`\`\`
14890
14920
 
14891
14921
  ## Discover, then call
@@ -14922,8 +14952,8 @@ const { OpenMcpClient } = require("@axiom-lattice/open-mcp-client");
14922
14952
  async function main() {
14923
14953
  const client = OpenMcpClient.fromEnv(); // API_GATEWAY_URL + OPEN_API_TOKEN
14924
14954
  const tools = await client.listTools(); // exactly what this agent may call
14925
- const pick = tools.find((t) => t.name === "kb_search") ?? tools[0];
14926
- const out = await client.callTool(pick.name, { query: "refund policy" });
14955
+ const pick = tools.find((t) => t.name === "collection_search_collection") ?? tools[0];
14956
+ const out = await client.callTool(pick.name, { collection: "docs", query: "refund policy" });
14927
14957
  console.log(JSON.stringify({ called: pick.name, result: out.json() }));
14928
14958
  }
14929
14959
 
@@ -26653,7 +26683,7 @@ var LEGACY_PLUGIN_CONNECTION_FIELDS = Object.freeze({
26653
26683
  list_entries: Object.freeze({ argumentField: "collection", configField: "collectionKeys", allowAllField: "connectAll" }),
26654
26684
  add_entries: Object.freeze({ argumentField: "collection", configField: "collectionKeys", allowAllField: "connectAll" }),
26655
26685
  update_entry: Object.freeze({ argumentField: "collection", configField: "collectionKeys", allowAllField: "connectAll" }),
26656
- delete_entry: Object.freeze({ argumentField: "collection", configField: "collectionKeys", allowAllField: "connectAll" }),
26686
+ delete_entries: Object.freeze({ argumentField: "collection", configField: "collectionKeys", allowAllField: "connectAll" }),
26657
26687
  get_collection: Object.freeze({ argumentField: "name", configField: "collectionKeys", allowAllField: "connectAll" }),
26658
26688
  update_collection: Object.freeze({ argumentField: "name", configField: "collectionKeys", allowAllField: "connectAll" }),
26659
26689
  delete_collection: Object.freeze({ argumentField: "name", configField: "collectionKeys", allowAllField: "connectAll" })
@@ -41605,6 +41635,18 @@ async function listCollectionEntries(name, embeddingKey, tenantId2) {
41605
41635
  }
41606
41636
  return [];
41607
41637
  }
41638
+ async function deleteCollectionEntryIds(vectorStore, entryIds) {
41639
+ if (entryIds.length === 0) return;
41640
+ const typed = vectorStore;
41641
+ const storeType = typeof typed._vectorstoreType === "function" ? typed._vectorstoreType() : "";
41642
+ if (storeType === "pgvector" || storeType === "simple_memory") {
41643
+ await vectorStore.delete({ filter: { _id: { in: entryIds } } });
41644
+ return;
41645
+ }
41646
+ for (const entryId of entryIds) {
41647
+ await vectorStore.delete({ filter: { _id: entryId } });
41648
+ }
41649
+ }
41608
41650
  async function removeCollectionVectorStore(name, tenantId2) {
41609
41651
  const storeKey = buildKey(tenantId2, name);
41610
41652
  const tableName = buildTableName(tenantId2, name);
@@ -50919,8 +50961,10 @@ var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true
50919
50961
  const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
50920
50962
  if (scopeError) return scopeError;
50921
50963
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
50922
- const r = await collectionLatticeManager.removeCollection(tenantId2, input.name);
50923
- return r ? `Collection "${input.name}" deleted.` : `Collection "${input.name}" not found.`;
50964
+ const removed = await collectionLatticeManager.removeCollection(tenantId2, input.name);
50965
+ if (!removed) return `Collection "${input.name}" not found.`;
50966
+ await removeCollectionVectorStore(input.name, tenantId2);
50967
+ return `Collection "${input.name}" deleted.`;
50924
50968
  } catch (e) {
50925
50969
  return `Error: ${e.message}`;
50926
50970
  }
@@ -50965,20 +51009,27 @@ var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) =
50965
51009
  { name: "list_entries", description: `List entries in a collection. Shows ID and first 80 chars of content.`, schema: schema2 }
50966
51010
  );
50967
51011
 
50968
- // src/tool_lattice/collection/add_entry.ts
51012
+ // src/tool_lattice/collection/add_entries.ts
50969
51013
  var import_zod66 = __toESM(require("zod"));
50970
51014
  var import_langchain73 = require("langchain");
50971
51015
  var import_documents = require("@langchain/core/documents");
50972
51016
  var import_uuid11 = require("uuid");
51017
+ var import_protocols53 = require("@axiom-lattice/protocols");
50973
51018
  var schema3 = import_zod66.default.object({
50974
51019
  collection: import_zod66.default.string().describe("Collection name"),
50975
- content: import_zod66.default.string().describe("Entry content text"),
50976
- metadata: import_zod66.default.record(import_zod66.default.string(), import_zod66.default.unknown()).optional().describe("Metadata fields matching the collection schema")
51020
+ entries: import_zod66.default.array(
51021
+ import_zod66.default.object({
51022
+ content: import_zod66.default.string().refine((value) => value.trim().length > 0, {
51023
+ message: "content must not be blank"
51024
+ }).describe("Entry content text"),
51025
+ metadata: import_zod66.default.record(import_zod66.default.string(), import_zod66.default.unknown()).optional().describe("Metadata fields matching the collection schema")
51026
+ })
51027
+ ).min(1).max(import_protocols53.COLLECTION_ENTRY_BATCH_MAX)
50977
51028
  });
50978
- function key3(t, n) {
50979
- return `${t}:${n}`;
51029
+ function key3(tenantId2, collection) {
51030
+ return `${tenantId2}:${collection}`;
50980
51031
  }
50981
- var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain73.tool)(
51032
+ var createAddEntriesTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain73.tool)(
50982
51033
  async (input, _exeConfig) => {
50983
51034
  try {
50984
51035
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -50996,17 +51047,29 @@ var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (
50996
51047
  tenantId2
50997
51048
  );
50998
51049
  }
50999
- const id = (0, import_uuid11.v4)();
51000
- await vs.addDocuments([new import_documents.Document({
51001
- pageContent: input.content,
51002
- metadata: { _id: id, _created_at: (/* @__PURE__ */ new Date()).toISOString(), ...input.metadata || {} }
51003
- })]);
51004
- return `Entry added to "${input.collection}". ID: ${id}`;
51050
+ const documents = input.entries.map((entry) => {
51051
+ const id = (0, import_uuid11.v4)();
51052
+ return new import_documents.Document({
51053
+ pageContent: entry.content,
51054
+ metadata: {
51055
+ ...entry.metadata || {},
51056
+ _id: id,
51057
+ _created_at: (/* @__PURE__ */ new Date()).toISOString()
51058
+ }
51059
+ });
51060
+ });
51061
+ await vs.addDocuments(documents);
51062
+ const ids = documents.map((document) => document.metadata._id).join(", ");
51063
+ return `Added ${documents.length} entries to "${input.collection}". IDs: ${ids}`;
51005
51064
  } catch (error) {
51006
- return `Error adding entry to "${input.collection}": ${error instanceof Error ? error.message : String(error)}`;
51065
+ return `Error adding entries to "${input.collection}": ${error instanceof Error ? error.message : String(error)}`;
51007
51066
  }
51008
51067
  },
51009
- { name: "add_entry", description: `Add a new entry to a collection. Use get_collection first to see available metadata fields.`, schema: schema3 }
51068
+ {
51069
+ name: "add_entries",
51070
+ description: "Add multiple new entries to a collection in batches of up to 50.",
51071
+ schema: schema3
51072
+ }
51010
51073
  );
51011
51074
 
51012
51075
  // src/tool_lattice/collection/update_entry.ts
@@ -51027,44 +51090,98 @@ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
51027
51090
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
51028
51091
  if (scopeError) return scopeError;
51029
51092
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
51030
- const vs = vectorStoreLatticeManager.getVectorStoreClient(key4(tenantId2, input.collection));
51093
+ const collection = await collectionLatticeManager.getCollection(tenantId2, input.collection);
51094
+ if (!collection) return `Collection "${input.collection}" not found.`;
51095
+ let vs;
51031
51096
  try {
51032
- await vs.delete({ filter: { _id: input.entryId } });
51097
+ vs = vectorStoreLatticeManager.getVectorStoreClient(key4(tenantId2, input.collection));
51033
51098
  } catch {
51099
+ vs = await getOrCreateCollectionVectorStore(
51100
+ input.collection,
51101
+ collection.embeddingKey,
51102
+ tenantId2
51103
+ );
51104
+ }
51105
+ const docs = await listCollectionEntries(input.collection, collection.embeddingKey, tenantId2);
51106
+ const existing = docs.find((document) => document.metadata._id === input.entryId);
51107
+ if (!existing) return `Entry ${input.entryId} not found in "${input.collection}".`;
51108
+ await vs.delete({ filter: { _id: input.entryId } });
51109
+ const now = (/* @__PURE__ */ new Date()).toISOString();
51110
+ const callerMetadata = Object.fromEntries(
51111
+ Object.entries(input.metadata || {}).filter(([key6]) => !key6.startsWith("_"))
51112
+ );
51113
+ const nextDocument = {
51114
+ pageContent: input.content ?? existing.pageContent,
51115
+ metadata: {
51116
+ ...existing.metadata,
51117
+ ...callerMetadata,
51118
+ _id: input.entryId,
51119
+ _created_at: existing.metadata._created_at ?? now,
51120
+ _updated_at: now
51121
+ }
51122
+ };
51123
+ try {
51124
+ await vs.addDocuments([nextDocument]);
51125
+ } catch (error) {
51126
+ try {
51127
+ await vs.addDocuments([existing]);
51128
+ } catch {
51129
+ }
51130
+ throw error;
51034
51131
  }
51035
- await vs.addDocuments([{ pageContent: input.content || "", metadata: { _id: input.entryId, _updated_at: (/* @__PURE__ */ new Date()).toISOString(), ...input.metadata || {} } }]);
51036
51132
  return `Entry ${input.entryId} updated in "${input.collection}".`;
51037
- } catch {
51038
- return `Collection "${input.collection}" not found.`;
51133
+ } catch (error) {
51134
+ return `Error updating entry in "${input.collection}": ${error instanceof Error ? error.message : String(error)}`;
51039
51135
  }
51040
51136
  },
51041
51137
  { name: "update_entry", description: `Update an entry by ID. Provide at least content or metadata.`, schema: schema4 }
51042
51138
  );
51043
51139
 
51044
- // src/tool_lattice/collection/delete_entry.ts
51140
+ // src/tool_lattice/collection/delete_entries.ts
51045
51141
  var import_zod68 = __toESM(require("zod"));
51046
51142
  var import_langchain75 = require("langchain");
51143
+ var import_protocols54 = require("@axiom-lattice/protocols");
51047
51144
  var schema5 = import_zod68.default.object({
51048
51145
  collection: import_zod68.default.string().describe("Collection name"),
51049
- entryId: import_zod68.default.string().describe("Entry ID to delete")
51146
+ entryIds: import_zod68.default.array(
51147
+ import_zod68.default.string().refine((value) => value.trim().length > 0, {
51148
+ message: "entry id must not be blank"
51149
+ }).describe("Entry ID to delete")
51150
+ ).min(1).max(import_protocols54.COLLECTION_ENTRY_BATCH_MAX)
51050
51151
  });
51051
- function key5(t, n) {
51052
- return `${t}:${n}`;
51152
+ function key5(tenantId2, collection) {
51153
+ return `${tenantId2}:${collection}`;
51053
51154
  }
51054
- var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain75.tool)(
51155
+ var createDeleteEntriesTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain75.tool)(
51055
51156
  async (input, _exeConfig) => {
51056
51157
  try {
51057
51158
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
51058
51159
  if (scopeError) return scopeError;
51059
51160
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
51060
- const vs = vectorStoreLatticeManager.getVectorStoreClient(key5(tenantId2, input.collection));
51061
- await vs.delete({ filter: { _id: input.entryId } });
51062
- return `Entry ${input.entryId} deleted from "${input.collection}".`;
51063
- } catch {
51064
- return `Collection "${input.collection}" not found.`;
51161
+ let vs;
51162
+ try {
51163
+ vs = vectorStoreLatticeManager.getVectorStoreClient(key5(tenantId2, input.collection));
51164
+ } catch {
51165
+ const collection = await collectionLatticeManager.getCollection(tenantId2, input.collection);
51166
+ if (!collection) return `Collection "${input.collection}" not found.`;
51167
+ vs = await getOrCreateCollectionVectorStore(
51168
+ collection.name,
51169
+ collection.embeddingKey,
51170
+ tenantId2
51171
+ );
51172
+ }
51173
+ await deleteCollectionEntryIds(vs, input.entryIds);
51174
+ const noun = input.entryIds.length === 1 ? "entry" : "entries";
51175
+ return `Processed ${input.entryIds.length} ${noun} for deletion from "${input.collection}" (idempotent).`;
51176
+ } catch (error) {
51177
+ return `Error deleting entries from "${input.collection}": ${error instanceof Error ? error.message : String(error)}`;
51065
51178
  }
51066
51179
  },
51067
- { name: "delete_entry", description: `Delete an entry from a collection by ID.`, schema: schema5 }
51180
+ {
51181
+ name: "delete_entries",
51182
+ description: "Delete entries from a collection in batches of up to 50.",
51183
+ schema: schema5
51184
+ }
51068
51185
  );
51069
51186
 
51070
51187
  // src/middlewares/collectionMiddleware.ts
@@ -51092,9 +51209,9 @@ function createCollectionMiddleware(params) {
51092
51209
  createCreateCollectionTool({ collectionKeys, connectAll }),
51093
51210
  createUpdateCollectionTool(toolParams),
51094
51211
  createDeleteCollectionTool(toolParams),
51095
- createAddEntryTool(toolParams),
51212
+ createAddEntriesTool(toolParams),
51096
51213
  createUpdateEntryTool(toolParams),
51097
- createDeleteEntryTool(toolParams)
51214
+ createDeleteEntriesTool(toolParams)
51098
51215
  ]
51099
51216
  });
51100
51217
  }
@@ -51105,6 +51222,18 @@ var collectionPlugin = {
51105
51222
  capabilityBundleEligible: true,
51106
51223
  name: "Collection",
51107
51224
  description: "Provides vector search and CRUD access to knowledge collections",
51225
+ openExpose: [
51226
+ { name: "list_collections", readOnly: true, destructive: false },
51227
+ { name: "search_collection", readOnly: true, destructive: false },
51228
+ { name: "get_collection", readOnly: true, destructive: false },
51229
+ { name: "list_entries", readOnly: true, destructive: false },
51230
+ { name: "create_collection", readOnly: false, destructive: false },
51231
+ { name: "update_collection", readOnly: false, destructive: false },
51232
+ { name: "add_entries", readOnly: false, destructive: false },
51233
+ { name: "update_entry", readOnly: false, destructive: false },
51234
+ { name: "delete_collection", readOnly: false, destructive: true },
51235
+ { name: "delete_entries", readOnly: false, destructive: true }
51236
+ ],
51108
51237
  tools: [
51109
51238
  { name: "list_collections", description: "List all available collections" },
51110
51239
  { name: "search_collection", description: "Search for documents in a collection" },
@@ -51115,7 +51244,7 @@ var collectionPlugin = {
51115
51244
  { name: "delete_collection", description: "Delete a collection" },
51116
51245
  { name: "add_entries", description: "Add entries to a collection in batches" },
51117
51246
  { name: "update_entry", description: "Update an entry in a collection" },
51118
- { name: "delete_entry", description: "Delete an entry from a collection" }
51247
+ { name: "delete_entries", description: "Delete entries from a collection in batches" }
51119
51248
  ],
51120
51249
  configSchema: {
51121
51250
  type: "object",
@@ -52275,15 +52404,15 @@ var widgetPlugin = {
52275
52404
  var import_langchain82 = require("langchain");
52276
52405
  var import_zod72 = require("zod");
52277
52406
  var import_langgraph13 = require("@langchain/langgraph");
52278
- var import_protocols54 = require("@axiom-lattice/protocols");
52407
+ var import_protocols56 = require("@axiom-lattice/protocols");
52279
52408
 
52280
52409
  // src/services/taskWorkerRunConfig.ts
52281
- var import_protocols53 = require("@axiom-lattice/protocols");
52410
+ var import_protocols55 = require("@axiom-lattice/protocols");
52282
52411
  function resolveWorkerRunScope(input) {
52283
- const caller = (0, import_protocols53.resolveRunScope)(input.runConfig);
52412
+ const caller = (0, import_protocols55.resolveRunScope)(input.runConfig);
52284
52413
  return {
52285
- workspaceId: (0, import_protocols53.firstNonEmptyString)(input.invocation.workspaceId) ?? caller.workspaceId,
52286
- projectId: (0, import_protocols53.firstNonEmptyString)(input.invocation.projectId) ?? caller.projectId
52414
+ workspaceId: (0, import_protocols55.firstNonEmptyString)(input.invocation.workspaceId) ?? caller.workspaceId,
52415
+ projectId: (0, import_protocols55.firstNonEmptyString)(input.invocation.projectId) ?? caller.projectId
52287
52416
  };
52288
52417
  }
52289
52418
  function applyWorkerRunScope(runConfig, scope) {
@@ -52300,7 +52429,7 @@ function applyWorkerRunScope(runConfig, scope) {
52300
52429
  }
52301
52430
 
52302
52431
  // src/middlewares/taskMiddleware.ts
52303
- var import_protocols55 = require("@axiom-lattice/protocols");
52432
+ var import_protocols57 = require("@axiom-lattice/protocols");
52304
52433
 
52305
52434
  // src/middlewares/taskResponseSerialization.ts
52306
52435
  var TASK_RESPONSE_SCALAR_MAX_BYTES = 4096;
@@ -52789,7 +52918,7 @@ function classifyTaskAuthority(runConfig) {
52789
52918
  return delegatedTaskId ? { kind: "delegated", taskId: delegatedTaskId } : { kind: "ordinary" };
52790
52919
  }
52791
52920
  try {
52792
- const trusted = (0, import_protocols55.parseTrustedRunContext)(hasProjectTask ? { projectTask: runConfig.projectTask } : { projectRoom: runConfig.projectRoom });
52921
+ const trusted = (0, import_protocols57.parseTrustedRunContext)(hasProjectTask ? { projectTask: runConfig.projectTask } : { projectRoom: runConfig.projectRoom });
52793
52922
  return { kind: hasProjectTask ? "projectTask" : "projectRoom", trusted };
52794
52923
  } catch {
52795
52924
  return { kind: "invalid" };
@@ -53137,7 +53266,7 @@ function getTaskWorkItemStore() {
53137
53266
  return getStoreLattice("default", "taskWorkItem").store;
53138
53267
  }
53139
53268
  function getProjectTaskWorkItemStore() {
53140
- return (0, import_protocols55.requireProjectTaskWorkItemStore)(getTaskWorkItemStore());
53269
+ return (0, import_protocols57.requireProjectTaskWorkItemStore)(getTaskWorkItemStore());
53141
53270
  }
53142
53271
  function reviewInterruption(task) {
53143
53272
  const value = task.context?.interruption;
@@ -53188,7 +53317,7 @@ var manageTaskSchema = import_zod72.z.object({
53188
53317
  })).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"),
53189
53318
  content: import_zod72.z.string().optional().describe("Markdown content required for add_activity"),
53190
53319
  summary: import_zod72.z.string().optional().describe("Brief summary of the operation"),
53191
- executionResultId: import_zod72.z.string().refine(import_protocols55.isExecutionResultEventKey, {
53320
+ executionResultId: import_zod72.z.string().refine(import_protocols57.isExecutionResultEventKey, {
53192
53321
  message: "executionResultId must be the execution-result:<threadId> event key returned by task()"
53193
53322
  }).optional().describe(
53194
53323
  "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"
@@ -53253,7 +53382,7 @@ async function getPendingExecutionResultIds(store2, tenantId2, taskId) {
53253
53382
  order: "desc",
53254
53383
  limit: PENDING_EXECUTION_RESULT_LIMIT + 1
53255
53384
  });
53256
- const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0, import_protocols55.isExecutionResultEventKey)(item.eventKey));
53385
+ const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0, import_protocols57.isExecutionResultEventKey)(item.eventKey));
53257
53386
  const reconciliationRows = new Array(canonicalCandidates.length);
53258
53387
  let nextCandidateIndex = 0;
53259
53388
  let firstError;
@@ -53338,7 +53467,7 @@ function createTaskMiddleware(options = {}) {
53338
53467
  const trustedProject = authority.kind === "projectRoom" || authority.kind === "projectTask" ? authority.trusted : void 0;
53339
53468
  const trustedScope = trustedProject?.projectTask ?? trustedProject?.projectRoom;
53340
53469
  const tenantId2 = trustedScope?.tenantId ?? (rc.tenantId || "default");
53341
- const runScope = (0, import_protocols54.resolveRunScope)(rc);
53470
+ const runScope = (0, import_protocols56.resolveRunScope)(rc);
53342
53471
  const workspaceId = trustedScope?.workspaceId ?? runScope.workspaceId;
53343
53472
  const projectId = trustedScope?.projectId ?? runScope.projectId;
53344
53473
  const revalidateCaller = async () => {
@@ -53912,8 +54041,8 @@ function createTaskMiddleware(options = {}) {
53912
54041
  let reconciliationMetadata = {};
53913
54042
  let descriptionMutated = false;
53914
54043
  if (isAgentTask && input.description !== void 0 && !valuesEqual(input.description, existing.description)) {
53915
- const oldBelief = (0, import_protocols55.parseTaskBeliefState)(existing.description ?? "");
53916
- const newBelief = (0, import_protocols55.parseTaskBeliefState)(input.description);
54044
+ const oldBelief = (0, import_protocols57.parseTaskBeliefState)(existing.description ?? "");
54045
+ const newBelief = (0, import_protocols57.parseTaskBeliefState)(input.description);
53917
54046
  const hasBeliefState = oldBelief.success || newBelief.success;
53918
54047
  if (hasBeliefState) {
53919
54048
  await validateExecutionResult();
@@ -55421,7 +55550,7 @@ function createParseDocumentTool({
55421
55550
  }
55422
55551
 
55423
55552
  // src/middlewares/documentParserMiddleware.ts
55424
- var import_protocols56 = require("@axiom-lattice/protocols");
55553
+ var import_protocols58 = require("@axiom-lattice/protocols");
55425
55554
 
55426
55555
  // src/middlewares/documentBenchmarkWorkflow.ts
55427
55556
  var DOCUMENT_PARSER_BENCHMARK_YAML = `name: document-parser-benchmark
@@ -55963,7 +56092,7 @@ var documentParserPlugin = {
55963
56092
  agents: {
55964
56093
  "document-parser": {
55965
56094
  key: "document-parser",
55966
- type: import_protocols56.AgentType.DEEP_AGENT,
56095
+ type: import_protocols58.AgentType.DEEP_AGENT,
55967
56096
  name: "Document Parser",
55968
56097
  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.",
55969
56098
  prompt: DOCUMENT_PARSER_SYSTEM_PROMPT,
@@ -56013,7 +56142,7 @@ var documentParserPlugin = {
56013
56142
  },
56014
56143
  "document-parser-benchmark": {
56015
56144
  key: "document-parser-benchmark",
56016
- type: import_protocols56.AgentType.WORKFLOW,
56145
+ type: import_protocols58.AgentType.WORKFLOW,
56017
56146
  name: "Document Parser Benchmark",
56018
56147
  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.",
56019
56148
  prompt: "Benchmark document parsing engines: parse with 5 engines, score, and rank results.",
@@ -56050,7 +56179,7 @@ var documentParserPlugin = {
56050
56179
 
56051
56180
  // src/middlewares/projectRoomMiddleware.ts
56052
56181
  var import_crypto11 = require("crypto");
56053
- var import_protocols57 = require("@axiom-lattice/protocols");
56182
+ var import_protocols59 = require("@axiom-lattice/protocols");
56054
56183
  var import_langchain86 = require("langchain");
56055
56184
  var import_zod74 = require("zod");
56056
56185
  var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
@@ -56080,7 +56209,7 @@ function ownDataValue2(record, key6) {
56080
56209
  if (typeof record !== "object" || record === null || Array.isArray(record)) return void 0;
56081
56210
  try {
56082
56211
  const descriptor = Object.getOwnPropertyDescriptor(record, key6);
56083
- return (0, import_protocols57.descriptorDataValue)(descriptor)?.value;
56212
+ return (0, import_protocols59.descriptorDataValue)(descriptor)?.value;
56084
56213
  } catch {
56085
56214
  return void 0;
56086
56215
  }
@@ -56090,14 +56219,14 @@ function readTrustedRoomScope(config) {
56090
56219
  const runConfig = ownDataValue2(configurable, "runConfig");
56091
56220
  const projectRoom = ownDataValue2(runConfig, "projectRoom");
56092
56221
  try {
56093
- return (0, import_protocols57.parseTrustedRunContext)({ projectRoom }).projectRoom;
56222
+ return (0, import_protocols59.parseTrustedRunContext)({ projectRoom }).projectRoom;
56094
56223
  } catch {
56095
56224
  return void 0;
56096
56225
  }
56097
56226
  }
56098
56227
  function exactValues2(value, required, optional = []) {
56099
56228
  try {
56100
- return (0, import_protocols57.snapshotExactRecord)(value, required, optional);
56229
+ return (0, import_protocols59.snapshotExactRecord)(value, required, optional);
56101
56230
  } catch {
56102
56231
  return void 0;
56103
56232
  }
@@ -56133,7 +56262,7 @@ function snapshotMembership3(value) {
56133
56262
  return { ...values, joinedAt, updatedAt };
56134
56263
  }
56135
56264
  function snapshotRows(value) {
56136
- return (0, import_protocols57.snapshotExactArray)(value) ?? [];
56265
+ return (0, import_protocols59.snapshotExactArray)(value) ?? [];
56137
56266
  }
56138
56267
  async function rosterExemptMembershipProjection(scope) {
56139
56268
  const excluded = /* @__PURE__ */ new Set();
@@ -56258,7 +56387,7 @@ var projectRoomPlugin = {
56258
56387
  // src/middlewares/sandboxPluginsMiddleware.ts
56259
56388
  var import_langchain87 = require("langchain");
56260
56389
  var import_zod75 = require("zod");
56261
- var import_protocols58 = require("@axiom-lattice/protocols");
56390
+ var import_protocols60 = require("@axiom-lattice/protocols");
56262
56391
 
56263
56392
  // src/services/PluginUiToolRunner.ts
56264
56393
  var PluginNotFoundError = class extends Error {
@@ -57153,7 +57282,7 @@ async function main() {
57153
57282
  token: conn.platformApiKey,
57154
57283
  });
57155
57284
  const tools = await client.listTools(); // exactly what this handler may call
57156
- const kb = await client.callTool("kb_search", { collection: "docs", query: input.q });
57285
+ const kb = await client.callTool("collection_search_collection", { collection: "docs", query: input.q });
57157
57286
 
57158
57287
  process.stdout.write(JSON.stringify({ ok: true, result: kb }));
57159
57288
  }
@@ -57202,7 +57331,7 @@ output (e.g. the tool result), not on echoing the key.
57202
57331
  ## Discover, then call
57203
57332
 
57204
57333
  Never hardcode the tool list: the callable set is the key's grants. Call
57205
- \`listTools()\` at runtime. Tool names are \`{domain}_{action}\` (e.g. \`kb_search\`,
57334
+ \`listTools()\` at runtime. Tool names are \`{domain}_{action}\` (e.g. \`collection_search_collection\`,
57206
57335
  \`task_manage_task\`); args follow the tool's \`inputSchema\`. Return the result
57207
57336
  through the normal handler envelope (\`{ ok: true, result }\`) \u2014 see
57208
57337
  \`sandbox-plugins-handlers\`.
@@ -57223,7 +57352,7 @@ through the normal handler envelope (\`{ ok: true, result }\`) \u2014 see
57223
57352
  ## What the handler may call
57224
57353
 
57225
57354
  The API key carries **only its own grants**. Unlike agent \`code_eval\`, a plugin
57226
- key does not automatically get the sandbox/\`kb\` defaults; grant those explicitly
57355
+ key does not automatically get the sandbox/collection defaults; grant those explicitly
57227
57356
  on the key if the handler needs them. A call outside the key's grants fails
57228
57357
  (tool-not-found or \`GRANT_DENIED\`); retrying will not help. Give the plugin a
57229
57358
  least-privilege key.
@@ -57888,7 +58017,7 @@ var sandboxPluginsPlugin = {
57888
58017
  key: "plugin-builder",
57889
58018
  name: "Plugin Builder",
57890
58019
  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.",
57891
- type: import_protocols58.AgentType.DEEP_AGENT,
58020
+ type: import_protocols60.AgentType.DEEP_AGENT,
57892
58021
  prompt: PLUGIN_BUILDER_PROMPT,
57893
58022
  // Read-only discovery of connection identifiers (metadata only — never
57894
58023
  // config/secrets) so the builder can confirm a human configured a
@@ -59013,7 +59142,7 @@ var appSharePlugin = {
59013
59142
  // src/middlewares/longTermStoreMiddleware.ts
59014
59143
  var import_langchain89 = require("langchain");
59015
59144
  var import_zod77 = require("zod");
59016
- var import_protocols59 = require("@axiom-lattice/protocols");
59145
+ var import_protocols61 = require("@axiom-lattice/protocols");
59017
59146
  var DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
59018
59147
  var DEFAULT_SEARCH_LIMIT = 10;
59019
59148
  var MAX_SEARCH_LIMIT = 100;
@@ -59044,7 +59173,7 @@ function runtimeScope(exeConfig) {
59044
59173
  function normalizeSegments(value) {
59045
59174
  if (!Array.isArray(value) || value.length === 0) return void 0;
59046
59175
  const segments = value.map((segment) => typeof segment === "string" ? segment.trim() : "");
59047
- if (!segments.every((segment) => segment.length > 0 && !segment.includes(import_protocols59.STORE_IDENTITY_SEPARATOR))) return void 0;
59176
+ if (!segments.every((segment) => segment.length > 0 && !segment.includes(import_protocols61.STORE_IDENTITY_SEPARATOR))) return void 0;
59048
59177
  return segments;
59049
59178
  }
59050
59179
  function clampLimit2(value, fallback = DEFAULT_SEARCH_LIMIT) {
@@ -59055,7 +59184,7 @@ function failure3(error) {
59055
59184
  return JSON.stringify({ success: false, error });
59056
59185
  }
59057
59186
  function operationFailure(error) {
59058
- if (error instanceof import_protocols59.StoreValidationError) {
59187
+ if (error instanceof import_protocols61.StoreValidationError) {
59059
59188
  return failure3(error.message);
59060
59189
  }
59061
59190
  return failure3("Long-term store operation failed");
@@ -60770,6 +60899,7 @@ registerBuiltinPlugins();
60770
60899
  decrypt,
60771
60900
  decryptConfigFields,
60772
60901
  delegationService,
60902
+ deleteCollectionEntryIds,
60773
60903
  describeCronExpression,
60774
60904
  disconnectAllChannels,
60775
60905
  documentLearningPlugin,