@mastra/server 1.63.3-alpha.0 → 1.64.0-alpha.2

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.
@@ -4693,7 +4693,7 @@ function splitLines(text) {
4693
4693
  return result;
4694
4694
  }
4695
4695
  //#endregion
4696
- //#region ../memory/dist/src-BNtoxIHL.js
4696
+ //#region ../memory/dist/src-Br1yJXN1.js
4697
4697
  var __defProp$3 = Object.defineProperty;
4698
4698
  var __exportAll = (all, no_symbols) => {
4699
4699
  let target = {};
@@ -20678,6 +20678,12 @@ function requireVisible(scope, options, label) {
20678
20678
  if (!(0, _mastra_core_storage.isKnowledgeScopeVisible)(scope, options.scope)) throw new Error(`${label} is outside the curator's visible scope.`);
20679
20679
  }
20680
20680
  function createKnowledgeWriteTools(memory, options) {
20681
+ async function resolveWritableNode(id) {
20682
+ const node = await (await getStore(memory)).getNode(id);
20683
+ if (!node || node.mergedInto) throw new Error(`Knowledge node not found: ${id}`);
20684
+ requireVisible(node.scope, options, "Knowledge node");
20685
+ return node;
20686
+ }
20681
20687
  return {
20682
20688
  knowledge_append: (0, _mastra_core_tools.createTool)({
20683
20689
  id: "knowledge_append",
@@ -20748,7 +20754,7 @@ function createKnowledgeWriteTools(memory, options) {
20748
20754
  }),
20749
20755
  knowledge_update_node: (0, _mastra_core_tools.createTool)({
20750
20756
  id: "knowledge_update_node",
20751
- description: "Update a visible node name or kind using optimistic concurrency. Provide at least one of name or kind.",
20757
+ description: "Atomically rename and re-kind a visible node using optimistic concurrency.",
20752
20758
  inputSchema: {
20753
20759
  type: "object",
20754
20760
  properties: {
@@ -20769,17 +20775,18 @@ function createKnowledgeWriteTools(memory, options) {
20769
20775
  minLength: 1
20770
20776
  }
20771
20777
  },
20772
- required: ["node", "expectedVersion"],
20778
+ required: [
20779
+ "node",
20780
+ "expectedVersion",
20781
+ "name",
20782
+ "kind"
20783
+ ],
20773
20784
  additionalProperties: false
20774
20785
  },
20775
20786
  execute: async (input) => {
20776
20787
  const value = input;
20777
- if (value.name === void 0 && value.kind === void 0) throw new Error("knowledge_update_node requires at least one of: name, kind.");
20778
- const store = await getStore(memory);
20779
- const node = await store.getNode(value.node);
20780
- if (!node || node.mergedInto) throw new Error(`Knowledge node not found: ${value.node}`);
20781
- requireVisible(node.scope, options, "Knowledge node");
20782
- return store.updateNode({
20788
+ const node = await resolveWritableNode(value.node);
20789
+ return (await getStore(memory)).updateNode({
20783
20790
  id: node.id,
20784
20791
  version: value.expectedVersion,
20785
20792
  name: value.name,
@@ -20787,6 +20794,78 @@ function createKnowledgeWriteTools(memory, options) {
20787
20794
  });
20788
20795
  }
20789
20796
  }),
20797
+ knowledge_rename_node: (0, _mastra_core_tools.createTool)({
20798
+ id: "knowledge_rename_node",
20799
+ description: "Rename a visible node using optimistic concurrency.",
20800
+ inputSchema: {
20801
+ type: "object",
20802
+ properties: {
20803
+ node: {
20804
+ type: "string",
20805
+ minLength: 1
20806
+ },
20807
+ expectedVersion: {
20808
+ type: "integer",
20809
+ minimum: 1
20810
+ },
20811
+ name: {
20812
+ type: "string",
20813
+ minLength: 1
20814
+ }
20815
+ },
20816
+ required: [
20817
+ "node",
20818
+ "expectedVersion",
20819
+ "name"
20820
+ ],
20821
+ additionalProperties: false
20822
+ },
20823
+ execute: async (input) => {
20824
+ const value = input;
20825
+ const node = await resolveWritableNode(value.node);
20826
+ return (await getStore(memory)).updateNode({
20827
+ id: node.id,
20828
+ version: value.expectedVersion,
20829
+ name: value.name
20830
+ });
20831
+ }
20832
+ }),
20833
+ knowledge_set_node_kind: (0, _mastra_core_tools.createTool)({
20834
+ id: "knowledge_set_node_kind",
20835
+ description: "Change a visible node kind using optimistic concurrency.",
20836
+ inputSchema: {
20837
+ type: "object",
20838
+ properties: {
20839
+ node: {
20840
+ type: "string",
20841
+ minLength: 1
20842
+ },
20843
+ expectedVersion: {
20844
+ type: "integer",
20845
+ minimum: 1
20846
+ },
20847
+ kind: {
20848
+ type: "string",
20849
+ minLength: 1
20850
+ }
20851
+ },
20852
+ required: [
20853
+ "node",
20854
+ "expectedVersion",
20855
+ "kind"
20856
+ ],
20857
+ additionalProperties: false
20858
+ },
20859
+ execute: async (input) => {
20860
+ const value = input;
20861
+ const node = await resolveWritableNode(value.node);
20862
+ return (await getStore(memory)).updateNode({
20863
+ id: node.id,
20864
+ version: value.expectedVersion,
20865
+ kind: value.kind
20866
+ });
20867
+ }
20868
+ }),
20790
20869
  knowledge_merge_nodes: (0, _mastra_core_tools.createTool)({
20791
20870
  id: "knowledge_merge_nodes",
20792
20871
  description: "Merge a visible duplicate node into another visible node using source-version CAS.",
@@ -21320,7 +21399,7 @@ var Subconscious = class {
21320
21399
  const CURATION_AGENT = "curate";
21321
21400
  const DEFAULT_INSTRUCTIONS$1 = `Maintain durable scoped knowledge from the committed observation worklist.
21322
21401
 
21323
- Use the read tools to inspect existing nodes, knowledge records, mentions, backlinks, and long-form node content. Use the write tools to merge true duplicates, repair names and links, soft-delete superseded knowledge records, rescope knowledge records only when justified and permitted by their ceilings, and synthesize useful node content. Never restore deleted knowledge records. Never invent provenance, capture timestamps, scopes, ceilings, IDs, or versions; those are enforced by code. Resolve optimistic-concurrency conflicts by reading the latest record and retrying the intended mutation. Keep the reserved capture-guidance node concise and update it only with durable guidance that will improve future capture.
21402
+ Use the read tools to inspect existing nodes, knowledge records, mentions, backlinks, and long-form node content. Use the write tools to merge true duplicates, repair names and links, soft-delete superseded knowledge records, rescope knowledge records only when justified and permitted by their ceilings, and synthesize useful node content. When both a node name and kind must change, use knowledge_update_node so they commit atomically under one expectedVersion; use the single-field tools only when changing one field. Never restore deleted knowledge records. Never invent provenance, capture timestamps, scopes, ceilings, IDs, or versions; those are enforced by code. Resolve optimistic-concurrency conflicts by reading the latest record and retrying the intended mutation. Keep the reserved capture-guidance node concise and update it only with durable guidance that will improve future capture.
21324
21403
 
21325
21404
  For each significant entity node touched by a KnowledgeRecord in the current worklist, including people, projects, pull requests, issues, repositories, documents, and organizations, maintain a short entity description; do not walk nodes outside the worklist for this. Use the supplied record and read the named node once; do not search or browse unless its identity is ambiguous. Describe what the entity is, its current state, and links to its real-world object, then write it with knowledge_write_node_description, which always requires expectedVersion from the node you just read; after a version conflict, re-read the node and regenerate the description from its current state before retrying. If the node does not exist yet, create it first with knowledge_write_node_content, then re-read it for its fresh version before writing the description. Write one or two plain-text sentences, roughly 40 to 75 tokens; storage rejects any description over its hard length cap, so keep them tight and put long-form detail in node content instead. Include links only from the entity's own records or observations that explicitly associate the link with that entity; never invent a URL, identifier, file path, or provenance. Leave long-form node content alone unless you are synthesizing it deliberately; never shrink content into a synopsis. For entity-description maintenance only, skip low-signal nodes with only a trivial record, any system-kind node, and the reserved capture-guidance node.
21326
21405
 
@@ -27737,20 +27816,20 @@ function getUnobservedPartsPreservingToolCallPairs(message) {
27737
27816
  /**
27738
27817
  * Get the messages Observational Memory is allowed to work with.
27739
27818
  *
27740
- * Messages supplied through the `context` option are per-run ephemeral input. Core's
27741
- * persistence contract already treats them as never-persist: `MessageStateManager` routes
27742
- * them into `userContextMessages`, and `drainUnsavedMessages` only drains input/response.
27819
+ * Messages supplied through the `context` option and the synthetic `om-continuation`
27820
+ * message are prompt-only input. Core's persistence contract already treats context as
27821
+ * never-persist, while the continuation remains memory-sourced so it can stay in the live
27822
+ * actor prompt.
27743
27823
  *
27744
- * OM builds its windows from `get.all.db()`, which includes context messages, and then
27745
- * seals and persists candidates directly turning ephemeral context into durable user
27746
- * messages. Excluding them here keeps OM's window, sealing, persistence and token
27747
- * accounting consistent with that contract.
27824
+ * OM builds its windows from `get.all.db()`, which includes both categories, and then seals
27825
+ * and persists candidates directly. Excluding them here keeps OM's observation, buffering,
27826
+ * persistence, and token accounting consistent with their ephemeral contract.
27748
27827
  */
27749
27828
  function getObservableMessages(messageList) {
27750
- const allMessages = messageList.get.all.db();
27751
27829
  const contextMessageIds = messageList.makeMessageSourceChecker().context;
27752
- if (contextMessageIds.size === 0) return allMessages;
27753
- return allMessages.filter((message) => !contextMessageIds.has(message.id));
27830
+ return messageList.get.all.db().filter((message) => {
27831
+ return message.id !== "om-continuation" && !contextMessageIds.has(message.id);
27832
+ });
27754
27833
  }
27755
27834
  /**
27756
27835
  * Safely extract buffered observation chunks from a record.
@@ -46424,4 +46503,4 @@ const agentBuilderWorkflows = {
46424
46503
  //#endregion
46425
46504
  exports.agentBuilderWorkflows = agentBuilderWorkflows;
46426
46505
 
46427
- //# sourceMappingURL=dist-fQ5zEP_z.cjs.map
46506
+ //# sourceMappingURL=dist-BuyLBfu3.cjs.map