@linxin666/dsh-remote-bridge 0.4.15 → 0.4.17
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 +11 -6
- package/README.zh.md +11 -6
- package/lib/client.js.map +1 -1
- package/lib/index.js +980 -413
- package/lib/types/core/approvals.d.ts +10 -0
- package/lib/types/core/attachment-paths.d.ts +89 -0
- package/lib/types/core/connection.d.ts +8 -0
- package/lib/types/core/hub.d.ts +33 -26
- package/lib/types/core/protocol.d.ts +39 -1
- package/lib/types/core/questions.d.ts +20 -4
- package/lib/types/core/wire.d.ts +8 -0
- package/lib/types/index.d.ts +2 -16
- package/package.json +14 -14
- package/src/core/approvals.ts +13 -0
- package/src/core/attachment-paths.ts +288 -0
- package/src/core/connection.ts +160 -2
- package/src/core/hub.ts +155 -156
- package/src/core/protocol.ts +41 -1
- package/src/core/questions.ts +61 -14
- package/src/core/wire.ts +9 -0
- package/src/index.ts +3 -25
|
@@ -84,6 +84,16 @@ export declare class ApprovalRegistry {
|
|
|
84
84
|
* @returns whether the id was still pending; a stale, expired or unknown id is refused.
|
|
85
85
|
*/
|
|
86
86
|
resolve(id: string, decision: ClaimedDecision): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Release one question the host's own panel answered first.
|
|
89
|
+
*
|
|
90
|
+
* The release is not a decision: the panel's answer travels back through the
|
|
91
|
+
* answerer chain it came from, so the claim only has to stop being pending —
|
|
92
|
+
* which is what also makes a later answer from the phone refuse as unknown
|
|
93
|
+
* instead of settling a question that is already over.
|
|
94
|
+
* @returns whether this call released it; false when the phone already had.
|
|
95
|
+
*/
|
|
96
|
+
releaseToHost(id: string): boolean;
|
|
87
97
|
/**
|
|
88
98
|
* Withdraw the named questions, delegating each to the next answerer.
|
|
89
99
|
* @returns how many were still pending.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The image paths one session's own durable transcript whitelists, and the file
|
|
3
|
+
* decisions `session.attachment.path` takes on the one path it is handed.
|
|
4
|
+
*
|
|
5
|
+
* This module IS that method's authorization. The bridge serves bytes only for a
|
|
6
|
+
* path the session itself named, so the whitelist is computed here from that
|
|
7
|
+
* session's store and from nothing else: never a path a client chose, never a
|
|
8
|
+
* directory listing, never a second session.
|
|
9
|
+
*
|
|
10
|
+
* Two sources and no others:
|
|
11
|
+
* - an offload placeholder in a message body, `<path>…</path>` immediately
|
|
12
|
+
* followed by `<type>image</type>` — the envelope the harness writes when
|
|
13
|
+
* it keeps image bytes out of a durable message, and the one a phone already
|
|
14
|
+
* reads with `OffloadedImages.segments(of:)`;
|
|
15
|
+
* - the image reference of a durable tool result — `meta.path`, what
|
|
16
|
+
* `read_image` publishes through its `output.presentationMeta`, or a
|
|
17
|
+
* text block that is itself a JSON image reference, which is how a
|
|
18
|
+
* `run_code` program's own return value is persisted — and what a client
|
|
19
|
+
* draws as `ToolBlock.image(ImageRef(path:))`.
|
|
20
|
+
*
|
|
21
|
+
* A path either source names is kept only when it is a host absolute path: the
|
|
22
|
+
* request side admits nothing else, so a name that could never be asked for —
|
|
23
|
+
* a plugin's own namespace, a relative path — is not a whitelist entry.
|
|
24
|
+
*
|
|
25
|
+
* Records are the ones `session/page` answers and `turnsOfRecords`
|
|
26
|
+
* projects: `{event: {type, seq, time, data}}`.
|
|
27
|
+
* @module dsh-remote-bridge/core/attachment-paths
|
|
28
|
+
*/
|
|
29
|
+
/** One image a session's transcript names: the reference a client already drew. */
|
|
30
|
+
export interface AttachmentFacts {
|
|
31
|
+
/** The absolute path, byte for byte as the transcript wrote it. */
|
|
32
|
+
readonly path: string;
|
|
33
|
+
readonly mediaType?: string;
|
|
34
|
+
readonly bytes?: number;
|
|
35
|
+
readonly width?: number;
|
|
36
|
+
readonly height?: number;
|
|
37
|
+
}
|
|
38
|
+
/** One whitelisted path's bytes, or the code that refused them. */
|
|
39
|
+
export type AttachmentRead = {
|
|
40
|
+
readonly ok: true;
|
|
41
|
+
readonly image: AttachmentFacts;
|
|
42
|
+
readonly data: string;
|
|
43
|
+
} | {
|
|
44
|
+
readonly ok: false;
|
|
45
|
+
readonly code: string;
|
|
46
|
+
readonly msg: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The oldest entry seq one store page carries.
|
|
50
|
+
*
|
|
51
|
+
* A page read walks backwards by this number, so the walk has to read it off the
|
|
52
|
+
* page itself: the store's own `hasMore` says that older entries exist,
|
|
53
|
+
* never where they end.
|
|
54
|
+
* @param records - one `session/page` answer's records.
|
|
55
|
+
* @returns the smallest `event.seq` they carry, or undefined when they carry none.
|
|
56
|
+
*/
|
|
57
|
+
export declare function oldestSeqOf(records: readonly unknown[]): number | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Every image path one session's durable records whitelist.
|
|
60
|
+
* @param records - that session's own records, as `session/page` answered them.
|
|
61
|
+
* @returns one entry per path; a second sighting never erases a stated fact.
|
|
62
|
+
*/
|
|
63
|
+
export declare function attachmentPathsOf(records: readonly unknown[]): Map<string, AttachmentFacts>;
|
|
64
|
+
/**
|
|
65
|
+
* The media type one head declares, or undefined when it is none of the four.
|
|
66
|
+
*
|
|
67
|
+
* The signatures are the harness's own four — PNG, JPEG, GIF87a/89a and
|
|
68
|
+
* RIFF-WebP — because the bytes are what a client will decode.
|
|
69
|
+
* @param head - the file's first bytes, as read.
|
|
70
|
+
* @returns the media type, or undefined.
|
|
71
|
+
*/
|
|
72
|
+
export declare function mediaTypeOfSignature(head: Buffer): string | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Read one whitelisted path, applying the three file decisions in order.
|
|
75
|
+
*
|
|
76
|
+
* The whitelist is the first decision and it is not this function's: a caller
|
|
77
|
+
* hands over a path it already matched byte for byte. What is left is whether the
|
|
78
|
+
* file at that path is still the one the session named — `realpath()` has to
|
|
79
|
+
* return the same string, so a symlink pointing anywhere else is refused rather
|
|
80
|
+
* than followed — whether it is a regular file at all, and whether its own first
|
|
81
|
+
* bytes are one of the four image signatures. The extension is never consulted: a
|
|
82
|
+
* `.png` that is not a PNG is refused, and a PNG named `.txt` is served.
|
|
83
|
+
*
|
|
84
|
+
* The answer's `image` is the reference the session's transcript named; this
|
|
85
|
+
* read measures nothing into it. The magic decides, and the bytes are what crosses.
|
|
86
|
+
* @param facts - the whitelist entry the request matched.
|
|
87
|
+
* @returns the bytes as base64, or the refusal the first failing decision states.
|
|
88
|
+
*/
|
|
89
|
+
export declare function readAttachment(facts: AttachmentFacts): Promise<AttachmentRead>;
|
|
@@ -67,6 +67,14 @@ export declare const DEEP_HISTORY_WINDOW: {
|
|
|
67
67
|
readonly minTurns: 2;
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Highest number of sessions one connection keeps a computed whitelist for.
|
|
72
|
+
*
|
|
73
|
+
* Bounded because a long-lived connection must not grow with every session its
|
|
74
|
+
* client opens: four is a phone's own working set of session screens, and the
|
|
75
|
+
* least recently used one goes first.
|
|
76
|
+
*/
|
|
77
|
+
export declare const ATTACHMENT_WHITELIST_SESSIONS = 4;
|
|
70
78
|
/** Highest number of prompt receipts one connection remembers for idempotency. */
|
|
71
79
|
export declare const PROMPT_RECEIPT_LIMIT = 512;
|
|
72
80
|
/** Largest base64 text one prompt attachment may carry: 6 MiB (protocol §10.2). */
|
package/lib/types/core/hub.d.ts
CHANGED
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
* rather than the socket: with no paired connection on the wire but a device on
|
|
13
13
|
* the roster that registered for pushes, the question is claimed for that phone
|
|
14
14
|
* and the alert is its delivery (§11.3, §32). One predicate decides it — "can a
|
|
15
|
-
* device that is reachable right now receive a question card"
|
|
16
|
-
* again every time a connection finishes its hello, because a client that never
|
|
17
|
-
* declares `questions.v1` going online turns that answer into no.
|
|
15
|
+
* device that is reachable right now receive a question card".
|
|
18
16
|
*
|
|
19
17
|
* The claim on `user-questions/request` follows the same rules, with three
|
|
20
18
|
* differences that belong to the host's own semantics: delegating is not a
|
|
@@ -24,6 +22,14 @@
|
|
|
24
22
|
* to answer with; and the claim outlives the last paired device by a grace
|
|
25
23
|
* window, because a phone whose app the system suspended has refused nothing.
|
|
26
24
|
*
|
|
25
|
+
* Claiming is not swallowing any more. Both claims hand the same question to the
|
|
26
|
+
* host's own answerer chain the instant they exist, so the phone and the host's
|
|
27
|
+
* own panel hold one card each and the first answer settles it. Yielding is not
|
|
28
|
+
* delegating: the phone's card is only over once the other side really answered,
|
|
29
|
+
* which is why a question chain that rejects and an approval chain that falls
|
|
30
|
+
* through to its fail-closed `'unavailable'` end nothing here — the claim stays
|
|
31
|
+
* exactly as answerable as it was before the other surface existed.
|
|
32
|
+
*
|
|
27
33
|
* A presented page (`ui_present`, protocol §35) is the second claim that takes a
|
|
28
34
|
* grace window, and it takes the same one: the tool call it blocks is the agent's
|
|
29
35
|
* own wait, the card is the only place its answer can come from, and a phone that
|
|
@@ -57,12 +63,22 @@ export interface ApprovalRequestLike {
|
|
|
57
63
|
}
|
|
58
64
|
/** The summary line a phone shows for one question. */
|
|
59
65
|
export declare function approvalSummary(request: ApprovalRequestLike): string;
|
|
66
|
+
/**
|
|
67
|
+
* Whether an approval card is still the phone's to answer, or already over.
|
|
68
|
+
*
|
|
69
|
+
* A field of the payload rather than a second topic: a client written before it
|
|
70
|
+
* knows no such key, so it reads exactly the frame it always read and the
|
|
71
|
+
* question simply stays on screen until it is answered or refused.
|
|
72
|
+
*/
|
|
73
|
+
export type ApprovalState = 'open' | 'settled';
|
|
60
74
|
/** The `approval.request` payload one claim is published with. */
|
|
61
75
|
export interface ApprovalRequestPayload {
|
|
62
76
|
readonly sessionId: string;
|
|
63
77
|
readonly id: string;
|
|
64
78
|
readonly summary: string;
|
|
65
79
|
readonly toolName: string;
|
|
80
|
+
/** Absent means `open`, which is what every frame published before this field carries. */
|
|
81
|
+
readonly state?: ApprovalState;
|
|
66
82
|
}
|
|
67
83
|
/**
|
|
68
84
|
* How long a user question outlives the last paired device, in milliseconds.
|
|
@@ -79,28 +95,12 @@ export interface ApprovalRequestPayload {
|
|
|
79
95
|
*/
|
|
80
96
|
export declare const QUESTION_CLAIM_GRACE_MS = 60000;
|
|
81
97
|
/**
|
|
82
|
-
*
|
|
83
|
-
* notification only, in milliseconds (§32.2).
|
|
98
|
+
* What the hub is built with: the bridge's shared options.
|
|
84
99
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* When it runs out the claim is withdrawn and delegated, so the agent behind a
|
|
88
|
-
* timed ask waits at most this long past its own deadline and the agent behind a
|
|
89
|
-
* blocking ask (no call id, no deadline) waits at most this long in total — an
|
|
90
|
-
* accepted cost, because the alternative is a question that vanished while the
|
|
91
|
-
* phone was asleep. The window is the bridge's own constant and not the host's:
|
|
92
|
-
* a deployment overrides it, the host never sees it.
|
|
100
|
+
* A named type of its own so a suite can build a hub without the whole plugin,
|
|
101
|
+
* and so the options this class reads stay one declaration.
|
|
93
102
|
*/
|
|
94
|
-
export declare const OFFLINE_QUESTION_CLAIM_TTL_MS = 600000;
|
|
95
|
-
/** What the hub is built with: the bridge's shared options plus the windows it owns. */
|
|
96
103
|
export interface BridgeHubOptions extends BridgeConnectionOptions {
|
|
97
|
-
/**
|
|
98
|
-
* The offline claim window, in milliseconds.
|
|
99
|
-
*
|
|
100
|
-
* Defaults to {@link OFFLINE_QUESTION_CLAIM_TTL_MS}; a deployment knob, and the
|
|
101
|
-
* seam a suite uses to move the window instead of waiting it out.
|
|
102
|
-
*/
|
|
103
|
-
readonly offlineClaimTtlMs?: number;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* What one `ui_present` call ended as, with the count of connections that took
|
|
@@ -193,9 +193,14 @@ export declare class BridgeHub {
|
|
|
193
193
|
broadcastTo(capability: string, topic: string, payload: unknown): number;
|
|
194
194
|
/**
|
|
195
195
|
* The body of this plugin's `approval/request` listener.
|
|
196
|
+
*
|
|
197
|
+
* The claim yields the moment it exists: the host's own panel is offered the
|
|
198
|
+
* same question, so the phone and the panel hold one card each and the first
|
|
199
|
+
* answer decides. A panel that answers first ends the phone's claim and the phone
|
|
200
|
+
* is told; a phone that answers first leaves the panel's later answer ignored.
|
|
196
201
|
* @param request - the pending question.
|
|
197
202
|
* @param next - the rest of the answerer chain.
|
|
198
|
-
* @returns
|
|
203
|
+
* @returns the first decision, or whatever the next answerer says.
|
|
199
204
|
*/
|
|
200
205
|
approve(request: ApprovalRequestLike, next: () => Promise<ApprovalOutcome>): Promise<ApprovalOutcome>;
|
|
201
206
|
/**
|
|
@@ -209,9 +214,11 @@ export declare class BridgeHub {
|
|
|
209
214
|
* host's own when the ask is timed, and minted here when it is blocking and the
|
|
210
215
|
* host assigned none — either way the phone answers the id it was shown. A claim
|
|
211
216
|
* nobody received is withdrawn at once instead of holding the agent until the
|
|
212
|
-
* host's deadline.
|
|
213
|
-
*
|
|
214
|
-
*
|
|
217
|
+
* host's deadline. The host's own answerer chain is entered the instant the
|
|
218
|
+
* claim exists, in every mode, so the host's panel shows the same question and
|
|
219
|
+
* the first answer settles both. For a timed ask the host's own remaining wait
|
|
220
|
+
* travels with the first frame as `expiresAt`, and every later move of that
|
|
221
|
+
* deadline is re-published under the same call id.
|
|
215
222
|
* @param request - the pending question batch.
|
|
216
223
|
* @param next - the rest of the answerer chain.
|
|
217
224
|
* @returns the phone's answer, the host's own deadline outcome, or whatever the next answerer says.
|
|
@@ -13,6 +13,7 @@ export declare const METHOD_SESSION_HISTORY_DEEP = "session.history.deep";
|
|
|
13
13
|
export declare const METHOD_SESSION_PROMPT = "session.prompt";
|
|
14
14
|
export declare const METHOD_SESSION_INTERRUPT = "session.interrupt";
|
|
15
15
|
export declare const METHOD_SESSION_ATTACHMENT = "session.attachment";
|
|
16
|
+
export declare const METHOD_SESSION_ATTACHMENT_PATH = "session.attachment.path";
|
|
16
17
|
export declare const METHOD_SESSION_PERMISSIONS = "session.permissions";
|
|
17
18
|
export declare const METHOD_SESSION_SET_PERMISSION = "session.setPermission";
|
|
18
19
|
export declare const METHOD_SESSION_MODELS = "session.models";
|
|
@@ -270,6 +271,19 @@ export declare const CAP_UI = "ui.v1";
|
|
|
270
271
|
* `ui.request` 说 `settled` 时结束),而不是按一次它信不过的应答清卡。
|
|
271
272
|
*/
|
|
272
273
|
export declare const CAP_UI_LIST = "ui.list.v1";
|
|
274
|
+
/**
|
|
275
|
+
* Capability a client declares in `hello`'s `cap` array to be told that this
|
|
276
|
+
* bridge can hand it the bytes of an image a session already offloaded.
|
|
277
|
+
*
|
|
278
|
+
* An announcement and nothing more, the same shape as
|
|
279
|
+
* {@link CAP_SESSION_DEEP_HISTORY}: `session.attachment.path` is open to every
|
|
280
|
+
* paired connection, because it is a pure read of one session's own durable
|
|
281
|
+
* transcript that costs no other client anything. Declaring the capability is how
|
|
282
|
+
* a client learns the method exists, and a client that does not declare it loses
|
|
283
|
+
* only that knowledge — it never sees a frame from this channel, because it never
|
|
284
|
+
* asks for one.
|
|
285
|
+
*/
|
|
286
|
+
export declare const CAP_SESSION_ATTACHMENT_PATH = "session.attachment.path.v1";
|
|
273
287
|
/**
|
|
274
288
|
* 宿主配了第二会合点时,在 `hello` 的 `capabilities` 里公告的能力名。
|
|
275
289
|
*
|
|
@@ -485,6 +499,23 @@ export declare const CODE_UI_LIST_UNAVAILABLE = "ui-list-unavailable";
|
|
|
485
499
|
* an unaddressable one, rather than reading it blind.
|
|
486
500
|
*/
|
|
487
501
|
export declare const CODE_SESSION_NOT_FOLLOWABLE = "session-not-followable";
|
|
502
|
+
/**
|
|
503
|
+
* 该路径不在这次会话自己的持久 transcript 里:白名单只有两处来源,客户端自选的路径
|
|
504
|
+
* 一律不在其中。`realpath()` 解析结果不再等于该字符串时也回这一码——那个路径已经
|
|
505
|
+
* 指向别处,就不再是这次会话点过的那个文件。
|
|
506
|
+
*/
|
|
507
|
+
export declare const CODE_PATH_NOT_IN_SESSION = "path-not-in-session";
|
|
508
|
+
/**
|
|
509
|
+
* 白名单里有这个路径,但它已经不是一个常规文件:文件被删了,或被换成了目录、设备或
|
|
510
|
+
* fifo。它与 {@link CODE_PATH_NOT_IN_SESSION} 是两个答案——「这次会话没点过它」与
|
|
511
|
+
* 「点过的那个文件不在了」。
|
|
512
|
+
*/
|
|
513
|
+
export declare const CODE_ATTACHMENT_NOT_FOUND = "not-found";
|
|
514
|
+
/**
|
|
515
|
+
* 文件确实在,但它的文件头魔数不是 png/jpeg/webp/gif 四种之一。扩展名不作数:`.png`
|
|
516
|
+
* 里装的不是 PNG 就回这一码,而一个叫 `.txt` 的 PNG 照常服务。
|
|
517
|
+
*/
|
|
518
|
+
export declare const CODE_NOT_AN_IMAGE = "not-an-image";
|
|
488
519
|
export declare const CODE_SNAPSHOT_UNAVAILABLE = "snapshot-unavailable";
|
|
489
520
|
/**
|
|
490
521
|
* This host composes no job registry, so it has no background jobs to publish.
|
|
@@ -525,6 +556,13 @@ export declare const PROTO = 1;
|
|
|
525
556
|
/**
|
|
526
557
|
* Minor version this package speaks.
|
|
527
558
|
*
|
|
559
|
+
* 22 当按路径取图落地(与协议 §18 的 `session.history.deep` 同例的一条读通道):
|
|
560
|
+
* 新增 {@link CAP_SESSION_ATTACHMENT_PATH} 一个能力名与
|
|
561
|
+
* {@link METHOD_SESSION_ATTACHMENT_PATH} 一个方法,客户端因此从线路上读到一种新的
|
|
562
|
+
* 应答体,所以 minor 抬一格。这个方法对每一条已配对连接都开放,能力名只公告:它决定
|
|
563
|
+
* 的是客户端要不要露出取图能力,不决定桥放不放行,理由与 {@link CAP_SESSION_DEEP_HISTORY}
|
|
564
|
+
* 逐字相同。`proto` 仍为 1,没有任何既有帧、既有方法或既有键改形状;不声明这个
|
|
565
|
+
* 名字的客户端一帧都不发,两边互不知情时线路逐字节不变。
|
|
528
566
|
* 21 当可交互回复(协议 §35)落地:新增 {@link CAP_UI} 与 {@link CAP_UI_LIST}
|
|
529
567
|
* 两个能力名、{@link TOPIC_UI_REQUEST} 一个主题、{@link METHOD_UI_EVENT} 与
|
|
530
568
|
* {@link METHOD_UI_LIST} 两个方法,宿主半区还多一个模型工具 `ui_present`。客户端
|
|
@@ -636,7 +674,7 @@ export declare const PROTO = 1;
|
|
|
636
674
|
* declares the capability that plugin requires. No addition changed the major
|
|
637
675
|
* version, a frozen field, or an existing method or topic name.
|
|
638
676
|
*/
|
|
639
|
-
export declare const MINOR =
|
|
677
|
+
export declare const MINOR = 22;
|
|
640
678
|
/**
|
|
641
679
|
* The capabilities this bridge itself serves, and the opening half of what
|
|
642
680
|
* `hello` advertises.
|
|
@@ -57,15 +57,23 @@ export interface QuestionItem {
|
|
|
57
57
|
readonly options?: readonly QuestionOption[];
|
|
58
58
|
readonly multiSelect?: boolean;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* One item of the answer batch. `selected` is a mutable array because the host's
|
|
62
|
+
* own answer item declares it mutable, and a readonly array is not assignable to
|
|
63
|
+
* a mutable one - the host's `user-questions/request` handler is typed with its
|
|
64
|
+
* own answer type, so this mirror has to stay assignable to it.
|
|
65
|
+
*/
|
|
61
66
|
export interface QuestionAnswerItem {
|
|
62
67
|
readonly id: string;
|
|
63
|
-
readonly selected:
|
|
68
|
+
readonly selected: string[];
|
|
64
69
|
readonly custom?: string;
|
|
65
70
|
}
|
|
66
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* The whole answer batch the host's ask is settled with. `answers` is mutable for
|
|
73
|
+
* the same reason {@link QuestionAnswerItem} keeps `selected` mutable.
|
|
74
|
+
*/
|
|
67
75
|
export interface QuestionAnswer {
|
|
68
|
-
readonly answers:
|
|
76
|
+
readonly answers: QuestionAnswerItem[];
|
|
69
77
|
}
|
|
70
78
|
/**
|
|
71
79
|
* The `question.request` payload for one claim, and the `payload` of every
|
|
@@ -170,6 +178,14 @@ export interface ClaimedQuestionView {
|
|
|
170
178
|
export interface ClaimedQuestion extends ClaimedQuestionView {
|
|
171
179
|
/** The host's ask: the phone's answer, or whatever the next answerer says. */
|
|
172
180
|
readonly answer: Promise<QuestionAnswer>;
|
|
181
|
+
/**
|
|
182
|
+
* Hand the same question to the host's own answerer chain, once.
|
|
183
|
+
*
|
|
184
|
+
* Called by the hub the instant a claim exists, in every mode: the phone is
|
|
185
|
+
* not the only surface any more, so the host's own panel shows the card too
|
|
186
|
+
* and the first answer settles it.
|
|
187
|
+
*/
|
|
188
|
+
readonly startHostChain: () => void;
|
|
173
189
|
/**
|
|
174
190
|
* Epoch milliseconds at which the host's own deadline falls, from the first
|
|
175
191
|
* wait frame of this claim.
|
package/lib/types/core/wire.d.ts
CHANGED
|
@@ -74,6 +74,14 @@ export declare function sessionAddress(sessionId: string): SessionAddress;
|
|
|
74
74
|
export declare function subagentAddress(parentSessionId: string, childSessionId: string): SessionAddress;
|
|
75
75
|
/** The failure code the harness raises for a child addressed as an ordinary session. */
|
|
76
76
|
export declare const CODE_SUBAGENT_ADDRESS_REQUIRED = "session/agent-busy";
|
|
77
|
+
/**
|
|
78
|
+
* The failure the harness raises when a session address names a session this host
|
|
79
|
+
* does not have. `session/page` answers it, `session/projections` answers
|
|
80
|
+
* `null` for the same fact, and a caller that needs one name for "no such
|
|
81
|
+
* session" folds both into its own code rather than letting one fact cross as two
|
|
82
|
+
* different failures.
|
|
83
|
+
*/
|
|
84
|
+
export declare const CODE_HOST_SESSION_NOT_FOUND = "session/not-found";
|
|
77
85
|
/**
|
|
78
86
|
* One endpoint's declared argument names: the name of its single parameter, the
|
|
79
87
|
* empty declaration of a parameterless endpoint, or the exact names of an
|
package/lib/types/index.d.ts
CHANGED
|
@@ -24,9 +24,8 @@
|
|
|
24
24
|
* `question.answer` settles the host's own ask while it is open, or reaches a
|
|
25
25
|
* continued question through the host's Remote `answer`. With no paired
|
|
26
26
|
* connection on the wire the claim is still made when a roster device registered
|
|
27
|
-
* for notifications,
|
|
28
|
-
*
|
|
29
|
-
* delegates, and a timed question keeps the Host's own deadline.
|
|
27
|
+
* for notifications, and the alert is then its delivery (§11.3, §32). Every other
|
|
28
|
+
* case delegates, and a timed question keeps the Host's own deadline.
|
|
30
29
|
*
|
|
31
30
|
* The browser half lives in `src/client/` and is declared by `dsh.client`: one
|
|
32
31
|
* sidebar-foot panel that reads the same loopback-gated token route over a
|
|
@@ -67,19 +66,6 @@ export declare const ROSTER_PATH = "remote-bridge/devices.json";
|
|
|
67
66
|
* than to any one session, and it outlives every process (core/model-efforts.ts).
|
|
68
67
|
*/
|
|
69
68
|
export declare const EFFORT_PATH = "remote-bridge/model-efforts.json";
|
|
70
|
-
/** The environment variable that moves the offline claim window (§32.2). */
|
|
71
|
-
export declare const OFFLINE_CLAIM_TTL_ENV = "DSH_REMOTE_BRIDGE_OFFLINE_CLAIM_TTL_MS";
|
|
72
|
-
/**
|
|
73
|
-
* The offline claim window this process runs with.
|
|
74
|
-
*
|
|
75
|
-
* The window is the bridge's own constant and never a host fact, so a deployment
|
|
76
|
-
* moves it here. A value that is missing, unreadable or not positive falls back to
|
|
77
|
-
* the constant instead of closing the window: a zero window would silently switch
|
|
78
|
-
* the channel off, and an operator who wanted that would be turning off push.
|
|
79
|
-
* @param env - the process environment, injectable for a suite.
|
|
80
|
-
* @returns the window in milliseconds.
|
|
81
|
-
*/
|
|
82
|
-
export declare function offlineClaimTtl(env?: NodeJS.ProcessEnv): number;
|
|
83
69
|
/**
|
|
84
70
|
* The environment variable that moves when a still-waiting turn end is reported (§28).
|
|
85
71
|
*
|
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.17",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "Apache-2.0",
|
|
38
38
|
"dsh": {
|
|
39
39
|
"engines": {
|
|
40
|
-
"dsh": ">=0.2.2-rc.
|
|
40
|
+
"dsh": ">=0.2.2-rc.2"
|
|
41
41
|
},
|
|
42
42
|
"bundle": {
|
|
43
43
|
"patch": "./cordis.patch.yml"
|
|
@@ -57,23 +57,23 @@
|
|
|
57
57
|
"yaml": "^2.8.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@deepseek-ai/dsh": ">=0.2.2-rc.
|
|
60
|
+
"@deepseek-ai/dsh": ">=0.2.2-rc.2",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
66
|
-
"@deepseek-ai/dsh-api-gateway": "^0.2.2-rc.
|
|
67
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.
|
|
68
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.
|
|
69
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.
|
|
70
|
-
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.2-rc.
|
|
71
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.
|
|
72
|
-
"@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.
|
|
73
|
-
"@deepseek-ai/dsh-session": "^0.2.2-rc.
|
|
74
|
-
"@deepseek-ai/dsh-tools": "^0.2.2-rc.
|
|
75
|
-
"@deepseek-ai/dsh-typert-protocol": "^0.2.2-rc.
|
|
76
|
-
"@deepseek-ai/dsh-user-approval": "^0.2.2-rc.
|
|
66
|
+
"@deepseek-ai/dsh-api-gateway": "^0.2.2-rc.2",
|
|
67
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.2",
|
|
68
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.2",
|
|
69
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.2",
|
|
70
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.2-rc.2",
|
|
71
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.2",
|
|
72
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.2",
|
|
73
|
+
"@deepseek-ai/dsh-session": "^0.2.2-rc.2",
|
|
74
|
+
"@deepseek-ai/dsh-tools": "^0.2.2-rc.2",
|
|
75
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.2.2-rc.2",
|
|
76
|
+
"@deepseek-ai/dsh-user-approval": "^0.2.2-rc.2",
|
|
77
77
|
"@testing-library/dom": "^10.4.1",
|
|
78
78
|
"@testing-library/react": "^16.3.2",
|
|
79
79
|
"@types/node": "^22.20.0",
|
package/src/core/approvals.ts
CHANGED
|
@@ -132,6 +132,19 @@ export class ApprovalRegistry {
|
|
|
132
132
|
return this.#settle(id, decision) !== undefined
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Release one question the host's own panel answered first.
|
|
137
|
+
*
|
|
138
|
+
* The release is not a decision: the panel's answer travels back through the
|
|
139
|
+
* answerer chain it came from, so the claim only has to stop being pending —
|
|
140
|
+
* which is what also makes a later answer from the phone refuse as unknown
|
|
141
|
+
* instead of settling a question that is already over.
|
|
142
|
+
* @returns whether this call released it; false when the phone already had.
|
|
143
|
+
*/
|
|
144
|
+
releaseToHost(id: string): boolean {
|
|
145
|
+
return this.#settle(id, undefined) === true
|
|
146
|
+
}
|
|
147
|
+
|
|
135
148
|
/**
|
|
136
149
|
* Withdraw the named questions, delegating each to the next answerer.
|
|
137
150
|
* @returns how many were still pending.
|