@frockbot/applet-sdk 0.7.160 → 0.7.161
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/package.json +1 -1
- package/plugin/index.d.ts +256 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frockbot/applet-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.161",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Authoring SDK for FrockBot Applets: schema-first Durable Object server, TanStack DB client, component kit, linter, and the build pipeline.",
|
package/plugin/index.d.ts
CHANGED
|
@@ -442,60 +442,294 @@ export interface PluginHookContext extends PluginContext {
|
|
|
442
442
|
readonly event: PluginHookEvent;
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
+
/** The kinds of Turn the kernel admits. */
|
|
446
|
+
export type TurnType = "chat" | "agent" | "automation" | "subagent";
|
|
447
|
+
|
|
448
|
+
/** The agent a hook is running inside, as a hook payload carries it. */
|
|
449
|
+
export interface AgentSnapshot {
|
|
450
|
+
botId: string;
|
|
451
|
+
agentId: string;
|
|
452
|
+
sessionId: string;
|
|
453
|
+
status: "idle" | "running" | "disposed";
|
|
454
|
+
}
|
|
455
|
+
|
|
445
456
|
/** One step of the loop, as a hook payload carries it. */
|
|
446
|
-
export interface StepSnapshot {
|
|
457
|
+
export interface StepSnapshot extends AgentSnapshot {
|
|
458
|
+
compositionGenerationId: string;
|
|
459
|
+
turn: number;
|
|
447
460
|
step: number;
|
|
448
|
-
|
|
461
|
+
turnType: TurnType;
|
|
462
|
+
subagentRole?: string;
|
|
449
463
|
}
|
|
450
464
|
|
|
451
|
-
/**
|
|
465
|
+
/**
|
|
466
|
+
* One tool as the model is offered it. Exactly these three members: a tool
|
|
467
|
+
* returned from `agent/tool-exposure` with any other member is refused.
|
|
468
|
+
*/
|
|
452
469
|
export interface ToolSchema {
|
|
453
470
|
name: string;
|
|
454
471
|
description: string;
|
|
455
472
|
inputSchema: JsonSchema;
|
|
456
|
-
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/** What the system prompt is being assembled for. */
|
|
476
|
+
export interface PromptAssemblyContext {
|
|
477
|
+
sessionId: string;
|
|
478
|
+
provider: string;
|
|
479
|
+
model: string;
|
|
480
|
+
turnType: TurnType;
|
|
481
|
+
subagentRole?: string;
|
|
482
|
+
/** The step being assembled (1-based) and the last step the loop will run. */
|
|
483
|
+
step?: { current: number; max: number };
|
|
484
|
+
/** The Turn's deadline and the assembly instant, Unix epoch milliseconds. */
|
|
485
|
+
deadline?: { at: number; now: number };
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** The assembled system prompt: its text, and the sections it was built from. */
|
|
489
|
+
export interface PromptAssembly {
|
|
490
|
+
text: string;
|
|
491
|
+
sections: Array<{ id: string; text: string }>;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/** One tool call the model made. `input` is whatever the model sent. */
|
|
495
|
+
export interface ToolCall {
|
|
496
|
+
id: string;
|
|
497
|
+
name: string;
|
|
498
|
+
input: unknown;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/** The call a tool hook is about, minus anything live. */
|
|
502
|
+
export interface ToolCallContext {
|
|
503
|
+
botId: string;
|
|
504
|
+
agentId: string;
|
|
505
|
+
sessionId: string;
|
|
506
|
+
compositionGenerationId: string;
|
|
507
|
+
effectId: string;
|
|
508
|
+
toolCall?: ToolCall;
|
|
509
|
+
turnType: TurnType;
|
|
510
|
+
subagentRole?: string;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* The durable root an attachment's bytes live in, as the kernel records it.
|
|
515
|
+
* Unlike {@link WorkspaceRoot}, which a Plugin names and the authority
|
|
516
|
+
* completes, this one carries the User id.
|
|
517
|
+
*/
|
|
518
|
+
export type AttachmentRoot =
|
|
519
|
+
| { kind: "bot-instructions"; userId: string; botId: string }
|
|
520
|
+
| { kind: "user-instructions"; userId: string }
|
|
521
|
+
| { kind: "bot-memory"; userId: string; botId: string }
|
|
522
|
+
| { kind: "user-memory"; userId: string }
|
|
523
|
+
| { kind: "project-memory"; userId: string; projectId: string }
|
|
524
|
+
| {
|
|
525
|
+
kind: "package-declared";
|
|
526
|
+
userId: string;
|
|
527
|
+
packageId: string;
|
|
528
|
+
rootId: string;
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
/** Where an attachment's bytes live: a durable root and a relative path. */
|
|
532
|
+
export interface AttachmentPath {
|
|
533
|
+
root: AttachmentRoot;
|
|
534
|
+
path: string;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/** A binary a tool produced, named by where it lives rather than by its bytes. */
|
|
538
|
+
export interface ToolAttachment {
|
|
539
|
+
kind: "image";
|
|
540
|
+
mediaType: "image/png" | "image/jpeg" | "image/webp";
|
|
541
|
+
workspacePath: AttachmentPath;
|
|
542
|
+
contentHash: string;
|
|
543
|
+
bytes: number;
|
|
544
|
+
/** Resolved bytes, present only in memory for one model request. */
|
|
545
|
+
dataBase64?: string;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* A tool's settled result, as the loop records it. Not {@link ToolResult},
|
|
550
|
+
* which is what a Plugin's own `execute` answers with.
|
|
551
|
+
*/
|
|
552
|
+
export interface ToolCallResult {
|
|
553
|
+
content: string;
|
|
554
|
+
isError: boolean;
|
|
555
|
+
/** The Turn ends once this result is recorded. */
|
|
556
|
+
endsTurn?: boolean;
|
|
557
|
+
attachments?: ToolAttachment[];
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Whether a call is ready to run or already answered. A hook may deny a ready
|
|
562
|
+
* call with a result; it may not lift a denial or change the call.
|
|
563
|
+
*/
|
|
564
|
+
export type ToolPreparation =
|
|
565
|
+
| { kind: "ready"; call: ToolCall; idempotent: boolean }
|
|
566
|
+
| { kind: "denied"; call: ToolCall; result: ToolCallResult };
|
|
567
|
+
|
|
568
|
+
/** Provider content the kernel replays on later turns; opaque to a Plugin. */
|
|
569
|
+
export interface ModelReplayState {
|
|
570
|
+
connectionId?: string;
|
|
571
|
+
connectionGeneration?: string;
|
|
572
|
+
provider: string;
|
|
573
|
+
model: string;
|
|
574
|
+
content: string;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** One message in a model request. */
|
|
578
|
+
export type ModelMessage =
|
|
579
|
+
| { role: "user"; content: string }
|
|
580
|
+
| {
|
|
581
|
+
role: "assistant";
|
|
582
|
+
content: string;
|
|
583
|
+
toolCalls: ToolCall[];
|
|
584
|
+
providerState?: ModelReplayState;
|
|
585
|
+
}
|
|
586
|
+
| {
|
|
587
|
+
role: "tool";
|
|
588
|
+
callId: string;
|
|
589
|
+
name: string;
|
|
590
|
+
content: string;
|
|
591
|
+
isError: boolean;
|
|
592
|
+
attachments?: ToolAttachment[];
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/** The JSON Schema subset a structured response may be held to. */
|
|
596
|
+
export type StructuredOutputSchema =
|
|
597
|
+
| {
|
|
598
|
+
type: "object";
|
|
599
|
+
properties?: Record<string, StructuredOutputSchema>;
|
|
600
|
+
required?: string[];
|
|
601
|
+
additionalProperties?: boolean;
|
|
602
|
+
enum?: unknown[];
|
|
603
|
+
title?: string;
|
|
604
|
+
description?: string;
|
|
605
|
+
}
|
|
606
|
+
| {
|
|
607
|
+
type: "array";
|
|
608
|
+
items: StructuredOutputSchema;
|
|
609
|
+
enum?: unknown[];
|
|
610
|
+
title?: string;
|
|
611
|
+
description?: string;
|
|
612
|
+
}
|
|
613
|
+
| {
|
|
614
|
+
type: "string" | "number" | "boolean";
|
|
615
|
+
enum?: unknown[];
|
|
616
|
+
title?: string;
|
|
617
|
+
description?: string;
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
export type ModelResponseFormat =
|
|
621
|
+
| { type: "json_schema"; name: string; schema: StructuredOutputSchema }
|
|
622
|
+
| { type: "json" };
|
|
623
|
+
|
|
624
|
+
/** The Connection a request was admitted under. */
|
|
625
|
+
export interface ModelBinding {
|
|
626
|
+
connectionId: string;
|
|
627
|
+
connectionGeneration?: string;
|
|
628
|
+
catalogGeneration?: string;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* One normalized model request. A hook may change `system`, `messages`,
|
|
633
|
+
* `tools` and `responseFormat`; a replacement that changes `requestId`,
|
|
634
|
+
* `provider`, `model` or `modelBinding` is refused.
|
|
635
|
+
*/
|
|
636
|
+
export interface ModelRequest {
|
|
637
|
+
requestId: string;
|
|
638
|
+
provider: string;
|
|
639
|
+
model: string;
|
|
640
|
+
system: string;
|
|
641
|
+
messages: ModelMessage[];
|
|
642
|
+
tools: ToolSchema[];
|
|
643
|
+
responseFormat?: ModelResponseFormat;
|
|
644
|
+
modelBinding?: ModelBinding;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/** A Bot's look as the person picked it. */
|
|
648
|
+
export type BotLook = "inherit" | "studio" | "custom";
|
|
649
|
+
|
|
650
|
+
/** The named looks a theme document is compiled from. */
|
|
651
|
+
export type ThemeLook = "ink" | "paper" | "studio";
|
|
652
|
+
|
|
653
|
+
/** Every colour is `#rrggbb`. */
|
|
654
|
+
export interface ThemeSurfaces {
|
|
655
|
+
window: string;
|
|
656
|
+
surface: string;
|
|
657
|
+
raised: string;
|
|
658
|
+
text: string;
|
|
659
|
+
muted: string;
|
|
660
|
+
line: string;
|
|
661
|
+
accent: string;
|
|
662
|
+
onAccent: string;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
export interface ThemeTokens {
|
|
666
|
+
surfaces: ThemeSurfaces;
|
|
667
|
+
type: "manrope" | "inter";
|
|
668
|
+
bubbles: { bot: "plain" | "raised"; me: "accent" | "tint" };
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** Tokens that take over from `after`, a 24-hour `HH:MM` time of day. */
|
|
672
|
+
export interface ThemePhase {
|
|
673
|
+
after: string;
|
|
674
|
+
tokens: ThemeTokens;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* The closed document the client paints a Bot from. The kernel re-validates a
|
|
679
|
+
* `theme/assemble` replacement and refuses one that has any other member,
|
|
680
|
+
* uses `approval`, `billing`, `Stop` or `grants` as a key anywhere, puts
|
|
681
|
+
* `text` under 4.5:1 against `window` or `surface`, `muted` under 3:1
|
|
682
|
+
* against `window`, or `onAccent` under 4.5:1 against `accent`, or has more
|
|
683
|
+
* than 24 `phases`. A refused document is charged to every Plugin that wraps
|
|
684
|
+
* `theme/assemble`, and the Bot keeps its last good theme.
|
|
685
|
+
*/
|
|
686
|
+
export interface ThemeDocument {
|
|
687
|
+
schemaVersion: 1;
|
|
688
|
+
look: ThemeLook;
|
|
689
|
+
tokens: ThemeTokens;
|
|
690
|
+
phases?: ThemePhase[];
|
|
457
691
|
}
|
|
458
692
|
|
|
459
693
|
/**
|
|
460
694
|
* What each hook receives, and the one value it may replace. A hook returns
|
|
461
695
|
* `undefined` to leave the value alone, or the replacement — the *whole*
|
|
462
696
|
* value, not a patch. A later Plugin sees an earlier Plugin's replacement.
|
|
463
|
-
* `agent/turn-stopping` is a notification:
|
|
697
|
+
* `agent/turn-stopping` is a notification: it may not replace anything.
|
|
464
698
|
*/
|
|
465
699
|
export interface PluginHookPayloads {
|
|
466
700
|
"system-prompt/assemble": {
|
|
467
|
-
context:
|
|
468
|
-
assembly:
|
|
701
|
+
context: PromptAssemblyContext;
|
|
702
|
+
assembly: PromptAssembly;
|
|
469
703
|
};
|
|
470
704
|
"agent/tool-exposure": { step: StepSnapshot; tools: ToolSchema[] };
|
|
471
|
-
"agent/request": { step: StepSnapshot; request:
|
|
705
|
+
"agent/request": { step: StepSnapshot; request: ModelRequest };
|
|
472
706
|
"tools/pre-execute": {
|
|
473
|
-
call:
|
|
474
|
-
context:
|
|
475
|
-
preparation:
|
|
707
|
+
call: ToolCall;
|
|
708
|
+
context: ToolCallContext;
|
|
709
|
+
preparation: ToolPreparation;
|
|
476
710
|
};
|
|
477
711
|
"tools/post-execute": {
|
|
478
|
-
call:
|
|
479
|
-
context:
|
|
480
|
-
result:
|
|
712
|
+
call: ToolCall;
|
|
713
|
+
context: ToolCallContext;
|
|
714
|
+
result: ToolCallResult;
|
|
481
715
|
};
|
|
482
|
-
"agent/turn-stopping": { agent:
|
|
716
|
+
"agent/turn-stopping": { agent: AgentSnapshot; turn: number };
|
|
483
717
|
"theme/assemble": {
|
|
484
|
-
document:
|
|
485
|
-
look:
|
|
718
|
+
document: ThemeDocument;
|
|
719
|
+
look: BotLook;
|
|
486
720
|
now: string;
|
|
487
721
|
timezone: string;
|
|
488
722
|
};
|
|
489
723
|
}
|
|
490
724
|
|
|
491
725
|
export interface PluginHookReplacements {
|
|
492
|
-
"system-prompt/assemble":
|
|
726
|
+
"system-prompt/assemble": PromptAssembly;
|
|
493
727
|
"agent/tool-exposure": ToolSchema[];
|
|
494
|
-
"agent/request":
|
|
495
|
-
"tools/pre-execute":
|
|
496
|
-
"tools/post-execute":
|
|
728
|
+
"agent/request": ModelRequest;
|
|
729
|
+
"tools/pre-execute": ToolPreparation;
|
|
730
|
+
"tools/post-execute": ToolCallResult;
|
|
497
731
|
"agent/turn-stopping": never;
|
|
498
|
-
"theme/assemble":
|
|
732
|
+
"theme/assemble": ThemeDocument;
|
|
499
733
|
}
|
|
500
734
|
|
|
501
735
|
export type PluginHook<Event extends PluginHookEvent> = (
|