@linxin666/dsh-remote-bridge 0.4.10 → 0.4.11
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.i18n.yaml +2 -2
- package/README.md +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +4 -4
- package/lib/client.js.map +1 -1
- package/lib/index.js +10 -10
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/toolview-slot.d.ts +3 -3
- package/lib/types/client/ui-card.d.ts +1 -1
- package/lib/types/core/connection.d.ts +1 -1
- package/lib/types/core/hub.d.ts +3 -3
- package/lib/types/core/protocol.d.ts +2 -2
- package/lib/types/core/ui.d.ts +1 -1
- package/lib/types/host/ui-tools.d.ts +1 -1
- package/lib/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/client/UiPresentRow.tsx +1 -1
- package/src/client/index.ts +2 -2
- package/src/client/toolview-slot.ts +3 -3
- package/src/client/ui-card.ts +1 -1
- package/src/core/connection.ts +1 -1
- package/src/core/hub.ts +4 -4
- package/src/core/protocol.ts +2 -2
- package/src/core/ui.ts +1 -1
- package/src/host/ui-tools.ts +4 -4
- package/src/index.ts +5 -5
package/lib/index.js
CHANGED
|
@@ -857,7 +857,7 @@ const CAP_USAGE_STATS = "usage.stats.v1";
|
|
|
857
857
|
* §24.1 同一判据):宿主公告同名项、客户端声明,双向缺一即当作这个能力不存在,
|
|
858
858
|
* 且不得把「宿主没这个能力」渲染成「这张卡不存在」或任何错误态。
|
|
859
859
|
*
|
|
860
|
-
* 宿主半区只有真实现了 `
|
|
860
|
+
* 宿主半区只有真实现了 `ui_present` 这一半的桥才把自己列进
|
|
861
861
|
* {@link SERVED_CAPABILITIES},所以一个客户端读到这个名字,就能断定 `ui.request`
|
|
862
862
|
* 会出现、`ui.event` 会被接受。
|
|
863
863
|
*/
|
|
@@ -7924,7 +7924,7 @@ var BridgeHub = class {
|
|
|
7924
7924
|
* Present one page to the clients that declared `ui.v1` and wait for the user's
|
|
7925
7925
|
* first action (§35).
|
|
7926
7926
|
*
|
|
7927
|
-
* The body of the `
|
|
7927
|
+
* The body of the `ui_present` tool call. Claimed only while a paired
|
|
7928
7928
|
* connection that declared the channel is on the wire: with none, a page would
|
|
7929
7929
|
* reach nobody, so the call answers `unavailable` at once instead of holding the
|
|
7930
7930
|
* agent on a wait no screen can end (§35.6 — the same judgement as §11.3's claim
|
|
@@ -8167,7 +8167,7 @@ var BridgeHub = class {
|
|
|
8167
8167
|
/**
|
|
8168
8168
|
* @returns whether a reachable right now connection can be shown a page (§35.6).
|
|
8169
8169
|
*
|
|
8170
|
-
* The one predicate `
|
|
8170
|
+
* The one predicate `ui_present` reads before it claims anything, and the reason
|
|
8171
8171
|
* a call with nobody on the wire answers `unavailable` without holding the agent:
|
|
8172
8172
|
* announcing a capability is the whole of what makes a client able to receive one.
|
|
8173
8173
|
*/
|
|
@@ -17673,7 +17673,7 @@ function toolAbortedBeforeDispatchResult(prior) {
|
|
|
17673
17673
|
//#endregion
|
|
17674
17674
|
//#region src/host/ui-tools.ts
|
|
17675
17675
|
/**
|
|
17676
|
-
* The `
|
|
17676
|
+
* The `ui_present` model tool: the agent hands one self-contained page to the
|
|
17677
17677
|
* clients paired with this host, and the user's first action comes back as that
|
|
17678
17678
|
* same tool call's result (protocol §35).
|
|
17679
17679
|
*
|
|
@@ -17708,12 +17708,12 @@ const UI_PRESENT_DESCRIPTION = [
|
|
|
17708
17708
|
].join(" ");
|
|
17709
17709
|
/** The canonical result body: one sentence, never the page itself. */
|
|
17710
17710
|
function describe(value) {
|
|
17711
|
-
if (typeof value !== "object" || value === null) return "
|
|
17711
|
+
if (typeof value !== "object" || value === null) return "ui_present finished";
|
|
17712
17712
|
const record = value;
|
|
17713
17713
|
if (record.ok === true) return `presented to ${typeof record.delivered === "number" ? record.delivered : 0} paired client(s); settled by the operator with "${typeof record.type === "string" ? record.type : "an action"}"`;
|
|
17714
17714
|
const reason = typeof record.reason === "string" ? record.reason : "unknown";
|
|
17715
17715
|
if (reason === "timeout" || reason === "cancelled") return `presented to ${typeof record.delivered === "number" ? record.delivered : 0} paired client(s); the card was released without an action (${reason})`;
|
|
17716
|
-
return `
|
|
17716
|
+
return `ui_present was refused: ${reason}`;
|
|
17717
17717
|
}
|
|
17718
17718
|
/**
|
|
17719
17719
|
* The presentation payload a transcript-rendering client reads (§35.10).
|
|
@@ -17747,7 +17747,7 @@ function presentationOf(args, value) {
|
|
|
17747
17747
|
*/
|
|
17748
17748
|
function createUiPresentTool(host) {
|
|
17749
17749
|
return defineTool({
|
|
17750
|
-
name: "
|
|
17750
|
+
name: "ui_present",
|
|
17751
17751
|
description: UI_PRESENT_DESCRIPTION,
|
|
17752
17752
|
parameters: {
|
|
17753
17753
|
html: {
|
|
@@ -18283,7 +18283,7 @@ const name = "remote-bridge";
|
|
|
18283
18283
|
* The Host services this plugin cannot run without.
|
|
18284
18284
|
*
|
|
18285
18285
|
* `tools` is what protocol §35 added: this bridge contributes one model tool of
|
|
18286
|
-
* its own (`
|
|
18286
|
+
* its own (`ui_present`), so a host that composes no tool registry is a host where
|
|
18287
18287
|
* the card channel has no caller — the row simply does not mount here.
|
|
18288
18288
|
*/
|
|
18289
18289
|
const inject = [
|
|
@@ -18703,11 +18703,11 @@ function applyImpl(ctx) {
|
|
|
18703
18703
|
}, "remote-bridge: protocol v1 routes");
|
|
18704
18704
|
ctx.effect(() => {
|
|
18705
18705
|
const disposeTool = ctx.tools.register(createUiPresentTool({ present: async (card, signal) => await hub.present(card, signal) }));
|
|
18706
|
-
log("model tool
|
|
18706
|
+
log("model tool ui_present registered");
|
|
18707
18707
|
return () => {
|
|
18708
18708
|
disposeTool();
|
|
18709
18709
|
};
|
|
18710
|
-
}, "remote-bridge:
|
|
18710
|
+
}, "remote-bridge: ui_present tool");
|
|
18711
18711
|
ctx.on("session/event", (session, event) => {
|
|
18712
18712
|
usage.record(session.id, event);
|
|
18713
18713
|
});
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* service, its roster, or its browser cookie path.
|
|
13
13
|
*
|
|
14
14
|
* The half also draws the transcript side of §35.11: one keyed `tool.call.toolview`
|
|
15
|
-
* entry renders a `
|
|
15
|
+
* entry renders a `ui_present` call's whole page in a controlled frame, while the
|
|
16
16
|
* phone stays the only place an action can be answered.
|
|
17
17
|
*
|
|
18
18
|
* Export discipline (packages/AGENTS.md): the /client surface carries only what
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* shape locally:
|
|
12
12
|
*
|
|
13
13
|
* - the slot is keyed and session-scoped, and its key is the wire Tool name
|
|
14
|
-
* (`
|
|
14
|
+
* (`ui_present`), which is what makes one registration draw the card's body
|
|
15
15
|
* without shadowing the official `tool-call` renderer;
|
|
16
16
|
* - the owner publishes the call identity plus a stage union, mirrored here from
|
|
17
17
|
* the upstream `ToolCallPhaseProps`: `preparing`, `start` and `result`. The
|
|
@@ -32,7 +32,7 @@ import { type UiPresentRowProps } from './UiPresentRow.tsx';
|
|
|
32
32
|
/** The keyed Tool view slot the official row dispatches into. */
|
|
33
33
|
export declare const TOOLVIEW_SLOT = "tool.call.toolview";
|
|
34
34
|
/** The wire Tool name this package renders: the keyed cell it claims. */
|
|
35
|
-
export declare const PRESENT_TOOL = "
|
|
35
|
+
export declare const PRESENT_TOOL = "ui_present";
|
|
36
36
|
/** The registration options this seam needs. */
|
|
37
37
|
export interface ToolviewRegistration {
|
|
38
38
|
/** Exact SlotMap key. */
|
|
@@ -54,7 +54,7 @@ export interface ToolviewSlotHost {
|
|
|
54
54
|
readonly slots: unknown;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* Contribute the `
|
|
57
|
+
* Contribute the `ui_present` card into the Tool row.
|
|
58
58
|
*
|
|
59
59
|
* The contribution is declaration-aware: `inject` waits for the official slot
|
|
60
60
|
* declaration, so a GUI composed without a Tool layer has no keyed cell and thus
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The transcript reading of one `
|
|
2
|
+
* The transcript reading of one `ui_present` call (protocol §35.10, §35.11):
|
|
3
3
|
* what the desktop row draws, decided without touching the DOM.
|
|
4
4
|
*
|
|
5
5
|
* A card has two sources and neither may be dropped. While the call is still
|
|
@@ -91,7 +91,7 @@ export interface BridgeConnectionOptions {
|
|
|
91
91
|
/** Pending user questions: the claims this bridge holds and the answer path back to the host. */
|
|
92
92
|
readonly questions: QuestionClaims;
|
|
93
93
|
/**
|
|
94
|
-
* 整页卡(§35):`
|
|
94
|
+
* 整页卡(§35):`ui_present` 持有的每一张卡,`ui.event` 结算它们,`ui.list`
|
|
95
95
|
* 把它们念回去。与提问表平级、各自认领各自结算——两条通道互不改形状(§35.8)。
|
|
96
96
|
*/
|
|
97
97
|
readonly ui: UiCards;
|
package/lib/types/core/hub.d.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* to answer with; and the claim outlives the last paired device by a grace
|
|
25
25
|
* window, because a phone whose app the system suspended has refused nothing.
|
|
26
26
|
*
|
|
27
|
-
* A presented page (`
|
|
27
|
+
* A presented page (`ui_present`, protocol §35) is the second claim that takes a
|
|
28
28
|
* grace window, and it takes the same one: the tool call it blocks is the agent's
|
|
29
29
|
* own wait, the card is the only place its answer can come from, and a phone that
|
|
30
30
|
* was suspended has refused nothing either. It differs in one direction only —
|
|
@@ -103,7 +103,7 @@ export interface BridgeHubOptions extends BridgeConnectionOptions {
|
|
|
103
103
|
readonly offlineClaimTtlMs?: number;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
|
-
* What one `
|
|
106
|
+
* What one `ui_present` call ended as, with the count of connections that took
|
|
107
107
|
* the first frame.
|
|
108
108
|
*
|
|
109
109
|
* The count is here rather than in the card registry because it is a fact about
|
|
@@ -221,7 +221,7 @@ export declare class BridgeHub {
|
|
|
221
221
|
* Present one page to the clients that declared `ui.v1` and wait for the user's
|
|
222
222
|
* first action (§35).
|
|
223
223
|
*
|
|
224
|
-
* The body of the `
|
|
224
|
+
* The body of the `ui_present` tool call. Claimed only while a paired
|
|
225
225
|
* connection that declared the channel is on the wire: with none, a page would
|
|
226
226
|
* reach nobody, so the call answers `unavailable` at once instead of holding the
|
|
227
227
|
* agent on a wait no screen can end (§35.6 — the same judgement as §11.3's claim
|
|
@@ -245,7 +245,7 @@ export declare const CAP_USAGE_STATS = "usage.stats.v1";
|
|
|
245
245
|
* §24.1 同一判据):宿主公告同名项、客户端声明,双向缺一即当作这个能力不存在,
|
|
246
246
|
* 且不得把「宿主没这个能力」渲染成「这张卡不存在」或任何错误态。
|
|
247
247
|
*
|
|
248
|
-
* 宿主半区只有真实现了 `
|
|
248
|
+
* 宿主半区只有真实现了 `ui_present` 这一半的桥才把自己列进
|
|
249
249
|
* {@link SERVED_CAPABILITIES},所以一个客户端读到这个名字,就能断定 `ui.request`
|
|
250
250
|
* 会出现、`ui.event` 会被接受。
|
|
251
251
|
*/
|
|
@@ -503,7 +503,7 @@ export declare const PROTO = 1;
|
|
|
503
503
|
*
|
|
504
504
|
* 21 当可交互回复(协议 §35)落地:新增 {@link CAP_UI} 与 {@link CAP_UI_LIST}
|
|
505
505
|
* 两个能力名、{@link TOPIC_UI_REQUEST} 一个主题、{@link METHOD_UI_EVENT} 与
|
|
506
|
-
* {@link METHOD_UI_LIST} 两个方法,宿主半区还多一个模型工具 `
|
|
506
|
+
* {@link METHOD_UI_LIST} 两个方法,宿主半区还多一个模型工具 `ui_present`。客户端
|
|
507
507
|
* 因此从线路上读到两项新能力名、一种新主题与两种新应答体,所以 minor 抬一格;
|
|
508
508
|
* `proto` 仍为 1,没有任何既有帧、既有方法或既有键改形状。工具结果是**新增**的:
|
|
509
509
|
* 老会话、老 prompt、老回合都不受影响,工具名进入宿主工具表之后只有新回合才可能
|
package/lib/types/core/ui.d.ts
CHANGED
|
@@ -171,7 +171,7 @@ export interface OpenCardInput {
|
|
|
171
171
|
*/
|
|
172
172
|
readonly onSettled?: (card: UiCardView) => void;
|
|
173
173
|
}
|
|
174
|
-
/** The presentation one `
|
|
174
|
+
/** The presentation one `ui_present` call is waiting on, as the hub publishes it. */
|
|
175
175
|
export interface ClaimedCard extends UiCardView {
|
|
176
176
|
/** The user's action, or the refusal that ended the card. Never rejects. */
|
|
177
177
|
readonly outcome: Promise<UiPresentOutcome>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `
|
|
2
|
+
* The `ui_present` model tool: the agent hands one self-contained page to the
|
|
3
3
|
* clients paired with this host, and the user's first action comes back as that
|
|
4
4
|
* same tool call's result (protocol §35).
|
|
5
5
|
*
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - `approval/request` is claimed in-process while a paired device is connected,
|
|
14
14
|
* and delegated (`next()`) in every other case, which the Host normalizes to
|
|
15
15
|
* the fail-closed `'unavailable'`.
|
|
16
|
-
* - `
|
|
16
|
+
* - `ui_present` is this bridge's own model tool (protocol §35): one whole
|
|
17
17
|
* self-contained page is announced as `ui.request` to the paired clients that
|
|
18
18
|
* declared `ui.v1`, and the user's first action inside it comes back as that
|
|
19
19
|
* tool call's result. `ui.event` settles it, `ui.list` reads the cards still
|
|
@@ -42,7 +42,7 @@ export declare const name = "remote-bridge";
|
|
|
42
42
|
* The Host services this plugin cannot run without.
|
|
43
43
|
*
|
|
44
44
|
* `tools` is what protocol §35 added: this bridge contributes one model tool of
|
|
45
|
-
* its own (`
|
|
45
|
+
* its own (`ui_present`), so a host that composes no tool registry is a host where
|
|
46
46
|
* the card channel has no caller — the row simply does not mount here.
|
|
47
47
|
*/
|
|
48
48
|
export declare const inject: string[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-remote-bridge",
|
|
3
3
|
"description": "DSH remote bridge: the host half serves protocol v1 over one exact /ios/v1 WebSocket route — session roster, history baseline, prompting, live turn increments with tool activity, interrupt, and in-process agent approval — to a device paired by a one-shot bootstrap token and a P-256 challenge-response, with the token endpoint admitted only from this machine; the browser half adds one sidebar-foot panel that shows that same one-shot token as a QR symbol and draws an interactive card inside the tool row without answering it, and adds no wire surface",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.11",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The transcript row of one `
|
|
2
|
+
* The transcript row of one `ui_present` call: the whole page an agent handed
|
|
3
3
|
* into the session, drawn in a controlled frame (protocol §35.11).
|
|
4
4
|
*
|
|
5
5
|
* The row renders and does not answer. The frame carries `srcdoc` and the one
|
package/src/client/index.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* service, its roster, or its browser cookie path.
|
|
13
13
|
*
|
|
14
14
|
* The half also draws the transcript side of §35.11: one keyed `tool.call.toolview`
|
|
15
|
-
* entry renders a `
|
|
15
|
+
* entry renders a `ui_present` call's whole page in a controlled frame, while the
|
|
16
16
|
* phone stays the only place an action can be answered.
|
|
17
17
|
*
|
|
18
18
|
* Export discipline (packages/AGENTS.md): the /client surface carries only what
|
|
@@ -80,7 +80,7 @@ export function apply(ctx: ClientContext): void {
|
|
|
80
80
|
})
|
|
81
81
|
|
|
82
82
|
// The transcript card of an interactive presentation (§35.11): one keyed
|
|
83
|
-
// registration under the wire Tool name draws the body of a `
|
|
83
|
+
// registration under the wire Tool name draws the body of a `ui_present` call,
|
|
84
84
|
// so the official Tool row keeps everything else — identity, timing and the
|
|
85
85
|
// dispatch tree — and no Chat Node renderer is shadowed.
|
|
86
86
|
registerPresentToolview(ctx, NS)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* shape locally:
|
|
12
12
|
*
|
|
13
13
|
* - the slot is keyed and session-scoped, and its key is the wire Tool name
|
|
14
|
-
* (`
|
|
14
|
+
* (`ui_present`), which is what makes one registration draw the card's body
|
|
15
15
|
* without shadowing the official `tool-call` renderer;
|
|
16
16
|
* - the owner publishes the call identity plus a stage union, mirrored here from
|
|
17
17
|
* the upstream `ToolCallPhaseProps`: `preparing`, `start` and `result`. The
|
|
@@ -35,7 +35,7 @@ import { UiPresentRow, type UiPresentRowProps } from './UiPresentRow.tsx'
|
|
|
35
35
|
export const TOOLVIEW_SLOT = 'tool.call.toolview'
|
|
36
36
|
|
|
37
37
|
/** The wire Tool name this package renders: the keyed cell it claims. */
|
|
38
|
-
export const PRESENT_TOOL = '
|
|
38
|
+
export const PRESENT_TOOL = 'ui_present'
|
|
39
39
|
|
|
40
40
|
/** The registration options this seam needs. */
|
|
41
41
|
export interface ToolviewRegistration {
|
|
@@ -61,7 +61,7 @@ export interface ToolviewSlotHost {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Contribute the `
|
|
64
|
+
* Contribute the `ui_present` card into the Tool row.
|
|
65
65
|
*
|
|
66
66
|
* The contribution is declaration-aware: `inject` waits for the official slot
|
|
67
67
|
* declaration, so a GUI composed without a Tool layer has no keyed cell and thus
|
package/src/client/ui-card.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The transcript reading of one `
|
|
2
|
+
* The transcript reading of one `ui_present` call (protocol §35.10, §35.11):
|
|
3
3
|
* what the desktop row draws, decided without touching the DOM.
|
|
4
4
|
*
|
|
5
5
|
* A card has two sources and neither may be dropped. While the call is still
|
package/src/core/connection.ts
CHANGED
|
@@ -191,7 +191,7 @@ export interface BridgeConnectionOptions {
|
|
|
191
191
|
/** Pending user questions: the claims this bridge holds and the answer path back to the host. */
|
|
192
192
|
readonly questions: QuestionClaims
|
|
193
193
|
/**
|
|
194
|
-
* 整页卡(§35):`
|
|
194
|
+
* 整页卡(§35):`ui_present` 持有的每一张卡,`ui.event` 结算它们,`ui.list`
|
|
195
195
|
* 把它们念回去。与提问表平级、各自认领各自结算——两条通道互不改形状(§35.8)。
|
|
196
196
|
*/
|
|
197
197
|
readonly ui: UiCards
|
package/src/core/hub.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* to answer with; and the claim outlives the last paired device by a grace
|
|
25
25
|
* window, because a phone whose app the system suspended has refused nothing.
|
|
26
26
|
*
|
|
27
|
-
* A presented page (`
|
|
27
|
+
* A presented page (`ui_present`, protocol §35) is the second claim that takes a
|
|
28
28
|
* grace window, and it takes the same one: the tool call it blocks is the agent's
|
|
29
29
|
* own wait, the card is the only place its answer can come from, and a phone that
|
|
30
30
|
* was suspended has refused nothing either. It differs in one direction only —
|
|
@@ -143,7 +143,7 @@ export interface BridgeHubOptions extends BridgeConnectionOptions {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
|
-
* What one `
|
|
146
|
+
* What one `ui_present` call ended as, with the count of connections that took
|
|
147
147
|
* the first frame.
|
|
148
148
|
*
|
|
149
149
|
* The count is here rather than in the card registry because it is a fact about
|
|
@@ -475,7 +475,7 @@ export class BridgeHub {
|
|
|
475
475
|
* Present one page to the clients that declared `ui.v1` and wait for the user's
|
|
476
476
|
* first action (§35).
|
|
477
477
|
*
|
|
478
|
-
* The body of the `
|
|
478
|
+
* The body of the `ui_present` tool call. Claimed only while a paired
|
|
479
479
|
* connection that declared the channel is on the wire: with none, a page would
|
|
480
480
|
* reach nobody, so the call answers `unavailable` at once instead of holding the
|
|
481
481
|
* agent on a wait no screen can end (§35.6 — the same judgement as §11.3's claim
|
|
@@ -745,7 +745,7 @@ export class BridgeHub {
|
|
|
745
745
|
/**
|
|
746
746
|
* @returns whether a reachable right now connection can be shown a page (§35.6).
|
|
747
747
|
*
|
|
748
|
-
* The one predicate `
|
|
748
|
+
* The one predicate `ui_present` reads before it claims anything, and the reason
|
|
749
749
|
* a call with nobody on the wire answers `unavailable` without holding the agent:
|
|
750
750
|
* announcing a capability is the whole of what makes a client able to receive one.
|
|
751
751
|
*/
|
package/src/core/protocol.ts
CHANGED
|
@@ -263,7 +263,7 @@ export const CAP_USAGE_STATS = 'usage.stats.v1'
|
|
|
263
263
|
* §24.1 同一判据):宿主公告同名项、客户端声明,双向缺一即当作这个能力不存在,
|
|
264
264
|
* 且不得把「宿主没这个能力」渲染成「这张卡不存在」或任何错误态。
|
|
265
265
|
*
|
|
266
|
-
* 宿主半区只有真实现了 `
|
|
266
|
+
* 宿主半区只有真实现了 `ui_present` 这一半的桥才把自己列进
|
|
267
267
|
* {@link SERVED_CAPABILITIES},所以一个客户端读到这个名字,就能断定 `ui.request`
|
|
268
268
|
* 会出现、`ui.event` 会被接受。
|
|
269
269
|
*/
|
|
@@ -581,7 +581,7 @@ export const PROTO = 1
|
|
|
581
581
|
*
|
|
582
582
|
* 21 当可交互回复(协议 §35)落地:新增 {@link CAP_UI} 与 {@link CAP_UI_LIST}
|
|
583
583
|
* 两个能力名、{@link TOPIC_UI_REQUEST} 一个主题、{@link METHOD_UI_EVENT} 与
|
|
584
|
-
* {@link METHOD_UI_LIST} 两个方法,宿主半区还多一个模型工具 `
|
|
584
|
+
* {@link METHOD_UI_LIST} 两个方法,宿主半区还多一个模型工具 `ui_present`。客户端
|
|
585
585
|
* 因此从线路上读到两项新能力名、一种新主题与两种新应答体,所以 minor 抬一格;
|
|
586
586
|
* `proto` 仍为 1,没有任何既有帧、既有方法或既有键改形状。工具结果是**新增**的:
|
|
587
587
|
* 老会话、老 prompt、老回合都不受影响,工具名进入宿主工具表之后只有新回合才可能
|
package/src/core/ui.ts
CHANGED
|
@@ -206,7 +206,7 @@ export interface OpenCardInput {
|
|
|
206
206
|
readonly onSettled?: (card: UiCardView) => void
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
/** The presentation one `
|
|
209
|
+
/** The presentation one `ui_present` call is waiting on, as the hub publishes it. */
|
|
210
210
|
export interface ClaimedCard extends UiCardView {
|
|
211
211
|
/** The user's action, or the refusal that ended the card. Never rejects. */
|
|
212
212
|
readonly outcome: Promise<UiPresentOutcome>
|
package/src/host/ui-tools.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `
|
|
2
|
+
* The `ui_present` model tool: the agent hands one self-contained page to the
|
|
3
3
|
* clients paired with this host, and the user's first action comes back as that
|
|
4
4
|
* same tool call's result (protocol §35).
|
|
5
5
|
*
|
|
@@ -88,7 +88,7 @@ export type UiPresentValue =
|
|
|
88
88
|
|
|
89
89
|
/** The canonical result body: one sentence, never the page itself. */
|
|
90
90
|
function describe(value: unknown): string {
|
|
91
|
-
if (typeof value !== 'object' || value === null) return '
|
|
91
|
+
if (typeof value !== 'object' || value === null) return 'ui_present finished'
|
|
92
92
|
const record = value as { ok?: unknown; reason?: unknown; type?: unknown; delivered?: unknown }
|
|
93
93
|
if (record.ok === true) {
|
|
94
94
|
const delivered = typeof record.delivered === 'number' ? record.delivered : 0
|
|
@@ -100,7 +100,7 @@ function describe(value: unknown): string {
|
|
|
100
100
|
const delivered = typeof record.delivered === 'number' ? record.delivered : 0
|
|
101
101
|
return `presented to ${delivered} paired client(s); the card was released without an action (${reason})`
|
|
102
102
|
}
|
|
103
|
-
return `
|
|
103
|
+
return `ui_present was refused: ${reason}`
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/**
|
|
@@ -137,7 +137,7 @@ function presentationOf(args: { html: string; title?: string; height?: number },
|
|
|
137
137
|
*/
|
|
138
138
|
export function createUiPresentTool(host: UiToolHost): ToolDefinition {
|
|
139
139
|
return defineTool({
|
|
140
|
-
name: '
|
|
140
|
+
name: 'ui_present',
|
|
141
141
|
description: UI_PRESENT_DESCRIPTION,
|
|
142
142
|
parameters: {
|
|
143
143
|
html: {
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - `approval/request` is claimed in-process while a paired device is connected,
|
|
14
14
|
* and delegated (`next()`) in every other case, which the Host normalizes to
|
|
15
15
|
* the fail-closed `'unavailable'`.
|
|
16
|
-
* - `
|
|
16
|
+
* - `ui_present` is this bridge's own model tool (protocol §35): one whole
|
|
17
17
|
* self-contained page is announced as `ui.request` to the paired clients that
|
|
18
18
|
* declared `ui.v1`, and the user's first action inside it comes back as that
|
|
19
19
|
* tool call's result. `ui.event` settles it, `ui.list` reads the cards still
|
|
@@ -82,7 +82,7 @@ export const name = 'remote-bridge'
|
|
|
82
82
|
* The Host services this plugin cannot run without.
|
|
83
83
|
*
|
|
84
84
|
* `tools` is what protocol §35 added: this bridge contributes one model tool of
|
|
85
|
-
* its own (`
|
|
85
|
+
* its own (`ui_present`), so a host that composes no tool registry is a host where
|
|
86
86
|
* the card channel has no caller — the row simply does not mount here.
|
|
87
87
|
*/
|
|
88
88
|
export const inject = ['typertGateway', 'webServer', 'tools']
|
|
@@ -541,7 +541,7 @@ function applyImpl(ctx: Context): void {
|
|
|
541
541
|
}
|
|
542
542
|
}, 'remote-bridge: protocol v1 routes')
|
|
543
543
|
|
|
544
|
-
// §35 的模型工具:`
|
|
544
|
+
// §35 的模型工具:`ui_present` 把 agent 写的整页交给已配对的客户端,并在用户
|
|
545
545
|
// 动作时把结构化事件作为它自己的返回值交回。注册在 `ctx.effect` 里、返回
|
|
546
546
|
// disposer,所以插件卸载时工具名随行消失,宿主工具表不会留下一根指向空实现的
|
|
547
547
|
// 指针;`execute` 把 `exec.signal` 一路传到认领表,回合被取消时那张卡立刻结算。
|
|
@@ -549,9 +549,9 @@ function applyImpl(ctx: Context): void {
|
|
|
549
549
|
const disposeTool = ctx.tools.register(createUiPresentTool({
|
|
550
550
|
present: async (card, signal) => await hub.present(card, signal),
|
|
551
551
|
}))
|
|
552
|
-
log('model tool
|
|
552
|
+
log('model tool ui_present registered')
|
|
553
553
|
return () => { disposeTool() }
|
|
554
|
-
}, 'remote-bridge:
|
|
554
|
+
}, 'remote-bridge: ui_present tool')
|
|
555
555
|
|
|
556
556
|
// 会话事件是 `usage.session` 唯一的来源:桥不读会话日志、也不回填历史,所以
|
|
557
557
|
// 这个监听器挂上之前广播的事件不会有读数,宿主没广播过的窗口也不会被编出来。
|