feat(wave1): @mosaic/types populated + @mosaic/queue migrated to use it (#1)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
{
|
||||
"name": "@mosaic/types",
|
||||
"version": "0.1.0",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"README.md"
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
}
|
||||
},
|
||||
"files": ["dist"],
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"test": "echo \"No tests for @mosaic/types\"",
|
||||
"lint": "echo \"No lint configured for @mosaic/types\"",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit"
|
||||
"typecheck": "tsc --noEmit",
|
||||
"lint": "echo 'ok'",
|
||||
"test": "echo 'ok'"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,342 @@
|
||||
// @mosaic/types - shared type definitions
|
||||
export type Placeholder = Record<string, never>;
|
||||
// @mosaic/types
|
||||
// Shared foundational types extracted from queue, bootstrap, and context packages.
|
||||
|
||||
// === Queue ===
|
||||
|
||||
export type TaskStatus =
|
||||
| 'pending'
|
||||
| 'claimed'
|
||||
| 'in-progress'
|
||||
| 'completed'
|
||||
| 'failed'
|
||||
| 'blocked';
|
||||
|
||||
export type TaskPriority = 'critical' | 'high' | 'medium' | 'low';
|
||||
|
||||
export type TaskLane = 'planning' | 'coding' | 'any';
|
||||
|
||||
export interface Task {
|
||||
readonly id: string;
|
||||
readonly project: string;
|
||||
readonly mission: string;
|
||||
readonly taskId: string;
|
||||
readonly title: string;
|
||||
readonly description?: string;
|
||||
readonly status: TaskStatus;
|
||||
readonly priority: TaskPriority;
|
||||
readonly dependencies: readonly string[];
|
||||
readonly lane: TaskLane;
|
||||
readonly claimedBy?: string;
|
||||
readonly claimedAt?: number;
|
||||
readonly claimTTL?: number;
|
||||
readonly completedAt?: number;
|
||||
readonly failedAt?: number;
|
||||
readonly failureReason?: string;
|
||||
readonly completionSummary?: string;
|
||||
readonly retryCount: number;
|
||||
readonly metadata?: Readonly<Record<string, unknown>>;
|
||||
readonly createdAt: number;
|
||||
readonly updatedAt: number;
|
||||
}
|
||||
|
||||
export interface CreateTaskInput {
|
||||
readonly project: string;
|
||||
readonly mission: string;
|
||||
readonly taskId: string;
|
||||
readonly title: string;
|
||||
readonly description?: string;
|
||||
readonly priority?: TaskPriority;
|
||||
readonly dependencies?: readonly string[];
|
||||
readonly lane?: TaskLane;
|
||||
readonly metadata?: Readonly<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export interface TaskListFilters {
|
||||
readonly project?: string;
|
||||
readonly mission?: string;
|
||||
readonly status?: TaskStatus;
|
||||
}
|
||||
|
||||
export interface TaskUpdateInput {
|
||||
readonly title?: string;
|
||||
readonly description?: string;
|
||||
readonly status?: TaskStatus;
|
||||
readonly priority?: TaskPriority;
|
||||
readonly dependencies?: readonly string[];
|
||||
readonly lane?: TaskLane;
|
||||
readonly claimedBy?: string;
|
||||
readonly claimedAt?: number;
|
||||
readonly claimTTL?: number;
|
||||
readonly completedAt?: number;
|
||||
readonly failedAt?: number;
|
||||
readonly failureReason?: string;
|
||||
readonly completionSummary?: string;
|
||||
readonly retryCount?: number;
|
||||
readonly metadata?: Readonly<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export interface ClaimTaskInput {
|
||||
readonly agentId: string;
|
||||
readonly ttlSeconds: number;
|
||||
}
|
||||
|
||||
export interface ReleaseTaskInput {
|
||||
readonly agentId?: string;
|
||||
}
|
||||
|
||||
export interface HeartbeatTaskInput {
|
||||
readonly agentId?: string;
|
||||
readonly ttlSeconds?: number;
|
||||
}
|
||||
|
||||
export interface CompleteTaskInput {
|
||||
readonly agentId?: string;
|
||||
readonly summary?: string;
|
||||
}
|
||||
|
||||
export interface FailTaskInput {
|
||||
readonly agentId?: string;
|
||||
readonly reason: string;
|
||||
}
|
||||
|
||||
// === Agent ===
|
||||
|
||||
export type AgentMessageRole =
|
||||
| 'user'
|
||||
| 'assistant'
|
||||
| 'tool'
|
||||
| 'system'
|
||||
| (string & {});
|
||||
|
||||
export interface AgentMessage {
|
||||
readonly role: AgentMessageRole;
|
||||
readonly content: unknown;
|
||||
readonly timestamp?: number;
|
||||
readonly [key: string]: unknown;
|
||||
}
|
||||
|
||||
export type OpenBrainThoughtMetadata = Readonly<
|
||||
Record<string, unknown> & {
|
||||
sessionId?: string;
|
||||
turn?: number;
|
||||
role?: string;
|
||||
type?: string;
|
||||
}
|
||||
>;
|
||||
|
||||
export interface OpenBrainThought {
|
||||
readonly id: string;
|
||||
readonly content: string;
|
||||
readonly source: string;
|
||||
readonly metadata?: OpenBrainThoughtMetadata;
|
||||
readonly createdAt?: string;
|
||||
readonly updatedAt?: string;
|
||||
readonly score?: number;
|
||||
readonly [key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface OpenBrainThoughtInput {
|
||||
readonly content: string;
|
||||
readonly source: string;
|
||||
readonly metadata?: OpenBrainThoughtMetadata;
|
||||
}
|
||||
|
||||
export interface OpenBrainSearchInput {
|
||||
readonly query: string;
|
||||
readonly limit: number;
|
||||
readonly source?: string;
|
||||
}
|
||||
|
||||
// === Context Engine ===
|
||||
|
||||
export interface AssembleResult {
|
||||
readonly messages: readonly AgentMessage[];
|
||||
readonly estimatedTokens: number;
|
||||
readonly systemPromptAddition?: string;
|
||||
}
|
||||
|
||||
export interface CompactResultData {
|
||||
readonly summary?: string;
|
||||
readonly firstKeptEntryId?: string;
|
||||
readonly tokensBefore: number;
|
||||
readonly tokensAfter?: number;
|
||||
readonly details?: unknown;
|
||||
}
|
||||
|
||||
export interface CompactResult {
|
||||
readonly ok: boolean;
|
||||
readonly compacted: boolean;
|
||||
readonly reason?: string;
|
||||
readonly result?: CompactResultData;
|
||||
}
|
||||
|
||||
export interface IngestResult {
|
||||
readonly ingested: boolean;
|
||||
}
|
||||
|
||||
export interface IngestBatchResult {
|
||||
readonly ingestedCount: number;
|
||||
}
|
||||
|
||||
export interface BootstrapResult {
|
||||
readonly bootstrapped: boolean;
|
||||
readonly importedMessages?: number;
|
||||
readonly reason?: string;
|
||||
}
|
||||
|
||||
export interface ContextEngineInfo {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly version?: string;
|
||||
readonly ownsCompaction?: boolean;
|
||||
}
|
||||
|
||||
export interface SubagentSpawnPreparation {
|
||||
readonly rollback: () => void | Promise<void>;
|
||||
}
|
||||
|
||||
export type SubagentEndReason = 'deleted' | 'completed' | 'swept' | 'released';
|
||||
|
||||
export interface ContextEngineBootstrapParams {
|
||||
readonly sessionId: string;
|
||||
readonly sessionFile: string;
|
||||
}
|
||||
|
||||
export interface ContextEngineIngestParams {
|
||||
readonly sessionId: string;
|
||||
readonly message: AgentMessage;
|
||||
readonly isHeartbeat?: boolean;
|
||||
}
|
||||
|
||||
export interface ContextEngineIngestBatchParams {
|
||||
readonly sessionId: string;
|
||||
readonly messages: readonly AgentMessage[];
|
||||
readonly isHeartbeat?: boolean;
|
||||
}
|
||||
|
||||
export interface ContextEngineAfterTurnParams {
|
||||
readonly sessionId: string;
|
||||
readonly sessionFile: string;
|
||||
readonly messages: readonly AgentMessage[];
|
||||
readonly prePromptMessageCount: number;
|
||||
readonly autoCompactionSummary?: string;
|
||||
readonly isHeartbeat?: boolean;
|
||||
readonly tokenBudget?: number;
|
||||
readonly legacyCompactionParams?: Readonly<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export interface ContextEngineAssembleParams {
|
||||
readonly sessionId: string;
|
||||
readonly messages: readonly AgentMessage[];
|
||||
readonly tokenBudget?: number;
|
||||
}
|
||||
|
||||
export interface ContextEngineCompactParams {
|
||||
readonly sessionId: string;
|
||||
readonly sessionFile: string;
|
||||
readonly tokenBudget?: number;
|
||||
readonly force?: boolean;
|
||||
readonly currentTokenCount?: number;
|
||||
readonly compactionTarget?: 'budget' | 'threshold';
|
||||
readonly customInstructions?: string;
|
||||
readonly legacyParams?: Readonly<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export interface ContextEnginePrepareSubagentSpawnParams {
|
||||
readonly parentSessionKey: string;
|
||||
readonly childSessionKey: string;
|
||||
readonly ttlMs?: number;
|
||||
}
|
||||
|
||||
export interface ContextEngineSubagentEndedParams {
|
||||
readonly childSessionKey: string;
|
||||
readonly reason: SubagentEndReason;
|
||||
}
|
||||
|
||||
export interface ContextEngine {
|
||||
readonly info: ContextEngineInfo;
|
||||
bootstrap?(params: ContextEngineBootstrapParams): Promise<BootstrapResult>;
|
||||
ingest(params: ContextEngineIngestParams): Promise<IngestResult>;
|
||||
ingestBatch?(params: ContextEngineIngestBatchParams): Promise<IngestBatchResult>;
|
||||
afterTurn?(params: ContextEngineAfterTurnParams): Promise<void>;
|
||||
assemble(params: ContextEngineAssembleParams): Promise<AssembleResult>;
|
||||
compact(params: ContextEngineCompactParams): Promise<CompactResult>;
|
||||
prepareSubagentSpawn?(
|
||||
params: ContextEnginePrepareSubagentSpawnParams,
|
||||
): Promise<SubagentSpawnPreparation | undefined>;
|
||||
onSubagentEnded?(params: ContextEngineSubagentEndedParams): Promise<void>;
|
||||
dispose?(): Promise<void>;
|
||||
}
|
||||
|
||||
export type ContextEngineFactory = () => ContextEngine | Promise<ContextEngine>;
|
||||
|
||||
export interface PluginLogger {
|
||||
readonly debug?: (...args: unknown[]) => void;
|
||||
readonly info?: (...args: unknown[]) => void;
|
||||
readonly warn?: (...args: unknown[]) => void;
|
||||
readonly error?: (...args: unknown[]) => void;
|
||||
}
|
||||
|
||||
export interface OpenClawPluginApi {
|
||||
readonly pluginConfig?: Readonly<Record<string, unknown>>;
|
||||
readonly logger?: PluginLogger;
|
||||
readonly registerContextEngine: (id: string, factory: ContextEngineFactory) => void;
|
||||
}
|
||||
|
||||
// === Wizard ===
|
||||
// Wizard bootstrap/setup types are package-specific but intentionally exported
|
||||
// for cross-package tooling and install orchestration.
|
||||
|
||||
export type WizardMode = 'quick' | 'advanced';
|
||||
export type InstallAction = 'fresh' | 'keep' | 'reconfigure' | 'reset';
|
||||
export type CommunicationStyle = 'direct' | 'friendly' | 'formal';
|
||||
export type RuntimeName = 'claude' | 'codex' | 'opencode';
|
||||
|
||||
export interface SoulConfig {
|
||||
readonly agentName?: string;
|
||||
readonly roleDescription?: string;
|
||||
readonly communicationStyle?: CommunicationStyle;
|
||||
readonly accessibility?: string;
|
||||
readonly customGuardrails?: string;
|
||||
}
|
||||
|
||||
export interface UserConfig {
|
||||
readonly userName?: string;
|
||||
readonly pronouns?: string;
|
||||
readonly timezone?: string;
|
||||
readonly background?: string;
|
||||
readonly accessibilitySection?: string;
|
||||
readonly communicationPrefs?: string;
|
||||
readonly personalBoundaries?: string;
|
||||
readonly projectsTable?: string;
|
||||
}
|
||||
|
||||
export interface GitProvider {
|
||||
readonly name: string;
|
||||
readonly url: string;
|
||||
readonly cli: string;
|
||||
readonly purpose: string;
|
||||
}
|
||||
|
||||
export interface ToolsConfig {
|
||||
readonly gitProviders?: readonly GitProvider[];
|
||||
readonly credentialsLocation?: string;
|
||||
readonly customToolsSection?: string;
|
||||
}
|
||||
|
||||
export interface RuntimeState {
|
||||
readonly detected: readonly RuntimeName[];
|
||||
readonly mcpConfigured: boolean;
|
||||
}
|
||||
|
||||
export interface WizardState {
|
||||
readonly mosaicHome: string;
|
||||
readonly sourceDir: string;
|
||||
readonly mode: WizardMode;
|
||||
readonly installAction: InstallAction;
|
||||
readonly soul: SoulConfig;
|
||||
readonly user: UserConfig;
|
||||
readonly tools: ToolsConfig;
|
||||
readonly runtimes: RuntimeState;
|
||||
readonly selectedSkills: readonly string[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user