@axiom-lattice/core 2.1.95 → 2.1.97

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
@@ -1538,11 +1538,13 @@ __export(index_exports, {
1538
1538
  AgentLatticeManager: () => AgentLatticeManager,
1539
1539
  AgentManager: () => AgentManager,
1540
1540
  AgentType: () => import_protocols.AgentType,
1541
+ BUILTIN_PLUGINS: () => BUILTIN_PLUGINS,
1541
1542
  BUILTIN_SKILLS: () => BUILTIN_SKILLS,
1542
1543
  ChunkBuffer: () => ChunkBuffer,
1543
1544
  ChunkBufferLatticeManager: () => ChunkBufferLatticeManager,
1544
1545
  CollectionLatticeManager: () => CollectionLatticeManager,
1545
1546
  CompositeBackend: () => CompositeBackend,
1547
+ ConnectionRegistry: () => ConnectionRegistry,
1546
1548
  ConsoleLoggerClient: () => ConsoleLoggerClient,
1547
1549
  CustomMetricsClient: () => CustomMetricsClient,
1548
1550
  CustomMiddlewareRegistry: () => CustomMiddlewareRegistry,
@@ -1592,6 +1594,7 @@ __export(index_exports, {
1592
1594
  MysqlDatabase: () => MysqlDatabase,
1593
1595
  PersonalAssistantConfig: () => PersonalAssistantConfig,
1594
1596
  PinoLoggerClient: () => PinoLoggerClient,
1597
+ PluginRegistry: () => PluginRegistry,
1595
1598
  PostgresDatabase: () => PostgresDatabase,
1596
1599
  PrometheusClient: () => PrometheusClient,
1597
1600
  Protocols: () => Protocols,
@@ -1754,6 +1757,7 @@ __export(index_exports, {
1754
1757
  sandboxLatticeManager: () => sandboxLatticeManager,
1755
1758
  sanitizeToolCallId: () => sanitizeToolCallId,
1756
1759
  scheduleLatticeManager: () => scheduleLatticeManager,
1760
+ serializePluginMeta: () => serializePluginMeta,
1757
1761
  setBindingRegistry: () => setBindingRegistry,
1758
1762
  setMenuRegistry: () => setMenuRegistry,
1759
1763
  skillLatticeManager: () => skillLatticeManager,
@@ -8836,6 +8840,31 @@ function createCodeEvalMiddleware(params = { vmIsolation: "agent" }) {
8836
8840
  tools: [createShellExecTool({ vmIsolation: params.vmIsolation })]
8837
8841
  });
8838
8842
  }
8843
+ var codeEvalPlugin = {
8844
+ meta: {
8845
+ type: "code_eval",
8846
+ name: "Code Evaluation",
8847
+ description: "Enables safe code execution",
8848
+ configSchema: {
8849
+ type: "object",
8850
+ title: "Code Evaluation Configuration",
8851
+ description: "Configure code execution sandbox settings",
8852
+ required: ["vmIsolation"],
8853
+ properties: {
8854
+ vmIsolation: {
8855
+ type: "string",
8856
+ title: "VM Isolation",
8857
+ description: "Controls how code execution is isolated between agents and projects",
8858
+ enum: ["global", "agent", "project"],
8859
+ default: "global",
8860
+ widget: "segmented"
8861
+ }
8862
+ }
8863
+ },
8864
+ defaultConfig: { vmIsolation: "global" }
8865
+ },
8866
+ middleware: (cfg) => createCodeEvalMiddleware(cfg)
8867
+ };
8839
8868
 
8840
8869
  // src/middlewares/browserMiddleware.ts
8841
8870
  var import_langchain38 = require("langchain");
@@ -8871,6 +8900,31 @@ function createBrowserMiddleware(params = { vmIsolation: "agent" }) {
8871
8900
  tools
8872
8901
  });
8873
8902
  }
8903
+ var browserPlugin = {
8904
+ meta: {
8905
+ type: "browser",
8906
+ name: "Browser",
8907
+ description: "Provides browser automation capabilities",
8908
+ configSchema: {
8909
+ type: "object",
8910
+ title: "Browser Configuration",
8911
+ description: "Configure browser automation settings",
8912
+ required: ["vmIsolation"],
8913
+ properties: {
8914
+ vmIsolation: {
8915
+ type: "string",
8916
+ title: "VM Isolation",
8917
+ description: "Controls how browser instances are isolated between agents and projects",
8918
+ enum: ["global", "agent", "project"],
8919
+ default: "agent",
8920
+ widget: "segmented"
8921
+ }
8922
+ }
8923
+ },
8924
+ defaultConfig: { headless: true, vmIsolation: "agent" }
8925
+ },
8926
+ middleware: (cfg) => createBrowserMiddleware(cfg)
8927
+ };
8874
8928
 
8875
8929
  // src/middlewares/sqlMiddleware.ts
8876
8930
  var import_langchain39 = require("langchain");
@@ -8897,6 +8951,36 @@ function createSqlMiddleware(params) {
8897
8951
  ]
8898
8952
  });
8899
8953
  }
8954
+ var sqlPlugin = {
8955
+ meta: {
8956
+ type: "sql",
8957
+ name: "SQL Database",
8958
+ description: "Provides SQL database query capabilities",
8959
+ tools: [
8960
+ { name: "list_tables_sql", description: "List all tables in a database" },
8961
+ { name: "info_sql", description: "Get information about a database connection" },
8962
+ { name: "query_checker_sql", description: "Check a SQL query for correctness" },
8963
+ { name: "query_sql", description: "Execute a SQL query" }
8964
+ ],
8965
+ configSchema: {
8966
+ type: "object",
8967
+ title: "SQL Configuration",
8968
+ description: "Configure database connection settings",
8969
+ required: ["databaseKeys"],
8970
+ properties: {
8971
+ databaseKeys: {
8972
+ type: "array",
8973
+ title: "Select Databases",
8974
+ description: "Select databases this agent can access (multi-select from registered databases)",
8975
+ items: { type: "string" },
8976
+ widget: "databaseSelect"
8977
+ }
8978
+ }
8979
+ },
8980
+ defaultConfig: { databaseKeys: [] }
8981
+ },
8982
+ middleware: (cfg) => createSqlMiddleware(cfg)
8983
+ };
8900
8984
 
8901
8985
  // src/middlewares/skillMiddleware.ts
8902
8986
  var import_langchain42 = require("langchain");
