openviber 0.5.0 → 0.5.2

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/index.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import { ModelMessage, LanguageModel } from 'ai';
2
2
  export { Output, ToolLoopAgent, generateText, stepCountIs, streamText } from 'ai';
3
+ import { z } from 'zod';
3
4
  import * as _openrouter_ai_sdk_provider from '@openrouter/ai-sdk-provider';
4
5
  import * as _ai_sdk_deepseek from '@ai-sdk/deepseek';
5
6
  import * as _ai_sdk_openai from '@ai-sdk/openai';
6
- import { z } from 'zod';
7
- import * as zustand from 'zustand';
8
- import { EventEmitter } from 'events';
9
7
 
10
8
  /**
11
9
  * Task - Individual execution units within a space
@@ -30,7 +28,7 @@ interface TaskDependency {
30
28
  taskId: string;
31
29
  type: "required" | "optional";
32
30
  }
33
- declare class Task$1 {
31
+ declare class Task {
34
32
  id: string;
35
33
  title: string;
36
34
  description: string;
@@ -74,7 +72,7 @@ declare class Task$1 {
74
72
  }): boolean;
75
73
  private calculateDuration;
76
74
  toJSON(): any;
77
- static fromJSON(data: any): Task$1;
75
+ static fromJSON(data: any): Task;
78
76
  }
79
77
 
80
78
  /**
@@ -91,22 +89,22 @@ interface PlanSummary {
91
89
  progressPercentage: number;
92
90
  }
93
91
  declare class Plan {
94
- tasks: Task$1[];
92
+ tasks: Task[];
95
93
  goal: string;
96
94
  createdAt: Date;
97
95
  updatedAt: Date;
98
96
  constructor({ tasks, goal }: {
99
- tasks?: Task$1[];
97
+ tasks?: Task[];
100
98
  goal: string;
101
99
  });
102
- addTask(task: Task$1): void;
100
+ addTask(task: Task): void;
103
101
  removeTask(taskId: string): boolean;
104
- getTaskById(taskId: string): Task$1 | undefined;
102
+ getTaskById(taskId: string): Task | undefined;
105
103
  updateTaskStatus(taskId: string, status: TaskStatus): boolean;
106
- getNextActionableTask(): Task$1 | undefined;
107
- getAllActionableTasks(maxTasks?: number): Task$1[];
108
- getTasksByStatus(status: TaskStatus): Task$1[];
109
- getTasksByAssignee(assignee: string): Task$1[];
104
+ getNextActionableTask(): Task | undefined;
105
+ getAllActionableTasks(maxTasks?: number): Task[];
106
+ getTasksByStatus(status: TaskStatus): Task[];
107
+ getTasksByAssignee(assignee: string): Task[];
110
108
  isComplete(): boolean;
111
109
  hasFailedTasks(): boolean;
112
110
  hasBlockedTasks(): boolean;
@@ -133,24 +131,12 @@ interface StreamChunk {
133
131
  };
134
132
  error?: ViberError;
135
133
  }
136
- interface ModelConfig$2 {
134
+ interface ModelConfig$1 {
137
135
  provider: 'openai' | 'anthropic' | 'deepseek' | 'local';
138
136
  model: string;
139
137
  temperature?: number;
140
138
  maxTokens?: number;
141
139
  }
142
- interface StorageConfig {
143
- type: 'local' | 'supabase';
144
- basePath?: string;
145
- supabaseUrl?: string;
146
- supabaseKey?: string;
147
- }
148
- interface ViberConfig {
149
- storage: StorageConfig;
150
- model: ModelConfig$2;
151
- streaming?: boolean;
152
- debug?: boolean;
153
- }
154
140
  /**
155
141
  * Space configuration - defines what the space is and how it works
156
142
  */
@@ -199,12 +185,137 @@ interface SpaceState {
199
185
  };
200
186
  progressPercentage?: number;
201
187
  }
202
-
188
+ interface AgentData {
189
+ id: string;
190
+ userId?: string;
191
+ name: string;
192
+ description: string;
193
+ category?: string;
194
+ icon?: string;
195
+ logoUrl?: string;
196
+ tags?: string[];
197
+ systemPrompt?: string;
198
+ llm?: {
199
+ provider: string;
200
+ model: string;
201
+ settings?: {
202
+ temperature?: number;
203
+ maxTokens?: number;
204
+ topP?: number;
205
+ frequencyPenalty?: number;
206
+ presencePenalty?: number;
207
+ };
208
+ };
209
+ tools?: string[];
210
+ author?: string;
211
+ version?: string;
212
+ usageExamples?: string[];
213
+ requirements?: string[];
214
+ createdAt?: string;
215
+ updatedAt?: string;
216
+ isCustom?: boolean;
217
+ }
218
+ interface ToolData {
219
+ id: string;
220
+ userId?: string;
221
+ name: string;
222
+ description: string;
223
+ type: "builtin" | "mcp" | "custom";
224
+ vendor?: string;
225
+ category?: string;
226
+ icon?: string;
227
+ logoUrl?: string;
228
+ config?: Record<string, any>;
229
+ configSchema?: any[];
230
+ features?: string[];
231
+ tags?: string[];
232
+ status?: "active" | "inactive" | "deprecated";
233
+ ready?: boolean;
234
+ createdAt?: string;
235
+ updatedAt?: string;
236
+ }
237
+ interface SpaceData {
238
+ id: string;
239
+ userId?: string;
240
+ name: string;
241
+ description?: string;
242
+ goal?: string;
243
+ config?: Record<string, any>;
244
+ teamConfig?: any;
245
+ activeArtifactId?: string;
246
+ createdAt?: string;
247
+ updatedAt?: string;
248
+ }
249
+ interface ArtifactData {
250
+ id: string;
251
+ spaceId?: string;
252
+ taskId?: string;
253
+ userId?: string;
254
+ category?: "input" | "intermediate" | "output";
255
+ storageKey: string;
256
+ originalName: string;
257
+ mimeType: string;
258
+ sizeBytes: number;
259
+ metadata?: Record<string, any>;
260
+ createdAt?: string;
261
+ updatedAt?: string;
262
+ }
263
+ interface ConversationData {
264
+ id: string;
265
+ spaceId?: string;
266
+ userId?: string;
267
+ title?: string;
268
+ messages?: any[];
269
+ metadata?: Record<string, any>;
270
+ createdAt?: string;
271
+ updatedAt?: string;
272
+ }
273
+ interface TaskData {
274
+ id: string;
275
+ spaceId?: string;
276
+ userId?: string;
277
+ title?: string;
278
+ description?: string;
279
+ status?: "pending" | "active" | "completed" | "failed";
280
+ result?: any;
281
+ metadata?: Record<string, any>;
282
+ model?: string;
283
+ mode?: string;
284
+ systemMessage?: string;
285
+ messages?: any[];
286
+ supervision?: any;
287
+ context?: any;
288
+ createdAt?: string;
289
+ updatedAt?: string;
290
+ }
291
+ interface ProviderModelConfig {
292
+ id: string;
293
+ name: string;
294
+ }
295
+ interface ModelProviderData {
296
+ id: string;
297
+ name: string;
298
+ provider: string;
299
+ enabled?: boolean;
300
+ baseUrl?: string;
301
+ apiKey?: string;
302
+ models?: string[] | ProviderModelConfig[];
303
+ config?: Record<string, any>;
304
+ createdAt?: string;
305
+ updatedAt?: string;
306
+ }
307
+ interface DatasourceData {
308
+ id: string;
309
+ name: string;
310
+ type: string;
311
+ config?: Record<string, any>;
312
+ createdAt?: string;
313
+ updatedAt?: string;
314
+ }
203
315
  /**
204
- * Configuration types for Viber agents and spaces
316
+ * Configuration for creating/initializing a Viber
205
317
  */
