Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
563 changes: 563 additions & 0 deletions src/protocol/cli.ts

Large diffs are not rendered by default.

1,104 changes: 1,104 additions & 0 deletions src/protocol/client.ts

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions src/protocol/custom-models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Source-of-truth mirror of factory-mono-alpha custom-model schemas (symbol-only).
// Verbatim copy of CustomModelBedrockSchema, ManagedCustomModelSchema, and
// CustomModelsSchema from packages/common/src/settings/schema.ts. Ported as-is
// per the no-modification rule (includes apiKey / aws credential fields).
// SandboxModeSchema is colocated here (one-liner from the same settings module).

import { z } from 'zod';

import { ModelProvider, ReasoningEffort, SandboxMode } from './enums.js';

const ReasoningEffortSchema = z.nativeEnum(ReasoningEffort);

export const SandboxModeSchema = z.nativeEnum(SandboxMode);

const CustomModelBedrockSchema = z.object({
awsProfile: z.string().optional(),
awsRegion: z.string().min(1).optional(),
bedrockBaseUrl: z.string().url().optional(),
awsAuthRefresh: z.string().optional(),
awsCredentialExport: z.string().optional(),
});

export const ManagedCustomModelSchema = z
.object({
model: z.string(),
id: z.string().optional(),
index: z.number().optional(),
baseUrl: z.string().optional(),
apiKey: z.string().optional(),
provider: z.nativeEnum(ModelProvider),
displayName: z.string().optional(),
maxContextLimit: z.number().optional(),
enableThinking: z.boolean().optional(),
thinkingMaxTokens: z.number().optional(),
maxOutputTokens: z.number().optional(),
reasoningEffort: ReasoningEffortSchema.optional(),
extraHeaders: z.record(z.string()).optional(),
extraArgs: z.record(z.unknown()).optional(),
noImageSupport: z.boolean().optional(),
bedrock: CustomModelBedrockSchema.optional(),
})
.superRefine((model, ctx) => {
if (model.provider === ModelProvider.BEDROCK_CONVERSE && !model.bedrock) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['bedrock'],
message:
'bedrock-converse custom models require a bedrock configuration block',
});
return;
}
if (model.bedrock) {
if (
model.provider !== ModelProvider.ANTHROPIC &&
model.provider !== ModelProvider.BEDROCK_CONVERSE
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['provider'],
message:
'bedrock custom models require provider "anthropic" or "bedrock-converse"',
});
}
return;
}
if (!model.baseUrl) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['baseUrl'],
message: 'baseUrl is required unless bedrock is configured',
});
}
if (!model.apiKey) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['apiKey'],
message: 'apiKey is required unless bedrock is configured',
});
}
});

export const CustomModelsSchema = z.array(ManagedCustomModelSchema);

export type ManagedCustomModel = z.infer<typeof ManagedCustomModelSchema>;
export type CustomModels = z.infer<typeof CustomModelsSchema>;
47 changes: 47 additions & 0 deletions src/protocol/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,50 @@ export enum ApiProvider {
BASETEN = 'baseten',
SNOWFLAKE = 'snowflake',
}

export enum ModelKind {
Concrete = 'concrete',
Router = 'router',
}

export enum LLMModelTier {
Standard = 'standard',
// Deprecated
Premium = 'premium',
// Extra Usage (overage) billing tier
Overage = 'overage',
}

// ---------------------------------------------------------------------------
// settings/enums.ts (leaf subset)
// ---------------------------------------------------------------------------

/**
* Settings hierarchy level enum.
* Precedence order (highest to lowest): Org -> Runtime -> Folder -> Project -> User
*/
export enum SettingsLevel {
Org = 'org',
Runtime = 'runtime',
User = 'user',
Project = 'project',
Folder = 'folder',
Dynamic = 'dynamic',
BuiltIn = 'builtin',
}

export enum DroidLocation {
Project = 'project',
Personal = 'personal',
}

export enum SkillLocation {
Project = 'project',
Personal = 'personal',
Builtin = 'builtin',
}

export enum SandboxMode {
PerCommand = 'per-command',
WholeProcess = 'whole-process',
}
5 changes: 5 additions & 0 deletions src/protocol/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ export * from './messages.js';
export * from './model-settings.js';
export * from './loop.js';
export * from './selectable-list-item.js';
export * from './custom-models.js';
export * from './mcp.js';
export * from './mission-decomposition.js';
export * from './cli.js';
export * from './client.js';
77 changes: 77 additions & 0 deletions src/protocol/mcp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Source-of-truth mirror of factory-mono-alpha MCP schemas.
// Verbatim copy of packages/common/src/droid/schemas/mcp.ts.

import { z } from 'zod';

import { McpServerStatus, McpServerType, SettingsLevel } from './enums.js';

// MCP primitives
export const McpServerNameSchema = z.string();
export const McpServerTypeSchema = z.enum(['stdio', 'http', 'sse']);

// Server config field schemas (used by registry and add-server requests)
export const McpHttpServerConfigFieldsSchema = z.object({
url: z.string().optional(),
});

export const McpStdioServerConfigFieldsSchema = z.object({
command: z.string().optional(),
args: z.array(z.string()).optional(),
});

// MCP server status (shared between LIST_MCP_SERVERS result and MCP_STATUS_CHANGED notification)
export const McpServerStatusInfoSchema = z.object({
name: z.string(),
status: z.nativeEnum(McpServerStatus),
source: z.nativeEnum(SettingsLevel),
isManaged: z.boolean(),
error: z.string().optional(),
toolCount: z.number().optional(),
serverType: z.nativeEnum(McpServerType),
hasAuthTokens: z.boolean().optional(),
requiresAuth: z.boolean().optional(),
pendingAuthUrl: z.string().optional(),
pendingAuthMessage: z.string().optional(),
pendingAuthState: z.string().optional(),
});

// MCP status summary (shared between LIST_MCP_SERVERS result and MCP_STATUS_CHANGED notification)
export const McpStatusSummarySchema = z.object({
total: z.number(),
connected: z.number(),
connecting: z.number(),
failed: z.number(),
disabled: z.number().optional(),
});

// MCP registry server entity
const McpRegistryServerBaseSchema = z.object({
name: McpServerNameSchema,
description: z.string(),
type: McpServerTypeSchema,
});

export const McpRegistryServerSchema = McpRegistryServerBaseSchema.merge(
McpHttpServerConfigFieldsSchema
)
.merge(McpStdioServerConfigFieldsSchema)
.extend({
note: z.string().optional(),
logoUrl: z.string().optional(),
});

// MCP tool entity
export const McpToolInfoSchema = z.object({
serverName: McpServerNameSchema,
name: z.string(),
description: z.string().optional(),
isEnabled: z.boolean(),
isReadOnly: z.boolean().optional(),
inputSchema: z
.object({
type: z.string().optional(),
properties: z.record(z.unknown()).optional(),
required: z.array(z.string()).optional(),
})
.optional(),
});
Loading
Loading