@tinyclaw/types 1.1.0-dev.7c8f470 → 1.1.0-dev.89e6aff
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 +141 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -428,6 +428,18 @@ export interface ChannelPlugin extends PluginMeta {
|
|
|
428
428
|
* These tools are merged into AgentContext.tools before the agent loop starts.
|
|
429
429
|
*/
|
|
430
430
|
getPairingTools?(secrets: SecretsManagerInterface, configManager: ConfigManagerInterface): Tool[];
|
|
431
|
+
/**
|
|
432
|
+
* Send an outbound message to a user on this channel.
|
|
433
|
+
* Optional — channels that support proactive messaging implement this.
|
|
434
|
+
* The gateway calls this method to deliver nudges, task results, etc.
|
|
435
|
+
*/
|
|
436
|
+
sendToUser?(userId: string, message: OutboundMessage): Promise<void>;
|
|
437
|
+
/**
|
|
438
|
+
* The userId prefix this channel owns (e.g. 'discord', 'friend', 'web').
|
|
439
|
+
* Used by the gateway to route outbound messages to the correct channel.
|
|
440
|
+
* If not provided, the gateway cannot route to this channel.
|
|
441
|
+
*/
|
|
442
|
+
readonly channelPrefix?: string;
|
|
431
443
|
}
|
|
432
444
|
/** A provider plugin registers an additional LLM provider. */
|
|
433
445
|
export interface ProviderPlugin extends PluginMeta {
|
|
@@ -458,6 +470,8 @@ export interface PluginRuntimeContext {
|
|
|
458
470
|
secrets: SecretsManagerInterface;
|
|
459
471
|
/** Config manager for reading/writing channel config. */
|
|
460
472
|
configManager: ConfigManagerInterface;
|
|
473
|
+
/** Outbound gateway for sending proactive messages across channels. */
|
|
474
|
+
gateway?: OutboundGateway;
|
|
461
475
|
}
|
|
462
476
|
/** The three enforcement actions defined by the SHIELD.md v0.1 spec. */
|
|
463
477
|
export type ShieldAction = 'block' | 'require_approval' | 'log';
|
|
@@ -546,6 +560,133 @@ export interface ShieldEngine {
|
|
|
546
560
|
/** Get all loaded threat entries (for debugging/audit). */
|
|
547
561
|
getThreats(): ThreatEntry[];
|
|
548
562
|
}
|
|
563
|
+
/** Priority levels for outbound messages. */
|
|
564
|
+
export type OutboundPriority = 'urgent' | 'normal' | 'low';
|
|
565
|
+
/** The source that triggered the outbound message. */
|
|
566
|
+
export type OutboundSource = 'background_task' | 'sub_agent' | 'reminder' | 'pulse' | 'system' | 'agent';
|
|
567
|
+
/**
|
|
568
|
+
* An outbound message to be delivered to a user.
|
|
569
|
+
*/
|
|
570
|
+
export interface OutboundMessage {
|
|
571
|
+
/** The message content to deliver. */
|
|
572
|
+
content: string;
|
|
573
|
+
/** Priority determines delivery urgency. */
|
|
574
|
+
priority: OutboundPriority;
|
|
575
|
+
/** What triggered this message. */
|
|
576
|
+
source: OutboundSource;
|
|
577
|
+
/** Optional metadata for channel-specific rendering. */
|
|
578
|
+
metadata?: Record<string, unknown>;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Outbound Gateway — routes proactive messages to users across channels.
|
|
582
|
+
*
|
|
583
|
+
* The gateway maintains a registry of channel senders (keyed by userId prefix)
|
|
584
|
+
* and resolves the correct channel for each outbound message by inspecting the
|
|
585
|
+
* userId prefix (e.g. 'discord:123' → Discord channel, 'web:owner' → Web SSE).
|
|
586
|
+
*/
|
|
587
|
+
export interface OutboundGateway {
|
|
588
|
+
/**
|
|
589
|
+
* Register a channel sender for a given userId prefix.
|
|
590
|
+
* Called during boot after channel plugins are loaded.
|
|
591
|
+
*/
|
|
592
|
+
register(prefix: string, sender: ChannelSender): void;
|
|
593
|
+
/**
|
|
594
|
+
* Unregister a channel sender (e.g. during shutdown).
|
|
595
|
+
*/
|
|
596
|
+
unregister(prefix: string): void;
|
|
597
|
+
/**
|
|
598
|
+
* Send a message to a specific user.
|
|
599
|
+
* Resolves the userId prefix → channel sender → delivers.
|
|
600
|
+
*/
|
|
601
|
+
send(userId: string, message: OutboundMessage): Promise<OutboundDeliveryResult>;
|
|
602
|
+
/**
|
|
603
|
+
* Broadcast a message to all registered channels.
|
|
604
|
+
* Each channel decides how to handle the broadcast (e.g. to all connected users).
|
|
605
|
+
*/
|
|
606
|
+
broadcast(message: OutboundMessage): Promise<OutboundDeliveryResult[]>;
|
|
607
|
+
/**
|
|
608
|
+
* Get all registered channel prefixes.
|
|
609
|
+
*/
|
|
610
|
+
getRegisteredChannels(): string[];
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* A channel sender — the outbound delivery contract that each channel implements.
|
|
614
|
+
* Registered with the gateway during boot.
|
|
615
|
+
*/
|
|
616
|
+
export interface ChannelSender {
|
|
617
|
+
/** The channel name (for logging/debugging). */
|
|
618
|
+
readonly name: string;
|
|
619
|
+
/** Send a message to a specific user on this channel. */
|
|
620
|
+
send(userId: string, message: OutboundMessage): Promise<void>;
|
|
621
|
+
/** Broadcast a message to all users on this channel. */
|
|
622
|
+
broadcast?(message: OutboundMessage): Promise<void>;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Result of an outbound delivery attempt.
|
|
626
|
+
*/
|
|
627
|
+
export interface OutboundDeliveryResult {
|
|
628
|
+
/** Whether delivery succeeded. */
|
|
629
|
+
success: boolean;
|
|
630
|
+
/** The channel prefix that handled delivery. */
|
|
631
|
+
channel: string;
|
|
632
|
+
/** The target userId. */
|
|
633
|
+
userId: string;
|
|
634
|
+
/** Error message if delivery failed. */
|
|
635
|
+
error?: string;
|
|
636
|
+
}
|
|
637
|
+
/** Categories of nudge notifications the agent can send proactively. */
|
|
638
|
+
export type NudgeCategory = 'task_complete' | 'task_failed' | 'reminder' | 'check_in' | 'insight' | 'system' | 'software_update' | 'agent_initiated';
|
|
639
|
+
/** A nudge queued for delivery. */
|
|
640
|
+
export interface Nudge {
|
|
641
|
+
/** Unique nudge identifier. */
|
|
642
|
+
id: string;
|
|
643
|
+
/** Target userId (e.g. 'web:owner', 'discord:123'). */
|
|
644
|
+
userId: string;
|
|
645
|
+
/** Category for filtering and user preferences. */
|
|
646
|
+
category: NudgeCategory;
|
|
647
|
+
/** The message content to deliver. */
|
|
648
|
+
content: string;
|
|
649
|
+
/** Delivery priority. */
|
|
650
|
+
priority: OutboundPriority;
|
|
651
|
+
/** When the nudge was created. */
|
|
652
|
+
createdAt: number;
|
|
653
|
+
/** When the nudge should be delivered (0 = immediately). */
|
|
654
|
+
deliverAfter: number;
|
|
655
|
+
/** Whether this nudge has been delivered. */
|
|
656
|
+
delivered: boolean;
|
|
657
|
+
/** Optional metadata for context. */
|
|
658
|
+
metadata?: Record<string, unknown>;
|
|
659
|
+
}
|
|
660
|
+
/** User preferences for nudge behavior. */
|
|
661
|
+
export interface NudgePreferences {
|
|
662
|
+
/** Master switch — disables all nudges when false. */
|
|
663
|
+
enabled: boolean;
|
|
664
|
+
/** Quiet hours start (24h format, e.g. '22:00'). Nudges are held until end. */
|
|
665
|
+
quietHoursStart?: string;
|
|
666
|
+
/** Quiet hours end (24h format, e.g. '08:00'). */
|
|
667
|
+
quietHoursEnd?: string;
|
|
668
|
+
/** Max nudges per hour (rate limiting). */
|
|
669
|
+
maxPerHour: number;
|
|
670
|
+
/** Per-category opt-out. Categories listed here are suppressed. */
|
|
671
|
+
suppressedCategories: NudgeCategory[];
|
|
672
|
+
}
|
|
673
|
+
/** The nudge engine interface. */
|
|
674
|
+
export interface NudgeEngine {
|
|
675
|
+
/** Queue a nudge for delivery. Respects quiet hours and preferences. */
|
|
676
|
+
schedule(nudge: Omit<Nudge, 'id' | 'createdAt' | 'delivered'>): string;
|
|
677
|
+
/** Process pending nudges — deliver those that are due. */
|
|
678
|
+
flush(): Promise<void>;
|
|
679
|
+
/** Get all pending (undelivered) nudges. */
|
|
680
|
+
pending(): Nudge[];
|
|
681
|
+
/** Cancel a pending nudge by id. */
|
|
682
|
+
cancel(id: string): boolean;
|
|
683
|
+
/** Update user preferences. */
|
|
684
|
+
setPreferences(prefs: Partial<NudgePreferences>): void;
|
|
685
|
+
/** Get current preferences. */
|
|
686
|
+
getPreferences(): NudgePreferences;
|
|
687
|
+
/** Shut down the engine (clear timers). */
|
|
688
|
+
stop(): void;
|
|
689
|
+
}
|
|
549
690
|
export interface Signal {
|
|
550
691
|
type: 'positive' | 'negative' | 'correction' | 'preference';
|
|
551
692
|
confidence: number;
|