@mastra/code-sdk 1.11.0-alpha.1 → 1.11.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 +3 -3
- package/dist/acp/agent.d.ts.map +1 -1
- package/dist/acp/agent.js +95 -22
- package/dist/acp/agent.js.map +1 -1
- package/dist/acp/runtime.d.ts.map +1 -1
- package/dist/acp/runtime.js +18 -10
- package/dist/acp/runtime.js.map +1 -1
- package/dist/agents/memory.d.ts +3 -1
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/memory.js +34 -23
- package/dist/agents/memory.js.map +1 -1
- package/dist/agents/model.d.ts +4 -39
- package/dist/agents/model.d.ts.map +1 -1
- package/dist/agents/model.js +31 -93
- package/dist/agents/model.js.map +1 -1
- package/dist/agents/prompts/agent-instructions.js +1 -1
- package/dist/auth/account-rotation-processor.d.ts +26 -54
- package/dist/auth/account-rotation-processor.d.ts.map +1 -1
- package/dist/auth/account-rotation-processor.js +105 -154
- package/dist/auth/account-rotation-processor.js.map +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/auth/providers/kimi-coding.js +2 -1
- package/dist/auth/providers/kimi-coding.js.map +1 -1
- package/dist/auth/providers/xai.js +2 -1
- package/dist/auth/providers/xai.js.map +1 -1
- package/dist/auth/storage.js +1 -1
- package/dist/auth/types.d.ts +1 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/clipboard/index.js +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/headless/cli.d.ts.map +1 -1
- package/dist/headless/cli.js +9 -4
- package/dist/headless/cli.js.map +1 -1
- package/dist/headless/run-mc.d.ts.map +1 -1
- package/dist/headless/run-mc.js +46 -42
- package/dist/headless/run-mc.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -27
- package/dist/index.js.map +1 -1
- package/dist/lsp/server.js +1 -1
- package/dist/onboarding/om-settings.d.ts +1 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -1
- package/dist/onboarding/om-settings.js +10 -1
- package/dist/onboarding/om-settings.js.map +1 -1
- package/dist/onboarding/settings.js +2 -2
- package/dist/providers/openai-codex.js +1 -1
- package/dist/schedules/run-script.js +1 -1
- package/dist/schema.d.ts +34 -19
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +11 -5
- package/dist/schema.js.map +1 -1
- package/dist/utils/open-url.d.ts +10 -0
- package/dist/utils/open-url.d.ts.map +1 -0
- package/dist/utils/open-url.js +30 -0
- package/dist/utils/open-url.js.map +1 -0
- package/dist/utils/project.js +2 -2
- package/dist/utils/signals-pubsub.d.ts +32 -4
- package/dist/utils/signals-pubsub.d.ts.map +1 -1
- package/dist/utils/signals-pubsub.js +207 -28
- package/dist/utils/signals-pubsub.js.map +1 -1
- package/dist/utils/slash-command-processor.js +1 -1
- package/dist/utils/update-check.js +1 -1
- package/package.json +12 -12
|
@@ -9,6 +9,7 @@ import type { GlobalSettings } from './settings.js';
|
|
|
9
9
|
export declare function hasExplicitOMConfiguration(settings: GlobalSettings): boolean;
|
|
10
10
|
/** Seed a built-in OM pack unless the user already chose one; true when settings changed. */
|
|
11
11
|
export declare function applyOMDefaultIfUnconfigured(settings: GlobalSettings, pack: OMPack): boolean;
|
|
12
|
+
export declare function seedProviderOMDefault(providerId: string): OMPack | undefined;
|
|
12
13
|
/**
|
|
13
14
|
* Apply a role-specific OM model override to an in-memory `GlobalSettings`.
|
|
14
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"om-settings.d.ts","sourceRoot":"","sources":["../../src/onboarding/om-settings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"om-settings.d.ts","sourceRoot":"","sources":["../../src/onboarding/om-settings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,0EAA0E;AAC1E,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAO5E;AAED,6FAA6F;AAC7F,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO5F;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,UAAU,GAAG,WAAW,EAC9B,OAAO,EAAE,MAAM,EACf,uBAAuB,EAAE,MAAM,GAAG,IAAI,GACrC,IAAI,CAgBN;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAIzE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveProviderOMDefault } from "./packs.js";
|
|
1
2
|
import { loadSettings, saveSettings } from "./settings.js";
|
|
2
3
|
//#region src/onboarding/om-settings.ts
|
|
3
4
|
/** Whether the user has already chosen any persisted OM model or pack. */
|
|
@@ -14,6 +15,14 @@ function applyOMDefaultIfUnconfigured(settings, pack) {
|
|
|
14
15
|
settings.models.omModelOverride = null;
|
|
15
16
|
return true;
|
|
16
17
|
}
|
|
18
|
+
function seedProviderOMDefault(providerId) {
|
|
19
|
+
const pack = resolveProviderOMDefault(providerId);
|
|
20
|
+
if (pack.id === "custom") return void 0;
|
|
21
|
+
const settings = loadSettings();
|
|
22
|
+
if (!applyOMDefaultIfUnconfigured(settings, pack)) return void 0;
|
|
23
|
+
saveSettings(settings);
|
|
24
|
+
return pack;
|
|
25
|
+
}
|
|
17
26
|
/**
|
|
18
27
|
* Apply a role-specific OM model override to an in-memory `GlobalSettings`.
|
|
19
28
|
*
|
|
@@ -42,6 +51,6 @@ function persistOmObserveAttachments(value) {
|
|
|
42
51
|
saveSettings(settings);
|
|
43
52
|
}
|
|
44
53
|
//#endregion
|
|
45
|
-
export { applyOMDefaultIfUnconfigured, applyOmRoleOverride, hasExplicitOMConfiguration, persistOmObserveAttachments };
|
|
54
|
+
export { applyOMDefaultIfUnconfigured, applyOmRoleOverride, hasExplicitOMConfiguration, persistOmObserveAttachments, seedProviderOMDefault };
|
|
46
55
|
|
|
47
56
|
//# sourceMappingURL=om-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"om-settings.js","names":[],"sources":["../../src/onboarding/om-settings.ts"],"sourcesContent":["/**\n * Pure `GlobalSettings` mutation helpers for observational-memory (OM)\n * configuration. Shared by the TUI `/om` command and the web settings\n * routes — no UI dependencies.\n */\nimport type { OMPack } from './packs.js';\nimport type { GlobalSettings } from './settings.js';\nimport { loadSettings, saveSettings } from './settings.js';\n\n/** Whether the user has already chosen any persisted OM model or pack. */\nexport function hasExplicitOMConfiguration(settings: GlobalSettings): boolean {\n const { activeOmPackId, omModelOverride, observerModelOverride, reflectorModelOverride } = settings.models;\n if (omModelOverride || observerModelOverride || reflectorModelOverride) return true;\n\n // 'custom' without a model is what onboarding persists when no provider was\n // reachable — a forced non-choice, not a preference worth preserving.\n return [settings.onboarding.omPackId, activeOmPackId].some(packId => packId && packId !== 'custom');\n}\n\n/** Seed a built-in OM pack unless the user already chose one; true when settings changed. */\nexport function applyOMDefaultIfUnconfigured(settings: GlobalSettings, pack: OMPack): boolean {\n if (hasExplicitOMConfiguration(settings)) return false;\n\n settings.onboarding.omPackId = pack.id;\n settings.models.activeOmPackId = pack.id;\n settings.models.omModelOverride = null;\n return true;\n}\n\n/**\n * Apply a role-specific OM model override to an in-memory `GlobalSettings`.\n *\n * When switching `activeOmPackId` from a built-in pack to `'custom'` we also\n * snapshot the *other* role's currently-resolved model into its override\n * field. Without this, the other role would silently lose its model on next\n * startup because `resolveOmRoleModel` would no longer resolve it from the\n * (now-overridden) pack.\n *\n * Exported for unit testing; `persistOmRoleOverride` is the disk-backed wrapper.\n */\nexport function applyOmRoleOverride(\n settings: GlobalSettings,\n role: 'observer' | 'reflector',\n modelId: string,\n otherRoleCurrentModelId: string | null,\n): void {\n const wasBuiltinPack = settings.models.activeOmPackId !== null && settings.models.activeOmPackId !== 'custom';\n\n if (role === 'observer') {\n if (wasBuiltinPack && otherRoleCurrentModelId && !settings.models.reflectorModelOverride) {\n settings.models.reflectorModelOverride = otherRoleCurrentModelId;\n }\n settings.models.observerModelOverride = modelId;\n } else {\n if (wasBuiltinPack && otherRoleCurrentModelId && !settings.models.observerModelOverride) {\n settings.models.observerModelOverride = otherRoleCurrentModelId;\n }\n settings.models.reflectorModelOverride = modelId;\n }\n\n settings.models.activeOmPackId = 'custom';\n}\n\nexport function persistOmObserveAttachments(value: 'auto' | boolean): void {\n const settings = loadSettings();\n settings.models.omObserveAttachments = value;\n saveSettings(settings);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"om-settings.js","names":[],"sources":["../../src/onboarding/om-settings.ts"],"sourcesContent":["/**\n * Pure `GlobalSettings` mutation helpers for observational-memory (OM)\n * configuration. Shared by the TUI `/om` command and the web settings\n * routes — no UI dependencies.\n */\nimport type { OMPack } from './packs.js';\nimport { resolveProviderOMDefault } from './packs.js';\nimport type { GlobalSettings } from './settings.js';\nimport { loadSettings, saveSettings } from './settings.js';\n\n/** Whether the user has already chosen any persisted OM model or pack. */\nexport function hasExplicitOMConfiguration(settings: GlobalSettings): boolean {\n const { activeOmPackId, omModelOverride, observerModelOverride, reflectorModelOverride } = settings.models;\n if (omModelOverride || observerModelOverride || reflectorModelOverride) return true;\n\n // 'custom' without a model is what onboarding persists when no provider was\n // reachable — a forced non-choice, not a preference worth preserving.\n return [settings.onboarding.omPackId, activeOmPackId].some(packId => packId && packId !== 'custom');\n}\n\n/** Seed a built-in OM pack unless the user already chose one; true when settings changed. */\nexport function applyOMDefaultIfUnconfigured(settings: GlobalSettings, pack: OMPack): boolean {\n if (hasExplicitOMConfiguration(settings)) return false;\n\n settings.onboarding.omPackId = pack.id;\n settings.models.activeOmPackId = pack.id;\n settings.models.omModelOverride = null;\n return true;\n}\n\nexport function seedProviderOMDefault(providerId: string): OMPack | undefined {\n const pack = resolveProviderOMDefault(providerId);\n // No cheap OM pack for this provider — leave OM open for a later login rather\n // than pinning observation and reflection to a full-size coding model.\n if (pack.id === 'custom') return undefined;\n\n const settings = loadSettings();\n if (!applyOMDefaultIfUnconfigured(settings, pack)) return undefined;\n\n saveSettings(settings);\n return pack;\n}\n\n/**\n * Apply a role-specific OM model override to an in-memory `GlobalSettings`.\n *\n * When switching `activeOmPackId` from a built-in pack to `'custom'` we also\n * snapshot the *other* role's currently-resolved model into its override\n * field. Without this, the other role would silently lose its model on next\n * startup because `resolveOmRoleModel` would no longer resolve it from the\n * (now-overridden) pack.\n *\n * Exported for unit testing; `persistOmRoleOverride` is the disk-backed wrapper.\n */\nexport function applyOmRoleOverride(\n settings: GlobalSettings,\n role: 'observer' | 'reflector',\n modelId: string,\n otherRoleCurrentModelId: string | null,\n): void {\n const wasBuiltinPack = settings.models.activeOmPackId !== null && settings.models.activeOmPackId !== 'custom';\n\n if (role === 'observer') {\n if (wasBuiltinPack && otherRoleCurrentModelId && !settings.models.reflectorModelOverride) {\n settings.models.reflectorModelOverride = otherRoleCurrentModelId;\n }\n settings.models.observerModelOverride = modelId;\n } else {\n if (wasBuiltinPack && otherRoleCurrentModelId && !settings.models.observerModelOverride) {\n settings.models.observerModelOverride = otherRoleCurrentModelId;\n }\n settings.models.reflectorModelOverride = modelId;\n }\n\n settings.models.activeOmPackId = 'custom';\n}\n\nexport function persistOmObserveAttachments(value: 'auto' | boolean): void {\n const settings = loadSettings();\n settings.models.omObserveAttachments = value;\n saveSettings(settings);\n}\n"],"mappings":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ThinkingLevel as resolveDefaultThinkingLevel$1 } from "../thinking.js";
|
|
2
1
|
import { getAppDataDir } from "../utils/project.js";
|
|
3
2
|
import { AuthStorage, PROVIDER_DEFAULT_MODELS } from "../auth/storage.js";
|
|
3
|
+
import { pruneUnknownModePackFallbacks, pruneUnknownPackAccountPreferences } from "./packs.js";
|
|
4
4
|
import { OPENAI_PREFIX, normalizeAnthropicModelId, remapOpenAIModelForCodexOAuth, stripMastraGatewayPrefix } from "../providers/model-ids.js";
|
|
5
|
+
import { THINKING_LEVEL_VALUES, isThinkingLevelSetting, resolveDefaultThinkingLevel as resolveDefaultThinkingLevel$1 } from "../thinking.js";
|
|
5
6
|
import { buildCodexStagehandFetch, createCodexMiddleware } from "../providers/openai-codex.js";
|
|
6
7
|
import { DEFAULT_STT_PROVIDER, resolveSTTModel } from "../voice/stt-registry.js";
|
|
7
|
-
import { pruneUnknownModePackFallbacks, pruneUnknownPackAccountPreferences } from "./packs.js";
|
|
8
8
|
import { dirname, join } from "path";
|
|
9
9
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
10
10
|
//#region src/onboarding/settings.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { supportsMaxReasoningEffort } from "../thinking.js";
|
|
2
1
|
import { AuthStorage } from "../auth/storage.js";
|
|
3
2
|
import { ProviderAuthRequiredError } from "../auth/provider-auth-error.js";
|
|
3
|
+
import { supportsMaxReasoningEffort } from "../thinking.js";
|
|
4
4
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
5
5
|
import { wrapLanguageModel } from "ai";
|
|
6
6
|
//#region src/providers/openai-codex.ts
|
package/dist/schema.d.ts
CHANGED
|
@@ -6,6 +6,24 @@ export type MastraCodeSessionState = {
|
|
|
6
6
|
modeId: string;
|
|
7
7
|
};
|
|
8
8
|
export type MastraCodeComposedState = MastraCodeState & MastraCodeSessionState;
|
|
9
|
+
export interface ModelRouteEntry {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
modelId: string;
|
|
13
|
+
accountId?: string;
|
|
14
|
+
memoryModelId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ModelRoute {
|
|
17
|
+
entries: ModelRouteEntry[];
|
|
18
|
+
}
|
|
19
|
+
export interface PendingModelFallback {
|
|
20
|
+
fromEntryId: string;
|
|
21
|
+
toEntryId: string;
|
|
22
|
+
toModelId: string;
|
|
23
|
+
threadId?: string;
|
|
24
|
+
reason: 'pool-exhausted' | 'persistent-outage';
|
|
25
|
+
at: string;
|
|
26
|
+
}
|
|
9
27
|
export interface MastraCodeState {
|
|
10
28
|
[key: string]: unknown;
|
|
11
29
|
[key: `subagentModelId_${string}`]: string | undefined;
|
|
@@ -56,21 +74,10 @@ export interface MastraCodeState {
|
|
|
56
74
|
cavemanObservations: boolean;
|
|
57
75
|
observeAttachments: 'auto' | boolean;
|
|
58
76
|
omScope?: 'thread' | 'resource';
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
* hop; cleared back to null once the TUI applies it. Declared here so
|
|
64
|
-
* consumers resolve it as a typed record instead of casting `unknown`.
|
|
65
|
-
*/
|
|
66
|
-
mastracodePendingPackFallback?: {
|
|
67
|
-
fromPackId: string;
|
|
68
|
-
toPackId: string;
|
|
69
|
-
toModelId: string;
|
|
70
|
-
threadId?: string;
|
|
71
|
-
reason: 'pool-exhausted' | 'persistent-outage';
|
|
72
|
-
at: string;
|
|
73
|
-
} | null;
|
|
77
|
+
/** Ordered host-supplied model and account fallback route for this thread. */
|
|
78
|
+
modelRoute?: ModelRoute;
|
|
79
|
+
/** One-hop fallback intent written by account rotation and consumed by the host. */
|
|
80
|
+
mastracodePendingModelFallback?: PendingModelFallback | null;
|
|
74
81
|
/**
|
|
75
82
|
* Session-level reasoning-effort override. When unset, the effective level is
|
|
76
83
|
* resolved at request time from settings (`models.modeThinkingDefaults[mode]`
|
|
@@ -130,7 +137,15 @@ export interface MastraCodeState {
|
|
|
130
137
|
export declare const stateSchema: z.ZodObject<{
|
|
131
138
|
currentModelId: z.ZodOptional<z.ZodString>;
|
|
132
139
|
modeId: z.ZodOptional<z.ZodString>;
|
|
133
|
-
|
|
140
|
+
modelRoute: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
142
|
+
id: z.ZodString;
|
|
143
|
+
label: z.ZodString;
|
|
144
|
+
modelId: z.ZodString;
|
|
145
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
146
|
+
memoryModelId: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
}, z.core.$strip>>;
|
|
134
149
|
subagentModelId: z.ZodOptional<z.ZodString>;
|
|
135
150
|
projectPath: z.ZodOptional<z.ZodString>;
|
|
136
151
|
projectName: z.ZodOptional<z.ZodString>;
|
|
@@ -195,9 +210,9 @@ export declare const stateSchema: z.ZodObject<{
|
|
|
195
210
|
activeForm: z.ZodString;
|
|
196
211
|
}, z.core.$strip>>>;
|
|
197
212
|
sandboxAllowedPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
213
|
+
mastracodePendingModelFallback: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
214
|
+
fromEntryId: z.ZodString;
|
|
215
|
+
toEntryId: z.ZodString;
|
|
201
216
|
toModelId: z.ZodString;
|
|
202
217
|
threadId: z.ZodOptional<z.ZodString>;
|
|
203
218
|
reason: z.ZodEnum<{
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CA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,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyJtB,CAAC"}
|
package/dist/schema.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { THINKING_LEVEL_VALUES } from "./thinking.js";
|
|
2
1
|
import { DEFAULT_CONFIG_DIR, DEFAULT_OM_MODEL_ID } from "./constants.js";
|
|
2
|
+
import { THINKING_LEVEL_VALUES } from "./thinking.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/schema.ts
|
|
5
5
|
const stateSchema = z.object({
|
|
6
6
|
currentModelId: z.string().optional(),
|
|
7
7
|
modeId: z.string().optional(),
|
|
8
|
-
|
|
8
|
+
modelRoute: z.object({ entries: z.array(z.object({
|
|
9
|
+
id: z.string().max(512),
|
|
10
|
+
label: z.string().max(512),
|
|
11
|
+
modelId: z.string().max(512),
|
|
12
|
+
accountId: z.string().max(512).optional(),
|
|
13
|
+
memoryModelId: z.string().max(512).optional()
|
|
14
|
+
})).max(32) }).optional(),
|
|
9
15
|
subagentModelId: z.string().optional(),
|
|
10
16
|
projectPath: z.string().optional(),
|
|
11
17
|
projectName: z.string().optional(),
|
|
@@ -63,9 +69,9 @@ const stateSchema = z.object({
|
|
|
63
69
|
activeForm: z.string()
|
|
64
70
|
})).default([]),
|
|
65
71
|
sandboxAllowedPaths: z.array(z.string()).default([]),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
mastracodePendingModelFallback: z.object({
|
|
73
|
+
fromEntryId: z.string(),
|
|
74
|
+
toEntryId: z.string(),
|
|
69
75
|
toModelId: z.string(),
|
|
70
76
|
threadId: z.string().optional(),
|
|
71
77
|
reason: z.enum(["pool-exhausted", "persistent-outage"]),
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import { z } from 'zod';\nimport { DEFAULT_CONFIG_DIR, DEFAULT_OM_MODEL_ID } from './constants.js';\nimport { THINKING_LEVEL_VALUES } from './thinking.js';\nimport type { ThinkingLevelSetting } from './thinking.js';\n\nexport type PermissionPolicy = 'allow' | 'ask' | 'deny';\n\nexport type MastraCodeSessionState = {\n currentModelId: string;\n modeId: string;\n};\n\nexport type MastraCodeComposedState = MastraCodeState & MastraCodeSessionState;\n\nexport interface MastraCodeState {\n [key: string]: unknown;\n [key: `subagentModelId_${string}`]: string | undefined;\n subagentModelId?: string;\n projectPath?: string;\n projectName?: string;\n /** Factory project that owns this session. */\n factoryProjectId?: string;\n /** Authoritative organization id seeded by factory at session construction. */\n factoryOrgId?: string;\n /**\n * Factory owns this session but could not resolve its organization. Knowledge\n * capture refuses rather than filing under a substituted identity; without the\n * marker a projectless factory session is indistinguishable from a local one.\n */\n factoryOrgUnresolved?: boolean;\n /** Linked repository used by this session when source-control execution is required. */\n projectRepositoryId?: string;\n /** Active feature branch checked out in the session workdir. */\n branch?: string;\n /**\n * The session's checkout contains third-party content (e.g. a PR branch\n * under review). Project-level instruction files (AGENTS.md, CLAUDE.md)\n * are attacker-writable there and must not be ingested into the system\n * prompt or injected as reminders.\n */\n untrustedCheckout?: boolean;\n /**\n * Trusted git ref (typically the PR's base branch) to serve project\n * instruction files from when the checkout is untrusted. Without it,\n * project-scope instruction files are skipped entirely.\n */\n baseRef?: string;\n /**\n * Skip the home-directory instruction files (~/.claude/AGENTS.md and\n * friends). Hosts running sessions for someone else set this so a run never\n * inherits the machine owner's personal configuration.\n */\n skipGlobalInstructions?: boolean;\n configDir: string;\n homeDir?: string;\n gitBranch?: string;\n lastCommand?: string;\n observerModelId: string;\n reflectorModelId: string;\n observationThreshold: number;\n reflectionThreshold: number;\n cavemanObservations: boolean;\n observeAttachments: 'auto' | boolean;\n omScope?: 'thread' | 'resource';\n /** Explicit model-pack identity for the current thread. */\n activeModelPackId?: string | null;\n /**\n * Pending pack hop written by the account-rotation processor on a cascade\n * hop; cleared back to null once the TUI applies it. Declared here so\n * consumers resolve it as a typed record instead of casting `unknown`.\n */\n mastracodePendingPackFallback?: {\n fromPackId: string;\n toPackId: string;\n toModelId: string;\n threadId?: string;\n reason: 'pool-exhausted' | 'persistent-outage';\n at: string;\n } | null;\n /**\n * Session-level reasoning-effort override. When unset, the effective level is\n * resolved at request time from settings (`models.modeThinkingDefaults[mode]`\n * falling back to `preferences.thinkingLevel`).\n */\n thinkingLevel?: ThinkingLevelSetting;\n yolo: boolean;\n permissionRules: {\n categories: Record<string, PermissionPolicy>;\n tools: Record<string, PermissionPolicy>;\n };\n smartEditing: boolean;\n notifications: 'bell' | 'system' | 'both' | 'off';\n tasks: Array<{\n id?: string;\n content: string;\n status: 'pending' | 'in_progress' | 'completed';\n activeForm: string;\n }>;\n sandboxAllowedPaths: string[];\n pluginSkillPaths: string[];\n pluginCommandPaths: string[];\n pluginInstructions: string[];\n activePlan: {\n title: string;\n plan: string;\n approvedAt: string;\n } | null;\n activeBrowserSettings?: {\n enabled: boolean;\n provider: 'stagehand' | 'agent-browser';\n headless?: boolean;\n viewport?: { width: number; height: number } | 'window';\n cdpUrl?: string;\n profile?: string;\n executablePath?: string;\n scope?: 'shared' | 'thread';\n stagehand?: {\n env: 'LOCAL' | 'BROWSERBASE';\n projectId?: string;\n model?: string;\n preserveUserDataDir?: boolean;\n };\n agentBrowser?: {\n storageState?: string;\n };\n };\n activeBrowserModel?: {\n modelName?: string;\n source: 'settings' | 'chat-model' | 'codex-oauth' | 'stagehand-default';\n viaCodexOAuth: boolean;\n };\n}\n\nexport const stateSchema = z.object({\n // Session-scoped selection.\n // validates state against this schema, so they MUST be declared here — Zod\n // strips unknown keys on parse, which would otherwise silently discard the\n // seeded model and leave the controller with no model selected.\n currentModelId: z.string().optional(),\n modeId: z.string().optional(),\n activeModelPackId: z.string().nullable().optional(),\n subagentModelId: z.string().optional(),\n projectPath: z.string().optional(),\n projectName: z.string().optional(),\n factoryProjectId: z.string().optional(),\n factoryOrgId: z.string().optional(),\n factoryOrgUnresolved: z.boolean().optional(),\n projectRepositoryId: z.string().optional(),\n branch: z.string().optional(),\n // Session operates on an untrusted checkout — suppress AGENTS.md ingestion.\n untrustedCheckout: z.boolean().optional(),\n // Trusted ref to serve instruction files from on untrusted checkouts.\n baseRef: z.string().optional(),\n // Skip the operator machine's home-directory instruction files.\n skipGlobalInstructions: z.boolean().optional(),\n configDir: z.string().default(DEFAULT_CONFIG_DIR),\n homeDir: z.string().optional(),\n gitBranch: z.string().optional(),\n lastCommand: z.string().optional(),\n // Observational Memory model settings\n observerModelId: z.string().default(DEFAULT_OM_MODEL_ID),\n reflectorModelId: z.string().default(DEFAULT_OM_MODEL_ID),\n // Observational Memory threshold settings\n observationThreshold: z.number().default(30_000),\n reflectionThreshold: z.number().default(40_000),\n // Whether observations and reflections use the terse caveman-style instruction.\n // Off by default — caveman style is opt-in via `/om` settings; observers and\n // reflectors fall back to their built-in (prose) behavior unless enabled.\n cavemanObservations: z.boolean().default(false),\n // Whether OM forwards image/file attachment parts to the Observer LLM.\n // 'auto' (default) checks the provider capabilities registry to decide.\n // true/false forces the setting regardless of model capabilities.\n observeAttachments: z.union([z.literal('auto'), z.boolean()]).default('auto'),\n // Observational Memory scope — 'thread' (per-conversation) or 'resource' (shared across threads)\n omScope: z.enum(['thread', 'resource']).optional(),\n // Thinking level for model reasoning effort. Optional: absent means \"no\n // session override\" — the effective level is resolved from settings\n // (per-mode defaults, then the global preference) at request time.\n thinkingLevel: z.preprocess(value => (value === null ? undefined : value), z.enum(THINKING_LEVEL_VALUES).optional()),\n // YOLO mode — auto-approve all tool calls\n yolo: z.boolean().default(false),\n // Permission rules — per-category and per-tool approval policies\n permissionRules: z\n .object({\n categories: z.record(z.string(), z.enum(['allow', 'ask', 'deny'])).default({}),\n tools: z.record(z.string(), z.enum(['allow', 'ask', 'deny'])).default({}),\n })\n .default({ categories: {}, tools: {} }),\n // Smart editing mode — use AST-based analysis for code edits\n smartEditing: z.boolean().default(true),\n // Notification mode — alert when TUI needs user attention\n notifications: z.enum(['bell', 'system', 'both', 'off']).default('off'),\n // Task list (ephemeral per-thread, cleared on thread switch/creation)\n tasks: z\n .array(\n z.object({\n id: z.string().optional(),\n content: z.string(),\n status: z.enum(['pending', 'in_progress', 'completed']),\n activeForm: z.string(),\n }),\n )\n .default([]),\n // Sandbox allowed paths (per-thread, absolute paths allowed in addition to project root)\n sandboxAllowedPaths: z.array(z.string()).default([]),\n // Pending pack hop written by the account-rotation processor on a cascade\n // hop; the TUI consumes it on `state_changed` to apply thread stickiness,\n // then clears it back to null. Must be declared — Zod strips unknown keys.\n mastracodePendingPackFallback: z\n .object({\n fromPackId: z.string(),\n toPackId: z.string(),\n toModelId: z.string(),\n threadId: z.string().optional(),\n reason: z.enum(['pool-exhausted', 'persistent-outage']),\n at: z.string(),\n })\n .nullish(),\n // Asset directories contributed by active plugins.\n pluginSkillPaths: z.array(z.string()).default([]),\n pluginCommandPaths: z.array(z.string()).default([]),\n pluginInstructions: z.array(z.string()).default([]),\n // Active plan (set when a plan is approved in Plan mode)\n activePlan: z\n .object({\n title: z.string(),\n plan: z.string(),\n approvedAt: z.string(),\n })\n .nullable()\n .default(null),\n // Active browser settings (tracks what's actually running vs. what's in the settings file)\n activeBrowserSettings: z\n .object({\n enabled: z.boolean(),\n provider: z.enum(['stagehand', 'agent-browser']),\n headless: z.boolean().optional(),\n viewport: z\n .union([\n z.object({\n width: z.number(),\n height: z.number(),\n }),\n z.literal('window'),\n ])\n .optional(),\n cdpUrl: z.string().optional(),\n profile: z.string().optional(),\n executablePath: z.string().optional(),\n scope: z.enum(['shared', 'thread']).optional(),\n stagehand: z\n .object({\n env: z.enum(['LOCAL', 'BROWSERBASE']),\n projectId: z.string().optional(),\n model: z.string().optional(),\n preserveUserDataDir: z.boolean().optional(),\n })\n .optional(),\n agentBrowser: z\n .object({\n storageState: z.string().optional(),\n })\n .optional(),\n })\n .optional(),\n // Model the active Stagehand browser was created with. Resolved once at\n // launch so /browser status reports what is really running even if the\n // user signs in/out of Codex afterwards.\n activeBrowserModel: z\n .object({\n modelName: z.string().optional(),\n source: z.enum(['settings', 'chat-model', 'codex-oauth', 'stagehand-default']),\n viaCodexOAuth: z.boolean(),\n })\n .optional(),\n});\n"],"mappings":";;;;AAqIA,MAAa,cAAc,EAAE,OAAO;CAKlC,gBAAgB,EAAE,OAAO,CAAC,CAAC,SAAS;CACpC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,mBAAmB,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAClD,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS;CACrC,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;CACjC,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;CACjC,kBAAkB,EAAE,OAAO,CAAC,CAAC,SAAS;CACtC,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS;CAClC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC3C,qBAAqB,EAAE,OAAO,CAAC,CAAC,SAAS;CACzC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAE5B,mBAAmB,EAAE,QAAQ,CAAC,CAAC,SAAS;CAExC,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAE7B,wBAAwB,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7C,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,kBAAkB;CAChD,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;CAEjC,iBAAiB,EAAE,OAAO,CAAC,CAAC,QAAQ,mBAAmB;CACvD,kBAAkB,EAAE,OAAO,CAAC,CAAC,QAAQ,mBAAmB;CAExD,sBAAsB,E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pC,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;GAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;GAC3B,qBAAqB,EAAE,QAAQ,CAAC,CAAC,SAAS;EAC5C,CAAC,CAAC,CACD,SAAS;EACZ,cAAc,EACX,OAAO,EACN,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS,EACpC,CAAC,CAAC,CACD,SAAS;CACd,CAAC,CAAC,CACD,SAAS;CAIZ,oBAAoB,EACjB,OAAO;EACN,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,QAAQ,EAAE,KAAK;GAAC;GAAY;GAAc;GAAe;EAAmB,CAAC;EAC7E,eAAe,EAAE,QAAQ;CAC3B,CAAC,CAAC,CACD,SAAS;AACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import { z } from 'zod';\nimport {\n DEFAULT_CONFIG_DIR,\n DEFAULT_OM_MODEL_ID,\n MODEL_ROUTE_MAX_ENTRIES,\n MODEL_ROUTE_MAX_FIELD_LENGTH,\n} from './constants.js';\nimport { THINKING_LEVEL_VALUES } from './thinking.js';\nimport type { ThinkingLevelSetting } from './thinking.js';\n\nexport type PermissionPolicy = 'allow' | 'ask' | 'deny';\n\nexport type MastraCodeSessionState = {\n currentModelId: string;\n modeId: string;\n};\n\nexport type MastraCodeComposedState = MastraCodeState & MastraCodeSessionState;\n\nexport interface ModelRouteEntry {\n id: string;\n label: string;\n modelId: string;\n accountId?: string;\n memoryModelId?: string;\n}\n\nexport interface ModelRoute {\n entries: ModelRouteEntry[];\n}\n\nexport interface PendingModelFallback {\n fromEntryId: string;\n toEntryId: string;\n toModelId: string;\n threadId?: string;\n reason: 'pool-exhausted' | 'persistent-outage';\n at: string;\n}\n\nexport interface MastraCodeState {\n [key: string]: unknown;\n [key: `subagentModelId_${string}`]: string | undefined;\n subagentModelId?: string;\n projectPath?: string;\n projectName?: string;\n /** Factory project that owns this session. */\n factoryProjectId?: string;\n /** Authoritative organization id seeded by factory at session construction. */\n factoryOrgId?: string;\n /**\n * Factory owns this session but could not resolve its organization. Knowledge\n * capture refuses rather than filing under a substituted identity; without the\n * marker a projectless factory session is indistinguishable from a local one.\n */\n factoryOrgUnresolved?: boolean;\n /** Linked repository used by this session when source-control execution is required. */\n projectRepositoryId?: string;\n /** Active feature branch checked out in the session workdir. */\n branch?: string;\n /**\n * The session's checkout contains third-party content (e.g. a PR branch\n * under review). Project-level instruction files (AGENTS.md, CLAUDE.md)\n * are attacker-writable there and must not be ingested into the system\n * prompt or injected as reminders.\n */\n untrustedCheckout?: boolean;\n /**\n * Trusted git ref (typically the PR's base branch) to serve project\n * instruction files from when the checkout is untrusted. Without it,\n * project-scope instruction files are skipped entirely.\n */\n baseRef?: string;\n /**\n * Skip the home-directory instruction files (~/.claude/AGENTS.md and\n * friends). Hosts running sessions for someone else set this so a run never\n * inherits the machine owner's personal configuration.\n */\n skipGlobalInstructions?: boolean;\n configDir: string;\n homeDir?: string;\n gitBranch?: string;\n lastCommand?: string;\n observerModelId: string;\n reflectorModelId: string;\n observationThreshold: number;\n reflectionThreshold: number;\n cavemanObservations: boolean;\n observeAttachments: 'auto' | boolean;\n omScope?: 'thread' | 'resource';\n /** Ordered host-supplied model and account fallback route for this thread. */\n modelRoute?: ModelRoute;\n /** One-hop fallback intent written by account rotation and consumed by the host. */\n mastracodePendingModelFallback?: PendingModelFallback | null;\n /**\n * Session-level reasoning-effort override. When unset, the effective level is\n * resolved at request time from settings (`models.modeThinkingDefaults[mode]`\n * falling back to `preferences.thinkingLevel`).\n */\n thinkingLevel?: ThinkingLevelSetting;\n yolo: boolean;\n permissionRules: {\n categories: Record<string, PermissionPolicy>;\n tools: Record<string, PermissionPolicy>;\n };\n smartEditing: boolean;\n notifications: 'bell' | 'system' | 'both' | 'off';\n tasks: Array<{\n id?: string;\n content: string;\n status: 'pending' | 'in_progress' | 'completed';\n activeForm: string;\n }>;\n sandboxAllowedPaths: string[];\n pluginSkillPaths: string[];\n pluginCommandPaths: string[];\n pluginInstructions: string[];\n activePlan: {\n title: string;\n plan: string;\n approvedAt: string;\n } | null;\n activeBrowserSettings?: {\n enabled: boolean;\n provider: 'stagehand' | 'agent-browser';\n headless?: boolean;\n viewport?: { width: number; height: number } | 'window';\n cdpUrl?: string;\n profile?: string;\n executablePath?: string;\n scope?: 'shared' | 'thread';\n stagehand?: {\n env: 'LOCAL' | 'BROWSERBASE';\n projectId?: string;\n model?: string;\n preserveUserDataDir?: boolean;\n };\n agentBrowser?: {\n storageState?: string;\n };\n };\n activeBrowserModel?: {\n modelName?: string;\n source: 'settings' | 'chat-model' | 'codex-oauth' | 'stagehand-default';\n viaCodexOAuth: boolean;\n };\n}\n\nexport const stateSchema = z.object({\n // Session-scoped selection. The controller validates state against this\n // schema, so these keys must be declared here — Zod strips unknown keys.\n currentModelId: z.string().optional(),\n modeId: z.string().optional(),\n modelRoute: z\n .object({\n entries: z\n .array(\n z.object({\n id: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n label: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n modelId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n accountId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH).optional(),\n memoryModelId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH).optional(),\n }),\n )\n .max(MODEL_ROUTE_MAX_ENTRIES),\n })\n .optional(),\n subagentModelId: z.string().optional(),\n projectPath: z.string().optional(),\n projectName: z.string().optional(),\n factoryProjectId: z.string().optional(),\n factoryOrgId: z.string().optional(),\n factoryOrgUnresolved: z.boolean().optional(),\n projectRepositoryId: z.string().optional(),\n branch: z.string().optional(),\n // Session operates on an untrusted checkout — suppress AGENTS.md ingestion.\n untrustedCheckout: z.boolean().optional(),\n // Trusted ref to serve instruction files from on untrusted checkouts.\n baseRef: z.string().optional(),\n // Skip the operator machine's home-directory instruction files.\n skipGlobalInstructions: z.boolean().optional(),\n configDir: z.string().default(DEFAULT_CONFIG_DIR),\n homeDir: z.string().optional(),\n gitBranch: z.string().optional(),\n lastCommand: z.string().optional(),\n // Observational Memory model settings\n observerModelId: z.string().default(DEFAULT_OM_MODEL_ID),\n reflectorModelId: z.string().default(DEFAULT_OM_MODEL_ID),\n // Observational Memory threshold settings\n observationThreshold: z.number().default(30_000),\n reflectionThreshold: z.number().default(40_000),\n // Whether observations and reflections use the terse caveman-style instruction.\n // Off by default — caveman style is opt-in via `/om` settings; observers and\n // reflectors fall back to their built-in (prose) behavior unless enabled.\n cavemanObservations: z.boolean().default(false),\n // Whether OM forwards image/file attachment parts to the Observer LLM.\n // 'auto' (default) checks the provider capabilities registry to decide.\n // true/false forces the setting regardless of model capabilities.\n observeAttachments: z.union([z.literal('auto'), z.boolean()]).default('auto'),\n // Observational Memory scope — 'thread' (per-conversation) or 'resource' (shared across threads)\n omScope: z.enum(['thread', 'resource']).optional(),\n // Thinking level for model reasoning effort. Optional: absent means \"no\n // session override\" — the effective level is resolved from settings\n // (per-mode defaults, then the global preference) at request time.\n thinkingLevel: z.preprocess(value => (value === null ? undefined : value), z.enum(THINKING_LEVEL_VALUES).optional()),\n // YOLO mode — auto-approve all tool calls\n yolo: z.boolean().default(false),\n // Permission rules — per-category and per-tool approval policies\n permissionRules: z\n .object({\n categories: z.record(z.string(), z.enum(['allow', 'ask', 'deny'])).default({}),\n tools: z.record(z.string(), z.enum(['allow', 'ask', 'deny'])).default({}),\n })\n .default({ categories: {}, tools: {} }),\n // Smart editing mode — use AST-based analysis for code edits\n smartEditing: z.boolean().default(true),\n // Notification mode — alert when TUI needs user attention\n notifications: z.enum(['bell', 'system', 'both', 'off']).default('off'),\n // Task list (ephemeral per-thread, cleared on thread switch/creation)\n tasks: z\n .array(\n z.object({\n id: z.string().optional(),\n content: z.string(),\n status: z.enum(['pending', 'in_progress', 'completed']),\n activeForm: z.string(),\n }),\n )\n .default([]),\n // Sandbox allowed paths (per-thread, absolute paths allowed in addition to project root)\n sandboxAllowedPaths: z.array(z.string()).default([]),\n // Pending route hop written by account rotation. The host consumes it on\n // `state_changed` to apply thread stickiness, then clears it back to null.\n mastracodePendingModelFallback: z\n .object({\n fromEntryId: z.string(),\n toEntryId: z.string(),\n toModelId: z.string(),\n threadId: z.string().optional(),\n reason: z.enum(['pool-exhausted', 'persistent-outage']),\n at: z.string(),\n })\n .nullish(),\n // Asset directories contributed by active plugins.\n pluginSkillPaths: z.array(z.string()).default([]),\n pluginCommandPaths: z.array(z.string()).default([]),\n pluginInstructions: z.array(z.string()).default([]),\n // Active plan (set when a plan is approved in Plan mode)\n activePlan: z\n .object({\n title: z.string(),\n plan: z.string(),\n approvedAt: z.string(),\n })\n .nullable()\n .default(null),\n // Active browser settings (tracks what's actually running vs. what's in the settings file)\n activeBrowserSettings: z\n .object({\n enabled: z.boolean(),\n provider: z.enum(['stagehand', 'agent-browser']),\n headless: z.boolean().optional(),\n viewport: z\n .union([\n z.object({\n width: z.number(),\n height: z.number(),\n }),\n z.literal('window'),\n ])\n .optional(),\n cdpUrl: z.string().optional(),\n profile: z.string().optional(),\n executablePath: z.string().optional(),\n scope: z.enum(['shared', 'thread']).optional(),\n stagehand: z\n .object({\n env: z.enum(['LOCAL', 'BROWSERBASE']),\n projectId: z.string().optional(),\n model: z.string().optional(),\n preserveUserDataDir: z.boolean().optional(),\n })\n .optional(),\n agentBrowser: z\n .object({\n storageState: z.string().optional(),\n })\n .optional(),\n })\n .optional(),\n // Model the active Stagehand browser was created with. Resolved once at\n // launch so /browser status reports what is really running even if the\n // user signs in/out of Codex afterwards.\n activeBrowserModel: z\n .object({\n modelName: z.string().optional(),\n source: z.enum(['settings', 'chat-model', 'codex-oauth', 'stagehand-default']),\n viaCodexOAuth: z.boolean(),\n })\n .optional(),\n});\n"],"mappings":";;;;AAoJA,MAAa,cAAc,EAAE,OAAO;CAGlC,gBAAgB,EAAE,OAAO,CAAC,CAAC,SAAS;CACpC,QAAQ,EAAE,OAAO,CAAC,CAAC,S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AC,CAAC,SAAS;GAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;GAC3B,qBAAqB,EAAE,QAAQ,CAAC,CAAC,SAAS;EAC5C,CAAC,CAAC,CACD,SAAS;EACZ,cAAc,EACX,OAAO,EACN,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS,EACpC,CAAC,CAAC,CACD,SAAS;CACd,CAAC,CAAC,CACD,SAAS;CAIZ,oBAAoB,EACjB,OAAO;EACN,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,QAAQ,EAAE,KAAK;GAAC;GAAY;GAAc;GAAe;EAAmB,CAAC;EAC7E,eAAe,EAAE,QAAQ;CAC3B,CAAC,CAAC,CACD,SAAS;AACd,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort browser opening for OAuth and other login flows.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Open a URL in the default browser without going through a shell.
|
|
6
|
+
* Only well-formed http(s) URLs are opened; anything else is ignored
|
|
7
|
+
* (the URL is still displayed for the user to open manually).
|
|
8
|
+
*/
|
|
9
|
+
export declare function openUrlInBrowser(url: string): void;
|
|
10
|
+
//# sourceMappingURL=open-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-url.d.ts","sourceRoot":"","sources":["../../src/utils/open-url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAsBlD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
//#region src/utils/open-url.ts
|
|
3
|
+
/**
|
|
4
|
+
* Best-effort browser opening for OAuth and other login flows.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Open a URL in the default browser without going through a shell.
|
|
8
|
+
* Only well-formed http(s) URLs are opened; anything else is ignored
|
|
9
|
+
* (the URL is still displayed for the user to open manually).
|
|
10
|
+
*/
|
|
11
|
+
function openUrlInBrowser(url) {
|
|
12
|
+
let parsed;
|
|
13
|
+
try {
|
|
14
|
+
parsed = new URL(url);
|
|
15
|
+
} catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
|
|
19
|
+
const [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]];
|
|
20
|
+
const child = spawn(cmd, args, {
|
|
21
|
+
stdio: "ignore",
|
|
22
|
+
detached: true
|
|
23
|
+
});
|
|
24
|
+
child.on("error", () => {});
|
|
25
|
+
child.unref();
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { openUrlInBrowser };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=open-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-url.js","names":[],"sources":["../../src/utils/open-url.ts"],"sourcesContent":["/**\n * Best-effort browser opening for OAuth and other login flows.\n */\n\nimport { spawn } from 'node:child_process';\n\n/**\n * Open a URL in the default browser without going through a shell.\n * Only well-formed http(s) URLs are opened; anything else is ignored\n * (the URL is still displayed for the user to open manually).\n */\nexport function openUrlInBrowser(url: string): void {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return;\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return;\n }\n\n const [cmd, args]: [string, string[]] =\n process.platform === 'darwin'\n ? ['open', [url]]\n : process.platform === 'win32'\n ? ['rundll32', ['url.dll,FileProtocolHandler', url]]\n : ['xdg-open', [url]];\n\n const child = spawn(cmd, args, { stdio: 'ignore', detached: true });\n // Opening the browser is best-effort — the URL is shown to the user as well.\n child.on('error', () => {});\n child.unref();\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,iBAAiB,KAAmB;CAClD,IAAI;CACJ,IAAI;EACF,SAAS,IAAI,IAAI,GAAG;CACtB,QAAQ;EACN;CACF;CACA,IAAI,OAAO,aAAa,WAAW,OAAO,aAAa,UACrD;CAGF,MAAM,CAAC,KAAK,QACV,QAAQ,aAAa,WACjB,CAAC,QAAQ,CAAC,GAAG,CAAC,IACd,QAAQ,aAAa,UACnB,CAAC,YAAY,CAAC,+BAA+B,GAAG,CAAC,IACjD,CAAC,YAAY,CAAC,GAAG,CAAC;CAE1B,MAAM,QAAQ,MAAM,KAAK,MAAM;EAAE,OAAO;EAAU,UAAU;CAAK,CAAC;CAElE,MAAM,GAAG,eAAe,CAAC,CAAC;CAC1B,MAAM,MAAM;AACd"}
|
package/dist/utils/project.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_CONFIG_DIR } from "../constants.js";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
3
|
+
import { createHash } from "crypto";
|
|
4
4
|
import fs from "fs";
|
|
5
|
+
import { execFile, execSync } from "child_process";
|
|
5
6
|
import os from "os";
|
|
6
|
-
import { createHash } from "crypto";
|
|
7
7
|
//#region src/utils/project.ts
|
|
8
8
|
/**
|
|
9
9
|
* Project detection utilities
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { PubSub, UnixSocketPubSub } from '@mastra/core/events';
|
|
2
2
|
import type { Event, EventCallback, LeaseProvider, PubSubDeliveryMode, SubscribeOptions } from '@mastra/core/events';
|
|
3
3
|
export type SignalsPubSubOptions = {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Also list this process's threads to, and find threads in, other projects on
|
|
6
|
+
* this machine: peer discovery runs in `<root>/_shared/` instead of this
|
|
7
|
+
* resource's directory.
|
|
8
|
+
*/
|
|
9
|
+
sharedAgentDiscovery?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Directory that holds every resource's socket directory. Defaults to the
|
|
12
|
+
* absolute path in `MASTRACODE_SIGNALS_SOCKET_ROOT`, else `/tmp/mc`.
|
|
13
|
+
*/
|
|
5
14
|
rootDir?: string;
|
|
6
15
|
};
|
|
7
16
|
/**
|
|
@@ -29,14 +38,25 @@ export declare function notificationDispatchLeaseKey(resourceId: string): string
|
|
|
29
38
|
* - Thread-owner discovery lives in `<root>/_shared/`, so a process that finds
|
|
30
39
|
* a thread claimed can reach the owner and hand it the signal. It only
|
|
31
40
|
* answers for a thread the asker names, so it discloses nothing new.
|
|
32
|
-
* -
|
|
33
|
-
*
|
|
41
|
+
* - Peer discovery (which lists threads) runs in `<root>/_shared/` when
|
|
42
|
+
* `sharedAgentDiscovery` is set, so processes in every project can list each
|
|
43
|
+
* other's threads. Without it, it stays in this resource's directory.
|
|
44
|
+
* - Everything else stays in this process's own resource directory.
|
|
34
45
|
*
|
|
35
46
|
* Stale sockets from crashed processes are handled by
|
|
36
47
|
* {@link UnixSocketPubSub}'s built-in election logic: it detects
|
|
37
48
|
* ECONNREFUSED on a dead broker socket, unlinks it, and re-elects.
|
|
38
49
|
* No blanket cleanup is needed here — that would break concurrent
|
|
39
50
|
* mc instances sharing a directory.
|
|
51
|
+
*
|
|
52
|
+
* One-shot reply topics (discovery and idle-acceptance replies) are
|
|
53
|
+
* reference-counted: every in-flight publish/subscribe and every live
|
|
54
|
+
* subscription holds a reference, and the topic's socket is closed as soon as
|
|
55
|
+
* the count drops to zero. Without this each request would keep a socket, a
|
|
56
|
+
* file descriptor and (for the broker) a socket file for the process lifetime.
|
|
57
|
+
* With `sharedAgentDiscovery`, another resource's thread topics are counted the
|
|
58
|
+
* same way, so a process that signals many threads elsewhere does not keep a
|
|
59
|
+
* socket open for each.
|
|
40
60
|
*/
|
|
41
61
|
declare class SignalsPubSub extends PubSub {
|
|
42
62
|
#private;
|
|
@@ -53,6 +73,13 @@ declare class SignalsPubSub extends PubSub {
|
|
|
53
73
|
}): Promise<void>;
|
|
54
74
|
subscribe(topic: string, cb: EventCallback, options?: SubscribeOptions): Promise<void>;
|
|
55
75
|
unsubscribe(topic: string, cb: EventCallback): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Drops a one-shot reply topic: its remaining subscriptions release their
|
|
78
|
+
* references and the socket closes once no operation still uses it. Other
|
|
79
|
+
* topics (workflow events, thread streams) have subscribers in other
|
|
80
|
+
* processes that need the broker, so clearing them is a no-op.
|
|
81
|
+
*/
|
|
82
|
+
clearTopic(topic: string): Promise<void>;
|
|
56
83
|
flush(): Promise<void>;
|
|
57
84
|
close(): Promise<void>;
|
|
58
85
|
/** Get the underlying socket for a topic (for testing/inspection). */
|
|
@@ -64,7 +91,8 @@ declare class SignalsPubSub extends PubSub {
|
|
|
64
91
|
*
|
|
65
92
|
* Topics live under `/tmp/mc/<resourceId>/`, except that a thread's stream and
|
|
66
93
|
* leases live under its own resource's directory and thread-owner discovery
|
|
67
|
-
* under `/tmp/mc/_shared/` (see {@link SignalsPubSub}).
|
|
94
|
+
* under `/tmp/mc/_shared/` (see {@link SignalsPubSub}). With
|
|
95
|
+
* `sharedAgentDiscovery`, peer discovery runs there too. Stale sockets from
|
|
68
96
|
* crashed processes are handled by the underlying {@link UnixSocketPubSub}'s
|
|
69
97
|
* broker election logic.
|
|
70
98
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals-pubsub.d.ts","sourceRoot":"","sources":["../../src/utils/signals-pubsub.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"signals-pubsub.d.ts","sourceRoot":"","sources":["../../src/utils/signals-pubsub.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,E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