@assistant-ui/appos 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/dist/chunks/ai-call.js +71 -0
- package/dist/chunks/ai-sdk.js +66 -0
- package/dist/chunks/src.js +1468 -0
- package/dist/index.js +1662 -0
- package/dist/next-page.js +150 -0
- package/dist/next-runtime.js +102 -0
- package/dist/next-server.js +50 -0
- package/dist/next.js +215 -0
- package/dist/pack.js +112 -0
- package/dist/server.js +77 -0
- package/dist/types/packages/appos-client/src/ai-sdk.d.ts +7 -0
- package/dist/types/packages/appos-client/src/index.d.ts +661 -0
- package/dist/types/packages/appos-client/src/theme.d.ts +16 -0
- package/dist/types/packages/appos-client/src/update-text.d.ts +13 -0
- package/dist/types/packages/appos-host/src/AppOSApp.d.ts +20 -0
- package/dist/types/packages/appos-host/src/ai-call.d.ts +31 -0
- package/dist/types/packages/appos-host/src/ai.d.ts +61 -0
- package/dist/types/packages/appos-host/src/embed.d.ts +119 -0
- package/dist/types/packages/appos-host/src/index.d.ts +6 -0
- package/dist/types/packages/appos-host/src/next/adapter.d.ts +43 -0
- package/dist/types/packages/appos-host/src/next/page.d.ts +1 -0
- package/dist/types/packages/appos-host/src/next/routes.d.ts +2 -0
- package/dist/types/packages/appos-host/src/next/runtime.d.ts +11 -0
- package/dist/types/packages/appos-host/src/next/server.d.ts +22 -0
- package/dist/types/packages/appos-host/src/pack.d.ts +16 -0
- package/dist/types/packages/appos-host/src/server.d.ts +23 -0
- package/dist/types/src/lib/ai-spend.d.ts +51 -0
- package/dist/types/src/lib/bundle-meta.d.ts +13 -0
- package/dist/types/src/lib/color-scheme.d.ts +17 -0
- package/dist/types/src/lib/external-link.d.ts +5 -0
- package/dist/types/src/lib/frame-pinch.d.ts +6 -0
- package/dist/types/src/lib/pack.d.ts +17 -0
- package/dist/types/src/lib/swbn/cbor.d.ts +16 -0
- package/dist/types/src/lib/swbn/identity.d.ts +121 -0
- package/dist/types/src/lib/swbn/integrity.d.ts +51 -0
- package/dist/types/src/lib/swbn/keys.d.ts +25 -0
- package/dist/types/src/lib/swbn/manifest.d.ts +144 -0
- package/dist/types/src/lib/swbn/release.d.ts +39 -0
- package/package.json +43 -4
- package/README.md +0 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type PublicKey } from "./keys";
|
|
2
|
+
export declare const MAGIC: Uint8Array<ArrayBuffer>;
|
|
3
|
+
/**
|
|
4
|
+
* "2b\0\0", what Chrome and wbn-sign 0.3.x write and read. (The explainer's
|
|
5
|
+
* text says "2\0\0\0"; implementations use 2b.) The only version accepted.
|
|
6
|
+
*/
|
|
7
|
+
export declare const VERSION: Uint8Array<ArrayBuffer>;
|
|
8
|
+
export interface BundleSignature {
|
|
9
|
+
key: PublicKey;
|
|
10
|
+
signature: Uint8Array;
|
|
11
|
+
/** The signature's attributes map, as raw CBOR. */
|
|
12
|
+
attributes: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
export interface SignedBundle {
|
|
15
|
+
webBundleId: string;
|
|
16
|
+
signatures: BundleSignature[];
|
|
17
|
+
/** The integrity block with an empty signature list: part of what's signed. */
|
|
18
|
+
stripped: Uint8Array;
|
|
19
|
+
/** The .wbn after the integrity block. */
|
|
20
|
+
bundle: Uint8Array;
|
|
21
|
+
}
|
|
22
|
+
/** True if the bytes start with the integrity block magic. */
|
|
23
|
+
export declare function isSigned(bytes: Uint8Array): boolean;
|
|
24
|
+
/** True if the bytes look like an unsigned Web Bundle. */
|
|
25
|
+
export declare function isWebBundle(bytes: Uint8Array): boolean;
|
|
26
|
+
/** Parses the integrity block. Does not check any signature. */
|
|
27
|
+
export declare function parseSignedBundle(bytes: Uint8Array): SignedBundle;
|
|
28
|
+
/** The .wbn inside a signed bundle, or the bytes as they are if unsigned. */
|
|
29
|
+
export declare function innerBundle(bytes: Uint8Array): Uint8Array;
|
|
30
|
+
/** The bytes a signature covers. */
|
|
31
|
+
export declare function dataToBeSigned(bundleHash: Uint8Array, stripped: Uint8Array, attributes: Uint8Array): Uint8Array;
|
|
32
|
+
export declare function sha512(bytes: Uint8Array): Promise<Uint8Array>;
|
|
33
|
+
/** Decompresses a 33-byte P-256 point to the 65-byte uncompressed form. */
|
|
34
|
+
export declare function decompressP256(raw: Uint8Array): Uint8Array;
|
|
35
|
+
/** DER ECDSA-Sig-Value to raw r||s (64 bytes). Raw input passes through. */
|
|
36
|
+
export declare function derToRaw(sig: Uint8Array): Uint8Array;
|
|
37
|
+
/**
|
|
38
|
+
* Checks every signature against the bundle. Throws unless all of them are
|
|
39
|
+
* valid. Returns the signing keys as "ed25519:<base64url>" strings. Says
|
|
40
|
+
* nothing about whether the keys may sign for the bundle's id.
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifySignatures(signed: SignedBundle): Promise<string[]>;
|
|
43
|
+
/** Something that can sign: a WebCrypto key pair, or a Node key in the CLI. */
|
|
44
|
+
export interface Signer {
|
|
45
|
+
key: PublicKey;
|
|
46
|
+
sign(data: Uint8Array): Promise<Uint8Array>;
|
|
47
|
+
}
|
|
48
|
+
/** Wraps an Ed25519 WebCrypto private key (extractable or not). */
|
|
49
|
+
export declare function webCryptoSigner(privateKey: CryptoKey, publicRaw: Uint8Array): Signer;
|
|
50
|
+
/** Signs a .wbn (or re-signs a .swbn's inner bundle) into a .swbn. */
|
|
51
|
+
export declare function signBundle(bytes: Uint8Array, webBundleId: string, signers: Signer[]): Promise<Uint8Array>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type KeyType = "ed25519" | "ecdsa-p256";
|
|
2
|
+
export interface PublicKey {
|
|
3
|
+
type: KeyType;
|
|
4
|
+
raw: Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
/** RFC 4648 base32, lowercase, no padding. */
|
|
7
|
+
export declare function base32(bytes: Uint8Array): string;
|
|
8
|
+
export declare function toBase64Url(bytes: Uint8Array): string;
|
|
9
|
+
/** Decodes base64 or base64url, padded or not. Throws on anything else. */
|
|
10
|
+
export declare function fromBase64(text: string): Uint8Array;
|
|
11
|
+
export declare function formatKey(key: PublicKey): string;
|
|
12
|
+
/** Parses "ed25519:<base64>" (or "ecdsa-p256:…"). Returns undefined if invalid. */
|
|
13
|
+
export declare function parseKey(text: unknown): PublicKey | undefined;
|
|
14
|
+
/** The canonical text form of a key string, or undefined if invalid. */
|
|
15
|
+
export declare function normalizeKey(text: unknown): string | undefined;
|
|
16
|
+
export declare function sha256(bytes: Uint8Array): Promise<Uint8Array>;
|
|
17
|
+
/** Decodes lowercase unpadded base32. Undefined unless it round-trips. */
|
|
18
|
+
export declare function fromBase32(text: string): Uint8Array | undefined;
|
|
19
|
+
export declare function base58btc(bytes: Uint8Array): string;
|
|
20
|
+
export declare function fromBase58btc(text: string): Uint8Array | undefined;
|
|
21
|
+
/** "z6Mk…" (Ed25519) or "zDn…" (P-256, compressed) multibase to a key. */
|
|
22
|
+
export declare function parseMultikey(text: unknown): PublicKey | undefined;
|
|
23
|
+
export declare function toMultikey(key: PublicKey): string;
|
|
24
|
+
/** A JWK (OKP/Ed25519 or EC/P-256) to a key. */
|
|
25
|
+
export declare function parseJwk(jwk: unknown): PublicKey | undefined;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export { compareVersions, parseVersion } from "./release";
|
|
2
|
+
/** appos.actors: { Name: { main } }, the app's LiveWorkers (01-spec/08-live-workers.md). */
|
|
3
|
+
export type LiveWorkersInfo = Record<string, {
|
|
4
|
+
main: string;
|
|
5
|
+
}>;
|
|
6
|
+
/** The code a host runs for this app's LiveWorkers: their one module and its classes. */
|
|
7
|
+
export interface BackendInfo {
|
|
8
|
+
/** The LiveWorkers' module, a path inside the bundle ("board.js"). */
|
|
9
|
+
main: string;
|
|
10
|
+
/** The classes it exports, one per LiveWorker name. */
|
|
11
|
+
classes: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* appos.server: one fetch handler (`export default { fetch }`) for the paths
|
|
15
|
+
* it serves, such as a Next.js app's route handlers (docs/nextjs.md). The
|
|
16
|
+
* cloud runs it as the app's server Worker; without a cloud the page runs it.
|
|
17
|
+
*/
|
|
18
|
+
export interface ServerInfo {
|
|
19
|
+
/** The module, a path inside the bundle ("_appos/server.js"). */
|
|
20
|
+
main: string;
|
|
21
|
+
/** The paths it answers, as Next.js route patterns ("/api/items/[id]"). */
|
|
22
|
+
routes: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface ManifestInfo {
|
|
25
|
+
/** appos.did; non-strings are stringified so they never match a DID. */
|
|
26
|
+
did?: string;
|
|
27
|
+
/** "version", if present (validated by verifyBundle, see release.ts). */
|
|
28
|
+
version?: string;
|
|
29
|
+
/** appos.build, if present and a positive integer. */
|
|
30
|
+
build?: number;
|
|
31
|
+
/** Why appos.build was refused, when it is present but malformed. */
|
|
32
|
+
buildError?: string;
|
|
33
|
+
/** appos.channels: more update feeds by name (the default is appos.update). */
|
|
34
|
+
channels?: Record<string, string>;
|
|
35
|
+
/** appos.update: the update manifest URL, if it is a string. */
|
|
36
|
+
update?: string;
|
|
37
|
+
/** appos.home: true when the app has a home file (01-spec/01-app-files.md, "Home files"). */
|
|
38
|
+
home?: true;
|
|
39
|
+
/** appos.multiple: true when the app opens several files at once (a workspace). */
|
|
40
|
+
multiple?: true;
|
|
41
|
+
/**
|
|
42
|
+
* appos.extension: what the app's files show after their name ("md", "board"), for show only: a file's app (its
|
|
43
|
+
* DID) is its type, and its path is the same with or without it (docs/backend.md, "File paths").
|
|
44
|
+
*/
|
|
45
|
+
extension?: string;
|
|
46
|
+
/**
|
|
47
|
+
* appos.placement "server": the app's files work best on an always-on server host (a git server, an MCP server), so
|
|
48
|
+
* the New dialog warns before one goes on a device. Absent: no preference.
|
|
49
|
+
*/
|
|
50
|
+
placement?: "server";
|
|
51
|
+
/** appos.permissions: browser features the app's frame gets (FRAME_PERMISSIONS). */
|
|
52
|
+
permissions?: FramePermission[];
|
|
53
|
+
/** appos.embeddable: the pages of the app other apps may show inside theirs (appos.embed), by path. */
|
|
54
|
+
embeddable?: string[];
|
|
55
|
+
/** appos.actors as the code to run (module and classes), when well formed. */
|
|
56
|
+
backend?: BackendInfo;
|
|
57
|
+
/** appos.actors. */
|
|
58
|
+
actors?: LiveWorkersInfo;
|
|
59
|
+
/** appos.server, when well formed. */
|
|
60
|
+
server?: ServerInfo;
|
|
61
|
+
/**
|
|
62
|
+
* appos.openWeb: the app may ask its files' owners to open a file to the open web (docs/backend.md, "Open to the
|
|
63
|
+
* web"), with the largest request body such a request may carry. Declaring it opens nothing.
|
|
64
|
+
*/
|
|
65
|
+
openWeb?: OpenWebInfo;
|
|
66
|
+
/**
|
|
67
|
+
* appos.mcp: true when each of the app's files serves an MCP server for agents at its address + /mcp, the
|
|
68
|
+
* LiveWorker's onMcp(request) (docs/backend.md, "MCP"). The manifest is the registration.
|
|
69
|
+
*/
|
|
70
|
+
mcp?: true;
|
|
71
|
+
/** Why appos.actors, appos.server, appos.network, appos.openWeb or appos.mcp was refused. */
|
|
72
|
+
backendError?: string;
|
|
73
|
+
/**
|
|
74
|
+
* appos.network: the hosts the LiveWorkers may fetch (https only), or "none".
|
|
75
|
+
* Missing means "none": a LiveWorker reaches nothing it did not declare.
|
|
76
|
+
*/
|
|
77
|
+
network?: "none" | string[];
|
|
78
|
+
}
|
|
79
|
+
/** What appos.permissions may list, and the iframe allow feature each delegates. */
|
|
80
|
+
export declare const FRAME_PERMISSIONS: {
|
|
81
|
+
readonly "local-network": "local-network-access";
|
|
82
|
+
};
|
|
83
|
+
export type FramePermission = keyof typeof FRAME_PERMISSIONS;
|
|
84
|
+
/** appos.permissions: the known names, once each; anything else is ignored (a newer appOS may know it). */
|
|
85
|
+
export declare function parsePermissions(v: unknown): FramePermission[] | undefined;
|
|
86
|
+
/** appos.embeddable: the paths it lists, once each, at most 16; anything else is ignored. */
|
|
87
|
+
export declare function parseEmbeddable(v: unknown): string[] | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* What every app's frame gets: copying (share links and the like) and keeping the screen on while it's in front (a
|
|
90
|
+
* dictation, a recipe). Without screen-wake-lock Chrome refuses navigator.wakeLock in the frame by permissions policy.
|
|
91
|
+
*/
|
|
92
|
+
/** appos.extension: 1 to 16 lowercase letters or digits, no dot. */
|
|
93
|
+
export declare const EXTENSION_RE: RegExp;
|
|
94
|
+
export declare const BASE_FRAME_ALLOW: readonly ["clipboard-write", "screen-wake-lock"];
|
|
95
|
+
/** The allow features for an app's frame: what it declared (FRAME_PERMISSIONS). */
|
|
96
|
+
export declare function frameAllow(permissions: readonly FramePermission[] | undefined): string[];
|
|
97
|
+
export declare const MAX_BACKEND_CLASSES = 16;
|
|
98
|
+
export declare const MAX_NETWORK_HOSTS = 32;
|
|
99
|
+
/**
|
|
100
|
+
* appos.actors: { Name: { main } }. v1 runs one bundled module per app, so
|
|
101
|
+
* every LiveWorker names the same main. Returns the normalized LiveWorkers or an error.
|
|
102
|
+
*/
|
|
103
|
+
export declare function parseLiveWorkers(v: unknown): {
|
|
104
|
+
actors: LiveWorkersInfo;
|
|
105
|
+
main: string;
|
|
106
|
+
} | {
|
|
107
|
+
error: string;
|
|
108
|
+
};
|
|
109
|
+
export declare const MAX_SERVER_ROUTES = 256;
|
|
110
|
+
/** appos.server: { main, routes }. Returns it normalized, or an error. */
|
|
111
|
+
export declare function parseServer(v: unknown): ServerInfo | {
|
|
112
|
+
error: string;
|
|
113
|
+
};
|
|
114
|
+
/** appos.openWeb: { maxBody } in bytes; the default and the most a request from the open web may carry. */
|
|
115
|
+
export interface OpenWebInfo {
|
|
116
|
+
maxBody: number;
|
|
117
|
+
}
|
|
118
|
+
export declare const OPEN_WEB_DEFAULT_BODY: number;
|
|
119
|
+
/** The most the platform streams to a LiveWorker in one request from the open web (the Workers runtime's own cap). */
|
|
120
|
+
export declare const OPEN_WEB_MAX_BODY: number;
|
|
121
|
+
/** appos.openWeb: true, {} or { maxBody: <bytes> }, the body capped at OPEN_WEB_MAX_BODY. */
|
|
122
|
+
export declare function parseOpenWeb(v: unknown): OpenWebInfo | {
|
|
123
|
+
error: string;
|
|
124
|
+
};
|
|
125
|
+
type BackendFields = "backend" | "backendError" | "network" | "actors" | "server" | "openWeb" | "mcp";
|
|
126
|
+
/** Validates appos.actors, appos.server, appos.network, appos.openWeb and appos.mcp; never throws. */
|
|
127
|
+
export declare function parseBackend(appos: Record<string, unknown>): Pick<ManifestInfo, BackendFields>;
|
|
128
|
+
/** A channel name: lowercase, like "beta" or "dev". */
|
|
129
|
+
export declare const CHANNEL_NAME: RegExp;
|
|
130
|
+
/** The channel appos.update is. */
|
|
131
|
+
export declare const DEFAULT_CHANNEL = "stable";
|
|
132
|
+
export declare const MAX_CHANNELS = 8;
|
|
133
|
+
/**
|
|
134
|
+
* appos.channels: { name: feed URL }. Malformed entries, and "stable" (that
|
|
135
|
+
* is appos.update), are dropped; the URLs are checked when used.
|
|
136
|
+
*/
|
|
137
|
+
export declare function parseChannels(v: unknown): Record<string, string> | undefined;
|
|
138
|
+
/** Reads the app's manifest from a .wbn: the <link rel=manifest>, else
|
|
139
|
+
* /manifest.webmanifest or /manifest.json. */
|
|
140
|
+
export declare function readManifest(wbn: Uint8Array): ManifestInfo;
|
|
141
|
+
/** One file of a .wbn by path ("/backend.js"), or undefined if it has none. */
|
|
142
|
+
export declare function readBundleFile(wbn: Uint8Array, path: string): Uint8Array | undefined;
|
|
143
|
+
/** The manifest's appos.did, read from a .wbn. */
|
|
144
|
+
export declare function manifestDid(wbn: Uint8Array): string | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** A bundle's place in its app's history. */
|
|
2
|
+
export interface Release {
|
|
3
|
+
/** The manifest's "version": display only once `build` is set. */
|
|
4
|
+
version?: string;
|
|
5
|
+
/** appos.build. */
|
|
6
|
+
build?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Largest build number accepted (fits every store and header). */
|
|
9
|
+
export declare const MAX_BUILD: number;
|
|
10
|
+
/** Longest display version accepted. */
|
|
11
|
+
export declare const MAX_VERSION_LENGTH = 64;
|
|
12
|
+
/** "1.2.3" -> [1, 2, 3]. Undefined if it is not 1–4 dot-separated integers. */
|
|
13
|
+
export declare function parseVersion(v: string): number[] | undefined;
|
|
14
|
+
/** Compares versions; missing parts are 0 ("1" == "1.0"). */
|
|
15
|
+
export declare function compareVersions(a: number[], b: number[]): number;
|
|
16
|
+
/** appos.build: a positive integer, or undefined. */
|
|
17
|
+
export declare function parseBuild(v: unknown): number | undefined;
|
|
18
|
+
/** A display version: 1–64 characters, no control characters. */
|
|
19
|
+
export declare function isDisplayVersion(v: unknown): v is string;
|
|
20
|
+
/**
|
|
21
|
+
* Why a bundle's release is not acceptable, or undefined. With a build the
|
|
22
|
+
* version is display text; without one it must be a dot-number (missing
|
|
23
|
+
* counts as "0"), because it is what orders the app.
|
|
24
|
+
*/
|
|
25
|
+
export declare function releaseError(r: Release): string | undefined;
|
|
26
|
+
/** A stored release: older records kept only the version string. */
|
|
27
|
+
export declare function asRelease(r: Release | string | undefined | null): Release;
|
|
28
|
+
/**
|
|
29
|
+
* -1, 0 or 1. Both with builds: by build. Neither: by dot-version (one
|
|
30
|
+
* that doesn't parse counts as 0). Mixed: the one with a build is newer.
|
|
31
|
+
*/
|
|
32
|
+
export declare function compareReleases(a: Release, b: Release): number;
|
|
33
|
+
export declare const releaseLess: (a: Release, b: Release) => boolean;
|
|
34
|
+
/** The same build: equal builds, or (no builds) the same version text. */
|
|
35
|
+
export declare function sameRelease(a: Release, b: Release): boolean;
|
|
36
|
+
/** "2.3.1 (42)", or the version alone for apps without builds. */
|
|
37
|
+
export declare function releaseLabel(r: Release): string;
|
|
38
|
+
/** The higher of two releases (ties keep `a`). */
|
|
39
|
+
export declare function maxRelease(a: Release, b: Release): Release;
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/appos",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Embed appOS apps in a website: <AppOSApp src>, host services, default permissions",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/assistant-ui/appOS.git",
|
|
9
|
+
"directory": "packages/appos-host"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types/packages/appos-host/src/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./server": {
|
|
21
|
+
"types": "./dist/types/packages/appos-host/src/server.d.ts",
|
|
22
|
+
"default": "./dist/server.js"
|
|
23
|
+
},
|
|
24
|
+
"./pack": {
|
|
25
|
+
"types": "./dist/types/packages/appos-host/src/pack.d.ts",
|
|
26
|
+
"default": "./dist/pack.js"
|
|
27
|
+
},
|
|
28
|
+
"./next": {
|
|
29
|
+
"types": "./dist/types/packages/appos-host/src/next/adapter.d.ts",
|
|
30
|
+
"default": "./dist/next.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"esbuild": "0.28.2",
|
|
35
|
+
"wbn": "0.0.10"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": "^19.0.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"react": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
package/README.md
DELETED