march-ai-sdk 0.3.0 → 0.4.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.
- package/README.md +115 -10
- package/dist/{app-C_umwZXh.d.ts → app-Cf_umb8u.d.ts} +49 -51
- package/dist/extensions/langgraph.d.ts +1 -1
- package/dist/extensions/vercel-ai.d.ts +1 -1
- package/dist/index.d.ts +284 -4
- package/dist/index.js +357 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +18 -4
- package/src/streamer.ts +22 -27
- package/src/structural/artifact.ts +97 -0
- package/src/structural/base.ts +83 -0
- package/src/structural/index.ts +12 -0
- package/src/structural/stepper.ts +131 -0
- package/src/structural/surface.ts +93 -0
- package/src/structural/text-block.ts +102 -0
- package/src/artifact.ts +0 -59
package/README.md
CHANGED
|
@@ -339,13 +339,6 @@ agent.onMessage(async (message, sender) => {
|
|
|
339
339
|
}
|
|
340
340
|
})
|
|
341
341
|
|
|
342
|
-
// Add artifacts
|
|
343
|
-
streamer2.addArtifact({
|
|
344
|
-
url: '/dashboard/123',
|
|
345
|
-
type: 'iframe',
|
|
346
|
-
title: 'Dashboard',
|
|
347
|
-
})
|
|
348
|
-
|
|
349
342
|
// Set message metadata
|
|
350
343
|
streamer2.setMessageMetadata({
|
|
351
344
|
model: 'gpt-4o',
|
|
@@ -365,8 +358,105 @@ agent.onMessage(async (message, sender) => {
|
|
|
365
358
|
| `finish(awaiting?)` | Finish streaming with done=true signal |
|
|
366
359
|
| `setResponseSchema(schema)` | Set JSON Schema for form rendering |
|
|
367
360
|
| `setMessageMetadata(metadata)` | Set message metadata |
|
|
368
|
-
| `
|
|
369
|
-
|
|
361
|
+
| `streamBy(structural)` | Bind a structural streamer for artifacts, surfaces, etc. |
|
|
362
|
+
|
|
363
|
+
### Structural Streaming
|
|
364
|
+
|
|
365
|
+
The SDK provides structural streaming components for rich content like artifacts, surfaces, text blocks, and steppers.
|
|
366
|
+
|
|
367
|
+
#### Artifact
|
|
368
|
+
|
|
369
|
+
Stream file artifacts (images, documents, iframes) with progress indication:
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { Artifact } from 'march-ai-sdk'
|
|
373
|
+
|
|
374
|
+
agent.onMessage(async (message, sender) => {
|
|
375
|
+
const streamer = agent.streamer(message)
|
|
376
|
+
|
|
377
|
+
// Create an artifact
|
|
378
|
+
const artifact = new Artifact()
|
|
379
|
+
|
|
380
|
+
// Signal generation started (optional)
|
|
381
|
+
streamer.streamBy(artifact).generating('Creating chart...', 0.5)
|
|
382
|
+
|
|
383
|
+
// ... do work ...
|
|
384
|
+
|
|
385
|
+
// Signal completion with artifact details
|
|
386
|
+
streamer.streamBy(artifact).done({
|
|
387
|
+
url: 'https://example.com/chart.png',
|
|
388
|
+
type: 'image',
|
|
389
|
+
title: 'Sales Chart',
|
|
390
|
+
description: 'Q4 2024 sales data',
|
|
391
|
+
metadata: { size: 1024, mimeType: 'image/png' }
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
streamer.stream('Here is your chart!')
|
|
395
|
+
await streamer.finish()
|
|
396
|
+
})
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
#### Surface
|
|
400
|
+
|
|
401
|
+
Stream embedded interactive components (iframes, embeds):
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
import { Surface } from 'march-ai-sdk'
|
|
405
|
+
|
|
406
|
+
const surface = new Surface()
|
|
407
|
+
streamer.streamBy(surface).generating('Loading calendar...')
|
|
408
|
+
streamer.streamBy(surface).done({
|
|
409
|
+
url: 'https://cal.com/embed/user',
|
|
410
|
+
type: 'iframe', // default
|
|
411
|
+
title: 'Schedule a Meeting'
|
|
412
|
+
})
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
#### TextBlock
|
|
416
|
+
|
|
417
|
+
Stream collapsible text content with titles and variants:
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
import { TextBlock } from 'march-ai-sdk'
|
|
421
|
+
|
|
422
|
+
const block = new TextBlock()
|
|
423
|
+
streamer.streamBy(block).setVariant('thinking')
|
|
424
|
+
streamer.streamBy(block).streamTitle('Analyzing...')
|
|
425
|
+
streamer.streamBy(block).streamBody('Step 1: Checking data\n')
|
|
426
|
+
streamer.streamBy(block).streamBody('Step 2: Processing\n')
|
|
427
|
+
streamer.streamBy(block).updateTitle('Analysis Complete')
|
|
428
|
+
streamer.streamBy(block).done()
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Variants: `thinking`, `note`, `warning`, `error`, `success`
|
|
432
|
+
|
|
433
|
+
#### Stepper
|
|
434
|
+
|
|
435
|
+
Stream multi-step progress indicators:
|
|
436
|
+
|
|
437
|
+
```typescript
|
|
438
|
+
import { Stepper } from 'march-ai-sdk'
|
|
439
|
+
|
|
440
|
+
const stepper = new Stepper({ steps: ['Fetch Data', 'Process', 'Generate Report'] })
|
|
441
|
+
streamer.streamBy(stepper).startStep(0)
|
|
442
|
+
// ... do work ...
|
|
443
|
+
streamer.streamBy(stepper).completeStep(0)
|
|
444
|
+
streamer.streamBy(stepper).startStep(1)
|
|
445
|
+
streamer.streamBy(stepper).addStep('Verify') // Add dynamic step
|
|
446
|
+
streamer.streamBy(stepper).completeStep(1)
|
|
447
|
+
streamer.streamBy(stepper).startStep(2)
|
|
448
|
+
streamer.streamBy(stepper).completeStep(2)
|
|
449
|
+
streamer.streamBy(stepper).done()
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
#### Structural Streaming Components
|
|
453
|
+
|
|
454
|
+
| Component | Purpose | Key Methods |
|
|
455
|
+
|-----------|---------|-------------|
|
|
456
|
+
| `Artifact` | Files, images, documents | `generating()`, `done()`, `error()` |
|
|
457
|
+
| `Surface` | Embedded iframes/widgets | `generating()`, `done()`, `error()` |
|
|
458
|
+
| `TextBlock` | Collapsible text content | `streamTitle()`, `streamBody()`, `setVariant()`, `done()` |
|
|
459
|
+
| `Stepper` | Multi-step progress | `startStep()`, `completeStep()`, `failStep()`, `addStep()`, `done()` |
|
|
370
460
|
|
|
371
461
|
## Extensions
|
|
372
462
|
|
|
@@ -612,6 +702,13 @@ ai-ts-framework/
|
|
|
612
702
|
│ ├── api-paths.ts # API endpoint configuration
|
|
613
703
|
│ ├── types.ts # TypeScript types
|
|
614
704
|
│ ├── exceptions.ts # Custom exceptions
|
|
705
|
+
│ ├── structural/ # Structural streaming components
|
|
706
|
+
│ │ ├── index.ts # Structural exports
|
|
707
|
+
│ │ ├── base.ts # StructuralStreamer base class
|
|
708
|
+
│ │ ├── artifact.ts # Artifact component
|
|
709
|
+
│ │ ├── surface.ts # Surface component
|
|
710
|
+
│ │ ├── text-block.ts # TextBlock component
|
|
711
|
+
│ │ └── stepper.ts # Stepper component
|
|
615
712
|
│ ├── proto/
|
|
616
713
|
│ │ └── gateway.proto # gRPC protocol definition
|
|
617
714
|
│ └── extensions/
|
|
@@ -623,7 +720,8 @@ ai-ts-framework/
|
|
|
623
720
|
│ ├── app.test.ts
|
|
624
721
|
│ ├── checkpoint-client.test.ts
|
|
625
722
|
│ ├── message.test.ts
|
|
626
|
-
│
|
|
723
|
+
│ ├── streamer.test.ts
|
|
724
|
+
│ └── structural-streaming.test.ts
|
|
627
725
|
├── tsup.config.ts # Build configuration
|
|
628
726
|
├── vitest.config.ts # Test configuration
|
|
629
727
|
├── tsconfig.json
|
|
@@ -688,6 +786,13 @@ import type {
|
|
|
688
786
|
Agent,
|
|
689
787
|
MarchAgentApp,
|
|
690
788
|
|
|
789
|
+
// Structural streaming
|
|
790
|
+
StructuralStreamer,
|
|
791
|
+
Artifact,
|
|
792
|
+
Surface,
|
|
793
|
+
TextBlock,
|
|
794
|
+
Stepper,
|
|
795
|
+
|
|
691
796
|
// Options
|
|
692
797
|
AppOptions,
|
|
693
798
|
RegisterOptions,
|
|
@@ -491,52 +491,43 @@ declare class GatewayClient {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
/**
|
|
494
|
-
* March Agent SDK -
|
|
495
|
-
* Port of Python march_agent/
|
|
494
|
+
* March Agent SDK - Structural Streaming Base
|
|
495
|
+
* Port of Python march_agent/structural/base.py
|
|
496
|
+
*
|
|
497
|
+
* Base class for structural streaming objects.
|
|
496
498
|
*/
|
|
497
499
|
|
|
498
500
|
/**
|
|
499
|
-
*
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Schema for artifact validation
|
|
505
|
-
*/
|
|
506
|
-
declare const ArtifactSchema: z.ZodObject<{
|
|
507
|
-
url: z.ZodString;
|
|
508
|
-
type: z.ZodEnum<["document", "image", "iframe", "video", "audio", "code", "link", "file"]>;
|
|
509
|
-
title: z.ZodOptional<z.ZodString>;
|
|
510
|
-
description: z.ZodOptional<z.ZodString>;
|
|
511
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
512
|
-
}, "strip", z.ZodTypeAny, {
|
|
513
|
-
url: string;
|
|
514
|
-
type: "code" | "document" | "image" | "iframe" | "video" | "audio" | "link" | "file";
|
|
515
|
-
metadata?: Record<string, unknown> | undefined;
|
|
516
|
-
title?: string | undefined;
|
|
517
|
-
description?: string | undefined;
|
|
518
|
-
}, {
|
|
519
|
-
url: string;
|
|
520
|
-
type: "code" | "document" | "image" | "iframe" | "video" | "audio" | "link" | "file";
|
|
521
|
-
metadata?: Record<string, unknown> | undefined;
|
|
522
|
-
title?: string | undefined;
|
|
523
|
-
description?: string | undefined;
|
|
524
|
-
}>;
|
|
525
|
-
type Artifact = z.infer<typeof ArtifactSchema>;
|
|
526
|
-
/**
|
|
527
|
-
* Input type for adding artifacts (without strict validation)
|
|
501
|
+
* Abstract base class for structural streaming objects.
|
|
502
|
+
*
|
|
503
|
+
* Structural streamers generate events but don't hold streaming state.
|
|
504
|
+
* The Streamer binds to them via streamBy() to enable streaming.
|
|
528
505
|
*/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
506
|
+
declare abstract class StructuralStreamer {
|
|
507
|
+
readonly id: string;
|
|
508
|
+
protected _streamer?: Streamer;
|
|
509
|
+
constructor(id?: string);
|
|
510
|
+
/**
|
|
511
|
+
* Generate a unique ID for this streamer type.
|
|
512
|
+
*/
|
|
513
|
+
protected abstract _generateId(): string;
|
|
514
|
+
/**
|
|
515
|
+
* Get the event type prefix (e.g., 'artifact', 'text_block').
|
|
516
|
+
*/
|
|
517
|
+
abstract getEventTypePrefix(): string;
|
|
518
|
+
/**
|
|
519
|
+
* Bind this structural streamer to a Streamer instance.
|
|
520
|
+
* Called by Streamer.streamBy(). Returns self for chaining.
|
|
521
|
+
*/
|
|
522
|
+
_bindStreamer(streamer: Streamer): this;
|
|
523
|
+
/**
|
|
524
|
+
* Send an event through the bound streamer.
|
|
525
|
+
*
|
|
526
|
+
* Creates event payload and sends via streamer._send().
|
|
527
|
+
* Returns self for method chaining.
|
|
528
|
+
*/
|
|
529
|
+
protected _sendEvent(action: string, data?: Record<string, unknown>): this;
|
|
535
530
|
}
|
|
536
|
-
/**
|
|
537
|
-
* Convert artifact input to validated artifact
|
|
538
|
-
*/
|
|
539
|
-
declare function toArtifact(input: ArtifactInput): Artifact;
|
|
540
531
|
|
|
541
532
|
/**
|
|
542
533
|
* March Agent SDK - Streamer
|
|
@@ -555,9 +546,7 @@ declare class Streamer {
|
|
|
555
546
|
private awaiting;
|
|
556
547
|
private responseSchema?;
|
|
557
548
|
private messageMetadata?;
|
|
558
|
-
private artifacts;
|
|
559
549
|
private streamedContent;
|
|
560
|
-
private firstChunkSent;
|
|
561
550
|
private finished;
|
|
562
551
|
constructor(options: {
|
|
563
552
|
agentName: string;
|
|
@@ -576,13 +565,21 @@ declare class Streamer {
|
|
|
576
565
|
*/
|
|
577
566
|
setMessageMetadata(metadata: Record<string, unknown>): this;
|
|
578
567
|
/**
|
|
579
|
-
*
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
*
|
|
568
|
+
* Bind a structural streamer to this streamer for event sending.
|
|
569
|
+
*
|
|
570
|
+
* Returns the structural object itself with streaming capability enabled.
|
|
571
|
+
*
|
|
572
|
+
* @param structural - StructuralStreamer instance (Artifact, Surface, etc.)
|
|
573
|
+
* @returns The same structural object, now bound to this streamer
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```typescript
|
|
577
|
+
* const artifact = new Artifact()
|
|
578
|
+
* s.streamBy(artifact).generating("Creating...")
|
|
579
|
+
* s.streamBy(artifact).done({ url: "...", type: "image" })
|
|
580
|
+
* ```
|
|
584
581
|
*/
|
|
585
|
-
|
|
582
|
+
streamBy<T extends StructuralStreamer>(structural: T): T;
|
|
586
583
|
/**
|
|
587
584
|
* Stream a content chunk.
|
|
588
585
|
*/
|
|
@@ -597,8 +594,9 @@ declare class Streamer {
|
|
|
597
594
|
finish(awaitingOverride?: boolean): Promise<void>;
|
|
598
595
|
/**
|
|
599
596
|
* Send message to router via gateway.
|
|
597
|
+
* This method is used internally and by structural streamers.
|
|
600
598
|
*/
|
|
601
|
-
|
|
599
|
+
_send(content: string, done: boolean, persist?: boolean, eventType?: string): void;
|
|
602
600
|
/**
|
|
603
601
|
* Store response schema on conversation for form validation.
|
|
604
602
|
*/
|
|
@@ -787,4 +785,4 @@ declare class MarchAgentApp {
|
|
|
787
785
|
shutdown(): void;
|
|
788
786
|
}
|
|
789
787
|
|
|
790
|
-
export { Agent as A, Conversation as C, GatewayClient as G, type
|
|
788
|
+
export { Agent as A, Conversation as C, GatewayClient as G, type KafkaMessage as K, MarchAgentApp as M, type ProduceAck as P, type RegisterOptions as R, StructuralStreamer as S, type UserSummary as U, SenderFilter as a, Message as b, Streamer as c, Memory as d, ConversationMessage as e, ConversationClient as f, MemoryClient as g, AttachmentClient as h, createAttachmentInfo as i, type AttachmentInfo as j, type KafkaHeaders as k, type AgentRegistrationData as l, type MessageHandler as m, type SenderFilterOptions as n, type StreamOptions as o, type StreamerOptions as p, type AppOptions as q, type ConversationData as r, type GetMessagesOptions as s, type MemoryMessage as t, type MemorySearchResult as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,287 @@
|
|
|
1
|
-
import { G as GatewayClient } from './app-
|
|
2
|
-
export { A as Agent,
|
|
1
|
+
import { S as StructuralStreamer, G as GatewayClient } from './app-Cf_umb8u.js';
|
|
2
|
+
export { A as Agent, l as AgentRegistrationData, q as AppOptions, h as AttachmentClient, j as AttachmentInfo, C as Conversation, f as ConversationClient, r as ConversationData, e as ConversationMessage, s as GetMessagesOptions, k as KafkaHeaders, K as KafkaMessage, M as MarchAgentApp, d as Memory, g as MemoryClient, t as MemoryMessage, u as MemorySearchResult, b as Message, m as MessageHandler, P as ProduceAck, R as RegisterOptions, a as SenderFilter, n as SenderFilterOptions, o as StreamOptions, c as Streamer, p as StreamerOptions, U as UserSummary, i as createAttachmentInfo } from './app-Cf_umb8u.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* March Agent SDK - Artifact Structural Streamer
|
|
7
|
+
* Port of Python march_agent/structural/artifact.py
|
|
8
|
+
*
|
|
9
|
+
* Artifact structural streamer for file/image/iframe artifacts.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Manages artifact lifecycle: generating -> done.
|
|
14
|
+
*
|
|
15
|
+
* Artifacts are files, images, iframes that are generated and displayed.
|
|
16
|
+
* Artifact data is persisted to database on done().
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const artifact = new Artifact() // ID auto-generated
|
|
21
|
+
* s.streamBy(artifact).generating("Creating chart...", 0.5)
|
|
22
|
+
* s.streamBy(artifact).done({
|
|
23
|
+
* url: "https://example.com/chart.png",
|
|
24
|
+
* type: "image",
|
|
25
|
+
* title: "Sales Chart"
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare class Artifact extends StructuralStreamer {
|
|
30
|
+
protected _generateId(): string;
|
|
31
|
+
getEventTypePrefix(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Signal artifact is being generated.
|
|
34
|
+
*
|
|
35
|
+
* @param message - Status message (e.g., "Creating chart...")
|
|
36
|
+
* @param progress - Progress value 0.0-1.0
|
|
37
|
+
* @returns this for method chaining
|
|
38
|
+
*/
|
|
39
|
+
generating(message?: string, progress?: number): this;
|
|
40
|
+
/**
|
|
41
|
+
* Signal artifact is complete and persist to database.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Artifact completion options
|
|
44
|
+
* @param options.url - URL to artifact
|
|
45
|
+
* @param options.type - Artifact type (image, iframe, document, video, audio, code, link, file)
|
|
46
|
+
* @param options.title - Display title
|
|
47
|
+
* @param options.description - Optional description
|
|
48
|
+
* @param options.metadata - Additional metadata (size, mimeType, dimensions, etc.)
|
|
49
|
+
* @returns this for method chaining
|
|
50
|
+
*/
|
|
51
|
+
done(options: {
|
|
52
|
+
url: string;
|
|
53
|
+
type: string;
|
|
54
|
+
title?: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
}): this;
|
|
58
|
+
/**
|
|
59
|
+
* Signal artifact generation failed.
|
|
60
|
+
*
|
|
61
|
+
* @param message - Error message
|
|
62
|
+
* @returns this for method chaining
|
|
63
|
+
*/
|
|
64
|
+
error(message: string): this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* March Agent SDK - Surface Structural Streamer
|
|
69
|
+
* Port of Python march_agent/structural/surface.py
|
|
70
|
+
*
|
|
71
|
+
* Surface structural streamer for embedded interactive components.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Manages embedded surface lifecycle (similar to Artifact).
|
|
76
|
+
*
|
|
77
|
+
* Surfaces are embedded interactive components (iframes, embeds).
|
|
78
|
+
* Surface data is persisted to database as artifacts with surface type.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const surface = new Surface()
|
|
83
|
+
* s.streamBy(surface).generating("Loading calendar...")
|
|
84
|
+
* s.streamBy(surface).done({ url: "https://cal.com/embed", type: "iframe" })
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare class Surface extends StructuralStreamer {
|
|
88
|
+
protected _generateId(): string;
|
|
89
|
+
getEventTypePrefix(): string;
|
|
90
|
+
/**
|
|
91
|
+
* Signal surface is loading.
|
|
92
|
+
*
|
|
93
|
+
* @param message - Status message (e.g., "Loading calendar...")
|
|
94
|
+
* @param progress - Progress value 0.0-1.0
|
|
95
|
+
* @returns this for method chaining
|
|
96
|
+
*/
|
|
97
|
+
generating(message?: string, progress?: number): this;
|
|
98
|
+
/**
|
|
99
|
+
* Signal surface is ready and persist to database.
|
|
100
|
+
*
|
|
101
|
+
* @param options - Surface completion options
|
|
102
|
+
* @param options.url - URL to surface
|
|
103
|
+
* @param options.type - Surface type (default: iframe)
|
|
104
|
+
* @param options.title - Display title
|
|
105
|
+
* @param options.description - Optional description
|
|
106
|
+
* @param options.metadata - Additional metadata
|
|
107
|
+
* @returns this for method chaining
|
|
108
|
+
*/
|
|
109
|
+
done(options: {
|
|
110
|
+
url: string;
|
|
111
|
+
type?: string;
|
|
112
|
+
title?: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
metadata?: Record<string, unknown>;
|
|
115
|
+
}): this;
|
|
116
|
+
/**
|
|
117
|
+
* Signal surface loading failed.
|
|
118
|
+
*
|
|
119
|
+
* @param message - Error message
|
|
120
|
+
* @returns this for method chaining
|
|
121
|
+
*/
|
|
122
|
+
error(message: string): this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* March Agent SDK - TextBlock Structural Streamer
|
|
127
|
+
* Port of Python march_agent/structural/text_block.py
|
|
128
|
+
*
|
|
129
|
+
* TextBlock structural streamer for collapsible text content.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Manages collapsible text block with title and body.
|
|
134
|
+
*
|
|
135
|
+
* Both title and body support streaming (append) and update (replace).
|
|
136
|
+
* TextBlock events are NOT persisted to database.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const block = new TextBlock() // ID auto-generated
|
|
141
|
+
* s.streamBy(block).setVariant("thinking")
|
|
142
|
+
* s.streamBy(block).streamTitle("Deep ")
|
|
143
|
+
* s.streamBy(block).streamTitle("Analysis...")
|
|
144
|
+
* s.streamBy(block).streamBody("Step 1: Check patterns\n")
|
|
145
|
+
* s.streamBy(block).streamBody("Step 2: Validate\n")
|
|
146
|
+
* s.streamBy(block).updateTitle("Analysis Complete")
|
|
147
|
+
* s.streamBy(block).done()
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
declare class TextBlock extends StructuralStreamer {
|
|
151
|
+
readonly initialTitle?: string;
|
|
152
|
+
constructor(options?: {
|
|
153
|
+
id?: string;
|
|
154
|
+
title?: string;
|
|
155
|
+
});
|
|
156
|
+
protected _generateId(): string;
|
|
157
|
+
getEventTypePrefix(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Stream title content (appends to existing).
|
|
160
|
+
*
|
|
161
|
+
* @param content - Content to append to title
|
|
162
|
+
* @returns this for method chaining
|
|
163
|
+
*/
|
|
164
|
+
streamTitle(content: string): this;
|
|
165
|
+
/**
|
|
166
|
+
* Stream body content (appends to existing).
|
|
167
|
+
*
|
|
168
|
+
* @param content - Content to append to body
|
|
169
|
+
* @returns this for method chaining
|
|
170
|
+
*/
|
|
171
|
+
streamBody(content: string): this;
|
|
172
|
+
/**
|
|
173
|
+
* Replace entire title.
|
|
174
|
+
*
|
|
175
|
+
* @param title - New title (replaces existing)
|
|
176
|
+
* @returns this for method chaining
|
|
177
|
+
*/
|
|
178
|
+
updateTitle(title: string): this;
|
|
179
|
+
/**
|
|
180
|
+
* Replace entire body.
|
|
181
|
+
*
|
|
182
|
+
* @param body - New body (replaces existing)
|
|
183
|
+
* @returns this for method chaining
|
|
184
|
+
*/
|
|
185
|
+
updateBody(body: string): this;
|
|
186
|
+
/**
|
|
187
|
+
* Set visual variant.
|
|
188
|
+
*
|
|
189
|
+
* @param variant - Visual style (thinking, note, warning, error, success)
|
|
190
|
+
* @returns this for method chaining
|
|
191
|
+
*/
|
|
192
|
+
setVariant(variant: 'thinking' | 'note' | 'warning' | 'error' | 'success' | string): this;
|
|
193
|
+
/**
|
|
194
|
+
* Mark text block as complete.
|
|
195
|
+
*
|
|
196
|
+
* @returns this for method chaining
|
|
197
|
+
*/
|
|
198
|
+
done(): this;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* March Agent SDK - Stepper Structural Streamer
|
|
203
|
+
* Port of Python march_agent/structural/stepper.py
|
|
204
|
+
*
|
|
205
|
+
* Stepper structural streamer for multi-step progress indicators.
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Manages multi-step progress indicator.
|
|
210
|
+
*
|
|
211
|
+
* Stepper events are NOT persisted to database.
|
|
212
|
+
* IDs are auto-generated - no need to provide them manually.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const stepper = new Stepper({ steps: ["Fetch", "Process", "Report"] }) // ID auto-generated
|
|
217
|
+
* s.streamBy(stepper).startStep(0)
|
|
218
|
+
* s.streamBy(stepper).completeStep(0)
|
|
219
|
+
* s.streamBy(stepper).startStep(1)
|
|
220
|
+
* s.streamBy(stepper).addStep("Verify") // Dynamic step
|
|
221
|
+
* s.streamBy(stepper).completeStep(1)
|
|
222
|
+
* s.streamBy(stepper).done()
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
declare class Stepper extends StructuralStreamer {
|
|
226
|
+
readonly steps: string[];
|
|
227
|
+
private _initialized;
|
|
228
|
+
constructor(options?: {
|
|
229
|
+
id?: string;
|
|
230
|
+
steps?: string[];
|
|
231
|
+
});
|
|
232
|
+
protected _generateId(): string;
|
|
233
|
+
getEventTypePrefix(): string;
|
|
234
|
+
/**
|
|
235
|
+
* Send initialization event with steps if not already sent.
|
|
236
|
+
* This is automatically called before any other stepper event.
|
|
237
|
+
*/
|
|
238
|
+
private _ensureInitialized;
|
|
239
|
+
/**
|
|
240
|
+
* Mark step as in progress.
|
|
241
|
+
*
|
|
242
|
+
* @param index - Step index to start
|
|
243
|
+
* @returns this for method chaining
|
|
244
|
+
*/
|
|
245
|
+
startStep(index: number): this;
|
|
246
|
+
/**
|
|
247
|
+
* Mark step as complete.
|
|
248
|
+
*
|
|
249
|
+
* @param index - Step index to complete
|
|
250
|
+
* @returns this for method chaining
|
|
251
|
+
*/
|
|
252
|
+
completeStep(index: number): this;
|
|
253
|
+
/**
|
|
254
|
+
* Mark step as failed.
|
|
255
|
+
*
|
|
256
|
+
* @param index - Step index that failed
|
|
257
|
+
* @param error - Optional error message
|
|
258
|
+
* @returns this for method chaining
|
|
259
|
+
*/
|
|
260
|
+
failStep(index: number, error?: string): this;
|
|
261
|
+
/**
|
|
262
|
+
* Add a new step dynamically.
|
|
263
|
+
*
|
|
264
|
+
* @param label - Step label
|
|
265
|
+
* @param index - Optional position to insert at
|
|
266
|
+
* @returns this for method chaining
|
|
267
|
+
*/
|
|
268
|
+
addStep(label: string, index?: number): this;
|
|
269
|
+
/**
|
|
270
|
+
* Update step label.
|
|
271
|
+
*
|
|
272
|
+
* @param index - Step index to update
|
|
273
|
+
* @param label - New label
|
|
274
|
+
* @returns this for method chaining
|
|
275
|
+
*/
|
|
276
|
+
updateStepLabel(index: number, label: string): this;
|
|
277
|
+
/**
|
|
278
|
+
* Mark stepper as complete (all steps finished).
|
|
279
|
+
*
|
|
280
|
+
* @returns this for method chaining
|
|
281
|
+
*/
|
|
282
|
+
done(): this;
|
|
283
|
+
}
|
|
284
|
+
|
|
5
285
|
/**
|
|
6
286
|
* March Agent SDK - Checkpoint Client
|
|
7
287
|
* Port of Python march_agent/checkpoint_client.py
|
|
@@ -255,6 +535,6 @@ declare class GatewayError extends MarchAgentError {
|
|
|
255
535
|
* @packageDocumentation
|
|
256
536
|
*/
|
|
257
537
|
|
|
258
|
-
declare const VERSION = "0.
|
|
538
|
+
declare const VERSION = "0.4.0";
|
|
259
539
|
|
|
260
|
-
export { AI_INVENTORY_PATHS, APIException, AgentStateClient, type AgentStateResponse, CONVERSATION_STORE_PATHS, CheckpointClient, type CheckpointConfig, type CheckpointData, type CheckpointMetadata, type CheckpointTuple, ConfigurationError, GatewayClient, GatewayError, HeartbeatError, HeartbeatManager, KafkaError, MEMORY_PATHS, MarchAgentError, RegistrationError, SERVICES, type ServiceName, VERSION };
|
|
540
|
+
export { AI_INVENTORY_PATHS, APIException, AgentStateClient, type AgentStateResponse, Artifact, CONVERSATION_STORE_PATHS, CheckpointClient, type CheckpointConfig, type CheckpointData, type CheckpointMetadata, type CheckpointTuple, ConfigurationError, GatewayClient, GatewayError, HeartbeatError, HeartbeatManager, KafkaError, MEMORY_PATHS, MarchAgentError, RegistrationError, SERVICES, type ServiceName, Stepper, StructuralStreamer, Surface, TextBlock, VERSION };
|