@@ -9597,12 +9681,23 @@ Response: \`{"message":"Hello, Simon!"}\`
9597
9681
  From your frontend JS, call the API using relative paths:
9598
9682
 
9599
9683
  \`\`\`js
9600
- // main.js
9684
+ // main.js \u2014 GET
9601
9685
  const res = await fetch(\`./api/hello.js?name=\${name}\`);
9602
9686
  const data = await res.json();
9603
9687
  console.log(data.message);
9688
+
9689
+ // POST with JSON body
9690
+ await fetch("./api/hello.js", {
9691
+ method: "POST",
9692
+ body: JSON.stringify({ title: "New Task", done: false }),
9693
+ });
9694
+
9695
+ // PUT / DELETE \u2014 same pattern
9696
+ await fetch("./api/hello.js", { method: "PUT", body: JSON.stringify({ id: 1, title: "Updated" }) });
9697
+ await fetch("./api/hello.js", { method: "DELETE", body: JSON.stringify({ id: 1 }) });
9604
9698
  \`\`\`
9605
9699
 
9700
+ The API receives the body as \`API_BODY\` env var (raw string), method as \`API_METHOD\`.
9606
9701
  The \`<base>\` tag injected into HTML ensures relative URLs resolve through the share proxy.
9607
9702
 
9608
9703
  ## 4. File Upload
@@ -9889,6 +9984,39 @@ ${skillsPrompt}
9889
9984
  }
9890
9985
  });
9891
9986
  }
9987
+ var skillPlugin = {
9988
+ meta: {
9989
+ type: "skill",
9990
+ name: "Skills",
9991
+ description: "Provides skill loading capabilities for the agent",
9992
+ configSchema: {
9993
+ type: "object",
9994
+ title: "Skills Configuration",
9995
+ description: "Configure which skills this agent can use",
9996
+ properties: {
9997
+ readAll: {
9998
+ type: "boolean",
9999
+ title: "Read All Skills",
10000
+ description: "When enabled, the agent will have access to all available skills automatically",
10001
+ default: false,
10002
+ widget: "switch"
10003
+ },
10004
+ skills: {
10005
+ type: "array",
10006
+ title: "Select Skills",
10007
+ description: "Select which skills this agent can use (ignored if 'Read All Skills' is enabled)",
10008
+ items: { type: "string" },
10009
+ widget: "skillSelect"
10010
+ }
10011
+ }
10012
+ },
10013
+ defaultConfig: {
10014
+ readAll: false,
10015
+ skills: []
10016
+ }
10017
+ },
10018
+ middleware: (cfg) => createSkillMiddleware(cfg)
10019
+ };
9892
10020
 
9893
10021
  // src/deep_agent_new/middleware/fs.ts
9894
10022
  var import_langchain43 = require("langchain");
@@ -10756,6 +10884,31 @@ ${systemPrompt}` : systemPrompt;
10756
10884
  }) : void 0
10757
10885
  });
10758
10886
  }
10887
+ var filesystemPlugin = {
10888
+ meta: {
10889
+ type: "filesystem",
10890
+ name: "Filesystem",
10891
+ description: "Provides file system operations for reading, writing, and managing files",
10892
+ configSchema: {
10893
+ type: "object",
10894
+ title: "Filesystem Configuration",
10895
+ description: "Configure filesystem isolation and access settings",
10896
+ required: ["vmIsolation"],
10897
+ properties: {
10898
+ vmIsolation: {
10899
+ type: "string",
10900
+ title: "VM Isolation",
10901
+ description: "Controls how filesystem access is isolated between agents and projects",
10902
+ enum: ["global", "agent", "project"],
10903
+ default: "global",
10904
+ widget: "segmented"
10905
+ }
10906
+ }
10907
+ },
10908
+ defaultConfig: { vmIsolation: "global" }
10909
+ },
10910
+ middleware: (cfg) => createFilesystemMiddleware(cfg)
10911
+ };
10759
10912
 
10760
10913
  // src/middlewares/metricsMiddleware.ts
10761
10914
  var import_langchain44 = require("langchain");
@@ -10790,6 +10943,45 @@ function createMetricsMiddleware(params) {
10790
10943
  ]
10791
10944
  });
10792
10945
  }
10946
+ var metricsPlugin = {
10947
+ meta: {
10948
+ type: "metrics",
10949
+ name: "Metrics",
10950
+ description: "Provides metrics querying capabilities",
10951
+ tools: [
10952
+ { name: "list_datasources", description: "List all datasources from all configured servers" },
10953
+ { name: "query_metrics_list", description: "Query available metrics from datasources" },
10954
+ { name: "query_metric_definition", description: "Get detailed definition of a specific metric" },
10955
+ { name: "query_semantic_metric_data", description: "Query actual metric data" },
10956
+ { name: "query_tables_list", description: "Query available tables from datasources" },
10957
+ { name: "query_table_definition", description: "Get detailed definition of a specific table" },
10958
+ { name: "execute_sql_query", description: "Execute custom SQL queries" }
10959
+ ],
10960
+ configSchema: {
10961
+ type: "object",
10962
+ title: "Metrics Configuration",
10963
+ description: "Configure metrics server access settings",
10964
+ properties: {
10965
+ connectAll: {
10966
+ type: "boolean",
10967
+ title: "Connect All Servers",
10968
+ description: "When enabled, the agent will connect to all available metrics servers automatically",
10969
+ default: false,
10970
+ widget: "switch"
10971
+ },
10972
+ serverKeys: {
10973
+ type: "array",
10974
+ title: "Select Metrics Servers",
10975
+ description: "Select metrics servers this agent can query (ignored if 'Connect All Servers' is enabled)",
10976
+ items: { type: "string" },
10977
+ widget: "metricsSelect"
10978
+ }
10979
+ }
10980
+ },
10981
+ defaultConfig: { connectAll: false, serverKeys: [] }
10982
+ },
10983
+ middleware: (cfg) => createMetricsMiddleware(cfg)
10984
+ };
10793
10985
 
10794
10986
  // src/middlewares/collectionMiddleware.ts
10795
10987
  var import_langchain55 = require("langchain");
@@ -11375,6 +11567,48 @@ function createCollectionMiddleware(params) {
11375
11567
  ]
11376
11568
  });
11377
11569
  }
11570
+ var collectionPlugin = {
11571
+ meta: {
11572
+ type: "collection",
11573
+ name: "Collection",
11574
+ description: "Provides vector search and CRUD access to knowledge collections",
11575
+ tools: [
11576
+ { name: "list_collections", description: "List all available collections" },
11577
+ { name: "search_collection", description: "Search for documents in a collection" },
11578
+ { name: "get_collection", description: "Get a specific collection's details" },
11579
+ { name: "list_entries", description: "List entries in a collection" },
11580
+ { name: "create_collection", description: "Create a new collection" },
11581
+ { name: "update_collection", description: "Update an existing collection" },
11582
+ { name: "delete_collection", description: "Delete a collection" },
11583
+ { name: "add_entry", description: "Add an entry to a collection" },
11584
+ { name: "update_entry", description: "Update an entry in a collection" },
11585
+ { name: "delete_entry", description: "Delete an entry from a collection" }
11586
+ ],
11587
+ configSchema: {
11588
+ type: "object",
11589
+ title: "Collection Configuration",
11590
+ description: "Configure collection access for this agent",
11591
+ properties: {
11592
+ connectAll: {
11593
+ type: "boolean",
11594
+ title: "Connect All Collections",
11595
+ description: "When enabled, the agent will have access to all collections automatically",
11596
+ default: false,
11597
+ widget: "switch"
11598
+ },
11599
+ collectionKeys: {
11600
+ type: "array",
11601
+ title: "Select Collections",
11602
+ description: "Select which collections this agent can access",
11603
+ items: { type: "string" },
11604
+ widget: "collectionSelect"
11605
+ }
11606
+ }
11607
+ },
11608
+ defaultConfig: { connectAll: false, collectionKeys: [] }
11609
+ },
11610
+ middleware: (cfg) => createCollectionMiddleware(cfg)
11611
+ };
11378
11612
 
11379
11613
  // src/middlewares/askUserClarifyMiddleware.ts
11380
11614
  var import_langchain57 = require("langchain");
@@ -11495,6 +11729,21 @@ function createAskUserClarifyMiddleware() {
11495
11729
  }
11496
11730
  });
11497
11731
  }
11732
+ var askUserClarifyPlugin = {
11733
+ meta: {
11734
+ type: "ask_user_to_clarify",
11735
+ name: "Ask User To Clarify",
11736
+ description: "Enables the agent to ask users clarifying questions",
11737
+ configSchema: {
11738
+ type: "object",
11739
+ title: "Ask User To Clarify Configuration",
11740
+ description: "Configure user clarification settings",
11741
+ properties: {}
11742
+ },
11743
+ defaultConfig: {}
11744
+ },
11745
+ middleware: () => createAskUserClarifyMiddleware()
11746
+ };
11498
11747
 
