dokiworlds-app-sdk 0.1.0 → 0.4.0
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/GUIDE.md +257 -0
- package/README.md +48 -26
- package/WORLD_PACKAGE_GUIDE.md +116 -0
- package/package.json +24 -20
- package/src/index.d.ts +86 -82
- package/src/index.js +310 -285
- package/src/llm_config.d.ts +13 -0
- package/src/llm_config.js +71 -0
package/src/index.d.ts
CHANGED
|
@@ -1,82 +1,86 @@
|
|
|
1
|
-
export declare const APP_PROTOCOL: "dokiworld.app";
|
|
2
|
-
export declare const APP_PROTOCOL_VERSION: 2;
|
|
3
|
-
export declare const DEFAULT_APP_LAUNCH_TIMEOUT_MS: number;
|
|
4
|
-
|
|
5
|
-
export interface AppContract<Data = unknown> {
|
|
6
|
-
contract: string;
|
|
7
|
-
version: number;
|
|
8
|
-
data: Data;
|
|
9
|
-
}
|
|
10
|
-
export interface AppLaunchRequest<Input = unknown> {
|
|
11
|
-
appId: string;
|
|
12
|
-
input: AppContract<Input>;
|
|
13
|
-
}
|
|
14
|
-
export type AppLaunchResult<Output = unknown> =
|
|
15
|
-
| { status: "completed"; output: AppContract<Output> }
|
|
16
|
-
| { status: "cancelled"; output?: never };
|
|
17
|
-
|
|
18
|
-
export interface AppSessionMessage {
|
|
19
|
-
type: string;
|
|
20
|
-
protocol: typeof APP_PROTOCOL;
|
|
21
|
-
protocolVersion: typeof APP_PROTOCOL_VERSION;
|
|
22
|
-
appId: string;
|
|
23
|
-
instanceId: string;
|
|
24
|
-
runId: string;
|
|
25
|
-
messageId: string;
|
|
26
|
-
payload: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
export interface AppSessionChannel {
|
|
29
|
-
send(type: string, payload: Record<string, unknown>): unknown;
|
|
30
|
-
onMessage(listener: (message: AppSessionMessage) => void | Promise<void>): () => void;
|
|
31
|
-
}
|
|
32
|
-
export declare class AppsCapabilityError extends Error {
|
|
33
|
-
readonly code: string;
|
|
34
|
-
}
|
|
35
|
-
export declare class AppsCapabilityTimeoutError extends AppsCapabilityError {}
|
|
36
|
-
export interface AppsClientExtension {
|
|
37
|
-
launch<Input = unknown, Output = unknown>(input: AppLaunchRequest<Input>): Promise<AppLaunchResult<Output>>;
|
|
38
|
-
dispose(): void;
|
|
39
|
-
}
|
|
40
|
-
export declare function createAppsClientExtension(
|
|
41
|
-
client: AppSessionChannel,
|
|
42
|
-
options?: { createId?: (kind: string) => string; launchTimeoutMs?: number },
|
|
43
|
-
): AppsClientExtension;
|
|
44
|
-
export declare function createAppsHostExtension(
|
|
45
|
-
host: AppSessionChannel,
|
|
46
|
-
handlers?: { launch?: (input: AppLaunchRequest) => AppLaunchResult | Promise<AppLaunchResult> },
|
|
47
|
-
): { dispose(): void };
|
|
48
|
-
export interface AppHost extends AppSessionChannel {
|
|
49
|
-
connect(handlers?: {
|
|
50
|
-
onComplete?: (output: AppContract) => { status: "accepted" | "rejected" } | Promise<{ status: "accepted" | "rejected" }>;
|
|
51
|
-
onRequestExit?: () => void;
|
|
52
|
-
}): () => void;
|
|
53
|
-
dispose(): void;
|
|
54
|
-
}
|
|
55
|
-
export declare function createAppHost(options: {
|
|
56
|
-
appId: string;
|
|
57
|
-
runId: string;
|
|
58
|
-
target: Window;
|
|
59
|
-
input: AppContract;
|
|
60
|
-
scope?: Window;
|
|
61
|
-
expectedOrigin?: string;
|
|
62
|
-
createId?: (kind: string) => string;
|
|
63
|
-
}): AppHost;
|
|
64
|
-
|
|
65
|
-
export interface AppClientOptions {
|
|
66
|
-
appId: string;
|
|
67
|
-
scope?: Window & { ReactNativeWebView?: { postMessage(message: string): void } };
|
|
68
|
-
targetOrigin?: string;
|
|
69
|
-
instanceId?: string;
|
|
70
|
-
createId?: (kind: string) => string;
|
|
71
|
-
readyRetryMs?: number;
|
|
72
|
-
}
|
|
73
|
-
export interface AppClient {
|
|
74
|
-
readonly appId: string;
|
|
75
|
-
readonly instanceId: string;
|
|
76
|
-
readonly runId: string | null;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
export declare const APP_PROTOCOL: "dokiworld.app";
|
|
2
|
+
export declare const APP_PROTOCOL_VERSION: 2;
|
|
3
|
+
export declare const DEFAULT_APP_LAUNCH_TIMEOUT_MS: number;
|
|
4
|
+
|
|
5
|
+
export interface AppContract<Data = unknown> {
|
|
6
|
+
contract: string;
|
|
7
|
+
version: number;
|
|
8
|
+
data: Data;
|
|
9
|
+
}
|
|
10
|
+
export interface AppLaunchRequest<Input = unknown> {
|
|
11
|
+
appId: string;
|
|
12
|
+
input: AppContract<Input>;
|
|
13
|
+
}
|
|
14
|
+
export type AppLaunchResult<Output = unknown> =
|
|
15
|
+
| { status: "completed"; output: AppContract<Output> }
|
|
16
|
+
| { status: "cancelled"; output?: never };
|
|
17
|
+
|
|
18
|
+
export interface AppSessionMessage {
|
|
19
|
+
type: string;
|
|
20
|
+
protocol: typeof APP_PROTOCOL;
|
|
21
|
+
protocolVersion: typeof APP_PROTOCOL_VERSION;
|
|
22
|
+
appId: string;
|
|
23
|
+
instanceId: string;
|
|
24
|
+
runId: string;
|
|
25
|
+
messageId: string;
|
|
26
|
+
payload: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export interface AppSessionChannel {
|
|
29
|
+
send(type: string, payload: Record<string, unknown>): unknown;
|
|
30
|
+
onMessage(listener: (message: AppSessionMessage) => void | Promise<void>): () => void;
|
|
31
|
+
}
|
|
32
|
+
export declare class AppsCapabilityError extends Error {
|
|
33
|
+
readonly code: string;
|
|
34
|
+
}
|
|
35
|
+
export declare class AppsCapabilityTimeoutError extends AppsCapabilityError {}
|
|
36
|
+
export interface AppsClientExtension {
|
|
37
|
+
launch<Input = unknown, Output = unknown>(input: AppLaunchRequest<Input>): Promise<AppLaunchResult<Output>>;
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
40
|
+
export declare function createAppsClientExtension(
|
|
41
|
+
client: AppSessionChannel,
|
|
42
|
+
options?: { createId?: (kind: string) => string; launchTimeoutMs?: number },
|
|
43
|
+
): AppsClientExtension;
|
|
44
|
+
export declare function createAppsHostExtension(
|
|
45
|
+
host: AppSessionChannel,
|
|
46
|
+
handlers?: { launch?: (input: AppLaunchRequest) => AppLaunchResult | Promise<AppLaunchResult> },
|
|
47
|
+
): { dispose(): void };
|
|
48
|
+
export interface AppHost extends AppSessionChannel {
|
|
49
|
+
connect(handlers?: {
|
|
50
|
+
onComplete?: (output: AppContract) => { status: "accepted" | "rejected" } | Promise<{ status: "accepted" | "rejected" }>;
|
|
51
|
+
onRequestExit?: () => void;
|
|
52
|
+
}): () => void;
|
|
53
|
+
dispose(): void;
|
|
54
|
+
}
|
|
55
|
+
export declare function createAppHost(options: {
|
|
56
|
+
appId: string;
|
|
57
|
+
runId: string;
|
|
58
|
+
target: Window;
|
|
59
|
+
input: AppContract;
|
|
60
|
+
scope?: Window;
|
|
61
|
+
expectedOrigin?: string;
|
|
62
|
+
createId?: (kind: string) => string;
|
|
63
|
+
}): AppHost;
|
|
64
|
+
|
|
65
|
+
export interface AppClientOptions {
|
|
66
|
+
appId: string;
|
|
67
|
+
scope?: Window & { ReactNativeWebView?: { postMessage(message: string): void } };
|
|
68
|
+
targetOrigin?: string;
|
|
69
|
+
instanceId?: string;
|
|
70
|
+
createId?: (kind: string) => string;
|
|
71
|
+
readyRetryMs?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface AppClient {
|
|
74
|
+
readonly appId: string;
|
|
75
|
+
readonly instanceId: string;
|
|
76
|
+
readonly runId: string | null;
|
|
77
|
+
/** Validated initialization input; each read is a detached copy. */
|
|
78
|
+
readonly input: AppContract | null;
|
|
79
|
+
readonly apps: AppsClientExtension;
|
|
80
|
+
whenReady(options?: { timeoutMs?: number }): Promise<AppContract>;
|
|
81
|
+
requestExit(): void;
|
|
82
|
+
complete(output: AppContract): Promise<"accepted" | "rejected">;
|
|
83
|
+
connect(): () => void;
|
|
84
|
+
dispose(): void;
|
|
85
|
+
}
|
|
86
|
+
export declare function createAppClient(options: AppClientOptions): AppClient;
|