@open-artifact/editor-kit 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 +4 -4
- package/src/agent.d.ts +4 -2
- package/src/agent.js +8 -2
- package/src/collab/CommentViews.d.ts +2 -0
- package/src/collab/CommentViews.js +2 -2
- package/src/collab/comments.d.ts +12 -0
- package/src/collab/comments.js +11 -1
- package/src/roles.d.ts +5 -2
- package/src/roles.js +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-artifact/editor-kit",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "What every artifact editor shares: collaboration (comments, presence, history), roles and host session, Shell chrome reports, find, recovery stashes, line merge, announcements, chrome primitives and design-system loading.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@base-ui/react": "^1.8.0",
|
|
25
|
-
"@open-artifact/design-system-core": "0.1
|
|
26
|
-
"@open-artifact/runtime": "0.1
|
|
27
|
-
"@open-artifact/ui": "0.1
|
|
25
|
+
"@open-artifact/design-system-core": "0.2.1",
|
|
26
|
+
"@open-artifact/runtime": "0.2.1",
|
|
27
|
+
"@open-artifact/ui": "0.2.1",
|
|
28
28
|
"clsx": "^2.1.1",
|
|
29
29
|
"lucide-react": "^1.65.0",
|
|
30
30
|
"zustand": "^5.0.10",
|
package/src/agent.d.ts
CHANGED
|
@@ -11,9 +11,11 @@ export interface AgentResultMessage {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* How the host took a request, for a toast. `subject` names what the agent
|
|
14
|
-
* checks next ("this design", "this deck", "this board").
|
|
14
|
+
* checks next ("this design", "this deck", "this board"). `agent` is its
|
|
15
|
+
* status: one that is not woken while it idles (`wakesIdle: false`) gets a
|
|
16
|
+
* queued request on its next turn, which the person starts.
|
|
15
17
|
*/
|
|
16
|
-
export declare function agentResultMessage(result: AgentSendResult, subject: string): AgentResultMessage;
|
|
18
|
+
export declare function agentResultMessage(result: Pick<AgentSendResult, 'status' | 'reason'>, subject: string, agent?: Pick<AgentStatus, 'name' | 'wakesIdle'>): AgentResultMessage;
|
|
17
19
|
/** A failed send result for an error thrown while sending. */
|
|
18
20
|
export declare function sendFailure(error: unknown): AgentSendResult;
|
|
19
21
|
/** Follows the agent's status (none without an agent); returns a function that stops. */
|
package/src/agent.js
CHANGED
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* How the host took a request, for a toast. `subject` names what the agent
|
|
8
|
-
* checks next ("this design", "this deck", "this board").
|
|
8
|
+
* checks next ("this design", "this deck", "this board"). `agent` is its
|
|
9
|
+
* status: one that is not woken while it idles (`wakesIdle: false`) gets a
|
|
10
|
+
* queued request on its next turn, which the person starts.
|
|
9
11
|
*/
|
|
10
|
-
export function agentResultMessage(result, subject) {
|
|
12
|
+
export function agentResultMessage(result, subject, agent) {
|
|
11
13
|
switch (result.status) {
|
|
12
14
|
case 'delivered':
|
|
13
15
|
return { title: 'Sent to the agent' };
|
|
14
16
|
case 'queued':
|
|
17
|
+
if (agent?.wakesIdle === false) {
|
|
18
|
+
const name = agent.name || 'The agent';
|
|
19
|
+
return { title: `Queued for ${name}`, description: `${name} gets it on its next turn. If it is idle, send it a message there to start one.` };
|
|
20
|
+
}
|
|
15
21
|
return { title: 'Queued for the agent', description: `It will see the request the next time it checks ${subject}.` };
|
|
16
22
|
case 'staged':
|
|
17
23
|
return { title: 'Request prepared', description: 'Your agent will ask before acting on it.' };
|
|
@@ -8,6 +8,8 @@ export declare const COMMENT_CURSOR: string;
|
|
|
8
8
|
export interface AgentBadge {
|
|
9
9
|
available: boolean;
|
|
10
10
|
name: string;
|
|
11
|
+
/** false: an idle agent is not woken (Cursor); what is sent waits until the person next talks to it. */
|
|
12
|
+
wakesIdle?: boolean;
|
|
11
13
|
}
|
|
12
14
|
/** A short "5m ago" style time. */
|
|
13
15
|
export declare function timeAgo(iso: string, now?: number): string;
|
|
@@ -7,7 +7,7 @@ import { EdgePiles, edgePiles, stackPins } from "./cds/edge-piles.js";
|
|
|
7
7
|
import { CommentsLayer, InLayer } from "./cds/layer.js";
|
|
8
8
|
import { commentMarkdown } from "./cds/markdown.js";
|
|
9
9
|
import { commentTime } from "./cds/time.js";
|
|
10
|
-
import { openMessageCount } from "./comments.js";
|
|
10
|
+
import { openMessageCount, queuedNote } from "./comments.js";
|
|
11
11
|
import { ALL_COMMENTS_RIGHT } from "./CommentList.js";
|
|
12
12
|
import { screenBox, toScreenPoint, toWorldPoint } from "./pins.js";
|
|
13
13
|
/** Pixels the pointer must travel before a press becomes a drag. */
|
|
@@ -487,7 +487,7 @@ function ThreadCardBody({ comments, agent, thread, state, maxHeight, onClose })
|
|
|
487
487
|
} })) : undefined, actions: commenting || topItems.length > 0 ? (_jsxs(Actions, { children: [commenting ? (_jsx(ResolveAction, { resolved: thread.status === 'resolved', busy: resolving, onResolve: () => {
|
|
488
488
|
setResolving(true);
|
|
489
489
|
void comments.resolve(thread.id, true).finally(() => setResolving(false));
|
|
490
|
-
} })) : null, _jsx(MoreMenu, { items: topItems })] })) : undefined, children: commentMarkdown(top.text) }), replies.length > 0 || working ? (_jsxs(Replies, { children: [replies.map((message) => (_jsx(Comment, { authorName: authorName(message, agent), agent: message.author.kind === 'agent', timestamp: commentTime(message.at), children: commentMarkdown(message.text) }, message.id))), working ? _jsx(Comment, { authorName: agent.name, agent: true, working: working, footnote: working === 'queued' ?
|
|
490
|
+
} })) : null, _jsx(MoreMenu, { items: topItems })] })) : undefined, children: commentMarkdown(top.text) }), replies.length > 0 || working ? (_jsxs(Replies, { children: [replies.map((message) => (_jsx(Comment, { authorName: authorName(message, agent), agent: message.author.kind === 'agent', timestamp: commentTime(message.at), children: commentMarkdown(message.text) }, message.id))), working ? _jsx(Comment, { authorName: agent.name, agent: true, working: working, footnote: working === 'queued' ? queuedNote(agent) : 'Working…' }) : null] })) : null] }));
|
|
491
491
|
}
|
|
492
492
|
export function CommentComposer(props) {
|
|
493
493
|
return (_jsx(InLayer, { children: _jsx(ComposerBody, { ...props }) }));
|
package/src/collab/comments.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export interface CommentsAdapter<A> {
|
|
|
39
39
|
canSendToAgent(): boolean;
|
|
40
40
|
/** The agent's name in toasts. */
|
|
41
41
|
agentName?(): string;
|
|
42
|
+
/** false: the agent is not woken while it idles, so the toast tells the person to message it. */
|
|
43
|
+
agentWakesIdle?(): boolean | undefined;
|
|
42
44
|
/** The viewer's name (the new comment's pin shows their initials; default `You`). */
|
|
43
45
|
viewerName?(): string;
|
|
44
46
|
/** Comment mode turned on or off (end text editing, pick the select tool…). */
|
|
@@ -141,6 +143,16 @@ export interface CommentsController<A> {
|
|
|
141
143
|
viewerName(): string;
|
|
142
144
|
}
|
|
143
145
|
/** Open (unresolved) thread count. */
|
|
146
|
+
/** Under a thread sent to the agent that has not taken it yet; one that is not woken while it idles needs a message. */
|
|
147
|
+
export declare function queuedNote(agent: {
|
|
148
|
+
name: string;
|
|
149
|
+
wakesIdle?: boolean;
|
|
150
|
+
}): string;
|
|
151
|
+
/** The toast after a thread goes to the agent; one that is not woken while it idles needs a message from the person. */
|
|
152
|
+
export declare function sentNotice(name: string, wakesIdle: boolean | undefined): {
|
|
153
|
+
title: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
};
|
|
144
156
|
export declare function openCount(threads: readonly CommentThread[]): number;
|
|
145
157
|
export declare function openMessageCount(threads: readonly CommentThread[]): number;
|
|
146
158
|
/** Creates an editor's comments controller. */
|
package/src/collab/comments.js
CHANGED
|
@@ -12,6 +12,16 @@ import { create } from 'zustand';
|
|
|
12
12
|
/** Longest message. */
|
|
13
13
|
export const COMMENT_TEXT_MAX = 4000;
|
|
14
14
|
/** Open (unresolved) thread count. */
|
|
15
|
+
/** Under a thread sent to the agent that has not taken it yet; one that is not woken while it idles needs a message. */
|
|
16
|
+
export function queuedNote(agent) {
|
|
17
|
+
return agent.wakesIdle === false ? `${agent.name} gets this on its next turn: send it a message to start one` : 'Waiting for the agent';
|
|
18
|
+
}
|
|
19
|
+
/** The toast after a thread goes to the agent; one that is not woken while it idles needs a message from the person. */
|
|
20
|
+
export function sentNotice(name, wakesIdle) {
|
|
21
|
+
return wakesIdle === false
|
|
22
|
+
? { title: `Sent to ${name}`, description: `${name} gets it on its next turn. If it is idle, send it a message there to start one.` }
|
|
23
|
+
: { title: `Sent to ${name}` };
|
|
24
|
+
}
|
|
15
25
|
export function openCount(threads) {
|
|
16
26
|
return threads.filter((t) => t.status === 'open').length;
|
|
17
27
|
}
|
|
@@ -247,7 +257,7 @@ export function createComments(adapter) {
|
|
|
247
257
|
return thread ? adapter.sendToAgent(thread, anchorOf(thread)) : false;
|
|
248
258
|
try {
|
|
249
259
|
put(await capability.sendToAgent(id));
|
|
250
|
-
notify(
|
|
260
|
+
notify(sentNotice(adapter.agentName?.() || 'the agent', adapter.agentWakesIdle?.()));
|
|
251
261
|
return true;
|
|
252
262
|
}
|
|
253
263
|
catch (error) {
|
package/src/roles.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* What each role may do in an artifact, the way the host's sharing rules
|
|
3
3
|
* allow it, so an editor only offers what the server will accept:
|
|
4
4
|
*
|
|
5
|
-
* - owner: everything, including sending requests to the agent
|
|
6
|
-
* files to the computer that shares the artifact
|
|
5
|
+
* - owner: everything, including sending requests to the agent, saving
|
|
6
|
+
* files to the computer that shares the artifact and calling its
|
|
7
|
+
* connectors (`mcp`);
|
|
7
8
|
* - editor (a guest who may edit): changes the artifact, removes comments
|
|
8
9
|
* and restores versions, but cannot reach the owner's agent or downloads;
|
|
9
10
|
* - commenter: comments (add, reply, resolve, move) on a read-only artifact;
|
|
@@ -26,6 +27,8 @@ export interface RoleAbilities {
|
|
|
26
27
|
canAsk: boolean;
|
|
27
28
|
/** Save files through the host's downloads, on the sharing computer (the owner alone; guests get a browser download). */
|
|
28
29
|
canSaveToHost: boolean;
|
|
30
|
+
/** Call the connectors (MCP servers) set up on the sharing computer (the owner alone). */
|
|
31
|
+
canUseConnectors: boolean;
|
|
29
32
|
}
|
|
30
33
|
/** The abilities of a role. An unknown role reads only. */
|
|
31
34
|
export declare function roleAbilities(role: Role | string): RoleAbilities;
|
package/src/roles.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* What each role may do in an artifact, the way the host's sharing rules
|
|
3
3
|
* allow it, so an editor only offers what the server will accept:
|
|
4
4
|
*
|
|
5
|
-
* - owner: everything, including sending requests to the agent
|
|
6
|
-
* files to the computer that shares the artifact
|
|
5
|
+
* - owner: everything, including sending requests to the agent, saving
|
|
6
|
+
* files to the computer that shares the artifact and calling its
|
|
7
|
+
* connectors (`mcp`);
|
|
7
8
|
* - editor (a guest who may edit): changes the artifact, removes comments
|
|
8
9
|
* and restores versions, but cannot reach the owner's agent or downloads;
|
|
9
10
|
* - commenter: comments (add, reply, resolve, move) on a read-only artifact;
|
|
@@ -16,7 +17,7 @@ export function roleAbilities(role) {
|
|
|
16
17
|
const owner = role === 'owner';
|
|
17
18
|
const edits = owner || role === 'editor';
|
|
18
19
|
const comments = edits || role === 'commenter';
|
|
19
|
-
return { canEdit: edits, canComment: comments, canRemoveComments: edits, canRestore: edits, canAsk: owner, canSaveToHost: owner };
|
|
20
|
+
return { canEdit: edits, canComment: comments, canRemoveComments: edits, canRestore: edits, canAsk: owner, canSaveToHost: owner, canUseConnectors: owner };
|
|
20
21
|
}
|
|
21
22
|
/** How the chrome names a read-only role (`null`: the viewer can edit). */
|
|
22
23
|
export function readOnlyLabel(role) {
|