11499
11748
  // src/middlewares/widgetMiddleware.ts
11500
11749
  var import_langchain60 = require("langchain");
@@ -12385,6 +12634,21 @@ function createWidgetMiddleware() {
12385
12634
  tools
12386
12635
  });
12387
12636
  }
12637
+ var widgetPlugin = {
12638
+ meta: {
12639
+ type: "widget",
12640
+ name: "Widget",
12641
+ description: "Enables the agent to render interactive HTML widgets",
12642
+ configSchema: {
12643
+ type: "object",
12644
+ title: "Widget Configuration",
12645
+ description: "Configure widget rendering capabilities (zero configuration required)",
12646
+ properties: {}
12647
+ },
12648
+ defaultConfig: {}
12649
+ },
12650
+ middleware: () => createWidgetMiddleware()
12651
+ };
12388
12652
 
12389
12653
  // src/middlewares/modelSelectorMiddleware.ts
12390
12654
  var import_langchain61 = require("langchain");
@@ -13000,6 +13264,31 @@ ${startupSections.join("\n\n")}
13000
13264
  }
13001
13265
  });
13002
13266
  }
13267
+ var clawPlugin = {
13268
+ meta: {
13269
+ type: "claw",
13270
+ name: "Memory",
13271
+ description: "Injects and manages memory/bootstrap files in the runtime workspace",
13272
+ configSchema: {
13273
+ type: "object",
13274
+ title: "Memory Configuration",
13275
+ description: "Configure bootstrap file injection behavior",
13276
+ properties: {
13277
+ injectBootstrapFiles: {
13278
+ type: "boolean",
13279
+ title: "Inject Bootstrap Files",
13280
+ description: "Automatically inject default bootstrap files into the workspace context",
13281
+ default: true,
13282
+ widget: "switch"
13283
+ }
13284
+ }
13285
+ },
13286
+ defaultConfig: {
13287
+ injectBootstrapFiles: true
13288
+ }
13289
+ },
13290
+ middleware: (cfg) => createClawMiddleware(cfg)
13291
+ };
13003
13292
 
13004
13293
  // src/middlewares/unknownToolHandlerMiddleware.ts
13005
13294
  var import_langchain63 = require("langchain");