206
-
207
- interface AgentConfig {
318
+ interface ViberConfig {
208
319
  id?: string;
209
320
  name: string;
210
321
  description: string;
@@ -222,15 +333,24 @@ interface AgentConfig {
222
333
  };
223
334
  };
224
335
  systemPrompt?: string;
336
+ promptFile?: string;
225
337
  tools?: string[];
226
338
  skills?: string[];
339
+ /** Primary coding CLI skill id (from settings); agent prefers it for coding tasks when set. */
340
+ primaryCodingCli?: string | null;
227
341
  personality?: string;
228
342
  temperature?: number;
229
343
  maxTokens?: number;
344
+ /** Maximum number of multi-step tool-call rounds (default: 10) */
345
+ maxSteps?: number;
230
346
  topP?: number;
231
347
  frequencyPenalty?: number;
232
348
  presencePenalty?: number;
233
- promptFile?: string;
349
+ metadata?: Record<string, any>;
350
+ mode?: "always_ask" | "agent_decides" | "always_execute" | "always-ask" | "agent-decides" | "viber_decides" | "viber-decides" | "always-execute";
351
+ workingMode?: "always_ask" | "agent_decides" | "always_execute" | "always-ask" | "agent-decides" | "viber_decides" | "viber-decides" | "always-execute";
352
+ requireApproval?: string[];
353
+ require_approval?: string[];
234
354
  [key: string]: any;
235
355
  }
236
356
 
@@ -351,6 +471,55 @@ declare class ConversationHistory {
351
471
  toModelMessages(): ModelMessage[];
352
472
  }
353
473
 
474
+ /**
475
+ * Tool System for Viber
476
+ *
477
+ * Coordinates between custom tools and MCP tools.
478
+ * Knows nothing about specific tool implementations.
479
+ */
480
+
481
+ interface CoreTool {
482
+ description: string;
483
+ inputSchema: z.ZodSchema | any;
484
+ execute: (args: any, context?: any) => Promise<any>;
485
+ }
486
+ /** Progress callback for tools to emit intermediate updates */
487
+ type ToolProgressCallback = (event: {
488
+ kind: string;
489
+ phase?: string;
490
+ message?: string;
491
+ data?: any;
492
+ }) => void;
493
+ /** Context passed through to tool execution */
494
+ interface ToolContext {
495
+ spaceId?: string;
496
+ oauthTokens?: {
497
+ google?: {
498
+ accessToken: string;
499
+ refreshToken?: string | null;
500
+ };
501
+ [provider: string]: {
502
+ accessToken: string;
503
+ refreshToken?: string | null;
504
+ } | undefined;
505
+ };
506
+ /** Optional progress callback for tools to emit intermediate updates */
507
+ onProgress?: ToolProgressCallback;
508
+ }
509
+ /**
510
+ * Build a tool map for streamText from an array of tool IDs
511
+ * Delegates to appropriate providers without knowing their internals
512
+ */
513
+ declare function buildToolMap(toolIds: string[], context?: ToolContext): Promise<Record<string, CoreTool>>;
514
+ /**
515
+ * Check if an object is a valid tool
516
+ */
517
+ declare function isValidTool(obj: any): boolean;
518
+ /**
519
+ * Clear MCP cache (useful for testing)
520
+ */
521
+ declare function clearToolCache(): void;
522
+
354
523
  /**
355
524
  * Agent - Config-driven agent implementation
356
525
  *
@@ -375,11 +544,11 @@ interface AgentResponse {
375
544
  * Config-driven Agent implementation
376
545
  * No subclasses needed - behavior is entirely config-driven
377
546
  */
