@theaiplatform/miniapp-sdk 0.2.4 → 0.3.1

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 CHANGED
@@ -1,16 +1,16 @@
1
1
  # The AI Platform Miniapp SDK
2
2
 
3
- `@theaiplatform/miniapp-sdk` is the public package for building portable
4
- miniapps that run in The AI Platform.
3
+ `@theaiplatform/miniapp-sdk` is the TypeScript SDK for building, testing, and
4
+ shipping portable miniapps on The AI Platform.
5
5
 
6
6
  ```bash
7
7
  pnpm add @theaiplatform/miniapp-sdk
8
8
  ```
9
9
 
10
10
  The package provides the host-injected SDK API, isolated surface lifecycle
11
- types, browser helpers, portable React UI components, manifest schema, and the
12
- Rspack/Rslib integration used to produce descriptor-backed Module Federation
13
- targets.
11
+ types, browser helpers, portable React UI components, manifest schema,
12
+ Rstest/Playwright integration, and the Rspack/Rslib integration used to produce
13
+ descriptor-backed Module Federation targets.
14
14
 
15
15
  Start with the [Miniapp SDK documentation](https://docs.theaiplatform.app/miniapps/).
16
16
 
@@ -27,8 +27,28 @@ Start with the [Miniapp SDK documentation](https://docs.theaiplatform.app/miniap
27
27
  - `@theaiplatform/miniapp-sdk/surface`
28
28
  - `@theaiplatform/miniapp-sdk/config`
29
29
  - `@theaiplatform/miniapp-sdk/rspack`
30
+ - `@theaiplatform/miniapp-sdk/testing/rstest`
30
31
  - `@theaiplatform/miniapp-sdk/config-schema.json`
31
32
 
33
+ ## In-app E2E testing in 0.3.1
34
+
35
+ The `/testing/rstest` entry point extends Rstest's Playwright fixtures with a
36
+ host-provided miniapp surface and exact TAP session provenance. Tests can assert
37
+ both the rendered UI and the package/surface identity selected by the Test Lab:
38
+
39
+ ```ts
40
+ import { expect, test } from '@theaiplatform/miniapp-sdk/testing/rstest';
41
+
42
+ test('mounts the miniapp surface', async ({ surface, tap }) => {
43
+ await expect(surface.locator('body')).toBeVisible();
44
+ expect(tap.packageId).toBe('tap_pkg_example_0001');
45
+ expect(tap.surfaceId).toBe('example-surface');
46
+ });
47
+ ```
48
+
49
+ Install `@rstest/core@0.11.3`, `@rstest/playwright@0.11.3`, and Playwright as
50
+ development dependencies when using this optional entry point.
51
+
32
52
  The host API is injected at runtime. Importing an entry point is safe in build
33
53
  tools and tests; host-backed calls fail when used outside a supported runtime.
34
54
  `sdk.storage` provides revisioned non-secret JSON scoped by the host to the
@@ -54,6 +74,28 @@ are not SDK capabilities. Job-key journaling suppresses
54
74
  routine reconnect duplicates, but physical exactly-once printing is impossible;
55
75
  every result therefore carries `physicalExactlyOnce: false`.
56
76
 
77
+ ## Terminal sessions in 0.3.0
78
+
79
+ `sdk.terminal?.v1` is an optional desktop-only terminal session API introduced
80
+ in SDK 0.3.0. It exposes
81
+ only the fixed `workspace-shell` and `neovim` profiles; package code cannot
82
+ choose an executable, environment, native terminal ID, working directory, or
83
+ filesystem path. `open()` returns a host-owned session with ordered binary
84
+ events, acknowledged binary writes, resize, and idempotent close. A dedicated
85
+ per-session channel applies byte credit and bounded buffering, so terminal
86
+ output never uses the ordinary miniapp host-action bridge as a data plane.
87
+ Packages opening a session declare the selected `terminal` profile and the
88
+ `filesystem-mount` resource `conversation-vfs:read-write`, plus the persisted
89
+ `terminal.session.open`, `filesystem.read`, and `filesystem.write` actions.
90
+ Capability discovery is authoritative: the initial host reports both profiles
91
+ unavailable. `workspace-shell` waits for positive conversation-scoped read
92
+ isolation, and `neovim` additionally waits for an integrity-locked runtime.
93
+
94
+ See the
95
+ [terminal API reference](https://docs.theaiplatform.app/miniapps/reference/sdk#terminal-sessions)
96
+ for capability detection, the required descriptor authorization, session
97
+ events, limits, and cleanup.
98
+
57
99
  ## Discovery metadata
58
100
 
59
101
  Descriptor-backed packages may assign up to three unique
@@ -600,27 +600,6 @@
600
600
  ],
601
601
  "type": "string"
602
602
  },
603
- "MiniAppReferencesManifest": {
604
- "additionalProperties": false,
605
- "description": "Manifest that references built TAP miniapp manifests.",
606
- "properties": {
607
- "$schema": {
608
- "description": "Optional JSON Schema reference for editor support.",
609
- "type": ["string", "null"]
610
- },
611
- "references": {
612
- "description": "References to built TAP miniapp manifests.\n\nString shorthand remains available for local and mutable development sources. An\nimmutable remote collection uses the object form (`{ \"url\": ..., \"hash\": ... }`) so\nevery child manifest carries its own SHA-256 integrity boundary.",
613
- "items": {
614
- "$ref": "#/$defs/MiniAppSource"
615
- },
616
- "minItems": 1,
617
- "type": "array"
618
- }
619
- },
620
- "required": ["references"],
621
- "title": "Tap Miniapp References Manifest",
622
- "type": "object"
623
- },
624
603
  "MiniAppSource": {
625
604
  "description": "Absolute URL or local path. Bundle entry paths are resolved relative to the manifest that declares them.",
626
605
  "oneOf": [
@@ -3694,12 +3673,8 @@
3694
3673
  {
3695
3674
  "$ref": "#/$defs/MiniAppBundleManifest",
3696
3675
  "description": "A single miniapp bundle with its runtime entrypoint."
3697
- },
3698
- {
3699
- "$ref": "#/$defs/MiniAppReferencesManifest",
3700
- "description": "A collection manifest that points at built miniapp manifests."
3701
3676
  }
3702
3677
  ],
3703
- "description": "Manifest for a Tap miniapp bundle or a collection of built miniapps.",
3678
+ "description": "Manifest for one Tap package or legacy miniapp bundle.",
3704
3679
  "title": "Tap Miniapp Manifest"
3705
3680
  }
package/dist/index.d.ts CHANGED
@@ -355,6 +355,8 @@ export declare type MiniAppPlatformApi = {
355
355
  credentials?: MiniAppCredentialsApi;
356
356
  /** Desktop host capability; feature-detect before use on portable targets. */
357
357
  printing?: MiniAppReceiptPrintingApi;
358
+ /** Desktop host capability; feature-detect before opening a terminal. */
359
+ terminal?: MiniAppTerminalApi;
358
360
  /** Browser capabilities appear only when the selected target supports them. */
359
361
  auth?: MiniAppAuthApi;
360
362
  vfs?: MiniAppVfsApi;
@@ -620,6 +622,76 @@ export declare type MiniAppStorageSetOptions = MiniAppStorageAddress & {
620
622
  expectedRevision: number | null;
621
623
  };
622
624
 
625
+ export declare type MiniAppTerminalApi = {
626
+ readonly v1: MiniAppTerminalV1Api;
627
+ };
628
+
629
+ /** Versioned, desktop-only host terminal capability. */
630
+ export declare type MiniAppTerminalV1Api = {
631
+ getCapabilities(): Promise<MiniAppTerminalV1Capabilities>;
632
+ open(options: MiniAppTerminalV1OpenOptions): Promise<MiniAppTerminalV1Session>;
633
+ };
634
+
635
+ export declare type MiniAppTerminalV1Capabilities = {
636
+ profiles: MiniAppTerminalV1Profile[];
637
+ limits: MiniAppTerminalV1Limits;
638
+ };
639
+
640
+ export declare type MiniAppTerminalV1DataEvent = {
641
+ type: 'data';
642
+ sequence: number;
643
+ data: Uint8Array;
644
+ };
645
+
646
+ export declare type MiniAppTerminalV1Event = MiniAppTerminalV1DataEvent | MiniAppTerminalV1ExitEvent;
647
+
648
+ export declare type MiniAppTerminalV1ExitEvent = {
649
+ type: 'exit';
650
+ sequence: number;
651
+ code: number | null;
652
+ signal: string | null;
653
+ reason: 'exited' | 'closed' | 'revoked' | 'error';
654
+ };
655
+
656
+ export declare type MiniAppTerminalV1Limits = {
657
+ maxSessionsPerDocument: number;
658
+ maxWriteBytes: number;
659
+ maxOutputBytesInFlight: number;
660
+ maxCols: number;
661
+ maxRows: number;
662
+ };
663
+
664
+ export declare type MiniAppTerminalV1OpenOptions = {
665
+ profile: MiniAppTerminalV1ProfileId;
666
+ cols: number;
667
+ rows: number;
668
+ };
669
+
670
+ export declare type MiniAppTerminalV1Profile = {
671
+ id: MiniAppTerminalV1ProfileId;
672
+ available: boolean;
673
+ unavailableReason: string | null;
674
+ };
675
+
676
+ /** Host-owned terminal runtime profiles exposed by `sdk.terminal.v1`. */
677
+ export declare type MiniAppTerminalV1ProfileId = 'workspace-shell' | 'neovim';
678
+
679
+ export declare type MiniAppTerminalV1ResizeOptions = {
680
+ cols: number;
681
+ rows: number;
682
+ };
683
+
684
+ export declare type MiniAppTerminalV1Session = {
685
+ /** Opaque host-minted session identity; it carries no ambient authority. */
686
+ readonly id: string;
687
+ readonly profile: MiniAppTerminalV1ProfileId;
688
+ /** Ordered output with byte-sized backpressure owned by the host session. */
689
+ readonly events: ReadableStream<MiniAppTerminalV1Event>;
690
+ write(data: Uint8Array): Promise<void>;
691
+ resize(options: MiniAppTerminalV1ResizeOptions): Promise<void>;
692
+ close(): Promise<void>;
693
+ };
694
+
623
695
  export declare type MiniAppUserProfile = {
624
696
  sub: string;
625
697
  name?: string | null;