mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
feat: add assistant mode, SSE streaming, and OpenCode server integration (#214)
This commit is contained in:
1 parent
3cc24288a6
commit
c3d6549f01
133 files changed
+7284
-6293
No files matched your search
@@ -51,7 +51,9 @@ export const DEFAULTS = {
|
||||
RECONNECT_DELAY_MS: 1000,
|
||||
MAX_RECONNECT_DELAY_MS: 30000,
|
||||
IDLE_GRACE_PERIOD_MS: 5000,
|
||||
HEARTBEAT_INTERVAL_MS: 60000,
|
||||
HEARTBEAT_INTERVAL_MS: 30000,
|
||||
STALL_THRESHOLD_MS: 90000,
|
||||
WATCHDOG_TICK_MS: 15000,
|
||||
},
|
||||
} as const
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ export * from './auth'
|
||||
export * from './sse'
|
||||
export * from './notifications'
|
||||
export * from './ssh'
|
||||
export * from './memory'
|
||||
export * from './schedule'
|
||||
export * from './skills'
|
||||
export * from './internal-assistant'
|
||||
@@ -0,0 +1,57 @@
|
||||
import { z } from 'zod'
|
||||
import { UserPreferencesSchema } from './settings'
|
||||
|
||||
export const AssistantNotificationPrioritySchema = z.enum(['normal', 'high'])
|
||||
|
||||
export const AssistantNotificationRequestSchema = z.object({
|
||||
title: z.string().min(1).max(120),
|
||||
body: z.string().min(1).max(500),
|
||||
url: z.string().min(1).max(500).optional(),
|
||||
tag: z.string().max(80).optional(),
|
||||
priority: AssistantNotificationPrioritySchema.default('normal'),
|
||||
})
|
||||
|
||||
export const AssistantNotificationResponseSchema = z.object({
|
||||
delivered: z.number(),
|
||||
expired: z.number(),
|
||||
failed: z.number(),
|
||||
noSubscriptions: z.boolean(),
|
||||
})
|
||||
|
||||
export const AssistantSettingsPatchSchema = UserPreferencesSchema.pick({
|
||||
theme: true,
|
||||
mode: true,
|
||||
defaultModel: true,
|
||||
defaultAgent: true,
|
||||
autoScroll: true,
|
||||
expandDiffs: true,
|
||||
expandToolCalls: true,
|
||||
showReasoning: true,
|
||||
simpleChatMode: true,
|
||||
leaderKey: true,
|
||||
directShortcuts: true,
|
||||
keyboardShortcuts: true,
|
||||
customCommands: true,
|
||||
notifications: true,
|
||||
repoOrder: true,
|
||||
repoSortMode: true,
|
||||
}).partial().strict()
|
||||
|
||||
export const ASSISTANT_SETTINGS_ALLOWED_KEYS = [
|
||||
'theme',
|
||||
'mode',
|
||||
'defaultModel',
|
||||
'defaultAgent',
|
||||
'autoScroll',
|
||||
'expandDiffs',
|
||||
'expandToolCalls',
|
||||
'showReasoning',
|
||||
'simpleChatMode',
|
||||
'leaderKey',
|
||||
'directShortcuts',
|
||||
'keyboardShortcuts',
|
||||
'customCommands',
|
||||
'notifications',
|
||||
'repoOrder',
|
||||
'repoSortMode',
|
||||
] as const
|
||||
@@ -1,166 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const MemoryScopeSchema = z.enum(['convention', 'decision', 'context'])
|
||||
export type MemoryScope = z.infer<typeof MemoryScopeSchema>
|
||||
|
||||
export const MemorySchema = z.object({
|
||||
id: z.number(),
|
||||
projectId: z.string(),
|
||||
scope: MemoryScopeSchema,
|
||||
content: z.string(),
|
||||
filePath: z.string().nullable(),
|
||||
accessCount: z.number().default(0),
|
||||
lastAccessedAt: z.number().nullable(),
|
||||
createdAt: z.number(),
|
||||
updatedAt: z.number(),
|
||||
})
|
||||
export type Memory = z.infer<typeof MemorySchema>
|
||||
|
||||
export const CreateMemoryRequestSchema = z.object({
|
||||
projectId: z.string(),
|
||||
scope: MemoryScopeSchema,
|
||||
content: z.string().min(1).max(10000),
|
||||
})
|
||||
export type CreateMemoryRequest = z.infer<typeof CreateMemoryRequestSchema>
|
||||
|
||||
export const UpdateMemoryRequestSchema = z.object({
|
||||
content: z.string().min(1).max(10000).optional(),
|
||||
scope: MemoryScopeSchema.optional(),
|
||||
})
|
||||
export type UpdateMemoryRequest = z.infer<typeof UpdateMemoryRequestSchema>
|
||||
|
||||
export const MemoryStatsSchema = z.object({
|
||||
projectId: z.string(),
|
||||
total: z.number(),
|
||||
byScope: z.record(MemoryScopeSchema, z.number()),
|
||||
})
|
||||
export type MemoryStats = z.infer<typeof MemoryStatsSchema>
|
||||
|
||||
export const MemoryListQuerySchema = z.object({
|
||||
projectId: z.string().optional(),
|
||||
scope: MemoryScopeSchema.optional(),
|
||||
content: z.string().optional(),
|
||||
limit: z.number().min(1).max(100).default(20),
|
||||
offset: z.number().min(0).default(0),
|
||||
})
|
||||
export type MemoryListQuery = z.infer<typeof MemoryListQuerySchema>
|
||||
|
||||
export const EmbeddingProviderTypeSchema = z.enum(['openai', 'voyage', 'local'])
|
||||
export type EmbeddingProviderType = z.infer<typeof EmbeddingProviderTypeSchema>
|
||||
|
||||
export const EmbeddingConfigSchema = z.object({
|
||||
provider: EmbeddingProviderTypeSchema,
|
||||
model: z.string(),
|
||||
dimensions: z.number().optional(),
|
||||
baseUrl: z.string().optional(),
|
||||
apiKey: z.string().optional(),
|
||||
})
|
||||
export type EmbeddingConfig = z.infer<typeof EmbeddingConfigSchema>
|
||||
|
||||
export const LoggingConfigSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
file: z.string().optional(),
|
||||
debug: z.boolean().optional(),
|
||||
})
|
||||
export type LoggingConfig = z.infer<typeof LoggingConfigSchema>
|
||||
|
||||
export const CompactionConfigSchema = z.object({
|
||||
customPrompt: z.boolean().optional(),
|
||||
maxContextTokens: z.number().optional(),
|
||||
})
|
||||
export type CompactionConfig = z.infer<typeof CompactionConfigSchema>
|
||||
|
||||
export const MemoryInjectionConfigSchema = z.object({
|
||||
enabled: z.boolean().optional(),
|
||||
maxResults: z.number().optional(),
|
||||
distanceThreshold: z.number().optional(),
|
||||
maxTokens: z.number().optional(),
|
||||
cacheTtlMs: z.number().optional(),
|
||||
debug: z.boolean().optional(),
|
||||
})
|
||||
export type MemoryInjectionConfig = z.infer<typeof MemoryInjectionConfigSchema>
|
||||
|
||||
export const MessagesTransformConfigSchema = z.object({
|
||||
enabled: z.boolean().optional(),
|
||||
debug: z.boolean().optional(),
|
||||
})
|
||||
export type MessagesTransformConfig = z.infer<typeof MessagesTransformConfigSchema>
|
||||
|
||||
export const LoopConfigSchema = z.object({
|
||||
enabled: z.boolean().optional(),
|
||||
defaultMaxIterations: z.number().optional(),
|
||||
cleanupWorktree: z.boolean().optional(),
|
||||
defaultAudit: z.boolean().optional(),
|
||||
model: z.string().optional(),
|
||||
minAudits: z.number().optional(),
|
||||
stallTimeoutMs: z.number().optional(),
|
||||
})
|
||||
export type LoopConfig = z.infer<typeof LoopConfigSchema>
|
||||
|
||||
export const PluginConfigSchema = z.object({
|
||||
dataDir: z.string().optional(),
|
||||
embedding: EmbeddingConfigSchema,
|
||||
dedupThreshold: z.number().min(0).max(1).default(0.25),
|
||||
logging: LoggingConfigSchema.optional(),
|
||||
compaction: CompactionConfigSchema.optional(),
|
||||
memoryInjection: MemoryInjectionConfigSchema.optional(),
|
||||
messagesTransform: MessagesTransformConfigSchema.optional(),
|
||||
executionModel: z.string().optional(),
|
||||
auditorModel: z.string().optional(),
|
||||
loop: LoopConfigSchema.optional(),
|
||||
ralph: LoopConfigSchema.optional(),
|
||||
})
|
||||
export type PluginConfig = z.infer<typeof PluginConfigSchema>
|
||||
|
||||
export const KvEntrySchema = z.object({
|
||||
key: z.string(),
|
||||
data: z.unknown(),
|
||||
createdAt: z.number(),
|
||||
updatedAt: z.number(),
|
||||
expiresAt: z.number(),
|
||||
})
|
||||
export type KvEntry = z.infer<typeof KvEntrySchema>
|
||||
|
||||
export const KvListQuerySchema = z.object({
|
||||
projectId: z.string(),
|
||||
prefix: z.string().optional(),
|
||||
})
|
||||
export type KvListQuery = z.infer<typeof KvListQuerySchema>
|
||||
|
||||
export const CreateKvEntryRequestSchema = z.object({
|
||||
projectId: z.string(),
|
||||
key: z.string(),
|
||||
data: z.unknown(),
|
||||
ttlMs: z.number().optional(),
|
||||
})
|
||||
export type CreateKvEntryRequest = z.infer<typeof CreateKvEntryRequestSchema>
|
||||
|
||||
export const UpdateKvEntryRequestSchema = z.object({
|
||||
data: z.unknown(),
|
||||
ttlMs: z.number().optional(),
|
||||
})
|
||||
export type UpdateKvEntryRequest = z.infer<typeof UpdateKvEntryRequestSchema>
|
||||
|
||||
export const LoopStateSchema = z.object({
|
||||
active: z.boolean(),
|
||||
sessionId: z.string(),
|
||||
worktreeName: z.string(),
|
||||
worktreeDir: z.string(),
|
||||
worktreeBranch: z.string().optional(),
|
||||
workspaceId: z.string().optional(),
|
||||
iteration: z.number(),
|
||||
maxIterations: z.number(),
|
||||
completionPromise: z.string().nullable().optional(),
|
||||
startedAt: z.string(),
|
||||
prompt: z.string().optional(),
|
||||
phase: z.enum(['coding', 'auditing']),
|
||||
audit: z.boolean().optional(),
|
||||
lastAuditResult: z.string().optional(),
|
||||
errorCount: z.number(),
|
||||
auditCount: z.number(),
|
||||
terminationReason: z.string().optional(),
|
||||
completedAt: z.string().optional(),
|
||||
worktree: z.boolean().optional(),
|
||||
modelFailed: z.boolean().optional(),
|
||||
})
|
||||
export type LoopState = z.infer<typeof LoopStateSchema>
|
||||
@@ -65,6 +65,26 @@ export const AssistantModeStatusSchema = z.object({
|
||||
agentsMd: AssistantModeFileSchema,
|
||||
opencodeJson: AssistantModeFileSchema,
|
||||
}),
|
||||
internalToken: z.object({
|
||||
path: z.string(),
|
||||
created: z.boolean(),
|
||||
exists: z.boolean().optional(),
|
||||
}).optional(),
|
||||
schedulesSkill: z.object({
|
||||
path: z.string(),
|
||||
created: z.boolean(),
|
||||
exists: z.boolean().optional(),
|
||||
}).optional(),
|
||||
notificationsSkill: z.object({
|
||||
path: z.string(),
|
||||
created: z.boolean(),
|
||||
exists: z.boolean().optional(),
|
||||
}).optional(),
|
||||
settingsSkill: z.object({
|
||||
path: z.string(),
|
||||
created: z.boolean(),
|
||||
exists: z.boolean().optional(),
|
||||
}).optional(),
|
||||
})
|
||||
|
||||
export const AssistantModeInitRequestSchema = z.object({
|
||||
|
||||
@@ -13,9 +13,6 @@ export type SkillScope = z.infer<typeof SkillScopeSchema>
|
||||
export const SkillFrontmatterSchema = z.object({
|
||||
name: SkillNameSchema,
|
||||
description: z.string().min(1).max(1024),
|
||||
license: z.string().optional(),
|
||||
compatibility: z.string().optional(),
|
||||
metadata: z.record(z.string(), z.string()).optional(),
|
||||
})
|
||||
|
||||
export type SkillFrontmatter = z.infer<typeof SkillFrontmatterSchema>
|
||||
@@ -24,9 +21,6 @@ export const CreateSkillRequestSchema = z.object({
|
||||
name: SkillNameSchema,
|
||||
description: z.string().min(1).max(1024),
|
||||
body: z.string(),
|
||||
license: z.string().optional(),
|
||||
compatibility: z.string().optional(),
|
||||
metadata: z.record(z.string(), z.string()).optional(),
|
||||
scope: SkillScopeSchema,
|
||||
repoId: z.number().optional(),
|
||||
})
|
||||
@@ -36,9 +30,6 @@ export type CreateSkillRequest = z.infer<typeof CreateSkillRequestSchema>
|
||||
export const UpdateSkillRequestSchema = z.object({
|
||||
description: z.string().min(1).max(1024).optional(),
|
||||
body: z.string().optional(),
|
||||
license: z.string().nullable().optional(),
|
||||
compatibility: z.string().nullable().optional(),
|
||||
metadata: z.record(z.string(), z.string()).nullable().optional(),
|
||||
})
|
||||
|
||||
export type UpdateSkillRequest = z.infer<typeof UpdateSkillRequestSchema>
|
||||
@@ -47,9 +38,6 @@ export interface SkillFileInfo {
|
||||
name: string
|
||||
description: string
|
||||
body: string
|
||||
license?: string
|
||||
compatibility?: string
|
||||
metadata?: Record<string, string>
|
||||
scope: SkillScope
|
||||
location: string
|
||||
repoId?: number
|
||||
|
||||
+11
-21
@@ -39,6 +39,12 @@ import {
|
||||
PushSubscriptionRecordSchema,
|
||||
PushNotificationPayloadSchema,
|
||||
} from '../schemas/notifications'
|
||||
import {
|
||||
AssistantNotificationPrioritySchema,
|
||||
AssistantNotificationRequestSchema,
|
||||
AssistantNotificationResponseSchema,
|
||||
AssistantSettingsPatchSchema,
|
||||
} from '../schemas/internal-assistant'
|
||||
|
||||
export type UserPreferences = z.infer<typeof UserPreferencesSchema>
|
||||
export type SettingsResponse = z.infer<typeof SettingsResponseSchema>
|
||||
@@ -75,6 +81,11 @@ export type PushSubscriptionRequest = z.infer<typeof PushSubscriptionRequestSche
|
||||
export type PushSubscriptionRecord = z.infer<typeof PushSubscriptionRecordSchema>
|
||||
export type PushNotificationPayload = z.infer<typeof PushNotificationPayloadSchema>
|
||||
|
||||
export type AssistantNotificationPriority = z.infer<typeof AssistantNotificationPrioritySchema>
|
||||
export type AssistantNotificationRequest = z.infer<typeof AssistantNotificationRequestSchema>
|
||||
export type AssistantNotificationResponse = z.infer<typeof AssistantNotificationResponseSchema>
|
||||
export type AssistantSettingsPatch = z.infer<typeof AssistantSettingsPatchSchema>
|
||||
|
||||
export { FetchError } from './errors'
|
||||
export type { ApiErrorResponse, ApiErrorCode, GitErrorCode } from './errors'
|
||||
|
||||
@@ -91,27 +102,6 @@ export type {
|
||||
ProviderSource,
|
||||
} from '../schemas/settings'
|
||||
|
||||
export type {
|
||||
Memory,
|
||||
MemoryScope,
|
||||
CreateMemoryRequest,
|
||||
UpdateMemoryRequest,
|
||||
MemoryStats,
|
||||
EmbeddingProviderType,
|
||||
EmbeddingConfig,
|
||||
LoggingConfig,
|
||||
CompactionConfig,
|
||||
MemoryInjectionConfig,
|
||||
MessagesTransformConfig,
|
||||
PluginConfig,
|
||||
KvEntry,
|
||||
KvListQuery,
|
||||
CreateKvEntryRequest,
|
||||
UpdateKvEntryRequest,
|
||||
LoopState,
|
||||
LoopConfig,
|
||||
} from '../schemas/memory'
|
||||
|
||||
export type {
|
||||
ScheduleMode,
|
||||
ScheduleRunTriggerSource,
|
||||
|
||||
Reference in new issue
Block a user