@mastra/code-sdk 1.15.0-alpha.1 → 1.15.0-alpha.10
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/acp/agent.d.ts.map +1 -1
- package/dist/acp/agent.js +1 -1
- package/dist/acp/agent.js.map +1 -1
- package/dist/acp/event-mapper.d.ts.map +1 -1
- package/dist/acp/event-mapper.js +1 -1
- package/dist/acp/event-mapper.js.map +1 -1
- package/dist/agent-connections/signal-provider.d.ts +1 -1
- package/dist/agent-connections/signal-provider.d.ts.map +1 -1
- package/dist/agent-connections/signal-provider.js.map +1 -1
- package/dist/agent-connections/state-processor.d.ts +2 -2
- package/dist/agent-connections/state-processor.d.ts.map +1 -1
- package/dist/agent-connections/state-processor.js.map +1 -1
- package/dist/agent-connections/thread-state.d.ts +1 -1
- package/dist/agent-connections/thread-state.d.ts.map +1 -1
- package/dist/agent-connections/thread-state.js.map +1 -1
- package/dist/agent-connections/tools.d.ts.map +1 -1
- package/dist/agent-connections/tools.js +1 -1
- package/dist/agent-connections/tools.js.map +1 -1
- package/dist/agents/background-completion.d.ts +15 -2
- package/dist/agents/background-completion.d.ts.map +1 -1
- package/dist/agents/background-completion.js +19 -2
- package/dist/agents/background-completion.js.map +1 -1
- package/dist/agents/credential-resolver.d.ts +6 -0
- package/dist/agents/credential-resolver.d.ts.map +1 -1
- package/dist/agents/credential-resolver.js +13 -4
- package/dist/agents/credential-resolver.js.map +1 -1
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/memory.js +1 -1
- package/dist/agents/memory.js.map +1 -1
- package/dist/agents/sandbox-filesystem.d.ts +32 -10
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -1
- package/dist/agents/sandbox-filesystem.js +208 -66
- package/dist/agents/sandbox-filesystem.js.map +1 -1
- package/dist/agents/workspace.d.ts.map +1 -1
- package/dist/agents/workspace.js +1 -0
- package/dist/agents/workspace.js.map +1 -1
- package/dist/experimental-agent.d.ts +1 -1
- package/dist/experimental-agent.d.ts.map +1 -1
- package/dist/experimental-agent.js.map +1 -1
- package/dist/factory/client.d.ts +41 -0
- package/dist/factory/client.d.ts.map +1 -0
- package/dist/factory/client.js +98 -0
- package/dist/factory/client.js.map +1 -0
- package/dist/factory/remote-controller.d.ts +34 -0
- package/dist/factory/remote-controller.d.ts.map +1 -0
- package/dist/factory/remote-controller.js +43 -0
- package/dist/factory/remote-controller.js.map +1 -0
- package/dist/factory/remote-session.d.ts +210 -0
- package/dist/factory/remote-session.d.ts.map +1 -0
- package/dist/factory/remote-session.js +420 -0
- package/dist/factory/remote-session.js.map +1 -0
- package/dist/headless/cli.d.ts +7 -0
- package/dist/headless/cli.d.ts.map +1 -1
- package/dist/headless/cli.js +19 -3
- package/dist/headless/cli.js.map +1 -1
- package/dist/headless/flags.d.ts.map +1 -1
- package/dist/headless/flags.js +2 -1
- package/dist/headless/flags.js.map +1 -1
- package/dist/headless/format.d.ts +2 -0
- package/dist/headless/format.d.ts.map +1 -1
- package/dist/headless/format.js +13 -1
- package/dist/headless/format.js.map +1 -1
- package/dist/headless/run-mc.d.ts.map +1 -1
- package/dist/headless/run-mc.js +48 -20
- package/dist/headless/run-mc.js.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -23
- package/dist/index.js.map +1 -1
- package/dist/onboarding/pack-activation.d.ts +2 -11
- package/dist/onboarding/pack-activation.d.ts.map +1 -1
- package/dist/onboarding/pack-activation.js.map +1 -1
- package/dist/onboarding/settings.d.ts +18 -0
- package/dist/onboarding/settings.d.ts.map +1 -1
- package/dist/onboarding/settings.js +28 -3
- package/dist/onboarding/settings.js.map +1 -1
- package/dist/platform/index.d.ts +74 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +200 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/process-memory-diagnostics.d.ts +2 -1
- package/dist/process-memory-diagnostics.d.ts.map +1 -1
- package/dist/process-memory-diagnostics.js.map +1 -1
- package/dist/providers/model-ids.d.ts +1 -0
- package/dist/providers/model-ids.d.ts.map +1 -1
- package/dist/providers/model-ids.js +6 -4
- package/dist/providers/model-ids.js.map +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js.map +1 -1
- package/dist/tools/workflows/create-workflow.d.ts.map +1 -1
- package/dist/tools/workflows/create-workflow.js +5 -1
- package/dist/tools/workflows/create-workflow.js.map +1 -1
- package/dist/utils/local-observability.d.ts +19 -0
- package/dist/utils/local-observability.d.ts.map +1 -0
- package/dist/utils/local-observability.js +57 -0
- package/dist/utils/local-observability.js.map +1 -0
- package/dist/utils/notification-dispatch.d.ts +27 -12
- package/dist/utils/notification-dispatch.d.ts.map +1 -1
- package/dist/utils/notification-dispatch.js +46 -24
- package/dist/utils/notification-dispatch.js.map +1 -1
- package/dist/utils/signals-pubsub.d.ts +5 -3
- package/dist/utils/signals-pubsub.d.ts.map +1 -1
- package/dist/utils/signals-pubsub.js +8 -6
- package/dist/utils/signals-pubsub.js.map +1 -1
- package/dist/utils/wake-session.d.ts +44 -0
- package/dist/utils/wake-session.d.ts.map +1 -0
- package/dist/utils/wake-session.js +86 -0
- package/dist/utils/wake-session.js.map +1 -0
- package/dist/workflows/register-primitives.js +4 -1
- package/dist/workflows/register-primitives.js.map +1 -1
- package/package.json +23 -23
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AgentController, Session } from '@mastra/core/agent-controller';
|
|
2
|
+
import type { LeaseProvider } from '@mastra/core/events';
|
|
3
|
+
/** A session here serves the thread's resource, but the thread belongs to another project. */
|
|
4
|
+
export declare const FOREIGN_THREAD: unique symbol;
|
|
5
|
+
/** The session a wake runs as, and the dispatch lease that covers the thread. */
|
|
6
|
+
export type WakeSession<TState> = {
|
|
7
|
+
session: Session<TState>;
|
|
8
|
+
/**
|
|
9
|
+
* The thread's scope (`threadScopeKey`) when it carries the session's whole
|
|
10
|
+
* scope: only the process holding that scope's dispatch lease delivers it.
|
|
11
|
+
* Unset for a thread with no scope, which the resource's lease covers.
|
|
12
|
+
*/
|
|
13
|
+
scope?: string;
|
|
14
|
+
};
|
|
15
|
+
/** A stable key for a session's thread scope, or `undefined` when it has none. */
|
|
16
|
+
export declare function threadScopeKey(scope: Record<string, string>): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The session a wake for `threadId` should run as, or `FOREIGN_THREAD` when
|
|
19
|
+
* this process serves the resource but not the thread.
|
|
20
|
+
*
|
|
21
|
+
* A resource is not a project: processes in different directories can share
|
|
22
|
+
* one resource id (to share recall, say), and each then has a live session for
|
|
23
|
+
* it. Picking by resource alone runs the thread in whichever process asked,
|
|
24
|
+
* with that process's workspace, tools and cwd. The thread's scope tags (the
|
|
25
|
+
* ones `thread.create()` stamps, such as `projectPath`) say which session it
|
|
26
|
+
* belongs to. A thread with no scope tags, or with tags no session here
|
|
27
|
+
* contradicts, keeps going to the resource's session.
|
|
28
|
+
*
|
|
29
|
+
* A session that has the thread open always owns it. When the thread belongs to
|
|
30
|
+
* another project, that session delivers it under a lease for this one thread
|
|
31
|
+
* (`openThreadScope`), and the thread's own project yields it while another
|
|
32
|
+
* process holds that lease (`leases`), so only one process runs it and the
|
|
33
|
+
* project's other threads stay with the project.
|
|
34
|
+
*/
|
|
35
|
+
export declare function findWakeSession<TState>(controller: Pick<AgentController<TState>, 'getSession'>, liveSessions: Iterable<Session<TState>>, { resourceId, threadId }: {
|
|
36
|
+
resourceId: string;
|
|
37
|
+
threadId: string;
|
|
38
|
+
}, leases?: Pick<LeaseProvider, 'getLeaseOwner'>): Promise<WakeSession<TState> | typeof FOREIGN_THREAD | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* The dispatch lease scopes a session needs: its own, plus a lease for its open
|
|
41
|
+
* thread alone when that thread belongs to another project (`findWakeSession`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function sessionLeaseScopes<TState>(session: Session<TState>): Promise<Array<string | undef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7G"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { findSessionForThread } from "../agents/background-completion.js";
|
|
2
|
+
import { notificationDispatchLeaseKey } from "./signals-pubsub.js";
|
|
3
|
+
//#region src/utils/wake-session.ts
|
|
4
|
+
/** A session here serves the thread's resource, but the thread belongs to another project. */
|
|
5
|
+
const FOREIGN_THREAD = Symbol("foreign-thread");
|
|
6
|
+
/** A stable key for a session's thread scope, or `undefined` when it has none. */
|
|
7
|
+
function threadScopeKey(scope) {
|
|
8
|
+
const entries = Object.entries(scope).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
9
|
+
return entries.length > 0 ? JSON.stringify(entries) : void 0;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The session a wake for `threadId` should run as, or `FOREIGN_THREAD` when
|
|
13
|
+
* this process serves the resource but not the thread.
|
|
14
|
+
*
|
|
15
|
+
* A resource is not a project: processes in different directories can share
|
|
16
|
+
* one resource id (to share recall, say), and each then has a live session for
|
|
17
|
+
* it. Picking by resource alone runs the thread in whichever process asked,
|
|
18
|
+
* with that process's workspace, tools and cwd. The thread's scope tags (the
|
|
19
|
+
* ones `thread.create()` stamps, such as `projectPath`) say which session it
|
|
20
|
+
* belongs to. A thread with no scope tags, or with tags no session here
|
|
21
|
+
* contradicts, keeps going to the resource's session.
|
|
22
|
+
*
|
|
23
|
+
* A session that has the thread open always owns it. When the thread belongs to
|
|
24
|
+
* another project, that session delivers it under a lease for this one thread
|
|
25
|
+
* (`openThreadScope`), and the thread's own project yields it while another
|
|
26
|
+
* process holds that lease (`leases`), so only one process runs it and the
|
|
27
|
+
* project's other threads stay with the project.
|
|
28
|
+
*/
|
|
29
|
+
async function findWakeSession(controller, liveSessions, { resourceId, threadId }, leases) {
|
|
30
|
+
const first = await findSessionForThread({
|
|
31
|
+
getSession: (sessionId) => controller.getSession(sessionId),
|
|
32
|
+
listLiveSessions: () => liveSessions
|
|
33
|
+
}, {
|
|
34
|
+
resourceId,
|
|
35
|
+
threadId
|
|
36
|
+
});
|
|
37
|
+
if (!first) return void 0;
|
|
38
|
+
const thread = await first.thread.getById({ threadId });
|
|
39
|
+
if (!thread || thread.resourceId !== resourceId) return { session: first };
|
|
40
|
+
const metadata = thread.metadata ?? {};
|
|
41
|
+
const candidates = [first, ...[...liveSessions].filter((session) => session !== first && session.identity.getResourceId() === resourceId)];
|
|
42
|
+
const matchesScope = (session) => Object.entries(session.getThreadScope()).every(([key, value]) => metadata[key] === void 0 || metadata[key] === value);
|
|
43
|
+
const open = candidates.find((session) => session.thread.getId() === threadId);
|
|
44
|
+
if (open) return {
|
|
45
|
+
session: open,
|
|
46
|
+
scope: matchesScope(open) ? threadLeaseScope(open, metadata) : openThreadScope(threadId)
|
|
47
|
+
};
|
|
48
|
+
const owner = candidates.find(matchesScope);
|
|
49
|
+
if (!owner) return FOREIGN_THREAD;
|
|
50
|
+
const scope = threadLeaseScope(owner, metadata);
|
|
51
|
+
if (scope !== void 0 && await leases?.getLeaseOwner(notificationDispatchLeaseKey(resourceId, openThreadScope(threadId)))) return FOREIGN_THREAD;
|
|
52
|
+
return {
|
|
53
|
+
session: owner,
|
|
54
|
+
scope
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The dispatch lease scopes a session needs: its own, plus a lease for its open
|
|
59
|
+
* thread alone when that thread belongs to another project (`findWakeSession`).
|
|
60
|
+
*/
|
|
61
|
+
async function sessionLeaseScopes(session) {
|
|
62
|
+
const own = threadScopeKey(session.getThreadScope());
|
|
63
|
+
const threadId = session.thread.getId();
|
|
64
|
+
if (!threadId) return [own];
|
|
65
|
+
const thread = await session.thread.getById({ threadId });
|
|
66
|
+
if (!thread || thread.resourceId !== session.identity.getResourceId()) return [own];
|
|
67
|
+
const metadata = thread.metadata ?? {};
|
|
68
|
+
return Object.entries(session.getThreadScope()).some(([key, value]) => metadata[key] !== void 0 && metadata[key] !== value) ? [own, openThreadScope(threadId)] : [own];
|
|
69
|
+
}
|
|
70
|
+
/** The lease scope for one thread a session has open from another project. */
|
|
71
|
+
function openThreadScope(threadId) {
|
|
72
|
+
return threadScopeKey({ openThread: threadId });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The lease scope covering a thread for `session`: the thread's own values for
|
|
76
|
+
* the session's scope keys, or unset when the thread lacks any of them.
|
|
77
|
+
*/
|
|
78
|
+
function threadLeaseScope(session, metadata = {}) {
|
|
79
|
+
const keys = Object.keys(session.getThreadScope());
|
|
80
|
+
if (!keys.every((key) => metadata[key] !== void 0)) return void 0;
|
|
81
|
+
return threadScopeKey(Object.fromEntries(keys.map((key) => [key, String(metadata[key])])));
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { FOREIGN_THREAD, findWakeSession, sessionLeaseScopes, threadScopeKey };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=wake-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wake-session.js","names":[],"sources":["../../src/utils/wake-session.ts"],"sourcesContent":["import type { AgentController, Session } from '@mastra/core/agent-controller';\nimport type { LeaseProvider } from '@mastra/core/events';\n\nimport { findSessionForThread } from '../agents/background-completion.js';\nimport { notificationDispatchLeaseKey } from './signals-pubsub.js';\n\n/** A session here serves the thread's resource, but the thread belongs to another project. */\nexport const FOREIGN_THREAD = Symbol('foreign-thread');\n\n/** The session a wake runs as, and the dispatch lease that covers the thread. */\nexport type WakeSession<TState> = {\n session: Session<TState>;\n /**\n * The thread's scope (`threadScopeKey`) when it carries the session's whole\n * scope: only the process holding that scope's dispatch lease delivers it.\n * Unset for a thread with no scope, which the resource's lease covers.\n */\n scope?: string;\n};\n\n/** A stable key for a session's thread scope, or `undefined` when it has none. */\nexport function threadScopeKey(scope: Record<string, string>): string | undefined {\n const entries = Object.entries(scope).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n return entries.length > 0 ? JSON.stringify(entries) : undefined;\n}\n\n/**\n * The session a wake for `threadId` should run as, or `FOREIGN_THREAD` when\n * this process serves the resource but not the thread.\n *\n * A resource is not a project: processes in different directories can share\n * one resource id (to share recall, say), and each then has a live session for\n * it. Picking by resource alone runs the thread in whichever process asked,\n * with that process's workspace, tools and cwd. The thread's scope tags (the\n * ones `thread.create()` stamps, such as `projectPath`) say which session it\n * belongs to. A thread with no scope tags, or with tags no session here\n * contradicts, keeps going to the resource's session.\n *\n * A session that has the thread open always owns it. When the thread belongs to\n * another project, that session delivers it under a lease for this one thread\n * (`openThreadScope`), and the thread's own project yields it while another\n * process holds that lease (`leases`), so only one process runs it and the\n * project's other threads stay with the project.\n */\nexport async function findWakeSession<TState>(\n controller: Pick<AgentController<TState>, 'getSession'>,\n liveSessions: Iterable<Session<TState>>,\n { resourceId, threadId }: { resourceId: string; threadId: string },\n leases?: Pick<LeaseProvider, 'getLeaseOwner'>,\n): Promise<WakeSession<TState> | typeof FOREIGN_THREAD | undefined> {\n const first = await findSessionForThread(\n { getSession: sessionId => controller.getSession(sessionId), listLiveSessions: () => liveSessions },\n { resourceId, threadId },\n );\n if (!first) return undefined;\n const thread = await first.thread.getById({ threadId });\n if (!thread || thread.resourceId !== resourceId) return { session: first };\n const metadata = (thread.metadata as Record<string, unknown> | undefined) ?? {};\n const candidates = [\n first,\n ...[...liveSessions].filter(session => session !== first && session.identity.getResourceId() === resourceId),\n ];\n const matchesScope = (session: Session<TState>) =>\n Object.entries(session.getThreadScope()).every(\n ([key, value]) => metadata[key] === undefined || metadata[key] === value,\n );\n const open = candidates.find(session => session.thread.getId() === threadId);\n if (open) {\n return { session: open, scope: matchesScope(open) ? threadLeaseScope(open, metadata) : openThreadScope(threadId) };\n }\n const owner = candidates.find(matchesScope);\n if (!owner) return FOREIGN_THREAD;\n const scope = threadLeaseScope(owner, metadata);\n if (\n scope !== undefined &&\n (await leases?.getLeaseOwner(notificationDispatchLeaseKey(resourceId, openThreadScope(threadId))))\n ) {\n return FOREIGN_THREAD;\n }\n return { session: owner, scope };\n}\n\n/**\n * The dispatch lease scopes a session needs: its own, plus a lease for its open\n * thread alone when that thread belongs to another project (`findWakeSession`).\n */\nexport async function sessionLeaseScopes<TState>(session: Session<TState>): Promise<Array<string | undefined>> {\n const own = threadScopeKey(session.getThreadScope());\n const threadId = session.thread.getId();\n if (!threadId) return [own];\n const thread = await session.thread.getById({ threadId });\n if (!thread || thread.resourceId !== session.identity.getResourceId()) return [own];\n const metadata = (thread.metadata as Record<string, unknown> | undefined) ?? {};\n const foreign = Object.entries(session.getThreadScope()).some(\n ([key, value]) => metadata[key] !== undefined && metadata[key] !== value,\n );\n return foreign ? [own, openThreadScope(threadId)] : [own];\n}\n\n/** The lease scope for one thread a session has open from another project. */\nfunction openThreadScope(threadId: string): string {\n return threadScopeKey({ openThread: threadId })!;\n}\n\n/**\n * The lease scope covering a thread for `session`: the thread's own values for\n * the session's scope keys, or unset when the thread lacks any of them.\n */\nfunction threadLeaseScope<TState>(\n session: Session<TState>,\n metadata: Record<string, unknown> = {},\n): string | undefined {\n const keys = Object.keys(session.getThreadScope());\n if (!keys.every(key => metadata[key] !== undefined)) return undefined;\n return threadScopeKey(Object.fromEntries(keys.map(key => [key, String(metadata[key])])));\n}\n"],"mappings":";;;;AAOA,MAAa,iBAAiB,OAAO,gBAAgB;;AAcrD,SAAgB,eAAe,OAAmD;CAChF,MAAM,UAAU,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAE;CACrF,OAAO,QAAQ,SAAS,IAAI,KAAK,UAAU,OAAO,IAAI,KAAA;AACxD;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,gBACpB,YACA,cACA,EAAE,YAAY,YACd,QACkE;CAClE,MAAM,QAAQ,MAAM,qBAClB;EAAE,aAAY,cAAa,WAAW,WAAW,SAAS;EAAG,wBAAwB;CAAa,GAClG;EAAE;EAAY;CAAS,CACzB;CACA,IAAI,CAAC,OAAO,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OAAO,QAAQ,QAAQ,eAAe,CAAC,CAAC,CAAC,MACtD,CAAC,KAAK,WAAW,SAAS,SAAS,KAAA,KAAa,SAAS,SAAS,KAExD,IAAI,CAAC,KAAK,gBAAgB,QAAQ,CAAC,IAAI,CAAC,GAAG;AAC1D;;AAGA,SAAS,gBAAgB,UAA0B;CACjD,OAAO,eAAe,EAAE,YAAY,SAAS,CAAC;AAChD;;;;;AAMA,SAAS,iBACP,SACA,WAAoC,CAAC,GACjB;CACpB,MAAM,OAAO,OAAO,KAAK,QAAQ,eAAe,CAAC;CACjD,IAAI,CAAC,KAAK,OAAM,QAAO,SAAS,SAAS,KAAA,CAAS,GAAG,OAAO,KAAA;CAC5D,OAAO,eAAe,OAAO,YAAY,KAAK,KAAI,QAAO,CAAC,KAAK,OAAO,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC;AACzF"}
|
|
@@ -17,7 +17,10 @@ async function registerWorkflowBuilderPrimitives(mastra, options) {
|
|
|
17
17
|
basePath: projectPath,
|
|
18
18
|
allowedPaths: [projectPath, ...allowedPaths]
|
|
19
19
|
}),
|
|
20
|
-
sandbox: new LocalSandbox({
|
|
20
|
+
sandbox: new LocalSandbox({
|
|
21
|
+
workingDirectory: projectPath,
|
|
22
|
+
timeout: 3e4
|
|
23
|
+
}),
|
|
21
24
|
tools: createMastraCodeWorkspaceTools()
|
|
22
25
|
});
|
|
23
26
|
const workspaceTools = await createWorkspaceTools(workspace, { workspace });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-primitives.js","names":[],"sources":["../../src/workflows/register-primitives.ts"],"sourcesContent":["/**\n * Statically register workflow-related primitives on the mastracode Mastra\n * instance so `mastra.listTools()` + `mastra.listAgents()` — and, therefore,\n * the workflow-builder's discovery + the workflow rehydrator — see everything\n * a workflow might want to compose:\n *\n * - workflow-builder sub-agent (so `create-workflow` can delegate)\n * - code-agent (as a plain agent, callable via agent steps)\n * - workspace tools (view/write/edit/find_files/execute_command/etc.)\n * - configured model-independent web tools so workflows can compose search/extract steps\n * - notification_inbox\n * - snapshot of MCP tools from mcpManager\n *\n * Called after `controller.init()` but before `startWorkers()` in both boot\n * paths, so `loadStoredWorkflows()` (inside startWorkers) sees the full\n * registry when rehydrating previously-saved workflows.\n *\n * Tradeoffs:\n * - MCP tools are snapshotted. Servers added after boot are invisible to\n * the workflow-builder until restart.\n * - Provider-native (Anthropic/OpenAI) web\n * tools are skipped because they'd freeze workflows to one model provider.\n * - Workflow tool steps get the closed-over workspace + auth (web provider\n * key, MCP server credentials), not per-request permissions — deliberate; if\n * the user built + saved the workflow they meant to run it.\n */\nimport type { Agent } from '@mastra/core/agent';\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createNotificationInboxTool } from '@mastra/core/notifications';\nimport { LocalFilesystem, LocalSandbox, Workspace, createWorkspaceTools } from '@mastra/core/workspace';\nimport { createMastraCodeWorkspaceTools } from '../agents/tool-availability.js';\nimport { LazyNotificationsStorage } from '../agents/tools.js';\nimport { workflowBuilderAgent } from '../agents/workflow-builder-agent.js';\nimport type { McpManager } from '../mcp';\nimport { MC_TOOLS } from '../tool-names.js';\nimport { createConfiguredWebTools } from '../tools/web-search.js';\n\nexport interface RegisterWorkflowBuilderPrimitivesOptions {\n projectPath: string;\n /**\n * Extra allowed paths the workspace can read/write. Mastracode normally\n * collects skill paths + sandboxAllowedPaths per-request; for the workflow\n * workspace we accept anything the caller wants up-front and trust the\n * worker process to honour the user's intent.\n */\n allowedPaths?: string[];\n /**\n * The code-agent Agent instance. Registered as `code-agent` so workflows\n * can compose it in agent steps. It already has full dynamic tool access\n * (workspace/MCP/web/etc.) via its own `tools: createDynamicTools(...)`.\n */\n codeAgent: Agent;\n /**\n * McpManager for snapshotting MCP tools at boot. Omit or pass undefined\n * if MCP is disabled — workflow-builder will just see fewer tools.\n */\n mcpManager?: McpManager;\n}\n\nexport async function registerWorkflowBuilderPrimitives(\n mastra: Mastra,\n options: RegisterWorkflowBuilderPrimitivesOptions,\n): Promise<void> {\n const { projectPath, allowedPaths = [], codeAgent, mcpManager } = options;\n\n // 1. Agents workflows can compose.\n mastra.addAgent(workflowBuilderAgent, 'workflow-builder');\n mastra.addAgent(codeAgent, 'code-agent');\n\n // 2. Workspace tools — bound to a project-rooted local workspace.\n const workspace = new Workspace({\n id: 'workflow-builder-workspace',\n name: 'Mastra Code Workspace (workflows)',\n filesystem: new LocalFilesystem({\n basePath: projectPath,\n allowedPaths: [projectPath, ...allowedPaths],\n }),\n sandbox: new LocalSandbox({ workingDirectory: projectPath }),\n tools: createMastraCodeWorkspaceTools(),\n });\n const workspaceTools = await createWorkspaceTools(workspace, { workspace });\n for (const [toolId, tool] of Object.entries(workspaceTools)) {\n mastra.addTool(tool, toolId);\n }\n\n // 3. Model-independent web tools. Provider-native web tools (Anthropic/OpenAI)\n // are model-locked and would freeze workflows to one provider.\n const configuredWebTools = createConfiguredWebTools();\n if (configuredWebTools) {\n mastra.addTool(configuredWebTools.web_search, 'web-search');\n mastra.addTool(configuredWebTools.web_extract, 'web-extract');\n }\n\n // 4. notification_inbox — LazyNotificationsStorage resolves the notifications\n // domain per-call rather than at boot, so it works even when the domain\n // isn't fully initialised yet.\n const storage = mastra.getStorage();\n if (storage) {\n const notificationInbox = createNotificationInboxTool({\n storage: new LazyNotificationsStorage(storage as never),\n });\n mastra.addTool(notificationInbox, MC_TOOLS.NOTIFICATION_INBOX);\n }\n\n // 5. MCP tools — snapshot the current set. Ids are already server-namespaced\n // (`${serverName}_${toolName}`), so the workflow rehydrator's\n // `mastra.getTool(id)` resolves them at run time.\n if (mcpManager) {\n for (const [toolId, tool] of Object.entries(mcpManager.getTools())) {\n mastra.addTool(tool, toolId);\n }\n }\n}\n"],"mappings":";;;;;;;;AA2DA,eAAsB,kCACpB,QACA,SACe;CACf,MAAM,EAAE,aAAa,eAAe,CAAC,GAAG,WAAW,eAAe;CAGlE,OAAO,SAAS,sBAAsB,kBAAkB;CACxD,OAAO,SAAS,WAAW,YAAY;CAGvC,MAAM,YAAY,IAAI,UAAU;EAC9B,IAAI;EACJ,MAAM;EACN,YAAY,IAAI,gBAAgB;GAC9B,UAAU;GACV,cAAc,CAAC,aAAa,GAAG,YAAY;EAC7C,CAAC;EACD,SAAS,IAAI,aAAa,
|
|
1
|
+
{"version":3,"file":"register-primitives.js","names":[],"sources":["../../src/workflows/register-primitives.ts"],"sourcesContent":["/**\n * Statically register workflow-related primitives on the mastracode Mastra\n * instance so `mastra.listTools()` + `mastra.listAgents()` — and, therefore,\n * the workflow-builder's discovery + the workflow rehydrator — see everything\n * a workflow might want to compose:\n *\n * - workflow-builder sub-agent (so `create-workflow` can delegate)\n * - code-agent (as a plain agent, callable via agent steps)\n * - workspace tools (view/write/edit/find_files/execute_command/etc.)\n * - configured model-independent web tools so workflows can compose search/extract steps\n * - notification_inbox\n * - snapshot of MCP tools from mcpManager\n *\n * Called after `controller.init()` but before `startWorkers()` in both boot\n * paths, so `loadStoredWorkflows()` (inside startWorkers) sees the full\n * registry when rehydrating previously-saved workflows.\n *\n * Tradeoffs:\n * - MCP tools are snapshotted. Servers added after boot are invisible to\n * the workflow-builder until restart.\n * - Provider-native (Anthropic/OpenAI) web\n * tools are skipped because they'd freeze workflows to one model provider.\n * - Workflow tool steps get the closed-over workspace + auth (web provider\n * key, MCP server credentials), not per-request permissions — deliberate; if\n * the user built + saved the workflow they meant to run it.\n */\nimport type { Agent } from '@mastra/core/agent';\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createNotificationInboxTool } from '@mastra/core/notifications';\nimport { LocalFilesystem, LocalSandbox, Workspace, createWorkspaceTools } from '@mastra/core/workspace';\nimport { createMastraCodeWorkspaceTools } from '../agents/tool-availability.js';\nimport { LazyNotificationsStorage } from '../agents/tools.js';\nimport { workflowBuilderAgent } from '../agents/workflow-builder-agent.js';\nimport type { McpManager } from '../mcp';\nimport { MC_TOOLS } from '../tool-names.js';\nimport { createConfiguredWebTools } from '../tools/web-search.js';\n\nexport interface RegisterWorkflowBuilderPrimitivesOptions {\n projectPath: string;\n /**\n * Extra allowed paths the workspace can read/write. Mastracode normally\n * collects skill paths + sandboxAllowedPaths per-request; for the workflow\n * workspace we accept anything the caller wants up-front and trust the\n * worker process to honour the user's intent.\n */\n allowedPaths?: string[];\n /**\n * The code-agent Agent instance. Registered as `code-agent` so workflows\n * can compose it in agent steps. It already has full dynamic tool access\n * (workspace/MCP/web/etc.) via its own `tools: createDynamicTools(...)`.\n */\n codeAgent: Agent;\n /**\n * McpManager for snapshotting MCP tools at boot. Omit or pass undefined\n * if MCP is disabled — workflow-builder will just see fewer tools.\n */\n mcpManager?: McpManager;\n}\n\nexport async function registerWorkflowBuilderPrimitives(\n mastra: Mastra,\n options: RegisterWorkflowBuilderPrimitivesOptions,\n): Promise<void> {\n const { projectPath, allowedPaths = [], codeAgent, mcpManager } = options;\n\n // 1. Agents workflows can compose.\n mastra.addAgent(workflowBuilderAgent, 'workflow-builder');\n mastra.addAgent(codeAgent, 'code-agent');\n\n // 2. Workspace tools — bound to a project-rooted local workspace.\n const workspace = new Workspace({\n id: 'workflow-builder-workspace',\n name: 'Mastra Code Workspace (workflows)',\n filesystem: new LocalFilesystem({\n basePath: projectPath,\n allowedPaths: [projectPath, ...allowedPaths],\n }),\n sandbox: new LocalSandbox({ workingDirectory: projectPath, timeout: 30_000 }),\n tools: createMastraCodeWorkspaceTools(),\n });\n const workspaceTools = await createWorkspaceTools(workspace, { workspace });\n for (const [toolId, tool] of Object.entries(workspaceTools)) {\n mastra.addTool(tool, toolId);\n }\n\n // 3. Model-independent web tools. Provider-native web tools (Anthropic/OpenAI)\n // are model-locked and would freeze workflows to one provider.\n const configuredWebTools = createConfiguredWebTools();\n if (configuredWebTools) {\n mastra.addTool(configuredWebTools.web_search, 'web-search');\n mastra.addTool(configuredWebTools.web_extract, 'web-extract');\n }\n\n // 4. notification_inbox — LazyNotificationsStorage resolves the notifications\n // domain per-call rather than at boot, so it works even when the domain\n // isn't fully initialised yet.\n const storage = mastra.getStorage();\n if (storage) {\n const notificationInbox = createNotificationInboxTool({\n storage: new LazyNotificationsStorage(storage as never),\n });\n mastra.addTool(notificationInbox, MC_TOOLS.NOTIFICATION_INBOX);\n }\n\n // 5. MCP tools — snapshot the current set. Ids are already server-namespaced\n // (`${serverName}_${toolName}`), so the workflow rehydrator's\n // `mastra.getTool(id)` resolves them at run time.\n if (mcpManager) {\n for (const [toolId, tool] of Object.entries(mcpManager.getTools())) {\n mastra.addTool(tool, toolId);\n }\n }\n}\n"],"mappings":";;;;;;;;AA2DA,eAAsB,kCACpB,QACA,SACe;CACf,MAAM,EAAE,aAAa,eAAe,CAAC,GAAG,WAAW,eAAe;CAGlE,OAAO,SAAS,sBAAsB,kBAAkB;CACxD,OAAO,SAAS,WAAW,YAAY;CAGvC,MAAM,YAAY,IAAI,UAAU;EAC9B,IAAI;EACJ,MAAM;EACN,YAAY,IAAI,gBAAgB;GAC9B,UAAU;GACV,cAAc,CAAC,aAAa,GAAG,YAAY;EAC7C,CAAC;EACD,SAAS,IAAI,aAAa;GAAE,kBAAkB;GAAa,SAAS;EAAO,CAAC;EAC5E,OAAO,+BAA+B;CACxC,CAAC;CACD,MAAM,iBAAiB,MAAM,qBAAqB,WAAW,EAAE,UAAU,CAAC;CAC1E,KAAK,MAAM,CAAC,QAAQ,SAAS,OAAO,QAAQ,cAAc,GACxD,OAAO,QAAQ,MAAM,MAAM;CAK7B,MAAM,qBAAqB,yBAAyB;CACpD,IAAI,oBAAoB;EACtB,OAAO,QAAQ,mBAAmB,YAAY,YAAY;EAC1D,OAAO,QAAQ,mBAAmB,aAAa,aAAa;CAC9D;CAKA,MAAM,UAAU,OAAO,WAAW;CAClC,IAAI,SAAS;EACX,MAAM,oBAAoB,4BAA4B,EACpD,SAAS,IAAI,yBAAyB,OAAgB,EACxD,CAAC;EACD,OAAO,QAAQ,mBAAmB,SAAS,kBAAkB;CAC/D;CAKA,IAAI,YACF,KAAK,MAAM,CAAC,QAAQ,SAAS,OAAO,QAAQ,WAAW,SAAS,CAAC,GAC/D,OAAO,QAAQ,MAAM,MAAM;AAGjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/code-sdk",
|
|
3
|
-
"version": "1.15.0-alpha.
|
|
3
|
+
"version": "1.15.0-alpha.10",
|
|
4
4
|
"description": "Mastra Code SDK: the agent core behind Mastra Code (everything except the TUI) — build your own UIs and surfaces on top of it",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@agentclientprotocol/sdk": "^0.21.0",
|
|
49
|
-
"@ai-sdk/amazon-bedrock": "^3.0.
|
|
50
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
51
|
-
"@ai-sdk/openai": "^3.0.
|
|
52
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
49
|
+
"@ai-sdk/amazon-bedrock": "^3.0.140",
|
|
50
|
+
"@ai-sdk/anthropic": "^3.0.133",
|
|
51
|
+
"@ai-sdk/openai": "^3.0.130",
|
|
52
|
+
"@ai-sdk/openai-compatible": "^2.0.85",
|
|
53
53
|
"@ast-grep/napi": "^0.42.0",
|
|
54
54
|
"@aws-sdk/credential-providers": "^3.1095.0",
|
|
55
|
-
"ai": "^6.0.
|
|
55
|
+
"ai": "^6.0.309",
|
|
56
56
|
"execa": "^9.6.1",
|
|
57
57
|
"libsql": "^0.5.29",
|
|
58
58
|
"posthog-node": "^5.46.1",
|
|
@@ -61,34 +61,34 @@
|
|
|
61
61
|
"vscode-jsonrpc": "^8.2.1",
|
|
62
62
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
63
63
|
"yaml": "^2.7.1",
|
|
64
|
-
"zod": "^4.6.
|
|
64
|
+
"zod": "^4.6.7",
|
|
65
65
|
"@mastra/agent-browser": "0.5.4-alpha.0",
|
|
66
|
-
"@mastra/core": "1.79.0-alpha.
|
|
67
|
-
"@mastra/
|
|
66
|
+
"@mastra/core": "1.79.0-alpha.9",
|
|
67
|
+
"@mastra/client-js": "1.56.0-alpha.9",
|
|
68
|
+
"@mastra/duckdb": "1.15.0-alpha.5",
|
|
69
|
+
"@mastra/fastembed": "1.3.4-alpha.2",
|
|
70
|
+
"@mastra/libsql": "1.27.0-alpha.3",
|
|
71
|
+
"@mastra/mcp": "2.5.0-alpha.1",
|
|
72
|
+
"@mastra/observability": "1.21.0-alpha.2",
|
|
73
|
+
"@mastra/memory": "1.39.0-alpha.6",
|
|
68
74
|
"@mastra/github-signals": "0.5.2-alpha.0",
|
|
69
|
-
"@mastra/
|
|
70
|
-
"@mastra/
|
|
71
|
-
"@mastra/memory": "1.39.0-alpha.0",
|
|
72
|
-
"@mastra/parallel": "0.1.3-alpha.0",
|
|
73
|
-
"@mastra/observability": "1.21.0-alpha.1",
|
|
74
|
-
"@mastra/libsql": "1.27.0-alpha.1",
|
|
75
|
-
"@mastra/pg": "1.32.0-alpha.1",
|
|
76
|
-
"@mastra/tavily": "1.1.3-alpha.0",
|
|
75
|
+
"@mastra/parallel": "0.1.3-alpha.1",
|
|
76
|
+
"@mastra/pg": "1.32.0-alpha.5",
|
|
77
77
|
"@mastra/schema-compat": "1.3.16-alpha.0",
|
|
78
|
+
"@mastra/tavily": "1.1.3-alpha.1",
|
|
78
79
|
"@mastra/stagehand": "0.3.6-alpha.0"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|
|
82
|
+
"@copilotkit/aimock": "^1.29.0",
|
|
81
83
|
"@libsql/client": "^0.18.0",
|
|
82
84
|
"@types/node": "22.20.1",
|
|
83
|
-
"eslint": "^10.7.0",
|
|
84
85
|
"tsdown": "0.22.9",
|
|
85
86
|
"tsx": "^4.23.1",
|
|
86
87
|
"typescript": "^6.0.3",
|
|
87
|
-
"typescript-eslint": "^8.57.0",
|
|
88
88
|
"vitest": "4.1.11",
|
|
89
|
-
"@internal/lint": "0.0.144",
|
|
90
89
|
"@internal/types-builder": "0.0.119",
|
|
91
|
-
"@internal/workspace-test-utils": "0.0.88"
|
|
90
|
+
"@internal/workspace-test-utils": "0.0.88",
|
|
91
|
+
"@internal/lint": "0.0.144"
|
|
92
92
|
},
|
|
93
93
|
"engines": {
|
|
94
94
|
"node": ">=22.19.0"
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"check": "tsc --noEmit",
|
|
99
99
|
"test": "vitest run",
|
|
100
100
|
"test:acp": "vitest run --config vitest.acp.config.ts",
|
|
101
|
-
"lint": "oxlint
|
|
102
|
-
"lint:fix": "oxlint --
|
|
101
|
+
"lint": "oxlint --type-aware .",
|
|
102
|
+
"lint:fix": "oxlint --type-aware --fix .",
|
|
103
103
|
"build:acp:dev": "node scripts/build-acp-dev.mjs",
|
|
104
104
|
"test:acp:conformance": "node scripts/run-acp-conformance.mjs",
|
|
105
105
|
"check:acp": "tsc --noEmit -p tsconfig.acp.json"
|