bazaar.it 0.1.0 → 0.2.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.
Files changed (57) hide show
  1. package/README.md +489 -3
  2. package/bin/baz.js +6 -1
  3. package/dist/commands/auth.d.ts +2 -0
  4. package/dist/commands/auth.js +109 -0
  5. package/dist/commands/capabilities.d.ts +2 -0
  6. package/dist/commands/capabilities.js +44 -0
  7. package/dist/commands/context.d.ts +13 -0
  8. package/dist/commands/context.js +498 -0
  9. package/dist/commands/export.d.ts +2 -0
  10. package/dist/commands/export.js +360 -0
  11. package/dist/commands/logs.d.ts +2 -0
  12. package/dist/commands/logs.js +180 -0
  13. package/dist/commands/loop.d.ts +2 -0
  14. package/dist/commands/loop.js +538 -0
  15. package/dist/commands/mcp.d.ts +2 -0
  16. package/dist/commands/mcp.js +143 -0
  17. package/dist/commands/media.d.ts +2 -0
  18. package/dist/commands/media.js +362 -0
  19. package/dist/commands/project.d.ts +2 -0
  20. package/dist/commands/project.js +786 -0
  21. package/dist/commands/prompt.d.ts +2 -0
  22. package/dist/commands/prompt.js +529 -0
  23. package/dist/commands/recipe.d.ts +15 -0
  24. package/dist/commands/recipe.js +607 -0
  25. package/dist/commands/review.d.ts +17 -0
  26. package/dist/commands/review.js +345 -0
  27. package/dist/commands/scenes.d.ts +2 -0
  28. package/dist/commands/scenes.js +481 -0
  29. package/dist/commands/share.d.ts +2 -0
  30. package/dist/commands/share.js +226 -0
  31. package/dist/commands/state.d.ts +2 -0
  32. package/dist/commands/state.js +171 -0
  33. package/dist/commands/status.d.ts +2 -0
  34. package/dist/commands/status.js +219 -0
  35. package/dist/commands/template.d.ts +2 -0
  36. package/dist/commands/template.js +123 -0
  37. package/dist/commands/verify.d.ts +2 -0
  38. package/dist/commands/verify.js +150 -0
  39. package/dist/index.d.ts +2 -0
  40. package/dist/index.js +124 -0
  41. package/dist/lib/api.d.ts +186 -0
  42. package/dist/lib/api.js +717 -0
  43. package/dist/lib/banner.d.ts +12 -0
  44. package/dist/lib/banner.js +69 -0
  45. package/dist/lib/config.d.ts +33 -0
  46. package/dist/lib/config.js +99 -0
  47. package/dist/lib/output.d.ts +52 -0
  48. package/dist/lib/output.js +162 -0
  49. package/dist/lib/project-state.d.ts +52 -0
  50. package/dist/lib/project-state.js +178 -0
  51. package/dist/lib/sse.d.ts +168 -0
  52. package/dist/lib/sse.js +227 -0
  53. package/dist/lib/version.d.ts +1 -0
  54. package/dist/lib/version.js +3 -0
  55. package/dist/repl.d.ts +4 -0
  56. package/dist/repl.js +764 -0
  57. package/package.json +39 -5
