@phreshos/server 0.1.13 → 0.1.14
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 +8 -16
- package/dist/domain.d.ts +1 -1
- package/dist/domain.js +13 -14
- package/dist/host.d.ts +2 -4
- package/dist/main.d.ts +1 -1
- package/dist/service.d.ts +1 -19
- package/dist/service.js +0 -20
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -149,31 +149,23 @@ rejects instead of reconfiguring the existing Process.
|
|
|
149
149
|
`host.service(key)` creates the exact opaque service handle. The
|
|
150
150
|
handler exposes its authored `name`, `enabled()`, `waitReady()`, lifecycle
|
|
151
151
|
subscriptions, and channel; it does not expose its Program or Endpoint as
|
|
152
|
-
separate fields. Services are
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
installed policy and API documentation before the Endpoint starts.
|
|
152
|
+
separate fields. Services are runtime bindings explicitly enabled by their
|
|
153
|
+
providing Endpoints; creating the providing Process remains the Program's
|
|
154
|
+
responsibility.
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
wait for readiness without reproducing Program-specific launch rules:
|
|
156
|
+
Readiness accepts an optional timeout directly:
|
|
159
157
|
|
|
160
158
|
```ts
|
|
161
|
-
await
|
|
162
|
-
await clientService.createAndWaitReady({ minimize: true })
|
|
159
|
+
await service.waitReady(10_000)
|
|
163
160
|
```
|
|
164
161
|
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
Programs may provide one agent-independent operating document. Its availability
|
|
163
|
+
is projected without loading it, and its content is read from the Program:
|
|
167
164
|
|
|
168
165
|
```ts
|
|
169
|
-
await
|
|
170
|
-
await service.timeout(5_000).waitReady()
|
|
171
|
-
await service.timeout(5_000).waitReady(10_000)
|
|
166
|
+
if (program.hasAgent) console.log(await program.agent())
|
|
172
167
|
```
|
|
173
168
|
|
|
174
|
-
The System owns the single deadline across Process creation, Endpoint startup,
|
|
175
|
-
and Service readiness. The creation capability exists only in the Server SDK.
|
|
176
|
-
|
|
177
169
|
`program.icon()` requests a guaranteed PNG `Blob` in `small`, `medium`, or
|
|
178
170
|
`large` form without exposing the Program's source path or the system's private
|
|
179
171
|
asset-hosting address. Omitting the size selects `medium`.
|
package/dist/domain.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export interface ProgramArea extends CoreProgramArea {
|
|
|
16
16
|
/** Client-safe Program data transported by the authoritative host. */
|
|
17
17
|
export interface EndpointDeclarationRecord {
|
|
18
18
|
start: boolean;
|
|
19
|
-
hasService: boolean;
|
|
20
19
|
}
|
|
21
20
|
export interface ClientDeclarationRecord extends EndpointDeclarationRecord {
|
|
22
21
|
title: string | null;
|
|
@@ -32,6 +31,7 @@ export interface ProgramRecord {
|
|
|
32
31
|
name: string;
|
|
33
32
|
version: string | null;
|
|
34
33
|
description: string | null;
|
|
34
|
+
hasAgent: boolean;
|
|
35
35
|
server: EndpointDeclarationRecord | null;
|
|
36
36
|
client: ClientDeclarationRecord | null;
|
|
37
37
|
}
|
package/dist/domain.js
CHANGED
|
@@ -43,11 +43,12 @@ class ProgramHandle extends ProgramBase {
|
|
|
43
43
|
get name() { return this.record.name; }
|
|
44
44
|
get version() { return this.record.version; }
|
|
45
45
|
get description() { return this.record.description; }
|
|
46
|
+
get hasAgent() { return this.record.hasAgent; }
|
|
46
47
|
get server() {
|
|
47
|
-
return this.record.server ? declaration(this.
|
|
48
|
+
return this.record.server ? declaration(this.record.server) : null;
|
|
48
49
|
}
|
|
49
50
|
get client() {
|
|
50
|
-
return this.record.client ? clientDeclaration(this.
|
|
51
|
+
return this.record.client ? clientDeclaration(this.record.client) : null;
|
|
51
52
|
}
|
|
52
53
|
get address() { return { identity: this.identity, reference: this.reference }; }
|
|
53
54
|
update(record) {
|
|
@@ -59,6 +60,12 @@ class ProgramHandle extends ProgramBase {
|
|
|
59
60
|
const answer = await wire.request(["icon", this.address, size]);
|
|
60
61
|
return new Blob([Uint8Array.from(answer[0])], { type: "image/png" });
|
|
61
62
|
}
|
|
63
|
+
async agent() {
|
|
64
|
+
if (!this.hasAgent)
|
|
65
|
+
return null;
|
|
66
|
+
const answer = await wire.request(["program-agent", this.address]);
|
|
67
|
+
return answer[0];
|
|
68
|
+
}
|
|
62
69
|
async installed() {
|
|
63
70
|
const answer = await wire.request(["installed", this.address]);
|
|
64
71
|
return answer[0];
|
|
@@ -78,16 +85,14 @@ class ProgramHandle extends ProgramBase {
|
|
|
78
85
|
await wire.request(["forget", this.address]);
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
|
-
function declaration(
|
|
88
|
+
function declaration(record) {
|
|
82
89
|
return Object.freeze({
|
|
83
|
-
start: record.start
|
|
84
|
-
hasService: () => record.hasService,
|
|
85
|
-
docs: () => endpointDocs(address, endpoint, record.hasService)
|
|
90
|
+
start: record.start
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
|
-
function clientDeclaration(
|
|
93
|
+
function clientDeclaration(record) {
|
|
89
94
|
return Object.freeze({
|
|
90
|
-
...declaration(
|
|
95
|
+
...declaration(record),
|
|
91
96
|
title: record.title,
|
|
92
97
|
size: record.size,
|
|
93
98
|
position: record.position,
|
|
@@ -95,12 +100,6 @@ function clientDeclaration(address, record) {
|
|
|
95
100
|
minimize: record.minimize
|
|
96
101
|
});
|
|
97
102
|
}
|
|
98
|
-
async function endpointDocs(address, endpoint, declared) {
|
|
99
|
-
if (!declared)
|
|
100
|
-
return null;
|
|
101
|
-
const answer = await wire.request(["endpoint-docs", address, endpoint]);
|
|
102
|
-
return answer[0];
|
|
103
|
-
}
|
|
104
103
|
class ProgramProcessHandle {
|
|
105
104
|
address;
|
|
106
105
|
constructor(address, reference) {
|
package/dist/host.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ export type ServerDescription = Readonly<{
|
|
|
7
7
|
location: string;
|
|
8
8
|
/** Whether newly created Processes start this Server by default. */
|
|
9
9
|
start?: boolean;
|
|
10
|
-
/** Absolute Markdown file documenting the Service this Server may expose. */
|
|
11
|
-
serviceDocs?: string;
|
|
12
10
|
/** Command used to install the Server's production dependencies. */
|
|
13
11
|
installCommand?: string;
|
|
14
12
|
/** Command used to start the Server from its production directory. */
|
|
@@ -20,8 +18,6 @@ export type ClientDescription = Readonly<{
|
|
|
20
18
|
location: string;
|
|
21
19
|
/** Whether newly created Processes start this Client by default. */
|
|
22
20
|
start?: boolean;
|
|
23
|
-
/** Absolute Markdown file documenting the Service this Client may expose. */
|
|
24
|
-
serviceDocs?: string;
|
|
25
21
|
/** Default Window title. */
|
|
26
22
|
title?: string;
|
|
27
23
|
/** Default Window size. */
|
|
@@ -44,6 +40,8 @@ type Description = Readonly<{
|
|
|
44
40
|
description?: string;
|
|
45
41
|
/** Absolute validated PNG source used to derive the Program's hosted icon sizes. */
|
|
46
42
|
icon?: string;
|
|
43
|
+
/** Absolute Markdown file describing Program-specific operation to agents. */
|
|
44
|
+
agent?: string;
|
|
47
45
|
/** Absolute directory used for the Program's persistent storage. */
|
|
48
46
|
storage: string;
|
|
49
47
|
}>;
|
package/dist/main.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { host, type Host, type HostProcess, type HostProgram, type ClientDescrip
|
|
|
2
2
|
export { current, type Current, type CurrentClient } from "./current.js";
|
|
3
3
|
export { type Answerer, type Channel } from "./channel.js";
|
|
4
4
|
export { type ProgramStartup } from "./startup.js";
|
|
5
|
-
export { ClientServiceHandler, ServerServiceHandler
|
|
5
|
+
export { ClientServiceHandler, ServerServiceHandler } from "./service.js";
|
|
6
6
|
export { ServiceHandler, type ClientServiceChannel, type ServerServiceChannel, type ServiceChannel, type ServiceKey, type ServiceLifecycleEvents } from "@phreshos/core";
|
|
7
7
|
export { Client, Endpoint, Process, Program, Server, type Window, type ProgramArea, type ProgramProcess } from "./domain.js";
|
|
8
8
|
export type { AnswerCapture, AnswerMessage, AnswerObserver, Askable, AskCapture, AskMessage, AskObserver, Capture, Captures, ChannelCapture, ChannelEvents, ChannelMessage, ClientTraffic, ClientDeclaration, Cleanup, DirectoryStat, EndpointDeclaration, EndpointTraffic, EntryStat, EventMessage, EventName, EventObserver, EventOptions, EventSubscriber, Exit, FileStat, Launch, LaunchClient, Layer, LogKind, LogRecord, LogSource, Message, OtherStat, Outcome, Position, ProgramEvents, ProgramPermission, ProgramProcessEvents, ProgramProcessExit, ProgramSql, ProgramStore, ProcessEvents, Publishable, ServedFile, ServerTraffic, Size, Subscribable, SubscribableEvents, SubscribableFallback, TimedAskable, TrafficCapture, TrafficEvents, TrafficMessage, Value, Theme, ThemeEvents, ThemeProperties, WallpaperLaunch, FileWallpaper, DesktopWallpaper, WritableTheme, WindowEvents, WindowGeometry, WindowLayer, WindowState } from "@phreshos/core";
|
package/dist/service.d.ts
CHANGED
|
@@ -1,31 +1,13 @@
|
|
|
1
|
-
import { ClientServiceHandler as CoreClientServiceHandler, ServerServiceHandler as CoreServerServiceHandler, type
|
|
1
|
+
import { ClientServiceHandler as CoreClientServiceHandler, ServerServiceHandler as CoreServerServiceHandler, type ServiceHandler, type ServiceKey } from "@phreshos/core";
|
|
2
2
|
import type { HandleAddress } from "./domain.js";
|
|
3
|
-
/** Timed view of a Server Endpoint Service available through the Server SDK. */
|
|
4
|
-
export interface TimedServerServiceHandler {
|
|
5
|
-
waitReady(timeout?: number): Promise<void>;
|
|
6
|
-
createAndWaitReady(timeout?: number): Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
/** Timed view of a Client Endpoint Service available through the Server SDK. */
|
|
9
|
-
export interface TimedClientServiceHandler {
|
|
10
|
-
waitReady(timeout?: number): Promise<void>;
|
|
11
|
-
createAndWaitReady(client?: LaunchClient, timeout?: number): Promise<void>;
|
|
12
|
-
}
|
|
13
3
|
/** Server-SDK handle for a Service provided by a Server Endpoint. */
|
|
14
4
|
export declare class ServerServiceHandler<Events extends object = {}> extends CoreServerServiceHandler<Events> {
|
|
15
5
|
protected constructor();
|
|
16
6
|
}
|
|
17
|
-
export interface ServerServiceHandler<Events extends object = {}> extends Timeoutable<TimedServerServiceHandler> {
|
|
18
|
-
createAndWaitReady(timeout?: number): Promise<void>;
|
|
19
|
-
timeout(milliseconds: number): TimedServerServiceHandler;
|
|
20
|
-
}
|
|
21
7
|
/** Server-SDK handle for a Service provided by a Client Endpoint. */
|
|
22
8
|
export declare class ClientServiceHandler<Events extends object = {}> extends CoreClientServiceHandler<Events> {
|
|
23
9
|
protected constructor();
|
|
24
10
|
}
|
|
25
|
-
export interface ClientServiceHandler<Events extends object = {}> extends Timeoutable<TimedClientServiceHandler> {
|
|
26
|
-
createAndWaitReady(client?: LaunchClient, timeout?: number): Promise<void>;
|
|
27
|
-
timeout(milliseconds: number): TimedClientServiceHandler;
|
|
28
|
-
}
|
|
29
11
|
export declare function prepareService<EventsMap extends object = {}>(key: ServiceKey & {
|
|
30
12
|
endpoint: "server";
|
|
31
13
|
}): ServerServiceHandler<EventsMap>;
|
package/dist/service.js
CHANGED
|
@@ -69,15 +69,6 @@ class ServerHandler extends ServerServiceHandler {
|
|
|
69
69
|
async waitReady(timeout) {
|
|
70
70
|
await wire.request(["service-wait-ready", this.key, timeout], timeout);
|
|
71
71
|
}
|
|
72
|
-
async createAndWaitReady(timeout) {
|
|
73
|
-
await wire.request(["service-create-and-wait-ready", this.key, undefined, timeout], timeout);
|
|
74
|
-
}
|
|
75
|
-
timeout(milliseconds) {
|
|
76
|
-
return Object.freeze({
|
|
77
|
-
waitReady: (timeout) => this.waitReady(timeout ?? milliseconds),
|
|
78
|
-
createAndWaitReady: (timeout) => this.createAndWaitReady(timeout ?? milliseconds)
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
72
|
}
|
|
82
73
|
class ClientHandler extends ClientServiceHandler {
|
|
83
74
|
key;
|
|
@@ -97,17 +88,6 @@ class ClientHandler extends ClientServiceHandler {
|
|
|
97
88
|
async waitReady(timeout) {
|
|
98
89
|
await wire.request(["service-wait-ready", this.key, timeout], timeout);
|
|
99
90
|
}
|
|
100
|
-
async createAndWaitReady(client, timeout) {
|
|
101
|
-
await wire.request(["service-create-and-wait-ready", this.key, client, timeout], timeout);
|
|
102
|
-
}
|
|
103
|
-
timeout(milliseconds) {
|
|
104
|
-
return Object.freeze({
|
|
105
|
-
waitReady: (timeout) => this.waitReady(timeout ?? milliseconds),
|
|
106
|
-
createAndWaitReady: (client, timeout) => {
|
|
107
|
-
return this.createAndWaitReady(client, timeout ?? milliseconds);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
91
|
}
|
|
112
92
|
export function prepareService(key) {
|
|
113
93
|
if (!isServiceKey(key))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "The SDK used by a Program's server endpoint.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"prepack": "node --run build"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@phreshos/core": "^0.1.
|
|
49
|
+
"@phreshos/core": "^0.1.12"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@msgpack/msgpack": "^3.1.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@phreshos/core": "^0.1.
|
|
55
|
+
"@phreshos/core": "^0.1.12",
|
|
56
56
|
"@types/node": "^26.2.0",
|
|
57
57
|
"typescript": "^6.0.3"
|
|
58
58
|
}
|