@web-applets/sdk 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +20 -19
- package/dist/core/applet.d.ts +2 -2
- package/dist/core/shared.d.ts +1 -1
- package/dist/core/shared.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -2,34 +2,24 @@
|
|
2
2
|
|
3
3
|
> An open spec & SDK for creating apps that agents can use.
|
4
4
|
|
5
|
-
|
5
|
+
💌 [Mailing List](https://groups.google.com/a/unternet.co/g/community)
|
6
6
|
|
7
7
|
## What is it?
|
8
8
|
|
9
|
-
Web Applets is an open specification for building software that both humans and AI can understand and use together
|
9
|
+
**Web Applets is an open specification for building software that both humans and AI can understand and use together.** Instead of forcing AI to operate traditional point-and-click apps built for humans, Web Applets creates a new kind of software designed for human-AI collaboration.
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
Web Applets are modular pieces of web software that:
|
14
|
-
|
15
|
-
- **Can be used directly by humans with rich, graphical interfaces**
|
16
|
-
- **Can be understood and operated by AI through a clear protocol**
|
17
|
-
- **Run locally in your environment, not on distant servers**
|
18
|
-
- **Share context and state with their environment**
|
19
|
-
- **Can be freely combined and composed**
|
11
|
+
Think of them a bit like Claude artifacts, but they _do stuff_ & _work anywhere_!
|
20
12
|
|
21
|
-
|
13
|
+
![Demo of a web applets chatbot](./docs/assets/applets-chat-demo.gif)
|
22
14
|
|
23
|
-
|
15
|
+
Think of any web software you use today - maps, documents, shopping, calendars - and imagine if instead of visiting these as separate websites, you could pull them into your own environment where both you and AI could use them together seamlessly. Web applets can do that!
|
24
16
|
|
25
|
-
- **Built on Web Standards:** Create applets using familiar web technologies (HTML, CSS, JavaScript)
|
17
|
+
- **Built on Web Standards:** Create applets using familiar web technologies (HTML, CSS, JavaScript, React, Vue, etc.)
|
26
18
|
- **AI-Native Protocol:** Applets expose their state and actions in a way AI can understand and use
|
27
19
|
- **Rich Interfaces:** Full support for complex graphical UIs, not just text
|
28
20
|
- **Local-First:** Runs in your environment, keeping your data under your control
|
29
21
|
- **Composable:** Applets can work together, sharing context and state
|
30
|
-
- **Open Standard:** Designed for interoperability, not platform lock-in
|
31
|
-
|
32
|
-
Web Applets aims to do for AI-enabled software what the web did for documents - create an open platform where anyone can build, share, and connect applications. We believe the future of software should be built on open collaboration, not tight integration with closed platforms.
|
22
|
+
- **Open Standard:** Designed for interoperability across clients, not platform lock-in
|
33
23
|
|
34
24
|
## Example
|
35
25
|
|
@@ -75,6 +65,17 @@ context.ondata = () => {
|
|
75
65
|
|
76
66
|
Done! If you load this up in the inspector and introduce yourself, it will respond by greeting you.
|
77
67
|
|
68
|
+
To use this applet, we need to load it in our host web app using the SDK. Assuming the applet lives in our public directory, here's what that might look like:
|
69
|
+
|
70
|
+
```js
|
71
|
+
const applet = await applets.load('/helloworld.applet');
|
72
|
+
applet.onstateupdated = (state) => console.log(state);
|
73
|
+
applet.dispatchAction('set_name', { name: 'Web Applets' });
|
74
|
+
// { name: 'Web Applets' }
|
75
|
+
```
|
76
|
+
|
77
|
+
For a live example you can download and play with now, check out the [applets chat demo](https://github.com/unternet-co/applets-chat).
|
78
|
+
|
78
79
|
## Getting started
|
79
80
|
|
80
81
|
Create a new web app with the applets SDK installed. You can do this quickly using our CLI:
|
@@ -93,7 +94,7 @@ Inside the generated folder, you'll find a basic web app setup:
|
|
93
94
|
|
94
95
|
Now if you run `npx @web-applets/inspector`, you should be able to test out your new applet directly. This applet will now work in any environment where the SDK is installed.
|
95
96
|
|
96
|
-
![A screenshot showing the 'playground' editing UI, with a web applets showing 'Hello, Web Applets'](docs/assets/web-applets-
|
97
|
+
![A screenshot showing the 'playground' editing UI, with a web applets showing 'Hello, Web Applets'](docs/assets/web-applets-inspector.png)
|
97
98
|
|
98
99
|
## Integrating Web Applets into your client
|
99
100
|
|
@@ -136,7 +137,7 @@ applet.data = { name: 'Ada Lovelace' };
|
|
136
137
|
|
137
138
|
This is a community project, and we're open to community members discussing the project direction, and submitting code!
|
138
139
|
|
139
|
-
To join the conversation, visit the Applets mailing list
|
140
|
+
To join the conversation, visit the Applets mailing list [here](https://groups.google.com/a/unternet.co/g/community). You can also find more about the company that's kicking off this work at [unternet.co](https://unternet.co)
|
140
141
|
|
141
142
|
## License
|
142
143
|
|
package/dist/core/applet.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AppletAction,
|
1
|
+
import { AppletAction, ActionParams, AppletManifest, AppletDataEvent, AppletResizeEvent, AppletActionsEvent, AppletMessageRelay, AppletReadyEvent } from './shared';
|
2
2
|
export declare function load(url: string, container?: HTMLIFrameElement): Promise<Applet>;
|
3
3
|
export interface AppletOptions {
|
4
4
|
manifest: AppletManifest;
|
@@ -10,7 +10,7 @@ export declare class Applet<T = any> extends EventTarget {
|
|
10
10
|
actions: AppletAction[];
|
11
11
|
container: HTMLIFrameElement;
|
12
12
|
constructor(manifest: AppletManifest, targetWindow: Window);
|
13
|
-
dispatchAction(actionId: string, params?: ActionParams): Promise<AppletMessage>;
|
13
|
+
dispatchAction(actionId: string, params?: ActionParams): Promise<import("./shared").AppletMessage>;
|
14
14
|
get data(): T;
|
15
15
|
set data(data: T);
|
16
16
|
get manifest(): AppletManifest;
|
package/dist/core/shared.d.ts
CHANGED
@@ -91,7 +91,7 @@ export declare class AppletActionMessage extends AppletMessage {
|
|
91
91
|
export declare class AppletInitMessage extends AppletMessage {
|
92
92
|
constructor();
|
93
93
|
}
|
94
|
-
export type AppletMessageType = 'action' | 'actions' | 'data' | 'init' | 'ready' | 'resolve' | 'resize';
|
94
|
+
export type AppletMessageType = 'action' | 'actions' | 'data' | 'init' | 'ready' | 'style' | 'resolve' | 'resize';
|
95
95
|
export type AppletMessageCallback = (message: AppletMessage) => Promise<void> | void;
|
96
96
|
export declare class AppletDataEvent extends Event {
|
97
97
|
data: any;
|
package/dist/core/shared.js
CHANGED
@@ -9,7 +9,8 @@ export async function loadManifest(pageUrl) {
|
|
9
9
|
const parser = new DOMParser();
|
10
10
|
const doc = parser.parseFromString(html, 'text/html');
|
11
11
|
const linkElem = doc.querySelector('link[rel="manifest"]');
|
12
|
-
const
|
12
|
+
const href = linkElem.getAttribute('href');
|
13
|
+
const manifestUrl = parseUrl(href, pageUrl);
|
13
14
|
const manifestRequest = await fetch(manifestUrl);
|
14
15
|
manifest = await manifestRequest.json();
|
15
16
|
// TODO: Add verification this is a valid manifest
|