march-start-cli 0.1.3 → 0.1.5

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.
@@ -284,14 +284,25 @@ agent.onMessage(async (message, sender) => {
284
284
  })
285
285
  ```
286
286
 
287
- #### Artifacts
287
+ #### Structural Streaming (Artifacts, Surfaces, TextBlocks, Steppers)
288
288
 
289
- Attach files, documents, or iframes to your response:
289
+ The SDK provides structural streaming components for rich content.
290
+
291
+ ##### Artifacts
292
+
293
+ Stream file artifacts with progress indication:
290
294
 
291
295
  ```typescript
296
+ import { Artifact } from '@march/agent'
297
+
292
298
  const streamer = agent.streamer(message)
299
+ const artifact = new Artifact()
300
+
301
+ // Optional: show generation progress
302
+ streamer.streamBy(artifact).generating('Generating report...', 0.5)
293
303
 
294
- streamer.addArtifact({
304
+ // Signal completion with artifact details
305
+ streamer.streamBy(artifact).done({
295
306
  url: `/api/reports/lab-results.pdf`,
296
307
  type: 'document',
297
308
  title: 'Lab Results',
@@ -299,27 +310,71 @@ streamer.addArtifact({
299
310
  metadata: { size: 1024000, mimeType: 'application/pdf' }
300
311
  })
301
312
 
302
- streamer.addArtifact({
313
+ streamer.stream('Here are your results.')
314
+ await streamer.finish()
315
+ ```
316
+
317
+ ##### Surfaces (Embedded iframes)
318
+
319
+ Stream embedded interactive content:
320
+
321
+ ```typescript
322
+ import { Surface } from '@march/agent'
323
+
324
+ const surface = new Surface()
325
+ streamer.streamBy(surface).generating('Loading dashboard...')
326
+ streamer.streamBy(surface).done({
303
327
  url: `/dashboard/${message.conversationId}`,
304
328
  type: 'iframe',
305
329
  title: 'Patient Dashboard',
306
330
  description: 'Interactive dashboard showing conversation statistics',
307
331
  })
332
+ ```
308
333
 
309
- streamer.stream('Here are your results.')
310
- await streamer.finish()
334
+ ##### TextBlocks (Collapsible Content)
335
+
336
+ Stream collapsible text with variants:
337
+
338
+ ```typescript
339
+ import { TextBlock } from '@march/agent'
340
+
341
+ const block = new TextBlock()
342
+ streamer.streamBy(block).setVariant('thinking')
343
+ streamer.streamBy(block).streamTitle('Analyzing symptoms...')
344
+ streamer.streamBy(block).streamBody('Checking medical database...\n')
345
+ streamer.streamBy(block).streamBody('Cross-referencing symptoms...\n')
346
+ streamer.streamBy(block).updateTitle('Analysis Complete')
347
+ streamer.streamBy(block).done()
348
+ ```
349
+
350
+ Variants: `thinking`, `note`, `warning`, `error`, `success`
351
+
352
+ ##### Steppers (Multi-step Progress)
353
+
354
+ Show multi-step progress indicators:
355
+
356
+ ```typescript
357
+ import { Stepper } from '@march/agent'
358
+
359
+ const stepper = new Stepper({ steps: ['Fetch Records', 'Analyze', 'Generate Report'] })
360
+ streamer.streamBy(stepper).startStep(0)
361
+ // ... fetch records ...
362
+ streamer.streamBy(stepper).completeStep(0)
363
+ streamer.streamBy(stepper).startStep(1)
364
+ // ... analyze ...
365
+ streamer.streamBy(stepper).completeStep(1)
366
+ streamer.streamBy(stepper).startStep(2)
367
+ // ... generate ...
368
+ streamer.streamBy(stepper).completeStep(2)
369
+ streamer.streamBy(stepper).done()
311
370
  ```
312
371
 
313
- | Artifact Type | Use Case |
314
- |---------------|----------|
315
- | `document` | PDFs, reports, guides |
316
- | `image` | Charts, diagrams, photos |
317
- | `iframe` | Interactive content, dashboards |
318
- | `video` | Tutorials, demos |
319
- | `audio` | Voice messages |
320
- | `code` | Source code snippets |
321
- | `link` | External URLs |
322
- | `file` | Generic downloads |
372
+ | Component | Purpose | Key Methods |
373
+ |-----------|---------|-------------|
374
+ | `Artifact` | Files, images, documents | `generating()`, `done()`, `error()` |
375
+ | `Surface` | Embedded iframes/widgets | `generating()`, `done()`, `error()` |
376
+ | `TextBlock` | Collapsible text content | `streamTitle()`, `streamBody()`, `setVariant()`, `done()` |
377
+ | `Stepper` | Multi-step progress | `startStep()`, `completeStep()`, `failStep()`, `addStep()`, `done()` |
323
378
 
324
379
  ---
325
380
 
@@ -1,6 +1,6 @@
1
1
  # Agent Configuration
2
2
  AGENT_NAME=my-agent
3
- AGENT_ABOUT=A helpful AI assistant
3
+ AGENT_ABOUT="A helpful AI assistant"
4
4
 
5
5
  # Gateway Configuration
6
6
  GATEWAY_URL=agent-gateway:8080
@@ -21,13 +21,13 @@ import { ChatOpenAI } from '@langchain/openai'
21
21
  import { HumanMessage, AIMessage, SystemMessage, type BaseMessage } from '@langchain/core/messages'
22
22
 
23
23
  // Import from local framework (change to 'march-ai-sdk' when published)
24
- import { MarchAgentApp, Message } from '../../ai-ts-framework/dist/index.js'
24
+ import { MarchAgentApp, Message, Artifact, Surface } from '../../ai-ts-framework/dist/index.js'
25
25
 
26
26
  // ============================================================================
27
27
  // CONFIGURATION
28
28
  // ============================================================================
29
29
 
30
- const AGENT_NAME = process.env.AGENT_NAME || 'my-agent'
30
+ const AGENT_NAME = process.env.AGENT_NAME || 'my-agent-ts'
31
31
  const AGENT_ABOUT = process.env.AGENT_ABOUT || 'A helpful AI assistant'
32
32
 
33
33
  const SYSTEM_PROMPT = `You are a helpful AI assistant. Your role is to assist users with their questions and tasks.
@@ -144,15 +144,20 @@ async function main() {
144
144
  hasAttachment: message.hasAttachment(),
145
145
  })
146
146
 
147
- // Add artifacts for testing frontend rendering
148
- streamer.addArtifact({
147
+ // Add structural streaming components for testing frontend rendering
148
+
149
+ // Surface for interactive dashboard (iframe)
150
+ const dashboard = new Surface()
151
+ streamer.streamBy(dashboard).done({
149
152
  url: `/api/dashboard/${message.conversationId}`,
150
153
  type: 'iframe',
151
154
  title: 'Patient Dashboard',
152
155
  description: 'Interactive dashboard showing conversation statistics',
153
156
  })
154
157
 
155
- streamer.addArtifact({
158
+ // Artifact for document
159
+ const report = new Artifact()
160
+ streamer.streamBy(report).done({
156
161
  url: `/api/artifacts/document/${message.conversationId}`,
157
162
  type: 'document',
158
163
  title: 'Health Summary Report',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "march-start-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CLI to scaffold new March AI agent projects",
5
5
  "type": "module",
6
6
  "bin": {