@mastra/core 1.1.0 → 1.2.0-alpha.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/CHANGELOG.md +74 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-RYVRCT7Z.cjs → chunk-22EV7GMK.cjs} +55 -19
- package/dist/chunk-22EV7GMK.cjs.map +1 -0
- package/dist/chunk-2QXNHEDL.js +8 -0
- package/dist/chunk-2QXNHEDL.js.map +1 -0
- package/dist/{chunk-OSIE5L6N.js → chunk-66BWIF4S.js} +7 -7
- package/dist/{chunk-OSIE5L6N.js.map → chunk-66BWIF4S.js.map} +1 -1
- package/dist/{chunk-IDDFKLI7.js → chunk-AC63Y6KP.js} +865 -1471
- package/dist/chunk-AC63Y6KP.js.map +1 -0
- package/dist/{chunk-4QJBNJI4.cjs → chunk-BLXWTBLL.cjs} +168 -168
- package/dist/{chunk-4QJBNJI4.cjs.map → chunk-BLXWTBLL.cjs.map} +1 -1
- package/dist/{chunk-KPIJA2R5.js → chunk-CILDTRXD.js} +2 -2
- package/dist/{chunk-KPIJA2R5.js.map → chunk-CILDTRXD.js.map} +1 -1
- package/dist/{chunk-OW7H7G5N.js → chunk-DWD5DB6W.js} +4 -4
- package/dist/{chunk-OW7H7G5N.js.map → chunk-DWD5DB6W.js.map} +1 -1
- package/dist/{chunk-MGOFRL36.cjs → chunk-EYUXOOSQ.cjs} +106 -39
- package/dist/chunk-EYUXOOSQ.cjs.map +1 -0
- package/dist/{chunk-FVVQY6UU.js → chunk-FAJYC6PA.js} +375 -23
- package/dist/chunk-FAJYC6PA.js.map +1 -0
- package/dist/{chunk-YQMDMIP6.js → chunk-FYMM4PKR.js} +1337 -312
- package/dist/chunk-FYMM4PKR.js.map +1 -0
- package/dist/{chunk-FAM74XPO.js → chunk-G6E3QNJC.js} +3741 -2912
- package/dist/chunk-G6E3QNJC.js.map +1 -0
- package/dist/{chunk-YSFYUEEG.cjs → chunk-I6PWV32C.cjs} +42 -10
- package/dist/chunk-I6PWV32C.cjs.map +1 -0
- package/dist/{chunk-VNGQXHUE.cjs → chunk-MCI7M6AT.cjs} +7 -7
- package/dist/{chunk-VNGQXHUE.cjs.map → chunk-MCI7M6AT.cjs.map} +1 -1
- package/dist/{chunk-4KQEQ4NM.js → chunk-NS33UC72.js} +55 -20
- package/dist/chunk-NS33UC72.js.map +1 -0
- package/dist/{chunk-4PERRFZD.cjs → chunk-OAOMKZXU.cjs} +1378 -353
- package/dist/chunk-OAOMKZXU.cjs.map +1 -0
- package/dist/{chunk-4ACKGMN2.cjs → chunk-ODNSWEMV.cjs} +7 -7
- package/dist/{chunk-4ACKGMN2.cjs.map → chunk-ODNSWEMV.cjs.map} +1 -1
- package/dist/{chunk-H4C5NORS.js → chunk-OQPAOUDS.js} +36 -5
- package/dist/chunk-OQPAOUDS.js.map +1 -0
- package/dist/{chunk-VAJRNUEF.js → chunk-SPVI7HCP.js} +76 -76
- package/dist/chunk-SPVI7HCP.js.map +1 -0
- package/dist/{chunk-ENLG644T.cjs → chunk-STNSGW7W.cjs} +1514 -2120
- package/dist/chunk-STNSGW7W.cjs.map +1 -0
- package/dist/{chunk-FZZI2V2T.js → chunk-USHB3SPM.js} +4 -4
- package/dist/{chunk-FZZI2V2T.js.map → chunk-USHB3SPM.js.map} +1 -1
- package/dist/{chunk-4NGQR4ML.cjs → chunk-UZL4H5P2.cjs} +5092 -4247
- package/dist/chunk-UZL4H5P2.cjs.map +1 -0
- package/dist/{chunk-DOVI2C5F.cjs → chunk-VZXYBFCX.cjs} +8 -8
- package/dist/{chunk-DOVI2C5F.cjs.map → chunk-VZXYBFCX.cjs.map} +1 -1
- package/dist/{chunk-4FUG3CNY.js → chunk-W3AQUG66.js} +3 -3
- package/dist/{chunk-4FUG3CNY.js.map → chunk-W3AQUG66.js.map} +1 -1
- package/dist/{chunk-SLMSUZBA.cjs → chunk-W57QS6F6.cjs} +400 -46
- package/dist/chunk-W57QS6F6.cjs.map +1 -0
- package/dist/{chunk-BG6DCMO2.js → chunk-XS2MED4Y.js} +105 -38
- package/dist/chunk-XS2MED4Y.js.map +1 -0
- package/dist/{chunk-HR67B4UM.cjs → chunk-XVHK5IAO.cjs} +15 -15
- package/dist/{chunk-HR67B4UM.cjs.map → chunk-XVHK5IAO.cjs.map} +1 -1
- package/dist/{chunk-RIPKI7ON.cjs → chunk-Y2SVKUOQ.cjs} +2 -2
- package/dist/{chunk-RIPKI7ON.cjs.map → chunk-Y2SVKUOQ.cjs.map} +1 -1
- package/dist/{chunk-LJOQ7WYC.cjs → chunk-ZCBG4ZQT.cjs} +4 -2
- package/dist/chunk-ZCBG4ZQT.cjs.map +1 -0
- package/dist/docs/README.md +2 -2
- package/dist/docs/SKILL.md +3 -3
- package/dist/docs/SOURCE_MAP.json +280 -270
- package/dist/docs/agents/01-overview.md +6 -2
- package/dist/docs/agents/02-using-tools.md +1 -0
- package/dist/docs/agents/06-processors.md +87 -1
- package/dist/docs/evals/01-overview.md +5 -5
- package/dist/docs/mcp/01-overview.md +2 -2
- package/dist/docs/observability/01-overview.md +1 -1
- package/dist/docs/observability/03-overview.md +3 -3
- package/dist/docs/processors/01-reference.md +100 -1
- package/dist/docs/rag/01-overview.md +1 -1
- package/dist/docs/rag/03-vector-databases.md +10 -1
- package/dist/docs/server/04-request-context.md +168 -0
- package/dist/docs/tools-mcp/01-mcp-overview.md +2 -2
- package/dist/docs/voice/01-overview.md +1 -1
- package/dist/docs/workflows/01-overview.md +9 -5
- package/dist/docs/workspace/01-overview.md +38 -31
- package/dist/docs/workspace/02-filesystem.md +9 -11
- package/dist/docs/workspace/03-sandbox.md +8 -10
- package/dist/docs/workspace/04-skills.md +24 -25
- package/dist/docs/workspace/05-search.md +34 -31
- package/dist/docs/workspace/06-reference.md +24 -149
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +15 -15
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +44 -15
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +11 -11
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +6 -0
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/models-dev-2HBSVUOS.js +3 -0
- package/dist/{models-dev-B2ESSYRH.js.map → models-dev-2HBSVUOS.js.map} +1 -1
- package/dist/models-dev-SOIECXXQ.cjs +12 -0
- package/dist/{models-dev-IQ54YHQ4.cjs.map → models-dev-SOIECXXQ.cjs.map} +1 -1
- package/dist/netlify-SSWMYSAX.js +3 -0
- package/dist/{netlify-KPCOQ52P.js.map → netlify-SSWMYSAX.js.map} +1 -1
- package/dist/netlify-TXZZCT6N.cjs +12 -0
- package/dist/{netlify-D6LNGTDH.cjs.map → netlify-TXZZCT6N.cjs.map} +1 -1
- package/dist/processors/index.cjs +44 -40
- package/dist/processors/index.js +1 -1
- package/dist/processors/processors/index.d.ts +1 -0
- package/dist/processors/processors/index.d.ts.map +1 -1
- package/dist/processors/processors/tool-search.d.ts +176 -0
- package/dist/processors/processors/tool-search.d.ts.map +1 -0
- package/dist/provider-registry-K5L4DHRK.js +3 -0
- package/dist/{provider-registry-B3CGX3OF.js.map → provider-registry-K5L4DHRK.js.map} +1 -1
- package/dist/provider-registry-ML2VWWLB.cjs +40 -0
- package/dist/{provider-registry-CHV3DFFA.cjs.map → provider-registry-ML2VWWLB.cjs.map} +1 -1
- package/dist/provider-registry.json +101 -34
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +16 -16
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +101 -101
- package/dist/storage/index.js +2 -2
- package/dist/storage/types.d.ts +4 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/constants.cjs +7 -3
- package/dist/workflows/constants.d.ts +1 -0
- package/dist/workflows/constants.d.ts.map +1 -1
- package/dist/workflows/constants.js +1 -1
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +8 -1
- package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
- package/dist/workflows/evented/helpers.d.ts +68 -0
- package/dist/workflows/evented/helpers.d.ts.map +1 -0
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +9 -17
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/types.d.ts +29 -0
- package/dist/workflows/evented/types.d.ts.map +1 -0
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +12 -3
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/utils.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +54 -3
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/index.cjs +28 -24
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/utils.d.ts +27 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +3 -0
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/index.cjs +32 -32
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/lifecycle.d.ts +2 -0
- package/dist/workspace/lifecycle.d.ts.map +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts +1 -2
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/sandbox.d.ts +0 -2
- package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
- package/dist/workspace/search/bm25.d.ts +2 -0
- package/dist/workspace/search/bm25.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/llm/model/provider-types.generated.d.ts +44 -15
- package/dist/chunk-4KQEQ4NM.js.map +0 -1
- package/dist/chunk-4NGQR4ML.cjs.map +0 -1
- package/dist/chunk-4PERRFZD.cjs.map +0 -1
- package/dist/chunk-BG6DCMO2.js.map +0 -1
- package/dist/chunk-ENLG644T.cjs.map +0 -1
- package/dist/chunk-FAM74XPO.js.map +0 -1
- package/dist/chunk-FVVQY6UU.js.map +0 -1
- package/dist/chunk-H4C5NORS.js.map +0 -1
- package/dist/chunk-IDDFKLI7.js.map +0 -1
- package/dist/chunk-LJOQ7WYC.cjs.map +0 -1
- package/dist/chunk-MGOFRL36.cjs.map +0 -1
- package/dist/chunk-RYVRCT7Z.cjs.map +0 -1
- package/dist/chunk-SLMSUZBA.cjs.map +0 -1
- package/dist/chunk-VAJRNUEF.js.map +0 -1
- package/dist/chunk-YEQB4VUA.js +0 -7
- package/dist/chunk-YEQB4VUA.js.map +0 -1
- package/dist/chunk-YQMDMIP6.js.map +0 -1
- package/dist/chunk-YSFYUEEG.cjs.map +0 -1
- package/dist/models-dev-B2ESSYRH.js +0 -3
- package/dist/models-dev-IQ54YHQ4.cjs +0 -12
- package/dist/netlify-D6LNGTDH.cjs +0 -12
- package/dist/netlify-KPCOQ52P.js +0 -3
- package/dist/provider-registry-B3CGX3OF.js +0 -3
- package/dist/provider-registry-CHV3DFFA.cjs +0 -40
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { extractLines, createWorkspaceTools } from './chunk-
|
|
1
|
+
import { extractLines, createWorkspaceTools, BM25Index } from './chunk-NS33UC72.js';
|
|
2
2
|
import { DefaultVoice } from './chunk-MQB7XFXP.js';
|
|
3
|
-
import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-
|
|
4
|
-
import { InMemoryStore } from './chunk-
|
|
3
|
+
import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-2QXNHEDL.js';
|
|
4
|
+
import { InMemoryStore } from './chunk-OQPAOUDS.js';
|
|
5
5
|
import { MessageList, coreContentToString, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-HIP5W3LZ.js';
|
|
6
6
|
import { parsePartialJson, isDeepEqualData, stepCountIs } from './chunk-UTLWS5LV.js';
|
|
7
7
|
import { generateId, asSchema, jsonSchema, APICallError, tool } from './chunk-CPLRD2VP.js';
|
|
8
|
-
import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-
|
|
8
|
+
import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-SPVI7HCP.js';
|
|
9
9
|
import { MastraLLMV1 } from './chunk-2CVY7S66.js';
|
|
10
10
|
import { noopLogger } from './chunk-PSCMWPLC.js';
|
|
11
11
|
import { PubSub } from './chunk-BVUMKER5.js';
|
|
@@ -601,7 +601,7 @@ function prepareToolsAndToolChoice({
|
|
|
601
601
|
if (Object.keys(tools || {}).length === 0) {
|
|
602
602
|
return {
|
|
603
603
|
tools: void 0,
|
|
604
|
-
toolChoice: void 0
|
|
604
|
+
toolChoice: toolChoice === "none" ? { type: "none" } : void 0
|
|
605
605
|
};
|
|
606
606
|
}
|
|
607
607
|
const filteredTools = activeTools != null ? Object.entries(tools || {}).filter(([name]) => activeTools.includes(name)) : Object.entries(tools || {});
|
|
@@ -5066,6 +5066,43 @@ function hydrateSerializedStepErrors(steps) {
|
|
|
5066
5066
|
}
|
|
5067
5067
|
return steps;
|
|
5068
5068
|
}
|
|
5069
|
+
function cleanSingleResult(result) {
|
|
5070
|
+
const { __state: _state, metadata, ...rest } = result;
|
|
5071
|
+
if (metadata && typeof metadata === "object" && !Array.isArray(metadata)) {
|
|
5072
|
+
const { nestedRunId: _nestedRunId, ...userMetadata } = metadata;
|
|
5073
|
+
if (Object.keys(userMetadata).length > 0) {
|
|
5074
|
+
return { ...rest, metadata: userMetadata };
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
return rest;
|
|
5078
|
+
}
|
|
5079
|
+
function cleanStepResult(stepResult) {
|
|
5080
|
+
if (stepResult === null || stepResult === void 0) {
|
|
5081
|
+
return stepResult;
|
|
5082
|
+
}
|
|
5083
|
+
if (typeof stepResult !== "object") {
|
|
5084
|
+
return stepResult;
|
|
5085
|
+
}
|
|
5086
|
+
if (Array.isArray(stepResult)) {
|
|
5087
|
+
return stepResult.map((item) => {
|
|
5088
|
+
if (item && typeof item === "object" && !Array.isArray(item)) {
|
|
5089
|
+
return cleanSingleResult(item);
|
|
5090
|
+
}
|
|
5091
|
+
return item;
|
|
5092
|
+
});
|
|
5093
|
+
}
|
|
5094
|
+
const result = stepResult;
|
|
5095
|
+
const cleaned = cleanSingleResult(result);
|
|
5096
|
+
if (Array.isArray(cleaned.output)) {
|
|
5097
|
+
cleaned.output = cleaned.output.map((item) => {
|
|
5098
|
+
if (item && typeof item === "object" && !Array.isArray(item)) {
|
|
5099
|
+
return cleanSingleResult(item);
|
|
5100
|
+
}
|
|
5101
|
+
return item;
|
|
5102
|
+
});
|
|
5103
|
+
}
|
|
5104
|
+
return cleaned;
|
|
5105
|
+
}
|
|
5069
5106
|
|
|
5070
5107
|
// src/workflows/handlers/control-flow.ts
|
|
5071
5108
|
async function executeParallel(engine, params) {
|
|
@@ -7245,10 +7282,28 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
7245
7282
|
return errorInstance.toJSON();
|
|
7246
7283
|
}
|
|
7247
7284
|
async fmtReturnValue(_pubsub, stepResults, lastOutput, error) {
|
|
7285
|
+
const cleanStepResults = {};
|
|
7286
|
+
for (const [stepId, stepResult] of Object.entries(stepResults)) {
|
|
7287
|
+
if (stepResult && typeof stepResult === "object" && !Array.isArray(stepResult) && "metadata" in stepResult) {
|
|
7288
|
+
const { metadata, ...rest } = stepResult;
|
|
7289
|
+
if (metadata) {
|
|
7290
|
+
const { nestedRunId: _nestedRunId, ...userMetadata } = metadata;
|
|
7291
|
+
if (Object.keys(userMetadata).length > 0) {
|
|
7292
|
+
cleanStepResults[stepId] = { ...rest, metadata: userMetadata };
|
|
7293
|
+
} else {
|
|
7294
|
+
cleanStepResults[stepId] = rest;
|
|
7295
|
+
}
|
|
7296
|
+
} else {
|
|
7297
|
+
cleanStepResults[stepId] = stepResult;
|
|
7298
|
+
}
|
|
7299
|
+
} else {
|
|
7300
|
+
cleanStepResults[stepId] = stepResult;
|
|
7301
|
+
}
|
|
7302
|
+
}
|
|
7248
7303
|
const base = {
|
|
7249
7304
|
status: lastOutput.status,
|
|
7250
|
-
steps:
|
|
7251
|
-
input:
|
|
7305
|
+
steps: cleanStepResults,
|
|
7306
|
+
input: cleanStepResults.input
|
|
7252
7307
|
};
|
|
7253
7308
|
if (lastOutput.status === "success") {
|
|
7254
7309
|
base.result = lastOutput.output;
|
|
@@ -9001,7 +9056,9 @@ var Workflow = class extends MastraBase {
|
|
|
9001
9056
|
const stepGraph = serializedStepGraph.find((stepGraph2) => stepGraph2?.step?.id === step);
|
|
9002
9057
|
finalSteps[step] = steps[step];
|
|
9003
9058
|
if (stepGraph && stepGraph?.step?.component === "WORKFLOW") {
|
|
9004
|
-
const
|
|
9059
|
+
const stepResult = steps[step];
|
|
9060
|
+
const nestedRunId = stepResult?.metadata?.nestedRunId ?? runId;
|
|
9061
|
+
const nestedSteps = await this.getWorkflowRunSteps({ runId: nestedRunId, workflowId: step });
|
|
9005
9062
|
if (nestedSteps) {
|
|
9006
9063
|
const updatedNestedSteps = Object.entries(nestedSteps).reduce(
|
|
9007
9064
|
(acc, [key, value]) => {
|
|
@@ -9081,11 +9138,16 @@ var Workflow = class extends MastraBase {
|
|
|
9081
9138
|
const fieldsSet = new Set(fields ?? []);
|
|
9082
9139
|
let steps = {};
|
|
9083
9140
|
if (includeAllFields || fieldsSet.has("steps")) {
|
|
9141
|
+
let rawSteps;
|
|
9084
9142
|
if (withNestedWorkflows) {
|
|
9085
|
-
|
|
9143
|
+
rawSteps = await this.getWorkflowRunSteps({ runId, workflowId: this.id });
|
|
9086
9144
|
} else {
|
|
9087
9145
|
const { input, ...stepsOnly } = snapshotState.context || {};
|
|
9088
|
-
|
|
9146
|
+
rawSteps = stepsOnly;
|
|
9147
|
+
}
|
|
9148
|
+
const { __state: _removedTopLevelState, ...stepsWithoutTopLevelState } = rawSteps;
|
|
9149
|
+
for (const [stepId, stepResult] of Object.entries(stepsWithoutTopLevelState)) {
|
|
9150
|
+
steps[stepId] = cleanStepResult(stepResult);
|
|
9089
9151
|
}
|
|
9090
9152
|
}
|
|
9091
9153
|
const result = {
|
|
@@ -13388,6 +13450,17 @@ var MastraLLMVNext = class extends MastraBase {
|
|
|
13388
13450
|
var PRIMITIVE_TYPES = z10.enum(["agent", "workflow", "none", "tool"]);
|
|
13389
13451
|
|
|
13390
13452
|
// src/loop/network/index.ts
|
|
13453
|
+
async function safeParseLLMJson(text) {
|
|
13454
|
+
if (!text?.trim()) {
|
|
13455
|
+
return null;
|
|
13456
|
+
}
|
|
13457
|
+
const preprocessed = escapeUnescapedControlCharsInJsonStrings(text);
|
|
13458
|
+
const { value, state } = await parsePartialJson(preprocessed);
|
|
13459
|
+
if (state === "successful-parse" || state === "repaired-parse") {
|
|
13460
|
+
return value;
|
|
13461
|
+
}
|
|
13462
|
+
return null;
|
|
13463
|
+
}
|
|
13391
13464
|
function filterMessagesForSubAgent(messages) {
|
|
13392
13465
|
return messages.filter((msg) => {
|
|
13393
13466
|
if (msg.role === "user") return true;
|
|
@@ -14211,10 +14284,8 @@ async function createNetworkLoop({
|
|
|
14211
14284
|
});
|
|
14212
14285
|
throw mastraError;
|
|
14213
14286
|
}
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
input = JSON.parse(inputData.prompt);
|
|
14217
|
-
} catch {
|
|
14287
|
+
const input = await safeParseLLMJson(inputData.prompt);
|
|
14288
|
+
if (input === null) {
|
|
14218
14289
|
const logger = mastra?.getLogger();
|
|
14219
14290
|
logger?.warn(
|
|
14220
14291
|
`Workflow execution step received invalid JSON prompt for workflow "${inputData.primitiveId}". Prompt was: "${inputData.prompt}". Returning error to routing agent for retry.`
|
|
@@ -14510,10 +14581,8 @@ async function createNetworkLoop({
|
|
|
14510
14581
|
throw mastraError;
|
|
14511
14582
|
}
|
|
14512
14583
|
const toolId = tool2.id;
|
|
14513
|
-
|
|
14514
|
-
|
|
14515
|
-
inputDataToUse = JSON.parse(inputData.prompt);
|
|
14516
|
-
} catch {
|
|
14584
|
+
const inputDataToUse = await safeParseLLMJson(inputData.prompt);
|
|
14585
|
+
if (inputDataToUse === null) {
|
|
14517
14586
|
logger?.warn(
|
|
14518
14587
|
`Tool execution step received invalid JSON prompt for tool "${toolId}". Prompt was: "${inputData.prompt}". Returning error to routing agent for retry.`
|
|
14519
14588
|
);
|
|
@@ -15107,8 +15176,8 @@ async function networkLoop({
|
|
|
15107
15176
|
}
|
|
15108
15177
|
});
|
|
15109
15178
|
const object = await result.object;
|
|
15110
|
-
const resumeDataFromLLM =
|
|
15111
|
-
if (Object.keys(resumeDataFromLLM).length > 0) {
|
|
15179
|
+
const resumeDataFromLLM = await safeParseLLMJson(object.resumeData);
|
|
15180
|
+
if (resumeDataFromLLM !== null && typeof resumeDataFromLLM === "object" && Object.keys(resumeDataFromLLM).length > 0) {
|
|
15112
15181
|
resumeDataFromTask = resumeDataFromLLM;
|
|
15113
15182
|
runIdFromTask = firstSuspendedTool.runId;
|
|
15114
15183
|
}
|
|
@@ -22590,6 +22659,289 @@ var ToolCallFilter = class {
|
|
|
22590
22659
|
return messages;
|
|
22591
22660
|
}
|
|
22592
22661
|
};
|
|
22662
|
+
var TOOL_SEARCH_TOKENIZE_OPTIONS = {
|
|
22663
|
+
lowercase: true,
|
|
22664
|
+
removePunctuation: false,
|
|
22665
|
+
minLength: 2,
|
|
22666
|
+
stopwords: /* @__PURE__ */ new Set(),
|
|
22667
|
+
splitPattern: /[\s\-_.,;:!?()[\]{}'"]+/
|
|
22668
|
+
};
|
|
22669
|
+
var ToolSearchProcessor = class {
|
|
22670
|
+
id = "tool-search";
|
|
22671
|
+
name = "Tool Search Processor";
|
|
22672
|
+
description = "Enables dynamic tool discovery and loading via search";
|
|
22673
|
+
allTools;
|
|
22674
|
+
searchConfig;
|
|
22675
|
+
ttl;
|
|
22676
|
+
/** BM25 index for tool search */
|
|
22677
|
+
bm25Index;
|
|
22678
|
+
/** Map from tool ID to full description (for result formatting) */
|
|
22679
|
+
toolDescriptions = /* @__PURE__ */ new Map();
|
|
22680
|
+
/**
|
|
22681
|
+
* Thread-scoped state management for loaded tools with TTL support.
|
|
22682
|
+
* Instance-scoped to prevent cross-processor interference.
|
|
22683
|
+
* Maps threadId -> ThreadState (tools + timestamp)
|
|
22684
|
+
*/
|
|
22685
|
+
threadLoadedTools = /* @__PURE__ */ new Map();
|
|
22686
|
+
constructor(options) {
|
|
22687
|
+
this.allTools = options.tools;
|
|
22688
|
+
this.searchConfig = {
|
|
22689
|
+
topK: options.search?.topK ?? 5,
|
|
22690
|
+
minScore: options.search?.minScore ?? 0
|
|
22691
|
+
};
|
|
22692
|
+
this.ttl = options.ttl ?? 36e5;
|
|
22693
|
+
this.bm25Index = new BM25Index({}, TOOL_SEARCH_TOKENIZE_OPTIONS);
|
|
22694
|
+
this.indexTools();
|
|
22695
|
+
if (this.ttl > 0) {
|
|
22696
|
+
this.scheduleCleanup();
|
|
22697
|
+
}
|
|
22698
|
+
}
|
|
22699
|
+
/**
|
|
22700
|
+
* Get the thread ID from the request context, or use 'default' as fallback.
|
|
22701
|
+
*/
|
|
22702
|
+
getThreadId(args) {
|
|
22703
|
+
return args.requestContext?.get(MASTRA_THREAD_ID_KEY) || "default";
|
|
22704
|
+
}
|
|
22705
|
+
/**
|
|
22706
|
+
* Get the set of loaded tool names for the current thread.
|
|
22707
|
+
* Updates the lastAccessed timestamp for TTL management.
|
|
22708
|
+
*/
|
|
22709
|
+
getLoadedToolNames(threadId) {
|
|
22710
|
+
if (!this.threadLoadedTools.has(threadId)) {
|
|
22711
|
+
this.threadLoadedTools.set(threadId, {
|
|
22712
|
+
tools: /* @__PURE__ */ new Set(),
|
|
22713
|
+
lastAccessed: Date.now()
|
|
22714
|
+
});
|
|
22715
|
+
}
|
|
22716
|
+
const state = this.threadLoadedTools.get(threadId);
|
|
22717
|
+
state.lastAccessed = Date.now();
|
|
22718
|
+
return state.tools;
|
|
22719
|
+
}
|
|
22720
|
+
/**
|
|
22721
|
+
* Get loaded tools as Tool objects for the current thread.
|
|
22722
|
+
*/
|
|
22723
|
+
getLoadedTools(threadId) {
|
|
22724
|
+
const loadedNames = this.getLoadedToolNames(threadId);
|
|
22725
|
+
const loadedTools = {};
|
|
22726
|
+
for (const toolName of loadedNames) {
|
|
22727
|
+
const tool2 = this.allTools[toolName] || Object.values(this.allTools).find((t) => t.id === toolName);
|
|
22728
|
+
if (tool2) {
|
|
22729
|
+
loadedTools[toolName] = tool2;
|
|
22730
|
+
}
|
|
22731
|
+
}
|
|
22732
|
+
return loadedTools;
|
|
22733
|
+
}
|
|
22734
|
+
/**
|
|
22735
|
+
* Clear loaded tools for a specific thread (useful for testing).
|
|
22736
|
+
*
|
|
22737
|
+
* @param threadId - The thread ID to clear, or 'default' if not provided
|
|
22738
|
+
*/
|
|
22739
|
+
clearState(threadId = "default") {
|
|
22740
|
+
this.threadLoadedTools.delete(threadId);
|
|
22741
|
+
}
|
|
22742
|
+
/**
|
|
22743
|
+
* Clear all thread state for this processor instance (useful for testing).
|
|
22744
|
+
*/
|
|
22745
|
+
clearAllState() {
|
|
22746
|
+
this.threadLoadedTools.clear();
|
|
22747
|
+
}
|
|
22748
|
+
/**
|
|
22749
|
+
* Clean up stale thread state based on TTL.
|
|
22750
|
+
* Removes threads that haven't been accessed within the TTL period.
|
|
22751
|
+
*
|
|
22752
|
+
* @returns Number of threads cleaned up
|
|
22753
|
+
*/
|
|
22754
|
+
cleanupStaleState() {
|
|
22755
|
+
if (this.ttl <= 0) return 0;
|
|
22756
|
+
const now = Date.now();
|
|
22757
|
+
let cleanedCount = 0;
|
|
22758
|
+
for (const [threadId, state] of this.threadLoadedTools.entries()) {
|
|
22759
|
+
if (now - state.lastAccessed > this.ttl) {
|
|
22760
|
+
this.threadLoadedTools.delete(threadId);
|
|
22761
|
+
cleanedCount++;
|
|
22762
|
+
}
|
|
22763
|
+
}
|
|
22764
|
+
return cleanedCount;
|
|
22765
|
+
}
|
|
22766
|
+
/**
|
|
22767
|
+
* Schedule periodic cleanup of stale thread state.
|
|
22768
|
+
* Runs cleanup every TTL/2 milliseconds to prevent unbounded memory growth.
|
|
22769
|
+
*/
|
|
22770
|
+
scheduleCleanup() {
|
|
22771
|
+
const cleanupInterval = Math.max(this.ttl / 2, 6e4);
|
|
22772
|
+
const intervalId = setInterval(() => {
|
|
22773
|
+
this.cleanupStaleState();
|
|
22774
|
+
}, cleanupInterval);
|
|
22775
|
+
if (intervalId.unref) {
|
|
22776
|
+
intervalId.unref();
|
|
22777
|
+
}
|
|
22778
|
+
}
|
|
22779
|
+
/**
|
|
22780
|
+
* Get statistics about current thread state (useful for monitoring).
|
|
22781
|
+
*
|
|
22782
|
+
* @returns Object with thread count and oldest access time
|
|
22783
|
+
*/
|
|
22784
|
+
getStateStats() {
|
|
22785
|
+
if (this.threadLoadedTools.size === 0) {
|
|
22786
|
+
return { threadCount: 0, oldestAccessTime: null };
|
|
22787
|
+
}
|
|
22788
|
+
let oldest = Date.now();
|
|
22789
|
+
for (const state of this.threadLoadedTools.values()) {
|
|
22790
|
+
if (state.lastAccessed < oldest) {
|
|
22791
|
+
oldest = state.lastAccessed;
|
|
22792
|
+
}
|
|
22793
|
+
}
|
|
22794
|
+
return {
|
|
22795
|
+
threadCount: this.threadLoadedTools.size,
|
|
22796
|
+
oldestAccessTime: oldest
|
|
22797
|
+
};
|
|
22798
|
+
}
|
|
22799
|
+
/**
|
|
22800
|
+
* Manually trigger cleanup of stale state (useful for testing and monitoring).
|
|
22801
|
+
*
|
|
22802
|
+
* @returns Number of threads cleaned up
|
|
22803
|
+
*/
|
|
22804
|
+
cleanupNow() {
|
|
22805
|
+
return this.cleanupStaleState();
|
|
22806
|
+
}
|
|
22807
|
+
/**
|
|
22808
|
+
* Index all tools into the BM25 index
|
|
22809
|
+
*/
|
|
22810
|
+
indexTools() {
|
|
22811
|
+
for (const tool2 of Object.values(this.allTools)) {
|
|
22812
|
+
const name = tool2.id;
|
|
22813
|
+
const description = tool2.description || "";
|
|
22814
|
+
this.bm25Index.add(name, `${name} ${description}`);
|
|
22815
|
+
this.toolDescriptions.set(name, description);
|
|
22816
|
+
}
|
|
22817
|
+
}
|
|
22818
|
+
/**
|
|
22819
|
+
* Search for tools matching the query using BM25 ranking
|
|
22820
|
+
* with name-match boosting.
|
|
22821
|
+
*
|
|
22822
|
+
* @param query - Search keywords
|
|
22823
|
+
* @returns Array of matching tools with scores, sorted by relevance
|
|
22824
|
+
*/
|
|
22825
|
+
searchTools(query) {
|
|
22826
|
+
if (this.bm25Index.size === 0) return [];
|
|
22827
|
+
const bm25Results = this.bm25Index.search(query, this.searchConfig.topK * 2, 0);
|
|
22828
|
+
if (bm25Results.length === 0) return [];
|
|
22829
|
+
const queryTokens = query.toLowerCase().split(/[\s\-_.,;:!?()[\]{}'"]+/).filter((t) => t.length > 1);
|
|
22830
|
+
const boostedResults = bm25Results.map((result) => {
|
|
22831
|
+
let score = result.score;
|
|
22832
|
+
const nameLower = result.id.toLowerCase();
|
|
22833
|
+
for (const term of queryTokens) {
|
|
22834
|
+
if (nameLower === term) {
|
|
22835
|
+
score += 5;
|
|
22836
|
+
} else if (nameLower.includes(term)) {
|
|
22837
|
+
score += 2;
|
|
22838
|
+
}
|
|
22839
|
+
}
|
|
22840
|
+
return { id: result.id, score };
|
|
22841
|
+
});
|
|
22842
|
+
return boostedResults.sort((a, b) => b.score - a.score).filter((r) => r.score > this.searchConfig.minScore).slice(0, this.searchConfig.topK).map((r) => {
|
|
22843
|
+
const description = this.toolDescriptions.get(r.id) || "";
|
|
22844
|
+
return {
|
|
22845
|
+
name: r.id,
|
|
22846
|
+
description: description.length > 150 ? description.slice(0, 147) + "..." : description,
|
|
22847
|
+
score: Math.round(r.score * 100) / 100
|
|
22848
|
+
};
|
|
22849
|
+
});
|
|
22850
|
+
}
|
|
22851
|
+
async processInputStep(args) {
|
|
22852
|
+
const { tools, messageList } = args;
|
|
22853
|
+
const threadId = this.getThreadId(args);
|
|
22854
|
+
const loadedToolNames = this.getLoadedToolNames(threadId);
|
|
22855
|
+
messageList.addSystem(
|
|
22856
|
+
"To discover available tools, call search_tools with a keyword query. To add a tool to the conversation, call load_tool with the tool name. Tools must be loaded before they can be used."
|
|
22857
|
+
);
|
|
22858
|
+
const searchTool = createTool({
|
|
22859
|
+
id: "search_tools",
|
|
22860
|
+
description: "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools with their names and descriptions. After finding a useful tool, use load_tool to make it available.",
|
|
22861
|
+
inputSchema: z.object({
|
|
22862
|
+
query: z.string().describe('Search keywords (e.g., "weather", "github issue", "database query")')
|
|
22863
|
+
}),
|
|
22864
|
+
outputSchema: z.object({
|
|
22865
|
+
results: z.array(
|
|
22866
|
+
z.object({
|
|
22867
|
+
name: z.string(),
|
|
22868
|
+
description: z.string(),
|
|
22869
|
+
score: z.number()
|
|
22870
|
+
})
|
|
22871
|
+
),
|
|
22872
|
+
message: z.string()
|
|
22873
|
+
}),
|
|
22874
|
+
execute: async ({ query }) => {
|
|
22875
|
+
const results = this.searchTools(query);
|
|
22876
|
+
if (results.length === 0) {
|
|
22877
|
+
return {
|
|
22878
|
+
results: [],
|
|
22879
|
+
message: `No tools found matching "${query}". Try different keywords.`
|
|
22880
|
+
};
|
|
22881
|
+
}
|
|
22882
|
+
return {
|
|
22883
|
+
results,
|
|
22884
|
+
message: `Found ${results.length} tool(s). Use load_tool with the exact tool name to make it available.`
|
|
22885
|
+
};
|
|
22886
|
+
}
|
|
22887
|
+
});
|
|
22888
|
+
const loadTool = createTool({
|
|
22889
|
+
id: "load_tool",
|
|
22890
|
+
description: "Load a specific tool into your context. Call this after finding a tool with search_tools. Once loaded, the tool will be available for use. Args: toolName - The exact name of the tool to load (from search results).",
|
|
22891
|
+
inputSchema: z.object({
|
|
22892
|
+
toolName: z.string().describe("The exact name of the tool to load (from search results)")
|
|
22893
|
+
}),
|
|
22894
|
+
outputSchema: z.object({
|
|
22895
|
+
success: z.boolean(),
|
|
22896
|
+
message: z.string(),
|
|
22897
|
+
toolName: z.string().optional()
|
|
22898
|
+
}),
|
|
22899
|
+
execute: async ({ toolName }) => {
|
|
22900
|
+
const matchingTool = this.allTools[toolName] ?? Object.values(this.allTools).find((tool2) => tool2.id === toolName);
|
|
22901
|
+
if (!matchingTool) {
|
|
22902
|
+
const availableToolNames = Object.keys(this.allTools).concat(
|
|
22903
|
+
Object.values(this.allTools).map((t) => t.id).filter((id) => !this.allTools[id])
|
|
22904
|
+
);
|
|
22905
|
+
const suggestions = availableToolNames.filter(
|
|
22906
|
+
(name) => name.toLowerCase().includes(toolName.toLowerCase()) || toolName.toLowerCase().includes(name.toLowerCase())
|
|
22907
|
+
);
|
|
22908
|
+
let message = `Tool "${toolName}" not found.`;
|
|
22909
|
+
if (suggestions.length > 0) {
|
|
22910
|
+
message += ` Did you mean: ${suggestions.slice(0, 3).join(", ")}?`;
|
|
22911
|
+
} else {
|
|
22912
|
+
message += " Use search_tools to find available tools.";
|
|
22913
|
+
}
|
|
22914
|
+
return {
|
|
22915
|
+
success: false,
|
|
22916
|
+
message
|
|
22917
|
+
};
|
|
22918
|
+
}
|
|
22919
|
+
if (loadedToolNames.has(toolName)) {
|
|
22920
|
+
return {
|
|
22921
|
+
success: true,
|
|
22922
|
+
message: `Tool "${toolName}" is already loaded and available.`,
|
|
22923
|
+
toolName
|
|
22924
|
+
};
|
|
22925
|
+
}
|
|
22926
|
+
loadedToolNames.add(toolName);
|
|
22927
|
+
return {
|
|
22928
|
+
success: true,
|
|
22929
|
+
message: `Tool "${toolName}" loaded successfully. It will be available on your next turn.`,
|
|
22930
|
+
toolName
|
|
22931
|
+
};
|
|
22932
|
+
}
|
|
22933
|
+
});
|
|
22934
|
+
const loadedTools = this.getLoadedTools(threadId);
|
|
22935
|
+
return {
|
|
22936
|
+
tools: {
|
|
22937
|
+
search_tools: searchTool,
|
|
22938
|
+
load_tool: loadTool,
|
|
22939
|
+
...tools ?? {},
|
|
22940
|
+
...loadedTools
|
|
22941
|
+
}
|
|
22942
|
+
};
|
|
22943
|
+
}
|
|
22944
|
+
};
|
|
22593
22945
|
|
|
22594
22946
|
// src/memory/working-memory-utils.ts
|
|
22595
22947
|
var WORKING_MEMORY_START_TAG = "<working_memory>";
|
|
@@ -24027,6 +24379,6 @@ var MockMemory = class extends MastraMemory {
|
|
|
24027
24379
|
}
|
|
24028
24380
|
};
|
|
24029
24381
|
|
|
24030
|
-
export { Agent, BaseProcessor, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, EventEmitterPubSub, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MastraScorer, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SkillsProcessor, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, TripWire, UnicodeNormalizer, WORKING_MEMORY_END_TAG, WORKING_MEMORY_START_TAG, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createScorer, createStep, createTimeTravelExecutionParams, createWorkflow, extractWorkingMemoryContent, extractWorkingMemoryTags, formatCheckFeedback, formatCompletionFeedback, formatValidationFeedback, generateFinalResult, generateStructuredFinalResult, getResumeLabelsByStepId, getStepIds, getStepResult, getZodErrors, globalEmbeddingCache, hydrateSerializedStepErrors, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, removeWorkingMemoryTags, resolveThreadIdFromArgs, runChecks, runCompletionScorers, runCountDeprecationMessage, runDefaultCompletionCheck, runValidation, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepRequestContext, validateStepResumeData, validateStepStateData, validateStepSuspendData };
|
|
24031
|
-
//# sourceMappingURL=chunk-
|
|
24032
|
-
//# sourceMappingURL=chunk-
|
|
24382
|
+
export { Agent, BaseProcessor, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, EventEmitterPubSub, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MastraScorer, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SkillsProcessor, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, ToolSearchProcessor, TripWire, UnicodeNormalizer, WORKING_MEMORY_END_TAG, WORKING_MEMORY_START_TAG, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cleanStepResult, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createScorer, createStep, createTimeTravelExecutionParams, createWorkflow, extractWorkingMemoryContent, extractWorkingMemoryTags, formatCheckFeedback, formatCompletionFeedback, formatValidationFeedback, generateFinalResult, generateStructuredFinalResult, getResumeLabelsByStepId, getStepIds, getStepResult, getZodErrors, globalEmbeddingCache, hydrateSerializedStepErrors, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, removeWorkingMemoryTags, resolveThreadIdFromArgs, runChecks, runCompletionScorers, runCountDeprecationMessage, runDefaultCompletionCheck, runValidation, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepRequestContext, validateStepResumeData, validateStepStateData, validateStepSuspendData };
|
|
24383
|
+
//# sourceMappingURL=chunk-FAJYC6PA.js.map
|
|
24384
|
+
//# sourceMappingURL=chunk-FAJYC6PA.js.map
|