378
- declare class Agent$1 {
547
+ declare class Agent {
379
548
  id: string;
380
549
  name: string;
381
550
  description: string;
382
- config: AgentConfig;
551
+ config: ViberConfig;
383
552
  provider: string;
384
553
  model: string;
385
554
  temperature?: number;
@@ -391,12 +560,22 @@ declare class Agent$1 {
391
560
  tools: string[];
392
561
  skills: string[];
393
562
  personality?: string;
563
+ maxSteps: number;
564
+ mode: "always_ask" | "agent_decides" | "always_execute";
565
+ requireApproval: Set<string>;
394
566
  private skillInstructions;
395
567
  private loadedSkillTools;
396
568
  private skillsLoaded;
397
- constructor(config: AgentConfig);
569
+ proxyFetch?: typeof fetch;
570
+ constructor(config: ViberConfig);
398
571
  /**
399
- * Ensure skills are loaded from registry
572
+ * Ensure skills are loaded from registry.
573
+ *
574
+ * Skills and tools are separate concepts (per Agent Skills spec):
575
+ * - Skills (SKILL.md) provide instructions — injected into the system prompt
576
+ * for progressive discovery. The agent learns WHEN and HOW to do things.
577
+ * - Tools (CoreTool) provide executable capabilities — registered in the
578
+ * ToolRegistry and loaded by namespace.
400
579
  */
401
580
  private ensureSkillsLoaded;
402
581
  /**
@@ -411,10 +590,14 @@ declare class Agent$1 {
411
590
  userId?: string;
412
591
  }): LanguageModel;
413
592
  /**
414
- * Get tools available to this agent
593
+ * Get tools available to this agent.
594
+ *
595
+ * Converts CoreTool format ({inputSchema}) to AI SDK format ({parameters})
596
+ * so that streamText() recognizes and exposes the tools to the model.
415
597
  */
416
598
  protected getTools(context?: {
417
599
  spaceId?: string;
600
+ metadata?: Record<string, unknown>;
418
601
  }): Promise<any>;
419
602
  /**
420
603
  * Prepare debug info without actually calling streamText
@@ -458,15 +641,27 @@ declare class Agent$1 {
458
641
  */
459
642
  getSummary(): Record<string, any>;
460
643
  }
461
-
644
+ type WorkingMode = "always_ask" | "agent_decides" | "always_execute";
462
645
  /**
463
- * ViberAgent - The space's conversational representative
464
- *
465
- * X is the interface between users and their spaces. Each space has an X agent
466
- * that acts as its representative. When you need to interact with a space, you
467
- * talk to X. ViberAgent merges TaskExecutor and Orchestrator functionality into a
468
- * single, user-friendly interface.
646
+ * Resolve the configured working mode from supported config keys.
647
+ */
648
+ declare function resolveWorkingMode(config: ViberConfig): WorkingMode;
649
+ /**
650
+ * Resolve tools that require explicit approval in agent_decides mode.
651
+ */
652
+ declare function resolveRequireApprovalTools(config: ViberConfig): Set<string>;
653
+ /**
654
+ * Check whether the current request metadata includes approval for a tool.
655
+ */
656
+ declare function hasToolApproval(metadata: Record<string, unknown> | undefined, toolName: string): boolean;
657
+ /**
658
+ * Wrap tools with working-mode approval checks.
469
659
  */
660
+ declare function applyWorkingModeToTools(tools: Record<string, CoreTool> | undefined, options: {
661
+ mode: WorkingMode;
662
+ requireApproval: Set<string>;
663
+ metadata?: Record<string, unknown>;
664
+ }): Record<string, CoreTool> | undefined;
470
665
 
471
666
  interface ViberOptions {
472
667
  model?: string;
@@ -474,6 +669,11 @@ interface ViberOptions {
474
669
  defaultGoal?: string;
475
670
  spaceId?: string;
476
671
  singleAgentId?: string;
672
+ /** User settings from Supabase (primary coding CLI etc.); node uses and caches locally */
673
+ settings?: {
674
+ primaryCodingCli?: string;
675
+ channelIds?: string[];
676
+ };
477
677
  }
478
678
  interface ViberStreamOptions {
479
679
  messages?: any[];
@@ -489,16 +689,16 @@ interface ViberAgentResponse extends AgentResponse {
489
689
  regeneratedSteps?: string[];
490
690
  planChanges?: Record<string, any>;
491
691
  }
492
- declare class ViberAgent extends Agent$1 {
692
+ declare class ViberAgent extends Agent {
493
693
  private space;
494
694
  readonly spaceId: string;
495
695
  private abortController?;
496
696
  private singleAgentId?;
497
- constructor(config: AgentConfig, space: Space$1, options?: ViberOptions);
697
+ constructor(config: ViberConfig, space: Space, options?: ViberOptions);
498
698
  /**
499
699
  * Getter for space (needed for external access)
500
700
  */
501
- getSpace(): Space$1;
701
+ getSpace(): Space;
502
702
  /**
503
703
  * Override getSystemPrompt to include plan and artifacts context
504
704
  */
@@ -550,6 +750,9 @@ declare class ViberAgent extends Agent$1 {
550
750
  private handleMessagePersistence;
551
751
  /**
552
752
  * Save space to storage
753
+ *
754
+ * @deprecated Space data is now persisted through the data adapter (spaces table).
755
+ * This method is kept for interface compatibility but performs no action.
553
756
  */
554
757
  private saveSpace;
555
758
  /**
@@ -594,175 +797,6 @@ declare class ViberAgent extends Agent$1 {
594
797
  static resume(spaceId: string, options?: ViberOptions): Promise<ViberAgent>;
595
798
  }
596
799
 
597
- /**
598
- * Base Storage - Abstract storage interface for all Viber storage needs
599
- */
600
- interface ArtifactInfo {
601
- id: string;
602
- storageKey: string;
603
- originalName: string;
604
- mimeType: string;
605
- sizeBytes: number;
606
- category?: "input" | "intermediate" | "output";
607
- metadata?: Record<string, any>;
608
- createdAt?: string;
609
- updatedAt?: string;
610
- }
611
- interface StorageAdapter {
612
- readFile(path: string): Promise<Buffer>;
613
- readTextFile(path: string): Promise<string>;
614
- writeFile(path: string, data: Buffer | string): Promise<void>;
615
- deleteFile(path: string): Promise<void>;
616
- exists(path: string): Promise<boolean>;
617
- mkdir(path: string): Promise<void>;
618
- readdir(path: string): Promise<string[]>;
619
- stat(path: string): Promise<any>;
620
- saveArtifact(spaceId: string, artifact: ArtifactInfo, buffer: Buffer): Promise<ArtifactInfo>;
621
- getArtifact(spaceId: string, artifactId: string): Promise<{
622
- info: ArtifactInfo;
623
- buffer: Buffer;
624
- } | null>;
625
- getArtifactInfo(spaceId: string, artifactId: string): Promise<ArtifactInfo | null>;
626
- listArtifacts(spaceId: string): Promise<ArtifactInfo[]>;
627
- deleteArtifact(spaceId: string, artifactId: string): Promise<void>;
628
- }
629
- /**
630
- * Base storage class with common operations
631
- */
632
- declare class BaseStorage {
633
- protected adapter: StorageAdapter;
634
- protected basePath: string;
635
- constructor(basePath?: string, adapter?: StorageAdapter);
636
- /**
637
- * Get full path relative to base
638
- */
639
- protected getPath(...segments: string[]): string;
640
- /**
641
- * Initialize storage (ensure directories exist)
642
- */
643
- initialize(): Promise<void>;
644
- /**
645
- * Read JSON file
646
- */
647
- readJSON<T = any>(relativePath: string): Promise<T | null>;
648
- /**
649
- * Read YAML file
650
- */
651
- readYaml<T = any>(relativePath: string): Promise<T | null>;
652
- /**
653
- * Write JSON file
654
- */
655
- writeJSON(relativePath: string, data: any): Promise<void>;
656
- /**
657
- * Write YAML file
658
- */
659
- writeYaml(relativePath: string, data: any): Promise<void>;
660
- /**
661
- * Check if file exists
662
- */
663
- exists(relativePath: string): Promise<boolean>;
664
- /**
665
- * Read text file
666
- */
667
- readTextFile(relativePath: string): Promise<string>;
668
- /**
669
- * Write file (text or binary)
670
- */
671
- writeFile(relativePath: string, data: Buffer | string): Promise<void>;
672
- /**
673
- * Delete file
674
- */
675
- delete(relativePath: string): Promise<void>;
676
- /**
677
- * List files in directory
678
- */
679
- list(relativePath?: string): Promise<string[]>;
680
- /**
681
- * Create directory
682
- */
683
- mkdir(relativePath: string): Promise<void>;
684
- /**
685
- * Read binary file
686
- */
687
- readFile(relativePath: string): Promise<Buffer>;
688
- /**
689
- * Copy file from one storage to another
690
- */
691
- copyFileTo(relativePath: string, targetStorage: BaseStorage, targetPath: string): Promise<void>;
692
- /**
693
- * Get file statistics (size, timestamps, etc.)
694
- */
695
- getArtifactFileStats(relativePath: string): Promise<any>;
696
- }
697
-
698
- /**
699
- * Space Storage - Handles storage operations for spaces
700
- */
701
-
702
- interface StorageOptions {
703
- rootPath: string;
704
- spaceId: string;
705
- adapter?: StorageAdapter;
706
- }
707
- declare class SpaceStorage extends BaseStorage {
708
- private spaceId;
709
- constructor(options: StorageOptions);
710
- getSpacePath(): string;
711
- getFilePath(filename: string): string;
712
- saveFile(filename: string, data: any): Promise<void>;
713
- saveFileBuffer(filename: string, data: Buffer): Promise<void>;
714
- /**
715
- * DEPRECATED: Use artifact operations below instead
716
- * Save an artifact file (low-level file operation only)
717
- */
718
- saveArtifact(storageKey: string, buffer: Buffer, metadata: {
719
- mimeType: string;
720
- size: number;
721
- artifactType?: string;
722
- }, originalFilename?: string): Promise<void>;
723
- /**
724
- * Save a complete artifact (both file AND metadata)
725
- */
726
- saveCompleteArtifact(artifact: ArtifactInfo, buffer: Buffer): Promise<ArtifactInfo>;
727
- /**
728
- * Get a complete artifact (both file AND metadata)
729
- */
730
- getCompleteArtifact(artifactId: string): Promise<{
731
- info: ArtifactInfo;
732
- buffer: Buffer;
733
- } | null>;
734
- /**
735
- * Get artifact metadata only (without loading the file)
736
- */
737
- getArtifactInfo(artifactId: string): Promise<ArtifactInfo | null>;
738
- /**
739
- * List all artifacts in this space
740
- */
741
- listArtifacts(): Promise<ArtifactInfo[]>;
742
- /**
743
- * Delete an artifact (both file AND metadata)
744
- */
745
- deleteCompleteArtifact(artifactId: string): Promise<void>;
746
- listFiles(): Promise<string[]>;
747
- createDirectory(dirname: string): Promise<void>;
748
- getMetadata(): Promise<any>;
749
- saveMetadata(metadata: any): Promise<void>;
750
- getArtifact(filename: string): Promise<{
751
- content: Buffer;
752
- metadata?: any;
753
- } | null>;
754
- cleanup(): Promise<void>;
755
- }
756
- declare class SpaceStorageFactory {
757
- private static getRootPath;
758
- private static rootPath;
759
- static setRootPath(rootPath: string): void;
760
- static create(spaceId: string): Promise<SpaceStorage>;
761
- static list(): Promise<string[]>;
762
- static exists(spaceId: string): Promise<boolean>;
763
- static delete(spaceId: string): Promise<void>;
764
- }
765
-
766
800
  /**
767
801
  * Collaboration Module - Multi-Agent Collaboration Engine
768
802
  *
@@ -810,7 +844,7 @@ declare class AgentCollaborationManager {
810
844
  private messageQueue;
811
845
  private sharedContext;
812
846
  private listeners;
813
- constructor(space: Space$1);
847
+ constructor(space: Space);
814
848
  /**
815
849
  * Send a message from one agent to another
816
850
  */
@@ -852,7 +886,7 @@ declare class ParallelExecutionEngine {
852
886
  private space;
853
887
  private maxConcurrency;
854
888
  private activeTasks;
855
- constructor(space: Space$1, maxConcurrency?: number);
889
+ constructor(space: Space, maxConcurrency?: number);
856
890
  /**
857
891
  * Execute multiple tasks in parallel
858
892
  */
@@ -877,7 +911,7 @@ declare class ParallelExecutionEngine {
877
911
  declare class CollaborativePlanner {
878
912
  private space;
879
913
  private collaborationManager;
880
- constructor(space: Space$1, collaborationManager: AgentCollaborationManager);
914
+ constructor(space: Space, collaborationManager: AgentCollaborationManager);
881
915
  /**
882
916
  * Create a collaborative plan with multiple agents
883
917
  */
@@ -903,7 +937,7 @@ declare class CollaborativePlanner {
903
937
  *
904
938
  * Key concepts:
905
939
  * - Space: Project container with shared configuration
906
- * - Task: Individual conversation threads within a space
940
+ * - Task: Individual conversation tasks within a space
907
941
  * - Each task has its own conversation history and artifacts
908
942
  */
909
943
 
@@ -917,15 +951,14 @@ interface SpaceTask {
917
951
  createdAt: Date;
918
952
  updatedAt: Date;
919
953
  }
920
- declare class Space$1 {
954
+ declare class Space {
921
955
  spaceId: string;
922
956
  userId?: string;
923
957
  config: SpaceConfig;
924
958
  history: ConversationHistory;
925
959
  tasks: Map<string, SpaceTask>;
926
960
  messageQueue: MessageQueue;
927
- agents: Map<string, Agent$1>;
928
- storage: SpaceStorage;
961
+ agents: Map<string, Agent>;
929
962
  goal: string;
930
963
  name: string;
931
964
  viberAgent?: ViberAgent;
@@ -936,14 +969,13 @@ declare class Space$1 {
936
969
  collaborationManager?: AgentCollaborationManager;
937
970
  parallelEngine?: ParallelExecutionEngine;
938
971
  collaborativePlanner?: CollaborativePlanner;
939
- constructor({ spaceId, userId, config, history, messageQueue, agents, storage, goal, name, viberAgent, }: {
972
+ constructor({ spaceId, userId, config, history, messageQueue, agents, goal, name, viberAgent, }: {
940
973
  spaceId: string;
941
974
  userId?: string;
942
975
  config: SpaceConfig;
943
976
  history: ConversationHistory;
944
977
  messageQueue: MessageQueue;
945
- agents: Map<string, Agent$1>;
946
- storage: SpaceStorage;
978
+ agents: Map<string, Agent>;
947
979
  goal: string;
948
980
  name?: string;
949
981
  viberAgent?: ViberAgent;
@@ -964,20 +996,32 @@ declare class Space$1 {
964
996
  * Update space task status (for conversation tasks, not Plan tasks)
965
997
  */
966
998
  updateSpaceTaskStatus(taskId: string, status: "active" | "completed" | "archived"): boolean;
967
- getAgent(name: string): Agent$1 | undefined;
968
- registerAgent(name: string, agent: Agent$1): void;
999
+ getAgent(name: string): Agent | undefined;
1000
+ registerAgent(name: string, agent: Agent): void;
969
1001
  complete(): void;
970
1002
  getContext(): Record<string, any>;
971
1003
  createPlan(plan: Plan): Promise<void>;
972
1004
  updatePlan(plan: Plan): Promise<void>;
973
1005
  setName(name: string): Promise<void>;
974
- getNextTask(): Promise<Task$1 | undefined>;
975
- getParallelTasks(maxTasks?: number): Promise<Task$1[]>;
1006
+ getNextTask(): Promise<Task | undefined>;
1007
+ getParallelTasks(maxTasks?: number): Promise<Task[]>;
976
1008
  updateTaskStatus(taskId: string, status: TaskStatus): Promise<boolean>;
977
1009
  assignTask(taskId: string, agentName: string): Promise<boolean>;
978
1010
  isPlanComplete(): boolean;
979
1011
  hasFailedTasks(): boolean;
1012
+ /**
1013
+ * Persist state
1014
+ *
1015
+ * @deprecated Space persistence is now handled by the API layer using SupabaseDatabaseAdapter.
1016
+ * This method is a no-op kept for interface compatibility.
1017
+ */
980
1018
  persistState(): Promise<void>;
1019
+ /**
1020
+ * Load state
1021
+ *
1022
+ * @deprecated Space data is loaded from the database.
1023
+ * This method is a no-op kept for interface compatibility.
1024
+ */
981
1025
  loadState(): Promise<boolean>;
982
1026
  loadPlan(): Promise<Plan | undefined>;
983
1027
  getState(): SpaceState;
@@ -992,7 +1036,7 @@ declare function startSpace({ goal, spaceId, userId, spaceRoot, name, model, }:
992
1036
  spaceRoot?: string;
993
1037
  name?: string;
994
1038
  model?: string;
995
- }): Promise<Space$1>;
1039
+ }): Promise<Space>;
996
1040
 
997
1041
  /**
998
1042
  * AI Provider Management
@@ -1006,12 +1050,14 @@ declare function startSpace({ goal, spaceId, userId, spaceRoot, name, model, }:
1006
1050
  * 3. Add case: `case "google": return createGoogleGenerativeAI({...})`
1007
1051
  * 4. Add environment variable handling
1008
1052
  */
1009
- type ModelProvider$1 = string;
1010
- interface ModelConfig$1 {
1011
- provider: ModelProvider$1;
1053
+ type ModelProvider = string;
1054
+ interface ModelConfig {
1055
+ provider: ModelProvider;
1012
1056
  modelName: string;
1013
1057
  apiKey?: string;
1014
1058
  baseURL?: string;
1059
+ /** Optional proxy-aware fetch to route API calls through an HTTP proxy */
1060
+ proxyFetch?: typeof fetch;
1015
1061
  spaceId?: string;
1016
1062
  userId?: string;
1017
1063
  storageRoot?: string;
@@ -1021,680 +1067,11 @@ interface ModelConfig$1 {
1021
1067
  /**
1022
1068
  * Get the appropriate AI provider instance
1023
1069
  */
1024
- declare function getModelProvider(config: ModelConfig$1): _ai_sdk_openai.OpenAIProvider | _ai_sdk_deepseek.DeepSeekProvider | _openrouter_ai_sdk_provider.OpenRouterProvider;
1070
+ declare function getModelProvider(config: ModelConfig): _ai_sdk_openai.OpenAIProvider | _ai_sdk_deepseek.DeepSeekProvider | _openrouter_ai_sdk_provider.OpenRouterProvider;
1025
1071
  /**
1026
1072
  * Parse model string to extract provider and model name
1027
1073
  * Examples: "gpt-4o" -> { provider: "openai", modelName: "gpt-4o" }
1028
1074
  */
1029
- declare function parseModelString(model: string): ModelConfig$1;
1030
-
1031
- /**
1032
- * Tool System for Viber
1033
- *
1034
- * Coordinates between custom tools and MCP tools.
1035
- * Knows nothing about specific tool implementations.
1036
- */
1037
-
1038
- interface CoreTool {
1039
- description: string;
1040
- inputSchema: z.ZodSchema | any;
1041
- execute: (args: any, context?: any) => Promise<any>;
1042
- }
1043
- /**
1044
- * Build a tool map for streamText from an array of tool IDs
1045
- * Delegates to appropriate providers without knowing their internals
1046
- */
1047
- declare function buildToolMap(toolIds: string[], context?: {
1048
- spaceId?: string;
1049
- }): Promise<Record<string, CoreTool>>;
1050
- /**
1051
- * Check if an object is a valid tool
1052
- */
1053
- declare function isValidTool(obj: any): boolean;
1054
- /**
1055
- * Clear MCP cache (useful for testing)
1056
- */
1057
- declare function clearToolCache(): void;
1058
-
1059
- /**
1060
- * Data types for Viber entities
1061
- * Moved from lib/data/types.ts to make Viber the single source of truth
1062
- */
1063
- interface Agent {
1064
- id: string;
1065
- userId?: string;
1066
- name: string;
1067
- description: string;
1068
- category?: string;
1069
- icon?: string;
1070
- logoUrl?: string;
1071
- tags?: string[];
1072
- systemPrompt?: string;
1073
- llm?: {
1074
- provider: string;
1075
- model: string;
1076
- settings?: {
1077
- temperature?: number;
1078
- maxTokens?: number;
1079
- topP?: number;
1080
- frequencyPenalty?: number;
1081
- presencePenalty?: number;
1082
- };
1083
- };
1084
- tools?: string[];
1085
- author?: string;
1086
- version?: string;
1087
- usageExamples?: string[];
1088
- requirements?: string[];
1089
- createdAt?: string;
1090
- updatedAt?: string;
1091
- }
1092
- interface Tool {
1093
- id: string;
1094
- userId?: string;
1095
- name: string;
1096
- description: string;
1097
- type: "builtin" | "mcp" | "custom";
1098
- vendor?: string;
1099
- category?: string;
1100
- icon?: string;
1101
- logoUrl?: string;
1102
- config?: Record<string, any>;
1103
- configSchema?: any[];
1104
- features?: string[];
1105
- tags?: string[];
1106
- status?: "active" | "inactive" | "deprecated";
1107
- ready?: boolean;
1108
- createdAt?: string;
1109
- updatedAt?: string;
1110
- }
1111
- interface Space {
1112
- id: string;
1113
- userId?: string;
1114
- name: string;
1115
- description?: string;
1116
- goal?: string;
1117
- config?: Record<string, any>;
1118
- teamConfig?: any;
1119
- activeArtifactId?: string;
1120
- createdAt?: string;
1121
- updatedAt?: string;
1122
- }
1123
- interface Artifact {
1124
- id: string;
1125
- spaceId?: string;
1126
- taskId?: string;
1127
- userId?: string;
1128
- category?: "input" | "intermediate" | "output";
1129
- storageKey: string;
1130
- originalName: string;
1131
- mimeType: string;
1132
- sizeBytes: number;
1133
- metadata?: Record<string, any>;
1134
- createdAt?: string;
1135
- updatedAt?: string;
1136
- }
1137
- interface Conversation {
1138
- id: string;
1139
- spaceId?: string;
1140
- userId?: string;
1141
- title?: string;
1142
- messages?: any[];
1143
- metadata?: Record<string, any>;
1144
- createdAt?: string;
1145
- updatedAt?: string;
1146
- }
1147
- interface Task {
1148
- id: string;
1149
- spaceId?: string;
1150
- userId?: string;
1151
- title?: string;
1152
- description?: string;
1153
- status?: "pending" | "active" | "completed" | "failed";
1154
- result?: any;
1155
- metadata?: Record<string, any>;
1156
- model?: string;
1157
- mode?: string;
1158
- systemMessage?: string;
1159
- messages?: any[];
1160
- supervision?: any;
1161
- context?: any;
1162
- createdAt?: string;
1163
- updatedAt?: string;
1164
- }
1165
- interface ModelConfig {
1166
- id: string;
1167
- name: string;
1168
- }
1169
- interface ModelProvider {
1170
- id: string;
1171
- name: string;
1172
- provider: string;
1173
- enabled?: boolean;
1174
- baseUrl?: string;
1175
- apiKey?: string;
1176
- models?: string[] | ModelConfig[];
1177
- config?: Record<string, any>;
1178
- createdAt?: string;
1179
- updatedAt?: string;
1180
- }
1181
- interface Datasource {
1182
- id: string;
1183
- name: string;
1184
- type: string;
1185
- config?: Record<string, any>;
1186
- createdAt?: string;
1187
- updatedAt?: string;
1188
- }
1189
-
1190
- /**
1191
- * DataAdapter interface for accessing agents, tools, spaces, etc.
1192
- * This is an internal interface used by ViberDataManager.
1193
- * External code should use ViberDataManager, not DataAdapter directly.
1194
- */
1195
-
1196
- /**
1197
- * Internal adapter interface for data persistence
1198
- * Implementations handle local files or remote database/API
1199
- */
1200
- interface DataAdapter {
1201
- getAgents(): Promise<Agent[]>;
1202
- getAgent(id: string): Promise<Agent | null>;
1203
- saveAgent(agent: Agent): Promise<Agent>;
1204
- deleteAgent(id: string): Promise<void>;
1205
- cloneAgent(id: string): Promise<Agent>;
1206
- getTools(): Promise<Tool[]>;
1207
- getTool(id: string): Promise<Tool | null>;
1208
- saveTool(tool: Tool): Promise<Tool>;
1209
- deleteTool(id: string): Promise<void>;
1210
- cloneTool(id: string): Promise<Tool>;
1211
- getSpaces(): Promise<Space[]>;
1212
- getSpace(id: string): Promise<Space | null>;
1213
- saveSpace(space: Space): Promise<Space>;
1214
- deleteSpace(id: string): Promise<void>;
1215
- getArtifacts(spaceId: string): Promise<Artifact[]>;
1216
- getArtifact(id: string): Promise<Artifact | null>;
1217
- saveArtifact(artifact: Artifact): Promise<Artifact>;
1218
- deleteArtifact(id: string): Promise<void>;
1219
- getArtifactsBySpace(spaceId: string): Promise<Artifact[]>;
1220
- getArtifactsByTask(taskId: string): Promise<Artifact[]>;
1221
- getArtifactsByCategory(spaceOrTaskId: string, category: "input" | "intermediate" | "output", isTask?: boolean): Promise<Artifact[]>;
1222
- getTasks(spaceId: string): Promise<Task[]>;
1223
- getTask(id: string): Promise<Task | null>;
1224
- saveTask(task: Task): Promise<Task>;
1225
- deleteTask(id: string): Promise<void>;
1226
- getConversations(spaceId: string): Promise<Conversation[]>;
1227
- getConversation(id: string): Promise<Conversation | null>;
1228
- saveConversation(conversation: Conversation): Promise<Conversation>;
1229
- deleteConversation(id: string): Promise<void>;
1230
- getModelProviders(): Promise<ModelProvider[]>;
1231
- getModelProvider(id: string): Promise<ModelProvider | null>;
1232
- saveModelProvider(provider: ModelProvider): Promise<ModelProvider>;
1233
- deleteModelProvider(id: string): Promise<void>;
1234
- getDatasources(): Promise<Datasource[]>;
1235
- getDatasource(id: string): Promise<Datasource | null>;
1236
- saveDatasource(datasource: Datasource): Promise<Datasource>;
1237
- deleteDatasource(id: string): Promise<void>;
1238
- }
1239
-
1240
- /**
1241
- * ViberDataManager - Unified Data Access Layer
1242
- *
1243
- * This is the single source of truth for all Viber data operations.
1244
- * It unifies DataAdapter (metadata) and SpaceStorage (files) into one interface.
1245
- *
1246
- * Key features:
1247
- * - Unified query interface for spaces, artifacts, tasks, agents, tools
1248
- * - Automatic caching
1249
- * - Real-time subscriptions (when supported)
1250
- * - Optimistic updates
1251
- */
1252
-
1253
- interface SpaceFilters {
1254
- userId?: string;
1255
- name?: string;
1256
- createdAfter?: Date;
1257
- createdBefore?: Date;
1258
- }
1259
- interface ArtifactFilters {
1260
- spaceId?: string;
1261
- taskId?: string;
1262
- category?: "input" | "intermediate" | "output";
1263
- mimeType?: string;
1264
- }
1265
- interface TaskFilters {
1266
- spaceId: string;
1267
- status?: "active" | "completed" | "archived";
1268
- createdAfter?: Date;
1269
- }
1270
- type Unsubscribe = () => void;
1271
- type SubscriptionCallback<T> = (data: T) => void;
1272
- /**
1273
- * ViberDataManager - Central data access layer
1274
- */
1275
- declare class ViberDataManager {
1276
- private dataAdapter;
1277
- private cache;
1278
- private subscriptions;
1279
- private cacheTTL;
1280
- constructor(dataAdapter?: DataAdapter);
1281
- /**
1282
- * Create a server-side instance (uses direct database access)
1283
- * Uses dynamic import to avoid bundling server code in client
1284
- *
1285
- * NOTE: This should only be called from server-side code (API routes, server components)
1286
- */
1287
- static createServer(): Promise<ViberDataManager>;
1288
- /**
1289
- * Create a server-side instance synchronously (for use in server contexts)
1290
- * This uses require() to avoid bundling in client code
1291
- */
1292
- static createServerSync(): ViberDataManager;
1293
- /**
1294
- * Create a client-side instance (uses API calls)
1295
- * @deprecated Client-side direct usage is deprecated. Use server actions instead.
1296
- */
1297
- static createClient(): ViberDataManager;
1298
- private getCacheKey;
1299
- private getCached;
1300
- private setCache;
1301
- private invalidateCache;
1302
- private notifySubscribers;
1303
- /**
1304
- * Get a single space by ID
1305
- */
1306
- getSpace(spaceId: string): Promise<Space | null>;
1307
- /**
1308
- * List all spaces with optional filters
1309
- */
1310
- listSpaces(filters?: SpaceFilters): Promise<Space[]>;
1311
- /**
1312
- * Create a new space
1313
- */
1314
- createSpace(space: Partial<Space>): Promise<Space>;
1315
- /**
1316
- * Update a space
1317
- */
1318
- updateSpace(spaceId: string, updates: Partial<Space>): Promise<Space>;
1319
- /**
1320
- * Delete a space
1321
- */
1322
- deleteSpace(spaceId: string): Promise<void>;
1323
- /**
1324
- * Subscribe to space changes
1325
- */
1326
- subscribeToSpace(spaceId: string, callback: SubscriptionCallback<Space | null>): Unsubscribe;
1327
- /**
1328
- * Subscribe to all spaces
1329
- */
1330
- subscribeToSpaces(callback: SubscriptionCallback<Space[]>): Unsubscribe;
1331
- /**
1332
- * Get artifacts for a space
1333
- */
1334
- getArtifacts(spaceId: string, filters?: ArtifactFilters): Promise<Artifact[]>;
1335
- /**
1336
- * Get a single artifact by ID
1337
- */
1338
- getArtifact(artifactId: string): Promise<Artifact | null>;
1339
- /**
1340
- * Create an artifact (metadata only - file upload handled separately)
1341
- */
1342
- createArtifact(spaceId: string, artifact: Partial<Artifact>): Promise<Artifact>;
1343
- /**
1344
- * Update an artifact
1345
- */
1346
- updateArtifact(artifactId: string, updates: Partial<Artifact>): Promise<Artifact>;
1347
- /**
1348
- * Delete an artifact
1349
- */
1350
- deleteArtifact(artifactId: string, spaceId: string): Promise<void>;
1351
- /**
1352
- * Subscribe to artifacts for a space
1353
- */
1354
- subscribeToArtifacts(spaceId: string, callback: SubscriptionCallback<Artifact[]>): Unsubscribe;
1355
- /**
1356
- * Get tasks for a space
1357
- */
1358
- getTasks(spaceId: string, filters?: TaskFilters): Promise<Task[]>;
1359
- /**
1360
- * Get a single task by ID
1361
- */
1362
- getTask(taskId: string): Promise<Task | null>;
1363
- /**
1364
- * Create a new task
1365
- */
1366
- createTask(spaceId: string, task: Partial<Task>): Promise<Task>;
1367
- /**
1368
- * Update a task
1369
- */
1370
- updateTask(taskId: string, updates: Partial<Task>): Promise<Task>;
1371
- /**
1372
- * Delete a task
1373
- */
1374
- deleteTask(taskId: string, spaceId: string): Promise<void>;
1375
- /**
1376
- * Subscribe to tasks for a space
1377
- */
1378
- subscribeToTasks(spaceId: string, callback: SubscriptionCallback<Task[]>): Unsubscribe;
1379
- /**
1380
- * Get all agents
1381
- */
1382
- getAgents(): Promise<Agent[]>;
1383
- /**
1384
- * Get a single agent by ID
1385
- */
1386
- getAgent(agentId: string): Promise<Agent | null>;
1387
- /**
1388
- * Get all tools
1389
- */
1390
- getTools(): Promise<Tool[]>;
1391
- /**
1392
- * Get a single tool by ID
1393
- */
1394
- getTool(toolId: string): Promise<Tool | null>;
1395
- /**
1396
- * Get SpaceStorage instance for a space
1397
- */
1398
- getSpaceStorage(spaceId: string): Promise<SpaceStorage>;
1399
- /**
1400
- * Upload an artifact file
1401
- */
1402
- uploadArtifactFile(spaceId: string, artifactId: string, file: File | Blob, filename: string): Promise<string>;
1403
- /**
1404
- * Download an artifact file
1405
- */
1406
- downloadArtifactFile(spaceId: string, storageKey: string): Promise<Blob>;
1407
- /**
1408
- * Delete an artifact file
1409
- */
1410
- deleteArtifactFile(spaceId: string, storageKey: string): Promise<void>;
1411
- }
1412
- declare function getViberDataManager(): ViberDataManager;
1413
- /**
1414
- * Get server-side ViberDataManager (for API routes and server components)
1415
- * This uses direct database access, not API calls
1416
- *
1417
- * NOTE: This function can only be called from server-side code
1418
- */
1419
- declare function getViberDataManagerServer(): ViberDataManager;
1420
-
1421
- interface ViberState {
1422
- spaces: Map<string, Space>;
1423
- currentSpaceId: string | null;
1424
- artifacts: Map<string, Artifact[]>;
1425
- tasks: Map<string, Task[]>;
1426
- agents: Agent[];
1427
- tools: Tool[];
1428
- loading: {
1429
- spaces: boolean;
1430
- artifacts: Record<string, boolean>;
1431
- tasks: Record<string, boolean>;
1432
- agents: boolean;
1433
- tools: boolean;
1434
- };
1435
- errors: {
1436
- spaces: Error | null;
1437
- artifacts: Record<string, Error | null>;
1438
- tasks: Record<string, Error | null>;
1439
- agents: Error | null;
1440
- tools: Error | null;
1441
- };
1442
- setSpaces: (spaces: Space[]) => void;
1443
- setSpace: (space: Space) => void;
1444
- removeSpace: (spaceId: string) => void;
1445
- setCurrentSpaceId: (spaceId: string | null) => void;
1446
- setArtifacts: (spaceId: string, artifacts: Artifact[]) => void;
1447
- addArtifact: (spaceId: string, artifact: Artifact) => void;
1448
- updateArtifact: (spaceId: string, artifactId: string, updates: Partial<Artifact>) => void;
1449
- removeArtifact: (spaceId: string, artifactId: string) => void;
1450
- setTasks: (spaceId: string, tasks: Task[]) => void;
1451
- addTask: (spaceId: string, task: Task) => void;
1452
- updateTask: (spaceId: string, taskId: string, updates: Partial<Task>) => void;
1453
- removeTask: (spaceId: string, taskId: string) => void;
1454
- setAgents: (agents: Agent[]) => void;
1455
- setTools: (tools: Tool[]) => void;
1456
- setLoading: (key: string, value: boolean) => void;
1457
- setError: (key: string, error: Error | null) => void;
1458
- syncSpaces: () => Promise<void>;
1459
- syncArtifacts: (spaceId: string) => Promise<void>;
1460
- syncTasks: (spaceId: string) => Promise<void>;
1461
- syncAgents: () => Promise<void>;
1462
- syncTools: () => Promise<void>;
1463
- }
1464
- declare const useViberStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ViberState>, "subscribe"> & {
1465
- subscribe: {
1466
- (listener: (selectedState: ViberState, previousSelectedState: ViberState) => void): () => void;
1467
- <U>(selector: (state: ViberState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
1468
- equalityFn?: ((a: U, b: U) => boolean) | undefined;
1469
- fireImmediately?: boolean;
1470
- } | undefined): () => void;
1471
- };
1472
- }>;
1473
- declare const useViberSpaces: () => Space[];
1474
- declare const useViberCurrentSpace: () => Space | null;
1475
- declare const useViberArtifacts: (spaceId: string | null | undefined) => Artifact[];
1476
- declare const useViberTasks: (spaceId: string | null | undefined) => Task[];
1477
-
1478
- /**
1479
- * ViberController - Daemon controller for outbound connection to command center
1480
- *
1481
- * A Viber is a local agent daemon that connects OUTBOUND to a central command center
1482
- * (Supen). This eliminates the need for public IPs or port forwarding.
1483
- *
1484
- * Features:
1485
- * - Persistent WebSocket connection to command center
1486
- * - Auto-reconnection on disconnect
1487
- * - Heartbeat/health monitoring
1488
- * - Task execution and event streaming
1489
- */
1490
-
1491
- interface ViberControllerConfig {
1492
- /** WebSocket URL to connect to (e.g., wss://supen.app/vibers/ws) */
1493
- serverUrl: string;
1494
- /** Authentication token */
1495
- token: string;
1496
- /** Unique identifier for this viber */
1497
- viberId: string;
1498
- /** Human-readable name for this viber */
1499
- viberName?: string;
1500
- /** Milliseconds between reconnection attempts */
1501
- reconnectInterval?: number;
1502
- /** Milliseconds between heartbeat messages */
1503
- heartbeatInterval?: number;
1504
- /** Enable desktop control tools */
1505
- enableDesktop?: boolean;
1506
- }
1507
- interface ViberSkillInfo {
1508
- id: string;
1509
- name: string;
1510
- description: string;
1511
- }
1512
- interface ViberInfo {
1513
- id: string;
1514
- name: string;
1515
- version: string;
1516
- platform: string;
1517
- capabilities: string[];
1518
- runningTasks: string[];
1519
- /** Skills available on this viber (from SKILL.md) */
1520
- skills?: ViberSkillInfo[];
1521
- }
1522
- interface ViberStatus {
1523
- platform: string;
1524
- uptime: number;
1525
- memory: NodeJS.MemoryUsage;
1526
- runningTasks: number;
1527
- }
1528
- type ControllerServerMessage = {
1529
- type: "task:submit";
1530
- taskId: string;
1531
- goal: string;
1532
- options?: ViberOptions;
1533
- messages?: {
1534
- role: string;
1535
- content: string;
1536
- }[];
1537
- } | {
1538
- type: "task:stop";
1539
- taskId: string;
1540
- } | {
1541
- type: "task:message";
1542
- taskId: string;
1543
- message: string;
1544
- } | {
1545
- type: "ping";
1546
- } | {
1547
- type: "config:update";
1548
- config: Partial<ViberControllerConfig>;
1549
- } | {
1550
- type: "terminal:list";
1551
- } | {
1552
- type: "terminal:attach";
1553
- target: string;
1554
- appId?: string;
1555
- } | {
1556
- type: "terminal:detach";
1557
- target: string;
1558
- appId?: string;
1559
- } | {
1560
- type: "terminal:input";
1561
- target: string;
1562
- keys: string;
1563
- appId?: string;
1564
- } | {
1565
- type: "terminal:resize";
1566
- target: string;
1567
- cols: number;
1568
- rows: number;
1569
- appId?: string;
1570
- };
1571
- type ControllerClientMessage = {
1572
- type: "connected";
1573
- viber: ViberInfo;
1574
- } | {
1575
- type: "task:started";
1576
- taskId: string;
1577
- spaceId: string;
1578
- } | {
1579
- type: "task:progress";
1580
- taskId: string;
1581
- event: any;
1582
- } | {
1583
- type: "task:completed";
1584
- taskId: string;
1585
- result: any;
1586
- } | {
1587
- type: "task:error";
1588
- taskId: string;
1589
- error: string;
1590
- } | {
1591
- type: "heartbeat";
1592
- status: ViberStatus;
1593
- } | {
1594
- type: "pong";
1595
- } | {
1596
- type: "terminal:list";
1597
- apps: any[];
1598
- sessions: any[];
1599
- panes: any[];
1600
- } | {
1601
- type: "terminal:attached";
1602
- target: string;
1603
- appId?: string;
1604
- ok: boolean;
1605
- error?: string;
1606
- } | {
1607
- type: "terminal:detached";
1608
- target: string;
1609
- appId?: string;
1610
- } | {
1611
- type: "terminal:output";
1612
- target: string;
1613
- appId?: string;
1614
- data: string;
1615
- } | {
1616
- type: "terminal:resized";
1617
- target: string;
1618
- appId?: string;
1619
- ok: boolean;
1620
- };
1621
- declare class ViberController extends EventEmitter {
1622
- private config;
1623
- private ws;
1624
- private reconnectTimer;
1625
- private heartbeatTimer;
1626
- /** taskId -> AbortController for stop (daemon = thin runtime, no Space/agent instance) */
1627
- private runningTasks;
1628
- private isConnected;
1629
- private shouldReconnect;
1630
- /** Terminal manager for streaming tmux panes */
1631
- private terminalManager;
1632
- constructor(config: ViberControllerConfig);
1633
- /**
1634
- * Start the viber daemon
1635
- */
1636
- start(): Promise<void>;
1637
- /**
1638
- * Stop the viber daemon
1639
- */
1640
- stop(): Promise<void>;
1641
- /**
1642
- * Get current connection status
1643
- */
1644
- getStatus(): {
1645
- connected: boolean;
1646
- runningTasks: number;
1647
- };
1648
- private connect;
1649
- private onConnected;
1650
- private onDisconnected;
1651
- private onError;
1652
- private onMessage;
1653
- private handleTaskSubmit;
1654
- private handleTaskStop;
1655
- private handleTaskMessage;
1656
- private handleTerminalList;
1657
- private handleTerminalAttach;
1658
- private handleTerminalDetach;
1659
- private handleTerminalInput;
1660
- private handleTerminalResize;
1661
- private send;
1662
- private startHeartbeat;
1663
- private stopHeartbeat;
1664
- private scheduleReconnect;
1665
- }
1666
-
1667
- /**
1668
- * Daemon runtime - thin clawdbot-alike assistant path
1669
- *
1670
- * No Space, no DataAdapter, no Storage. Loads a single agent config from file
1671
- * and runs streamText. Viber Board owns persistence and context; daemon only
1672
- * orchestrates local skills and the LLM.
1673
- */
1674
-
1675
- interface DaemonRunTaskOptions {
1676
- model?: string;
1677
- singleAgentId?: string;
1678
- agentConfig?: AgentConfig;
1679
- signal?: AbortSignal;
1680
- }
1681
- /**
1682
- * Load agent config from file (no DataAdapter).
1683
- * Tries built-in defaults then ~/.openviber/agents/{id}.yaml
1684
- */
1685
- declare function loadAgentConfig(agentId: string): Promise<AgentConfig | null>;
1686
- /**
1687
- * Run a single task: one agent, no Space, no storage.
1688
- * Returns stream result and agent for summary.
1689
- */
1690
- declare function runTask(goal: string, options: DaemonRunTaskOptions & {
1691
- taskId: string;
1692
- }, messages?: {
1693
- role: string;
1694
- content: string;
1695
- }[]): Promise<{
1696
- streamResult: Awaited<ReturnType<Agent$1["streamText"]>>;
1697
- agent: Agent$1;
1698
- }>;
1075
+ declare function parseModelString(model: string): ModelConfig;
1699
1076
 
1700
- export { Agent$1 as Agent, AgentCollaborationManager, type AgentConfig, type AgentContext, type AgentMessage, type AgentResponse, type ArtifactFilters, type ArtifactInfo, BaseStorage, CollaborativePlanner, type ControllerClientMessage, type ControllerServerMessage, ConversationHistory, type CoreTool, type DaemonRunTaskOptions, type Message, MessageQueue, type ModelConfig$2 as ModelConfig, type ModelProvider$1 as ModelProvider, ParallelExecutionEngine, type ParallelExecutionResult, type ParallelTask, Plan, type PlanSummary, type QueueListener, type QueueState, type QueuedMessage, type SharedContext, Space$1 as Space, type SpaceConfig, type SpaceFilters, type SpaceModel, type SpaceState, SpaceStorage, SpaceStorageFactory, type SpaceTask, type StorageAdapter, type StorageConfig, type StorageOptions, type StreamChunk, type SubscriptionCallback, Task$1 as Task, type TaskDependency, type TaskFilters, TaskStatus, type TaskStep, type Unsubscribe, ViberAgent, type ViberAgentResponse, type ViberConfig, ViberController, type ViberControllerConfig, ViberDataManager, type ViberError, type ViberInfo, type ViberMessage, type ViberOptions, type ViberSkillInfo, type ViberStatus, type ViberStreamOptions, buildToolMap, clearToolCache, getModelProvider, getTextContent, getViberDataManager, getViberDataManagerServer, isValidTool, loadAgentConfig, parseModelString, runTask, startSpace, useViberArtifacts, useViberCurrentSpace, useViberSpaces, useViberStore, useViberTasks };
1077
+ export { Agent, AgentCollaborationManager, type AgentContext, type AgentData, type AgentMessage, type AgentResponse, type ArtifactData, CollaborativePlanner, type ConversationData, ConversationHistory, type CoreTool, type DatasourceData, type Message, MessageQueue, type ModelConfig$1 as ModelConfig, type ModelProvider, type ModelProviderData, ParallelExecutionEngine, type ParallelExecutionResult, type ParallelTask, Plan, type PlanSummary, type ProviderModelConfig, type QueueListener, type QueueState, type QueuedMessage, type SharedContext, Space, type SpaceConfig, type SpaceData, type SpaceModel, type SpaceState, type SpaceTask, type StreamChunk, Task, type TaskData, type TaskDependency, TaskStatus, type TaskStep, type ToolContext, type ToolData, type ToolProgressCallback, ViberAgent, type ViberAgentResponse, type ViberConfig, type ViberError, type ViberMessage, type ViberOptions, type ViberStreamOptions, type WorkingMode, applyWorkingModeToTools, buildToolMap, clearToolCache, getModelProvider, getTextContent, hasToolApproval, isValidTool, parseModelString, resolveRequireApprovalTools, resolveWorkingMode, startSpace };