@open-artifact/server-sdk 0.1.0 → 0.2.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/package.json +2 -2
- package/src/frame/client/comments.js +26 -26
- package/src/frame/client/shell.js +1 -1
- package/src/frame/index.d.ts +1 -1
- package/src/frame/index.js +2 -2
- package/src/frame/wire.d.ts +2 -0
- package/src/serve.d.ts +2 -0
- package/src/serve.js +8 -0
|
@@ -709,7 +709,7 @@
|
|
|
709
709
|
cap: (method, arg) => cap("comments", method, arg),
|
|
710
710
|
sendToAgent,
|
|
711
711
|
refresh: refreshThreads,
|
|
712
|
-
agent: () => ({ available: !!session?.agent?.available, name: agentName() }),
|
|
712
|
+
agent: () => ({ available: !!session?.agent?.available, name: agentName(), ...session?.agent?.wakesIdle === false ? { wakesIdle: false } : {} }),
|
|
713
713
|
activeChanged: () => pushThreads(),
|
|
714
714
|
listChanged: (open) => setList(open),
|
|
715
715
|
modeChanged: (on) => setMode(on),
|
package/src/frame/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* └─ embeds ─▶ the original page on its own origin
|
|
11
11
|
* (http://<id>.frame.localhost:<port>/_f/<ver>/, Site.content)
|
|
12
12
|
*
|
|
13
|
-
* The page gets `window.
|
|
13
|
+
* The page gets `window.openartifact` from the Frame Runtime this server injects
|
|
14
14
|
* first in its <head> (client/runtime.ts). Every capability call is a
|
|
15
15
|
* `__frame_cap` postMessage to the inner shell (client/shell.ts), which
|
|
16
16
|
* carries it here over HTTP and pushes events (db changes, room, file and
|
package/src/frame/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* └─ embeds ─▶ the original page on its own origin
|
|
11
11
|
* (http://<id>.frame.localhost:<port>/_f/<ver>/, Site.content)
|
|
12
12
|
*
|
|
13
|
-
* The page gets `window.
|
|
13
|
+
* The page gets `window.openartifact` from the Frame Runtime this server injects
|
|
14
14
|
* first in its <head> (client/runtime.ts). Every capability call is a
|
|
15
15
|
* `__frame_cap` postMessage to the inner shell (client/shell.ts), which
|
|
16
16
|
* carries it here over HTTP and pushes events (db changes, room, file and
|
|
@@ -427,7 +427,7 @@ export class FrameSite {
|
|
|
427
427
|
readyTimeoutS: Number(this.declaration.monitoring?.readyTimeoutS) || 60,
|
|
428
428
|
me: this.me,
|
|
429
429
|
comments: { available: this.grants.includes('comments'), count: this.comments.openCount() },
|
|
430
|
-
agent: { available: !!this.ctx.daemon?.available, name: this.ctx.agentName ?? null },
|
|
430
|
+
agent: { available: !!this.ctx.daemon?.available, name: this.ctx.agentName ?? null, ...(this.ctx.agentWakesIdle === false ? { wakesIdle: false } : {}) },
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
/** The event stream of one inner shell: JSON objects, over a `baoyu-sse` WebSocket or as SSE. */
|
package/src/frame/wire.d.ts
CHANGED
|
@@ -59,9 +59,11 @@ export interface FrameSession {
|
|
|
59
59
|
available: boolean;
|
|
60
60
|
count: number;
|
|
61
61
|
};
|
|
62
|
+
/** wakesIdle false: an idle agent is not woken; what is sent waits for its next turn. */
|
|
62
63
|
agent: {
|
|
63
64
|
available: boolean;
|
|
64
65
|
name: string | null;
|
|
66
|
+
wakesIdle?: boolean;
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
export interface LocalUser {
|
package/src/serve.d.ts
CHANGED
|
@@ -97,6 +97,8 @@ export interface SiteContext {
|
|
|
97
97
|
agentHook: AgentHook;
|
|
98
98
|
/** The agent's display name, when the daemon knows it. */
|
|
99
99
|
agentName?: string;
|
|
100
|
+
/** false: the daemon cannot wake the agent while it idles; what is sent waits for its next turn. */
|
|
101
|
+
agentWakesIdle?: boolean;
|
|
100
102
|
/** Opening another folder from a page; this skeleton does not support it. */
|
|
101
103
|
open(): Promise<never>;
|
|
102
104
|
/**
|
package/src/serve.js
CHANGED
|
@@ -416,6 +416,13 @@ export class TypeServer {
|
|
|
416
416
|
catch {
|
|
417
417
|
agentName = undefined;
|
|
418
418
|
}
|
|
419
|
+
let agentWakesIdle;
|
|
420
|
+
try {
|
|
421
|
+
agentWakesIdle = (await this.daemon.presence(id)).wakesIdle;
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
agentWakesIdle = undefined;
|
|
425
|
+
}
|
|
419
426
|
const wake = async (body) => {
|
|
420
427
|
const out = await this.daemon.wake(id, body);
|
|
421
428
|
if (out.status === 'failed')
|
|
@@ -431,6 +438,7 @@ export class TypeServer {
|
|
|
431
438
|
local: (req) => isLoopback(req.socket.remoteAddress),
|
|
432
439
|
agentHook: { thread: (view) => wake({ threads: [view] }), request: (request) => wake({ requests: [request] }) },
|
|
433
440
|
...(agentName ? { agentName } : {}),
|
|
441
|
+
...(agentWakesIdle === false ? { agentWakesIdle } : {}),
|
|
434
442
|
contentOrigin: this.options.contentHosts && CONTENT_HOST.test(`${id}.frame.localhost:${this.port}`) ? `http://${id}.frame.localhost:${this.port}` : null,
|
|
435
443
|
open: async () => {
|
|
436
444
|
throw new OpenArtifactError('unsupported', 'Opening another folder from a page is not supported here.');
|