@vibevibes/sdk 0.4.0 → 0.6.0

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.
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Experience SDK Types
3
+ */
4
+ import type React from "react";
5
+ import type { z } from "zod";
6
+ export type ToolRisk = "low" | "medium" | "high";
7
+ export type CallToolFn = (name: string, input: Record<string, unknown>) => Promise<unknown>;
8
+ export type ZodFactory = typeof z;
9
+ export type ToolEvent = {
10
+ id: string;
11
+ ts: number;
12
+ actorId: string;
13
+ owner?: string;
14
+ tool: string;
15
+ input: Record<string, unknown>;
16
+ output?: unknown;
17
+ error?: string;
18
+ };
19
+ export type AgentSlot = {
20
+ role: string;
21
+ systemPrompt: string;
22
+ allowedTools?: string[];
23
+ autoSpawn?: boolean;
24
+ maxInstances?: number;
25
+ };
26
+ export type ParticipantSlot = {
27
+ role: string;
28
+ type?: "human" | "ai" | "any";
29
+ systemPrompt?: string;
30
+ allowedTools?: string[];
31
+ autoSpawn?: boolean;
32
+ maxInstances?: number;
33
+ };
34
+ export type ParticipantDetail = {
35
+ actorId: string;
36
+ type: "human" | "ai" | "unknown";
37
+ role?: string;
38
+ metadata?: Record<string, string>;
39
+ };
40
+ export type ExperienceManifest = {
41
+ id: string;
42
+ version: string;
43
+ title: string;
44
+ description: string;
45
+ requested_capabilities: string[];
46
+ agentSlots?: AgentSlot[];
47
+ participantSlots?: ParticipantSlot[];
48
+ category?: string;
49
+ tags?: string[];
50
+ };
51
+ export type StreamDef<TInput = any> = {
52
+ name: string;
53
+ description?: string;
54
+ input_schema: z.ZodTypeAny;
55
+ merge: (state: Record<string, any>, input: TInput, actorId: string) => Record<string, any>;
56
+ rateLimit?: number;
57
+ };
58
+ export type ToolCtx<TState extends Record<string, any> = Record<string, any>> = {
59
+ roomId: string;
60
+ actorId: string;
61
+ owner?: string;
62
+ state: TState;
63
+ setState: (newState: TState) => void;
64
+ timestamp: number;
65
+ memory: Record<string, any>;
66
+ setMemory: (updates: Record<string, any>) => void;
67
+ };
68
+ export type ToolDef<TInput = any, TOutput = any> = {
69
+ name: string;
70
+ description: string;
71
+ input_schema: z.ZodTypeAny;
72
+ risk: ToolRisk;
73
+ capabilities_required: string[];
74
+ handler: (ctx: ToolCtx, input: TInput) => Promise<TOutput>;
75
+ emits?: string[];
76
+ on?: Record<string, (ctx: ToolCtx, event: ToolEvent) => Promise<void>>;
77
+ persist?: boolean;
78
+ };
79
+ export type CanvasProps<TState extends Record<string, any> = Record<string, any>> = {
80
+ actorId: string;
81
+ sharedState: TState;
82
+ callTool: (name: string, input: Record<string, unknown>, predictFn?: (state: TState) => TState) => Promise<unknown>;
83
+ callTools?: (calls: Array<{
84
+ name: string;
85
+ input: Record<string, unknown>;
86
+ }>) => Promise<unknown[]>;
87
+ ephemeralState: Record<string, Record<string, any>>;
88
+ setEphemeral: (data: Record<string, any>) => void;
89
+ stream?: (name: string, input: Record<string, unknown>) => void;
90
+ participants: string[];
91
+ participantDetails?: ParticipantDetail[];
92
+ role?: "spectator" | "player";
93
+ };
94
+ export type ExpectChain<T> = {
95
+ toBe: (expected: T) => void;
96
+ toEqual: (expected: unknown) => void;
97
+ toBeTruthy: () => void;
98
+ toBeFalsy: () => void;
99
+ toContain: (item: unknown) => void;
100
+ toHaveProperty: (key: string, value?: unknown) => void;
101
+ toBeGreaterThan: (expected: number) => void;
102
+ toBeLessThan: (expected: number) => void;
103
+ not: ExpectChain<T>;
104
+ };
105
+ export type TestHelpers = {
106
+ tool: (name: string) => ToolDef;
107
+ ctx: (opts?: {
108
+ state?: Record<string, any>;
109
+ actorId?: string;
110
+ roomId?: string;
111
+ owner?: string;
112
+ }) => ToolCtx & {
113
+ getState: () => Record<string, any>;
114
+ };
115
+ expect: <T>(actual: T) => ExpectChain<T>;
116
+ snapshot: (label: string, value: unknown) => void;
117
+ observe: (state: Record<string, any>, actorId?: string) => Record<string, any>;
118
+ agentSlots: () => Array<{
119
+ role: string;
120
+ systemPrompt?: string;
121
+ allowedTools?: string[];
122
+ [k: string]: unknown;
123
+ }>;
124
+ };
125
+ export type TestDef = {
126
+ name: string;
127
+ run: (helpers: TestHelpers) => Promise<void>;
128
+ };
129
+ export type RegistryEntry = {
130
+ path: string;
131
+ };
132
+ export type ExperienceRegistry = {
133
+ experiences: Record<string, RegistryEntry>;
134
+ };
135
+ export type ExperienceModule = {
136
+ manifest: ExperienceManifest;
137
+ Canvas: React.FC<CanvasProps>;
138
+ tools: ToolDef[];
139
+ tests?: TestDef[];
140
+ stateSchema?: z.ZodTypeAny;
141
+ streams?: StreamDef[];
142
+ observe?: (state: Record<string, any>, event: ToolEvent | null, actorId: string) => Record<string, any>;
143
+ };
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Experience SDK Types
3
+ */
4
+ export {};