@@ -13188,6 +13477,53 @@ ${currentSystemPrompt}` : dateContext;
13188
13477
  }
13189
13478
  });
13190
13479
  }
13480
+ var datePlugin = {
13481
+ meta: {
13482
+ type: "date",
13483
+ name: "Current Date",
13484
+ description: "Injects the current date into the agent system prompt",
13485
+ configSchema: {
13486
+ type: "object",
13487
+ title: "Date Configuration",
13488
+ description: "Configure timezone for the current date",
13489
+ properties: {
13490
+ timezone: {
13491
+ type: "string",
13492
+ title: "Timezone",
13493
+ description: "Select timezone for displaying the current date",
13494
+ default: "UTC",
13495
+ enumLabels: {
13496
+ "UTC": "UTC (Coordinated Universal Time)",
13497
+ "America/New_York": "New York (EST/EDT)",
13498
+ "America/Chicago": "Chicago (CST/CDT)",
13499
+ "America/Denver": "Denver (MST/MDT)",
13500
+ "America/Los_Angeles": "Los Angeles (PST/PDT)",
13501
+ "America/Toronto": "Toronto (EST/EDT)",
13502
+ "America/Sao_Paulo": "S\xE3o Paulo (BRT)",
13503
+ "Europe/London": "London (GMT/BST)",
13504
+ "Europe/Paris": "Paris (CET/CEST)",
13505
+ "Europe/Berlin": "Berlin (CET/CEST)",
13506
+ "Europe/Moscow": "Moscow (MSK)",
13507
+ "Asia/Dubai": "Dubai (GST)",
13508
+ "Asia/Kolkata": "Kolkata (IST)",
13509
+ "Asia/Shanghai": "Shanghai (CST)",
13510
+ "Asia/Hong_Kong": "Hong Kong (HKT)",
13511
+ "Asia/Singapore": "Singapore (SGT)",
13512
+ "Asia/Tokyo": "Tokyo (JST)",
13513
+ "Asia/Seoul": "Seoul (KST)",
13514
+ "Australia/Sydney": "Sydney (AEDT/AEST)",
13515
+ "Pacific/Auckland": "Auckland (NZDT/NZST)"
13516
+ },
13517
+ widget: "select"
13518
+ }
13519
+ }
13520
+ },
13521
+ defaultConfig: {
13522
+ timezone: "UTC"
13523
+ }
13524
+ },
13525
+ middleware: (cfg) => createDateMiddleware(cfg)
13526
+ };
13191
13527
 
13192
13528
  // src/deep_agent_new/middleware/scheduler.ts
13193
13529
  var import_langchain66 = require("langchain");
@@ -16194,6 +16530,32 @@ function createSchedulerMiddleware(options = {}) {
16194
16530
  ]
16195
16531
  });
16196
16532
  }
16533
+ var schedulerPlugin = {
16534
+ meta: {
16535
+ type: "scheduler",
16536
+ name: "Scheduler",
16537
+ description: "Enables the agent to schedule future work",
16538
+ configSchema: {
16539
+ type: "object",
16540
+ title: "Scheduler Configuration",
16541
+ description: "Configure retry behavior for scheduled tasks",
16542
+ properties: {
16543
+ defaultMaxRetries: {
16544
+ type: "integer",
16545
+ title: "Default Max Retries",
16546
+ description: "Default retry count for scheduled tasks created through the middleware",
16547
+ default: 0,
16548
+ minimum: 0,
16549
+ widget: "numberInput"
16550
+ }
16551
+ }
16552
+ },
16553
+ defaultConfig: {
16554
+ defaultMaxRetries: 0
16555
+ }
16556
+ },
16557
+ middleware: (cfg) => createSchedulerMiddleware(cfg)
16558
+ };
16197
16559
 
16198
16560
  // src/middlewares/taskMiddleware.ts
16199
16561
  var import_langchain67 = require("langchain");
@@ -16326,28 +16688,128 @@ function createTaskMiddleware() {
16326
16688
  ]
16327
16689
  });
16328
16690
  }
16691
+ var taskPlugin = {
16692
+ meta: {
16693
+ type: "task",
16694
+ name: "Task Management",
16695
+ description: "Enables persistent task management with delegation and tracking",
16696
+ configSchema: {
16697
+ type: "object",
16698
+ title: "Task Management Configuration",
16699
+ description: "Zero-configuration task management",
16700
+ properties: {}
16701
+ },
16702
+ defaultConfig: {}
16703
+ },
16704
+ middleware: () => createTaskMiddleware()
16705
+ };
16706
+
16707
+ // src/plugin/metaSerializer.ts
16708
+ function tryExtractTools(plugin) {
16709
+ if (!plugin.middleware) return [];
16710
+ try {
16711
+ const result = plugin.middleware({});
16712
+ if (result instanceof Promise) return [];
16713
+ const mw = result;
16714
+ if (Array.isArray(mw.tools)) {
16715
+ return mw.tools.map((t) => ({
16716
+ name: t.name || "",
16717
+ description: t.description || ""
16718
+ }));
16719
+ }
16720
+ } catch {
16721
+ }
16722
+ return [];
16723
+ }
16724
+ function serializePluginMeta(plugin) {
16725
+ const meta = {
16726
+ type: plugin.meta.type,
16727
+ name: plugin.meta.name,
16728
+ description: plugin.meta.description,
16729
+ version: plugin.meta.version,
16730
+ source: plugin.meta.source,
16731
+ icon: plugin.meta.icon,
16732
+ tools: plugin.meta.tools ?? tryExtractTools(plugin),
16733
+ configSchema: plugin.meta.configSchema,
16734
+ defaultConfig: plugin.meta.defaultConfig
16735
+ };
16736
+ if (plugin.connection) {
16737
+ meta.connectionSchema = {
16738
+ fields: plugin.connection.fields,
16739
+ hasTest: typeof plugin.connection.test === "function",
16740
+ hasDiscover: typeof plugin.connection.discover === "function",
16741
+ resourceLabel: plugin.connection.resourceLabel
16742
+ };
16743
+ }
16744
+ return meta;
16745
+ }
16746
+
16747
+ // src/plugin/PluginRegistry.ts
16748
+ var PluginRegistry = class {
16749
+ /** Register a plugin (overwrites if type conflicts) */
16750
+ static register(plugin) {
16751
+ const key4 = plugin.meta.type;
16752
+ if (this.plugins.has(key4)) {
16753
+ console.warn(`[PluginRegistry] "${key4}" overwritten`);
16754
+ }
16755
+ this.plugins.set(key4, plugin);
16756
+ }
16757
+ /** Unregister */
16758
+ static unregister(key4) {
16759
+ return this.plugins.delete(key4);
16760
+ }
16761
+ /** Get plugin instance */
16762
+ static get(key4) {
16763
+ return this.plugins.get(key4);
16764
+ }
16765
+ /** Check if registered */
16766
+ static has(key4) {
16767
+ return this.plugins.has(key4);
16768
+ }
16769
+ /** List all registered plugin keys */
16770
+ static list() {
16771
+ return Array.from(this.plugins.keys());
16772
+ }
16773
+ /** Serialize all registered plugins to API-ready meta list */
16774
+ static listMeta() {
16775
+ return Array.from(this.plugins.values()).map(serializePluginMeta);
16776
+ }
16777
+ };
16778
+ PluginRegistry.plugins = /* @__PURE__ */ new Map();
16329
16779
 
16330
16780
  // src/agent_lattice/builders/CustomMiddlewareRegistry.ts
16331
16781
  var CustomMiddlewareRegistry = class {
16332
16782
  /**
16333
16783
  * Register a custom middleware factory under the given key.
16334
16784
  *
16335
- * The key is referenced by `config.key` in the database middleware configuration.
16336
- * When an agent is built, the framework looks up this key and calls the factory
16337
- * with the remaining config fields.
16785
+ * Supports three calling conventions:
16786
+ * - register(key, factory) legacy, wraps factory as anonymous Plugin
16787
+ * - register(key, factory, meta) — legacy with optional meta
16788
+ *
16789
+ * For new code, prefer PluginRegistry.register(plugin).
16338
16790
  *
16339
16791
  * @param key - Unique identifier, referenced in database config as `config.key`
16340
16792
  * @param factory - Function that receives config (minus `key`) and returns an AgentMiddleware
16341
- *
16342
- * @example
16343
- * ```ts
16344
- * CustomMiddlewareRegistry.register("my-logger", (config) =>
16345
- * createMiddleware({ name: "Logger", beforeAgent: async () => { ... } }),
16346
- * );
16347
- * ```
16793
+ * @param deprecatedMeta - Optional metadata for API discovery
16348
16794
  */
16349
- static register(key4, factory) {
16795
+ static register(key4, factory, deprecatedMeta) {
16350
16796
  this.factories.set(key4, factory);
16797
+ const existing = PluginRegistry.get(key4);
16798
+ if (existing) return;
16799
+ const plugin = {
16800
+ meta: {
16801
+ type: key4,
16802
+ name: deprecatedMeta?.name || key4,
16803
+ description: deprecatedMeta?.description || "",
16804
+ version: deprecatedMeta?.version,
16805
+ source: deprecatedMeta?.source,
16806
+ tools: deprecatedMeta?.tools,
16807
+ configSchema: deprecatedMeta?.configSchema,
16808
+ defaultConfig: deprecatedMeta?.defaultConfig
16809
+ },
16810
+ middleware: factory
16811
+ };
16812
+ PluginRegistry.register(plugin);
16351
16813
  }
16352
16814
  /**
16353
16815
  * Remove a previously registered factory.
@@ -16356,6 +16818,7 @@ var CustomMiddlewareRegistry = class {
16356
16818
  * @returns `true` if a factory was removed, `false` if the key was not found
16357
16819
  */
16358
16820
  static unregister(key4) {
16821
+ PluginRegistry.unregister(key4);
16359
16822
  return this.factories.delete(key4);
16360
16823
  }
16361
16824
  /**
@@ -16365,29 +16828,73 @@ var CustomMiddlewareRegistry = class {
16365
16828
  * @returns The factory function, or `undefined` if not registered
16366
16829
  */
16367
16830
  static get(key4) {
16368
- return this.factories.get(key4);
16831
+ const factory = this.factories.get(key4);
16832
+ if (factory) return factory;
16833
+ const plugin = PluginRegistry.get(key4);
16834
+ if (plugin?.middleware) {
16835
+ return ((config) => plugin.middleware(config));
16836
+ }
16837
+ return void 0;
16369
16838
  }
16370
16839
  /**
16371
16840
  * Check whether a factory is registered under the given key.
16372
- *
16373
- * @param key - The factory key to check
16374
16841
  */
16375
16842
  static has(key4) {
16376
- return this.factories.has(key4);
16843
+ return this.factories.has(key4) || PluginRegistry.has(key4);
16377
16844
  }
16378
16845
  /**
16379
16846
  * Get all currently registered factory keys.
16380
- *
16381
- * @returns Array of registered key strings
16382
16847
  */
16383
16848
  static list() {
16384
- return Array.from(this.factories.keys());
16849
+ const keys = new Set(this.factories.keys());
16850
+ for (const k of PluginRegistry.list()) keys.add(k);
16851
+ return Array.from(keys);
16385
16852
  }
16386
16853
  };
16387
16854
  CustomMiddlewareRegistry.factories = /* @__PURE__ */ new Map();
16388
16855
 
16856
+ // src/connection/ConnectionRegistry.ts
16857
+ var ConnectionRegistry = class {
16858
+ static setStore(store) {
16859
+ this.store = store;
16860
+ }
16861
+ static async list(type, tenantId) {
16862
+ this.ensureStore();
16863
+ return this.store.listByType(tenantId, type);
16864
+ }
16865
+ static async get(type, key4, tenantId) {
16866
+ this.ensureStore();
16867
+ return this.store.getByKey(tenantId, type, key4);
16868
+ }
16869
+ static async create(entry) {
16870
+ this.ensureStore();
16871
+ return this.store.create(entry);
16872
+ }
16873
+ static async update(tenantId, type, key4, updates) {
16874
+ this.ensureStore();
16875
+ return this.store.update(tenantId, type, key4, updates);
16876
+ }
16877
+ static async delete(tenantId, type, key4) {
16878
+ this.ensureStore();
16879
+ return this.store.delete(tenantId, type, key4);
16880
+ }
16881
+ static ensureStore() {
16882
+ if (!this.store) throw new Error("ConnectionStore not configured");
16883
+ }
16884
+ };
16885
+ ConnectionRegistry.store = null;
16886
+
16389
16887
  // src/agent_lattice/builders/commonMiddleware.ts
16390
- async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsIsExised) {
16888
+ function applyToolFilter(mw, allowedTools) {
16889
+ if (allowedTools?.length && mw.tools?.length) {
16890
+ mw.tools = mw.tools.filter((t) => {
16891
+ const toolName = t.name;
16892
+ return typeof toolName === "string" && allowedTools.includes(toolName);
16893
+ });
16894
+ }
16895
+ return mw;
16896
+ }
16897
+ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsIsExised, tenantId) {
16391
16898
  const middlewares = [];
16392
16899
  middlewares.push(createUnknownToolHandlerMiddleware());
16393
16900
  middlewares.push(createModelSelectorMiddleware());
@@ -16397,17 +16904,26 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
16397
16904
  if (needsFilesystemBackend && filesystemBackend) {
16398
16905
  if (!fsIsExised) {
16399
16906
  const options = { backend: filesystemBackend };
16400
- middlewares.push(createFilesystemMiddleware(options));
16907
+ middlewares.push(applyToolFilter(
16908
+ createFilesystemMiddleware(options),
16909
+ filesystemConfig?.allowedTools
16910
+ ));
16401
16911
  }
16402
16912
  }
16403
16913
  for (const config of middlewareConfigs) {
16404
16914
  if (!config.enabled || config.type === "filesystem") continue;
16405
16915
  switch (config.type) {
16406
16916
  case "code_eval":
16407
- middlewares.push(createCodeEvalMiddleware(config.config));
16917
+ middlewares.push(applyToolFilter(
16918
+ createCodeEvalMiddleware(config.config),
16919
+ config.allowedTools
16920
+ ));
16408
16921
  break;
16409
16922
  case "browser":
16410
- middlewares.push(createBrowserMiddleware(config.config));
16923
+ middlewares.push(applyToolFilter(
16924
+ createBrowserMiddleware(config.config),
16925
+ config.allowedTools
16926
+ ));
16411
16927
  break;
16412
16928
  case "sql":
16413
16929
  {
@@ -16420,21 +16936,30 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
16420
16936
  descriptions[db.key] = db.description || db.name || "";
16421
16937
  }
16422
16938
  }
16423
- middlewares.push(createSqlMiddleware({
16424
- databaseKeys: sqlConfig.databaseKeys,
16425
- databaseDescriptions: descriptions
16426
- }));
16939
+ middlewares.push(applyToolFilter(
16940
+ createSqlMiddleware({
16941
+ databaseKeys: sqlConfig.databaseKeys,
16942
+ databaseDescriptions: descriptions
16943
+ }),
16944
+ config.allowedTools
16945
+ ));
16427
16946
  }
16428
16947
  }
16429
16948
  break;
16430
16949
  case "skill":
16431
- middlewares.push(createSkillMiddleware(config.config));
16950
+ middlewares.push(applyToolFilter(
16951
+ createSkillMiddleware(config.config),
16952
+ config.allowedTools
16953
+ ));
16432
16954
  break;
16433
16955
  case "metrics":
16434
16956
  {
16435
16957
  const metricsConfig = config.config;
16436
16958
  if (metricsConfig.connectAll || metricsConfig.serverKeys && metricsConfig.serverKeys.length > 0) {
16437
- middlewares.push(createMetricsMiddleware(metricsConfig));
16959
+ middlewares.push(applyToolFilter(
16960
+ createMetricsMiddleware(metricsConfig),
16961
+ config.allowedTools
16962
+ ));
16438
16963
  }
16439
16964
  }
16440
16965
  break;
@@ -16442,36 +16967,57 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
16442
16967
  {
16443
16968
  const collectionConfig = config.config;
16444
16969
  if (collectionConfig.connectAll || collectionConfig.collectionKeys && collectionConfig.collectionKeys.length > 0) {
16445
- middlewares.push(createCollectionMiddleware(collectionConfig));
16970
+ middlewares.push(applyToolFilter(
16971
+ createCollectionMiddleware(collectionConfig),
16972
+ config.allowedTools
16973
+ ));
16446
16974
  }
16447
16975
  }
16448
16976
  break;
16449
16977
  case "ask_user_to_clarify":
16450
- middlewares.push(createAskUserClarifyMiddleware());
16978
+ middlewares.push(applyToolFilter(
16979
+ createAskUserClarifyMiddleware(),
16980
+ config.allowedTools
16981
+ ));
16451
16982
  break;
16452
16983
  case "widget":
16453
- middlewares.push(createWidgetMiddleware());
16984
+ middlewares.push(applyToolFilter(
16985
+ createWidgetMiddleware(),
16986
+ config.allowedTools
16987
+ ));
16454
16988
  break;
16455
16989
  case "claw":
16456
16990
  if (filesystemBackend) {
16457
16991
  const clawMiddlewareConfig = config.config;
16458
- middlewares.push(createClawMiddleware({
16459
- backend: filesystemBackend,
16460
- injectBootstrapFiles: clawMiddlewareConfig.injectBootstrapFiles ?? true,
16461
- bootstrapFiles: clawMiddlewareConfig.bootstrapFiles ?? {}
16462
- }));
16992
+ middlewares.push(applyToolFilter(
16993
+ createClawMiddleware({
16994
+ backend: filesystemBackend,
16995
+ injectBootstrapFiles: clawMiddlewareConfig.injectBootstrapFiles ?? true,
16996
+ bootstrapFiles: clawMiddlewareConfig.bootstrapFiles ?? {}
16997
+ }),
16998
+ config.allowedTools
16999
+ ));
16463
17000
  } else {
16464
17001
  console.warn("[claw middleware] Filesystem backend not available. Claw middleware requires filesystem backend to function.");
16465
17002
  }
16466
17003
  break;
16467
17004
  case "date":
16468
- middlewares.push(createDateMiddleware(config.config));
17005
+ middlewares.push(applyToolFilter(
17006
+ createDateMiddleware(config.config),
17007
+ config.allowedTools
17008
+ ));
16469
17009
  break;
16470
17010
  case "scheduler":
16471
- middlewares.push(createSchedulerMiddleware(config.config));
17011
+ middlewares.push(applyToolFilter(
17012
+ createSchedulerMiddleware(config.config),
17013
+ config.allowedTools
17014
+ ));
16472
17015
  break;
16473
17016
  case "task":
16474
- middlewares.push(createTaskMiddleware());
17017
+ middlewares.push(applyToolFilter(
17018
+ createTaskMiddleware(),
17019
+ config.allowedTools
17020
+ ));
16475
17021
  break;
16476
17022
  case "custom":
16477
17023
  {
@@ -16479,8 +17025,20 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
16479
17025
  const { key: key4, ...rest } = customConfig;
16480
17026
  const factory = CustomMiddlewareRegistry.get(key4);
16481
17027
  if (factory) {
17028
+ if (rest.connections?.length && tenantId) {
17029
+ const resolved = (await Promise.all(
17030
+ rest.connections.map(async (connKey) => {
17031
+ const entry = await ConnectionRegistry.get(key4, connKey, tenantId);
17032
+ return entry ? { key: connKey, config: entry.config } : null;
17033
+ })
17034
+ )).filter(Boolean);
17035
+ rest._resolvedConnections = resolved;
17036
+ }
16482
17037
  const middleware = factory(rest);
16483
- middlewares.push(middleware instanceof Promise ? await middleware : middleware);
17038
+ middlewares.push(applyToolFilter(
17039
+ middleware instanceof Promise ? await middleware : middleware,
17040
+ config.allowedTools
17041
+ ));
16484
17042
  } else {
16485
17043
  console.warn(
16486
17044
  `[custom middleware] No factory registered for key "${key4}". Use CustomMiddlewareRegistry.register("${key4}", factory) before building the agent.`
@@ -16488,6 +17046,30 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
16488
17046
  }
16489
17047
  }
16490
17048
  break;
17049
+ default:
17050
+ {
17051
+ const plugin = PluginRegistry.get(config.type);
17052
+ if (plugin?.middleware) {
17053
+ const pluginConfig = config.config;
17054
+ if (pluginConfig.connections?.length && tenantId) {
17055
+ const resolved = (await Promise.all(
17056
+ pluginConfig.connections.map(async (connKey) => {
17057
+ const entry = await ConnectionRegistry.get(config.type, connKey, tenantId);
17058
+ return entry ? { key: connKey, config: entry.config } : null;
17059
+ })
17060
+ )).filter(Boolean);
17061
+ pluginConfig._resolvedConnections = resolved;
17062
+ }
17063
+ const mw = plugin.middleware(pluginConfig);
17064
+ middlewares.push(applyToolFilter(
17065
+ mw instanceof Promise ? await mw : mw,
17066
+ config.allowedTools
17067
+ ));
17068
+ } else {
17069
+ console.warn(`[commonMiddleware] Unknown middleware type "${config.type}" \u2014 skipping`);
17070
+ }
17071
+ }
17072
+ break;
16491
17073
  }
16492
17074
  }
16493
17075
  return middlewares;
@@ -16671,8 +17253,8 @@ function createFilesystemBackendFactory(middlewareConfigs) {
16671
17253
 
16672
17254
  // src/agent_lattice/builders/ReActAgentGraphBuilder.ts
16673
17255
  var ReActAgentGraphBuilder = class {
16674
- async createMiddlewares(middlewareConfigs) {
16675
- return await createCommonMiddlewares(middlewareConfigs);
17256
+ async createMiddlewares(middlewareConfigs, tenantId) {
17257
+ return await createCommonMiddlewares(middlewareConfigs, void 0, void 0, tenantId);
16676
17258
  }
16677
17259
  /**
16678
17260
  * 构建ReAct Agent Graph
@@ -16689,7 +17271,7 @@ var ReActAgentGraphBuilder = class {
16689
17271
  const stateSchema2 = createReactAgentSchema(params.stateSchema);
16690
17272
  const middlewareConfigs = params.middleware || [];
16691
17273
  const filesystemBackend = createFilesystemBackendFactory(middlewareConfigs);
16692
- const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend);
17274
+ const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend, void 0, params.tenantId);
16693
17275
  return (0, import_langchain68.createAgent)({
16694
17276
  model: params.model,
16695
17277
  tools,
@@ -19039,7 +19621,7 @@ var DeepAgentGraphBuilder = class {
19039
19621
  }));
19040
19622
  const middlewareConfigs = params.middleware || [];
19041
19623
  const filesystemBackend = createFilesystemBackendFactory(middlewareConfigs);
19042
- const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend, true);
19624
+ const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend, true, params.tenantId);
19043
19625
  const deepAgent = createDeepAgent({
19044
19626
  tools,
19045
19627
  model: params.model,
@@ -21088,7 +21670,7 @@ var ProcessingAgentGraphBuilder = class {
21088
21670
  }));
21089
21671
  const middlewareConfigs = params.middleware || [];
21090
21672
  const filesystemBackend = createFilesystemBackendFactory(middlewareConfigs);
21091
- const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend, true);
21673
+ const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend, true, params.tenantId);
21092
21674
  const topologyConfig = middlewareConfigs.find(
21093
21675
  (m) => m.type === "topology" && m.enabled
21094
21676
  );
@@ -21350,7 +21932,7 @@ var WorkflowAgentGraphBuilder = class {
21350
21932
  const checkpointer = getCheckpointSaver("default");
21351
21933
  const tools = params.tools.map((t) => t.executor).filter(Boolean);
21352
21934
  const middlewareConfigs = params.middleware || [];
21353
- const middlewares = await createCommonMiddlewares(middlewareConfigs, void 0, false);
21935
+ const middlewares = await createCommonMiddlewares(middlewareConfigs, void 0, false, params.tenantId);
21354
21936
  const askMiddlewares = await createCommonMiddlewares([
21355
21937
  {
21356
21938
  id: "ask_user_to_clarify",
@@ -21783,6 +22365,10 @@ async function configureStores(stores, options = {}) {
21783
22365
  }
21784
22366
  storeLatticeManager.registerLattice("default", type, store);
21785
22367
  }
22368
+ if (storeLatticeManager.hasLattice("default", "connection")) {
22369
+ const connectionStore = storeLatticeManager.getStoreLattice("default", "connection").store;
22370
+ ConnectionRegistry.setStore(connectionStore);
22371
+ }
21786
22372
  if (schedule !== void 0) {
21787
22373
  await initAndRegister(schedule, localDisposables);
21788
22374
  const scheduleConfig = {
@@ -23019,6 +23605,53 @@ registerToolLattice(
23019
23605
  }
23020
23606
  }
23021
23607
  );
23608
+ registerToolLattice(
23609
+ "list_middleware_types",
23610
+ {
23611
+ name: "list_middleware_types",
23612
+ description: "\u5217\u51FA\u5F53\u524D\u7CFB\u7EDF\u4E2D\u6240\u6709\u53EF\u7528\u7684\u4E2D\u95F4\u4EF6\u7C7B\u578B\uFF08Middlewares\uFF09\uFF0C\u5305\u62EC\u5185\u7F6E\u548C\u81EA\u5B9A\u4E49\u63D2\u4EF6\u3002\u8FD4\u56DE\u6BCF\u4E2A\u4E2D\u95F4\u4EF6\u7684 type\u3001name\u3001description\u3001tools \u6E05\u5355\uFF08\u652F\u6301 allowedTools \u8FC7\u6EE4\uFF09\u3001configSchema\uFF08\u914D\u7F6E\u9762\u677F\u9700\u8981\u54EA\u4E9B\u5B57\u6BB5\uFF09\u548C connectionSchema\uFF08\u662F\u5426\u652F\u6301\u8FDE\u63A5\u6D4B\u8BD5\u548C\u8D44\u6E90\u53D1\u73B0\uFF09\u3002\n\n\u4F7F\u7528\u573A\u666F\uFF1A\n1. \u5728\u521B\u5EFA agent \u524D\uFF0C\u5148\u8C03\u6B64\u5DE5\u5177\u4E86\u89E3\u6709\u54EA\u4E9B\u4E2D\u95F4\u4EF6\u53EF\u914D\u7F6E\n2. \u6839\u636E configSchema \u51B3\u5B9A\u9700\u8981\u63D0\u4F9B\u54EA\u4E9B\u914D\u7F6E\u5B57\u6BB5\uFF08\u5982 databaseKeys\u3001connections \u7B49\uFF09\n3. \u5982\u679C\u67D0\u4E2A\u4E2D\u95F4\u4EF6\u7684 connectionSchema \u5B58\u5728\uFF0C\u8BF4\u660E\u5B83\u662F\u8FDE\u63A5\u578B\u4E2D\u95F4\u4EF6\uFF0C\u9700\u8981\u518D\u8C03 list_connections \u83B7\u53D6\u53EF\u7528\u8FDE\u63A5\n4. \u7528\u8FD4\u56DE\u7684 type \u5B57\u6BB5\u6784\u5EFA middleware \u6570\u7EC4\u4F20\u7ED9 create_agent / update_agent",
23613
+ schema: import_zod64.default.object({})
23614
+ },
23615
+ async () => {
23616
+ const metas = PluginRegistry.listMeta();
23617
+ return JSON.stringify(metas);
23618
+ }
23619
+ );
23620
+ registerToolLattice(
23621
+ "list_connections",
23622
+ {
23623
+ name: "list_connections",
23624
+ description: "\u5217\u51FA\u6307\u5B9A\u63D2\u4EF6\u7C7B\u578B\u7684\u6240\u6709\u5DF2\u914D\u7F6E\u8FDE\u63A5\u3002\u7528\u4E8E\u67E5\u8BE2\u6709\u54EA\u4E9B\u53EF\u7528\u7684\u8FDE\u63A5\u5B9E\u4F8B\uFF08\u5982 'sap-prod', 'sap-dev'\uFF09\uFF0C\u65B9\u4FBF\u5728 agent \u914D\u7F6E\u4E2D\u9009\u62E9\u5177\u4F53\u8FDE\u63A5\u3002\n\n\u4F7F\u7528\u573A\u666F\uFF1A\n1. \u5148\u8C03 list_middleware_types \u786E\u5B9A\u67D0\u4E2A\u4E2D\u95F4\u4EF6\u662F\u8FDE\u63A5\u578B\uFF08\u6709 connectionSchema\uFF09\n2. \u8C03\u6B64\u5DE5\u5177\u4F20\u5165 type\uFF08\u5982 'erp'\uFF09\uFF0C\u83B7\u53D6\u8BE5\u7C7B\u578B\u4E0B\u5DF2\u914D\u597D\u7684\u8FDE\u63A5\u5217\u8868\n3. \u5728 create_agent \u7684 middleware[i].config.connections \u4E2D\u586B\u5165\u5BF9\u5E94\u7684 key \u503C\n\n\u8FD4\u56DE\u683C\u5F0F\uFF1A{ success: true, data: { records: [{ key, name, ... }] } }",
23625
+ schema: import_zod64.default.object({
23626
+ type: import_zod64.default.string().describe("\u63D2\u4EF6\u7C7B\u578B\u6807\u8BC6\uFF0C\u5982 'erp'\u3002\u4ECE list_middleware_types \u7684\u8FD4\u56DE\u4E2D\u83B7\u53D6")
23627
+ }),
23628
+ needUserApprove: false
23629
+ },
23630
+ async (input, config) => {
23631
+ const tenantId = getTenantId(config);
23632
+ try {
23633
+ const entries = await ConnectionRegistry.list(input.type, tenantId);
23634
+ return JSON.stringify({
23635
+ success: true,
23636
+ data: {
23637
+ records: entries.map((e) => ({
23638
+ key: e.key,
23639
+ name: e.name,
23640
+ description: e.description,
23641
+ updatedAt: e.updatedAt
23642
+ })),
23643
+ total: entries.length
23644
+ }
23645
+ });
23646
+ } catch (error) {
23647
+ return JSON.stringify({
23648
+ success: false,
23649
+ error: error.message,
23650
+ hint: "\u8BF7\u786E\u8BA4 ConnectionStore \u5DF2\u914D\u7F6E\u4E14\u63D2\u4EF6\u7C7B\u578B\u6B63\u786E\u3002\u8C03\u7528 list_middleware_types \u67E5\u770B\u53EF\u7528\u7C7B\u578B\u3002"
23651
+ });
23652
+ }
23653
+ }
23654
+ );
23022
23655
 
23023
23656
  // src/agent_lattice/agentArchitectConfig.ts
23024
23657
  var import_protocols14 = require("@axiom-lattice/protocols");
@@ -23338,101 +23971,29 @@ Returns: \`{ valid: boolean, stepCount, issues: [{ type: "error"|"warning", mess
23338
23971
 
23339
23972
  ### Middleware Config Reference
23340
23973
 
23974
+ **Always call \`list_middleware_types\` first** to see what middleware types are currently available, their config schemas, and whether they are connection-type middleware. The static list below may be outdated \u2014 the tool is the source of truth.
23975
+
23341
23976
  Each middleware entry uses this base shape:
23342
23977
 
23343
23978
  \`\`\`typescript
23344
23979
  {
23345
23980
  id: string, // Unique ID, usually same as type
23346
- type: string, // Middleware type from the table below
23981
+ type: string, // Middleware type from list_middleware_types
23347
23982
  name: string, // Display name
23348
23983
  description: string, // What this middleware provides
23349
23984
  enabled: true, // Always true for active middleware
23350
- config: { ... } // Type-specific config (see table)
23985
+ config: { ... } // Type-specific config (see list_middleware_types result)
23351
23986
  }
23352
23987
  \`\`\`
23353
23988
 
23354
- #### filesystem
23355
- Provides: \`ls\`, \`read_file\`, \`write_file\`, \`edit_file\`, \`glob\`, \`grep\`
23356
- | config field | type | description |
23357
- |-------------|------|-------------|
23358
- | backend | string | Pluggable backend, usually omitted (uses default) |
23359
- | systemPrompt | string? | Custom system prompt override for filesystem conventions |
23360
-
23361
- #### code_eval
23362
- Provides: \`run_code\` \u2014 execute Python/JavaScript in a sandbox
23363
- | config field | type | description |
23364
- |-------------|------|-------------|
23365
- | vmIsolation | "agent" | "project" | "global" | Sandbox isolation level. Default recommended: \`"agent"\` |
23366
- | timeout | number? | Execution timeout in milliseconds |
23367
- | memoryLimit | number? | Memory limit in MB |
23368
-
23369
- #### browser
23370
- Provides: \`browser_navigate\`, \`browser_click\`, \`browser_screenshot\`, \`browser_get_markdown\`, etc. (21 tools)
23371
- | config field | type | description |
23372
- |-------------|------|-------------|
23373
- | vmIsolation | "agent" | "project" | "global" | Sandbox isolation level. Default recommended: \`"agent"\` |
23374
- | headless | boolean? | Whether to run in headless mode |
23375
-
23376
- #### sql
23377
- Provides: \`sql_list_tables\`, \`sql_table_info\`, \`sql_query_checker\`, \`sql_query\`
23378
- | config field | type | description |
23379
- |-------------|------|-------------|
23380
- | databaseKeys | string[] | Array of database config keys to expose. Required. |
23381
- | databaseDescriptions | Record<string,string>? | Optional human-readable descriptions keyed by database key |
23382
-
23383
- #### skill
23384
- Provides: \`load_skill_content\` \u2014 load and read detailed skill instructions
23385
- | config field | type | description |
23386
- |-------------|------|-------------|
23387
- | skills | string[]? | List of specific skill IDs to expose |
23388
- | readAll | boolean? | When \`true\`, all available skills are exposed (recommended) |
23389
- | heading | string? | Optional heading for the skills section |
23390
- | extraNote | string? | Optional extra note appended after skills list |
23391
-
23392
- #### metrics
23393
- Provides: \`list_datasources\`, \`query_metrics_list\`, \`query_semantic_metric_data\`, \`query_tables_list\`, \`execute_sql_query\`, etc. (7 tools)
23394
- | config field | type | description |
23395
- |-------------|------|-------------|
23396
- | serverKeys | string[] | List of metrics server keys. Required. |
23397
- | serverDescriptions | Record<string,string>? | Optional descriptions for each server |
23398
- | connectAll | boolean? | When \`true\`, connects to all available metrics servers automatically |
23399
-
23400
- #### ask_user_to_clarify
23401
- Provides: \`ask_user_to_clarify\` \u2014 pause execution and present questions with predefined options to the user. The agent halts until the user responds, then receives the answers as structured data.
23402
- **Use this when:** the agent needs to confirm an action, get user approval, ask "which one?", or gather missing parameters. Without this middleware, the agent CANNOT interact with the user mid-execution.
23403
- Config: \`{}\` \u2014 no configuration needed.
23404
-
23405
- #### widget
23406
- Provides: \`load_guidelines\`, \`show_widget\` \u2014 render interactive HTML widgets and SVG diagrams
23407
- Config: \`{}\` \u2014 no configuration needed.
23408
-
23409
- #### claw
23410
- Provides: bootstrap file management (AGENTS.md, SOUL.md, etc.) \u2014 injects project context into system prompt
23411
- | config field | type | description |
23412
- |-------------|------|-------------|
23413
- | injectBootstrapFiles | boolean? | Whether to inject bootstrap files into system prompt. Default: \`true\` |
23414
- | bootstrapFiles | object? | Custom content for each bootstrap file |
23415
-
23416
- \`bootstrapFiles\` sub-fields: \`agents\`, \`soul\`, \`identity\`, \`user\`, \`tools\`, \`bootstrap\` \u2014 each is an optional string.
23417
-
23418
- #### date
23419
- Provides: \`get_current_date_time\` \u2014 get current date and time
23420
- | config field | type | description |
23421
- |-------------|------|-------------|
23422
- | timezone | string? | IANA timezone like \`"Asia/Shanghai"\` or \`"America/New_York"\`. Default: \`"UTC"\` |
23423
-
23424
- #### scheduler
23425
- Provides: \`schedule_at\`, \`schedule_after\`, \`schedule_recurring\`, \`cancel_scheduled_task\`, \`list_scheduled_tasks\`
23426
- | config field | type | description |
23427
- |-------------|------|-------------|
23428
- | defaultMaxRetries | number? | Default max retries for scheduled tasks. Default: \`0\` |
23429
-
23430
- #### topology [DEPRECATED \u2014 use WORKFLOW DSL instead]
23431
- Provides: \`read_topo_progress\` \u2014 enforces multi-agent workflow topology for PROCESSING agents only. Not needed for WORKFLOW agents.
23432
- | config field | type | description |
23433
- |-------------|------|-------------|
23434
- | edges | TopologyEdge[] | **Required.** Directed edges: \`{ from: string, to: string, purpose: string }\`. The \`purpose\` must describe the business intent of this delegation step. |
23435
- | trackingStore | object? | Optional persistence for workflow run tracking | |
23989
+ **Connection-type middleware** (those with \`connectionSchema\` in list_middleware_types output):
23990
+ 1. Call \`list_connections(type="xxx")\` to see available connection keys
23991
+ 2. Use the returned keys in \`config.connections: ["sap-prod", "sap-dev"]\`
23992
+
23993
+ **Tool filtering:** Use \`allowedTools\` to restrict which tools a middleware exposes:
23994
+ \`\`\`typescript
23995
+ { type: "browser", enabled: true, config: {}, allowedTools: ["browser_navigate", "browser_screenshot"] }
23996
+ \`\`\`
23436
23997
 
23437
23998
  ### When to use ask_user_to_clarify Middleware
23438
23999
 
@@ -23455,19 +24016,6 @@ Provides: \`read_topo_progress\` \u2014 enforces multi-agent workflow topology f
23455
24016
 
23456
24017
  **Design rule:** If your agent's system prompt says anything like "confirm with the user before...", "ask the user to choose...", or "get approval for...", you MUST include the \`ask_user_to_clarify\` middleware.
23457
24018
 
23458
- ### Quick Pick: Common Middleware Combos
23459
-
23460
- | Agent Role | Recommended Middleware |
23461
- |-----------|----------------------|
23462
- | Code assistant | code_eval, widget |
23463
- | Data analyst | sql, code_eval, widget |
23464
- | Web researcher | browser, widget |
23465
- | Operations / SRE | metrics, sql, widget |
23466
- | Process orchestrator | skill, date, scheduler, widget |
23467
- | General assistant | date, widget |
23468
- | Approval-gated operations | ask_user_to_clarify, widget |
23469
- | Interactive Q&A | ask_user_to_clarify, date, widget |
23470
-
23471
24019
  ### manage_binding Reference
23472
24020
 
23473
24021
  Use \`manage_binding\` to bind external senders (email, Lark, Slack) to agents. A binding routes inbound messages from the sender to the specified agent.
@@ -23598,6 +24146,8 @@ var agentArchitectConfig = {
23598
24146
  tools: [
23599
24147
  "list_agents",
23600
24148
  "list_tools",
24149
+ "list_middleware_types",
24150
+ "list_connections",
23601
24151
  "get_agent",
23602
24152
  "create_agent",
23603
24153
  "create_workflow",
@@ -26768,7 +27318,9 @@ function generateToken() {
26768
27318
  function createSharePayload(tenantId, workspaceId, projectId, userId, request) {
26769
27319
  const resourcePath = (request.resourcePath || "").replace(/^\/?project\/?/, "").replace(/\/+$/, "");
26770
27320
  if (!resourcePath || resourcePath === "/") {
26771
- throw new Error("Cannot share project root \u2014 share a subdirectory or file instead");
27321
+ if (request.visibility !== "internal") {
27322
+ throw new Error("Cannot share project root \u2014 share a subdirectory or file instead");
27323
+ }
26772
27324
  }
26773
27325
  return {
26774
27326
  address: createResourceAddress({
@@ -26895,6 +27447,28 @@ function clearEncryptionKeyCache() {
26895
27447
  keyValidated = false;
26896
27448
  }
26897
27449
 
27450
+ // src/plugin/BuiltinPlugins.ts
27451
+ var BUILTIN_PLUGINS = [
27452
+ filesystemPlugin,
27453
+ codeEvalPlugin,
27454
+ browserPlugin,
27455
+ sqlPlugin,
27456
+ skillPlugin,
27457
+ metricsPlugin,
27458
+ askUserClarifyPlugin,
27459
+ widgetPlugin,
27460
+ clawPlugin,
27461
+ datePlugin,
27462
+ schedulerPlugin,
27463
+ taskPlugin,
27464
+ collectionPlugin
27465
+ ];
27466
+ function registerBuiltinPlugins() {
27467
+ for (const plugin of BUILTIN_PLUGINS) {
27468
+ PluginRegistry.register(plugin);
27469
+ }
27470
+ }
27471
+
26898
27472
  // src/workflow/index.ts
26899
27473
  init_compile();
26900
27474
  init_parse_yaml();
@@ -27051,6 +27625,9 @@ var PersonalAssistantConfig = class {
27051
27625
  }
27052
27626
  };
27053
27627
  PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
27628
+
27629
+ // src/index.ts
27630
+ registerBuiltinPlugins();
27054
27631
  // Annotate the CommonJS export names for ESM import in node:
27055
27632
  0 && (module.exports = {
27056
27633
  AGENT_TASK_EVENT,
@@ -27059,11 +27636,13 @@ PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
27059
27636
  AgentLatticeManager,
27060
27637
  AgentManager,
27061
27638
  AgentType,
27639
+ BUILTIN_PLUGINS,
27062
27640
  BUILTIN_SKILLS,
27063
27641
  ChunkBuffer,
27064
27642
  ChunkBufferLatticeManager,
27065
27643
  CollectionLatticeManager,
27066
27644
  CompositeBackend,
27645
+ ConnectionRegistry,
27067
27646
  ConsoleLoggerClient,
27068
27647
  CustomMetricsClient,
27069
27648
  CustomMiddlewareRegistry,
@@ -27113,6 +27692,7 @@ PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
27113
27692
  MysqlDatabase,
27114
27693
  PersonalAssistantConfig,
27115
27694
  PinoLoggerClient,
27695
+ PluginRegistry,
27116
27696
  PostgresDatabase,
27117
27697
  PrometheusClient,
27118
27698
  Protocols,
@@ -27275,6 +27855,7 @@ PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
27275
27855
  sandboxLatticeManager,
27276
27856
  sanitizeToolCallId,
27277
27857
  scheduleLatticeManager,
27858
+ serializePluginMeta,
27278
27859
  setBindingRegistry,
27279
27860
  setMenuRegistry,
27280
27861
  skillLatticeManager,