@@ -0,0 +1,168 @@
1
+ export type StopReason = 'completed' | 'no_changes' | 'iteration_limit' | 'token_limit' | 'budget_limit' | 'error';
2
+ interface AssetPayload {
3
+ id: string;
4
+ url: string;
5
+ type: 'image' | 'video' | 'audio';
6
+ name?: string;
7
+ prompt?: string;
8
+ capabilityId?: string;
9
+ duration?: number | null;
10
+ width?: number | null;
11
+ height?: number | null;
12
+ aspectRatio?: string;
13
+ operationKey?: string;
14
+ quantity?: number;
15
+ estimatedCostUsd?: number;
16
+ costUsd?: number;
17
+ }
18
+ interface BudgetSummary {
19
+ budgetUsd: number;
20
+ claudeBilledUsd: number;
21
+ capabilityBilledUsd: number;
22
+ totalBilledUsd: number;
23
+ remainingUsd: number;
24
+ }
25
+ export type NormalizedSSEEvent = ReadyEvent | AssistantMessageChunkEvent | SceneAddedEvent | SceneUpdatedEvent | AgentActionEvent | AgentThinkingEvent | AgentToolInputEvent | AgentAssetEvent | WorkflowMessageEvent | RecipeMessageEvent | GenerationCompleteEvent | TitleUpdatedEvent | ErrorEvent | SidecarTokenEvent | SidecarCompleteEvent | SidecarErrorEvent | PreferenceSavedEvent | WorkerEventEvent | UnknownEvent;
26
+ interface ReadyEvent {
27
+ type: 'ready';
28
+ agentMode: boolean;
29
+ sidecarEnabled: boolean;
30
+ eventBusId?: string;
31
+ userMessage?: string;
32
+ imageUrls?: string[];
33
+ videoUrls?: string[];
34
+ audioUrls?: string[];
35
+ sceneUrls?: string[];
36
+ modelOverride?: string;
37
+ videoEngine?: string;
38
+ seedanceFirstImage?: string;
39
+ seedanceLastImage?: string;
40
+ seedanceReferenceImages?: string[];
41
+ useGitHub?: boolean;
42
+ clientRequestId?: string;
43
+ }
44
+ interface AssistantMessageChunkEvent {
45
+ type: 'assistant_message_chunk';
46
+ message: string;
47
+ isComplete: boolean;
48
+ clientRequestId?: string;
49
+ }
50
+ interface SceneAddedEvent {
51
+ type: 'scene_added';
52
+ sceneId: string;
53
+ sceneName: string;
54
+ progress: number;
55
+ sceneIndex?: number;
56
+ totalScenes?: number;
57
+ projectId?: string;
58
+ clientRequestId?: string;
59
+ }
60
+ interface SceneUpdatedEvent {
61
+ type: 'scene_updated';
62
+ sceneId: string;
63
+ sceneName: string;
64
+ progress: number;
65
+ sceneIndex?: number;
66
+ totalScenes?: number;
67
+ projectId?: string;
68
+ codeBefore?: string;
69
+ codeAfter?: string;
70
+ clientRequestId?: string;
71
+ }
72
+ interface AgentActionEvent {
73
+ type: 'agent_action';
74
+ action: string;
75
+ message: string;
76
+ toolName?: string;
77
+ sceneId?: string;
78
+ sceneName?: string;
79
+ elementName?: string;
80
+ iteration?: number;
81
+ clientRequestId?: string;
82
+ }
83
+ interface AgentThinkingEvent {
84
+ type: 'agent_thinking';
85
+ content: string;
86
+ clientRequestId?: string;
87
+ }
88
+ interface AgentToolInputEvent {
89
+ type: 'agent_tool_input';
90
+ toolName: string;
91
+ content: string;
92
+ clientRequestId?: string;
93
+ }
94
+ interface AgentAssetEvent {
95
+ type: 'agent_asset';
96
+ messageId: string;
97
+ asset: AssetPayload;
98
+ clientRequestId?: string;
99
+ }
100
+ interface WorkflowMessageEvent {
101
+ type: 'workflow_message';
102
+ messageId: string;
103
+ workflowCode: string;
104
+ workflowName: string;
105
+ description: string;
106
+ executionId?: string;
107
+ clientRequestId?: string;
108
+ }
109
+ interface RecipeMessageEvent {
110
+ type: 'recipe_message';
111
+ messageId: string;
112
+ recipe: unknown;
113
+ description: string;
114
+ clientRequestId?: string;
115
+ }
116
+ interface GenerationCompleteEvent {
117
+ type: 'generation_complete';
118
+ summary?: string;
119
+ stopReason?: StopReason;
120
+ totalScenes?: number;
121
+ projectId?: string;
122
+ completed?: boolean;
123
+ runId?: string;
124
+ budget?: BudgetSummary;
125
+ clientRequestId?: string;
126
+ }
127
+ interface TitleUpdatedEvent {
128
+ type: 'title_updated';
129
+ title: string;
130
+ clientRequestId?: string;
131
+ }
132
+ interface ErrorEvent {
133
+ type: 'error';
134
+ error: string;
135
+ canRetry?: boolean;
136
+ clientRequestId?: string;
137
+ }
138
+ interface SidecarTokenEvent {
139
+ type: 'sidecar_token';
140
+ content: string;
141
+ clientRequestId?: string;
142
+ }
143
+ interface SidecarCompleteEvent {
144
+ type: 'sidecar_complete';
145
+ clientRequestId?: string;
146
+ }
147
+ interface SidecarErrorEvent {
148
+ type: 'sidecar_error';
149
+ error: string;
150
+ clientRequestId?: string;
151
+ }
152
+ interface PreferenceSavedEvent {
153
+ type: 'preference_saved';
154
+ key: string;
155
+ value: string;
156
+ clientRequestId?: string;
157
+ }
158
+ interface WorkerEventEvent {
159
+ type: 'worker_event';
160
+ event: string;
161
+ clientRequestId?: string;
162
+ }
163
+ interface UnknownEvent {
164
+ type: 'unknown';
165
+ raw: unknown;
166
+ }
167
+ export declare function parseSSEEvent(raw: unknown): NormalizedSSEEvent;
168
+ export {};
@@ -0,0 +1,227 @@
1
+ function isObject(v) {
2
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
3
+ }
4
+ function str(v) {
5
+ return typeof v === 'string' ? v : undefined;
6
+ }
7
+ function num(v) {
8
+ return typeof v === 'number' ? v : undefined;
9
+ }
10
+ function bool(v) {
11
+ return Boolean(v);
12
+ }
13
+ const VALID_STOP_REASONS = new Set([
14
+ 'completed',
15
+ 'no_changes',
16
+ 'iteration_limit',
17
+ 'token_limit',
18
+ 'budget_limit',
19
+ 'error',
20
+ ]);
21
+ function stopReason(v) {
22
+ if (typeof v === 'string' && VALID_STOP_REASONS.has(v)) {
23
+ return v;
24
+ }
25
+ return undefined;
26
+ }
27
+ export function parseSSEEvent(raw) {
28
+ if (!isObject(raw) || typeof raw.type !== 'string') {
29
+ return { type: 'unknown', raw };
30
+ }
31
+ const type = raw.type;
32
+ const clientRequestId = str(raw.clientRequestId);
33
+ switch (type) {
34
+ case 'ready':
35
+ return {
36
+ type: 'ready',
37
+ agentMode: bool(raw.agentMode),
38
+ sidecarEnabled: bool(raw.sidecarEnabled),
39
+ eventBusId: str(raw.eventBusId),
40
+ userMessage: str(raw.userMessage),
41
+ imageUrls: Array.isArray(raw.imageUrls) ? raw.imageUrls : undefined,
42
+ videoUrls: Array.isArray(raw.videoUrls) ? raw.videoUrls : undefined,
43
+ audioUrls: Array.isArray(raw.audioUrls) ? raw.audioUrls : undefined,
44
+ sceneUrls: Array.isArray(raw.sceneUrls) ? raw.sceneUrls : undefined,
45
+ modelOverride: str(raw.modelOverride),
46
+ videoEngine: str(raw.videoEngine),
47
+ seedanceFirstImage: str(raw.seedanceFirstImage),
48
+ seedanceLastImage: str(raw.seedanceLastImage),
49
+ seedanceReferenceImages: Array.isArray(raw.seedanceReferenceImages)
50
+ ? raw.seedanceReferenceImages
51
+ : undefined,
52
+ useGitHub: raw.useGitHub === true ? true : undefined,
53
+ clientRequestId,
54
+ };
55
+ case 'assistant_message_chunk':
56
+ return {
57
+ type: 'assistant_message_chunk',
58
+ message: str(raw.message) ?? '',
59
+ isComplete: bool(raw.isComplete),
60
+ clientRequestId,
61
+ };
62
+ case 'scene_added': {
63
+ const d = isObject(raw.data) ? raw.data : raw;
64
+ return {
65
+ type: 'scene_added',
66
+ sceneId: str(d.sceneId) ?? '',
67
+ sceneName: str(d.sceneName) ?? '',
68
+ progress: num(d.progress) ?? 0,
69
+ sceneIndex: num(d.sceneIndex),
70
+ totalScenes: num(d.totalScenes),
71
+ projectId: str(d.projectId),
72
+ clientRequestId,
73
+ };
74
+ }
75
+ case 'scene_updated': {
76
+ const d = isObject(raw.data) ? raw.data : raw;
77
+ return {
78
+ type: 'scene_updated',
79
+ sceneId: str(d.sceneId) ?? '',
80
+ sceneName: str(d.sceneName) ?? '',
81
+ progress: num(d.progress) ?? 0,
82
+ sceneIndex: num(d.sceneIndex),
83
+ totalScenes: num(d.totalScenes),
84
+ projectId: str(d.projectId),
85
+ codeBefore: str(d.codeBefore),
86
+ codeAfter: str(d.codeAfter),
87
+ clientRequestId,
88
+ };
89
+ }
90
+ case 'agent_action':
91
+ return {
92
+ type: 'agent_action',
93
+ action: str(raw.action) ?? '',
94
+ message: str(raw.message) ?? '',
95
+ toolName: str(raw.toolName),
96
+ sceneId: str(raw.sceneId),
97
+ sceneName: str(raw.sceneName),
98
+ elementName: str(raw.elementName),
99
+ iteration: num(raw.iteration),
100
+ clientRequestId,
101
+ };
102
+ case 'agent_thinking':
103
+ return {
104
+ type: 'agent_thinking',
105
+ content: str(raw.content) ?? '',
106
+ clientRequestId,
107
+ };
108
+ case 'agent_tool_input':
109
+ return {
110
+ type: 'agent_tool_input',
111
+ toolName: str(raw.toolName) ?? '',
112
+ content: str(raw.content) ?? '',
113
+ clientRequestId,
114
+ };
115
+ case 'agent_asset': {
116
+ const asset = isObject(raw.asset) ? raw.asset : {};
117
+ return {
118
+ type: 'agent_asset',
119
+ messageId: str(raw.messageId) ?? '',
120
+ asset: {
121
+ id: str(asset.id) ?? '',
122
+ url: str(asset.url) ?? '',
123
+ type: str(asset.type) ?? 'image',
124
+ name: str(asset.name),
125
+ prompt: str(asset.prompt),
126
+ capabilityId: str(asset.capabilityId),
127
+ duration: num(asset.duration) ?? null,
128
+ width: num(asset.width) ?? null,
129
+ height: num(asset.height) ?? null,
130
+ aspectRatio: str(asset.aspectRatio),
131
+ operationKey: str(asset.operationKey),
132
+ quantity: num(asset.quantity),
133
+ estimatedCostUsd: num(asset.estimatedCostUsd),
134
+ costUsd: num(asset.costUsd),
135
+ },
136
+ clientRequestId,
137
+ };
138
+ }
139
+ case 'workflow_message':
140
+ return {
141
+ type: 'workflow_message',
142
+ messageId: str(raw.messageId) ?? '',
143
+ workflowCode: str(raw.workflowCode) ?? '',
144
+ workflowName: str(raw.workflowName) ?? '',
145
+ description: str(raw.description) ?? '',
146
+ executionId: str(raw.executionId),
147
+ clientRequestId,
148
+ };
149
+ case 'recipe_message':
150
+ return {
151
+ type: 'recipe_message',
152
+ messageId: str(raw.messageId) ?? '',
153
+ recipe: raw.recipe,
154
+ description: str(raw.description) ?? '',
155
+ clientRequestId,
156
+ };
157
+ case 'generation_complete': {
158
+ const d = isObject(raw.data) ? raw.data : raw;
159
+ let budget;
160
+ if (isObject(d.budget)) {
161
+ budget = {
162
+ budgetUsd: num(d.budget.budgetUsd) ?? 0,
163
+ claudeBilledUsd: num(d.budget.claudeBilledUsd) ?? 0,
164
+ capabilityBilledUsd: num(d.budget.capabilityBilledUsd) ?? 0,
165
+ totalBilledUsd: num(d.budget.totalBilledUsd) ?? 0,
166
+ remainingUsd: num(d.budget.remainingUsd) ?? 0,
167
+ };
168
+ }
169
+ return {
170
+ type: 'generation_complete',
171
+ summary: str(d.summary),
172
+ stopReason: stopReason(d.stopReason),
173
+ totalScenes: num(d.totalScenes),
174
+ projectId: str(d.projectId),
175
+ completed: d.completed === true ? true : d.completed === false ? false : undefined,
176
+ runId: str(d.runId),
177
+ budget,
178
+ clientRequestId,
179
+ };
180
+ }
181
+ case 'title_updated':
182
+ return {
183
+ type: 'title_updated',
184
+ title: str(raw.title) ?? '',
185
+ clientRequestId,
186
+ };
187
+ case 'error':
188
+ return {
189
+ type: 'error',
190
+ error: str(raw.error) ?? str(raw.message) ?? 'Unknown error',
191
+ canRetry: raw.canRetry === true ? true : undefined,
192
+ clientRequestId,
193
+ };
194
+ case 'sidecar_token':
195
+ return {
196
+ type: 'sidecar_token',
197
+ content: str(raw.content) ?? '',
198
+ clientRequestId,
199
+ };
200
+ case 'sidecar_complete':
201
+ return {
202
+ type: 'sidecar_complete',
203
+ clientRequestId,
204
+ };
205
+ case 'sidecar_error':
206
+ return {
207
+ type: 'sidecar_error',
208
+ error: str(raw.error) ?? '',
209
+ clientRequestId,
210
+ };
211
+ case 'preference_saved':
212
+ return {
213
+ type: 'preference_saved',
214
+ key: str(raw.key) ?? '',
215
+ value: str(raw.value) ?? '',
216
+ clientRequestId,
217
+ };
218
+ case 'worker_event':
219
+ return {
220
+ type: 'worker_event',
221
+ event: str(raw.event) ?? '',
222
+ clientRequestId,
223
+ };
224
+ default:
225
+ return { type: 'unknown', raw };
226
+ }
227
+ }
@@ -0,0 +1 @@
1
+ export declare const CLI_VERSION: string;
@@ -0,0 +1,3 @@
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ export const CLI_VERSION = require('../../package.json').version ?? '0.0.0';
package/dist/repl.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Start the interactive REPL
3
+ */
4
+ export declare function startRepl(): Promise<void>;