@songtonyli/dsh-cli 0.1.86 → 0.1.87
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 +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/LICENSE +201 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/README.md +9 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-cjs/index.js +859 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js +19 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/constants.js +1 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +12 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/http2/ClientHttp2SessionRef.js +51 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +251 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +135 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +46 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +180 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http2.js +2 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-https.js +2 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js +36 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js +21 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js +22 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +23 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/timing.js +4 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js +63 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/package.json +56 -0
- package/node_modules/@deepseek-ai/dsh-client-modules/lib/index.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +3 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +3 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +243 -25
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/LICENSE +201 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/README.md +9 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-cjs/index.js +859 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js +19 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/constants.js +1 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +12 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/http2/ClientHttp2SessionRef.js +51 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +251 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +135 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +46 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +180 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2.js +2 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-https.js +2 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js +36 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js +21 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js +22 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +23 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/timing.js +4 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js +63 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/package.json +56 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +13 -37
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +44 -29
- package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +12 -37
- package/node_modules/@smithy/core/dist-es/submodules/protocols/AbstractRpcV2Protocol.js +35 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +4 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/SmithyRpcV2JsonProtocol.js +8 -31
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +48 -6
- package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +9 -1
- package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +20 -2
- package/node_modules/@smithy/node-http-handler/dist-es/resolve-default-socket-timeout.js +4 -0
- package/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +16 -3
- package/node_modules/@smithy/node-http-handler/package.json +3 -3
- package/package.json +3 -3
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { HttpResponse, buildQueryString } from "@smithy/core/protocols";
|
|
2
|
+
import { buildAbortError } from "./build-abort-error";
|
|
3
|
+
import { getTransformedHeaders } from "./get-transformed-headers";
|
|
4
|
+
import { node_http2 } from "./node-http2";
|
|
5
|
+
import { NodeHttp2ConnectionManager } from "./node-http2-connection-manager";
|
|
6
|
+
import { writeRequestBody } from "./write-request-body";
|
|
7
|
+
const { constants } = node_http2;
|
|
8
|
+
export class NodeHttp2Handler {
|
|
9
|
+
config;
|
|
10
|
+
configProvider;
|
|
11
|
+
metadata = { handlerProtocol: "h2" };
|
|
12
|
+
connectionManager = new NodeHttp2ConnectionManager({});
|
|
13
|
+
static create(instanceOrOptions) {
|
|
14
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
15
|
+
return instanceOrOptions;
|
|
16
|
+
}
|
|
17
|
+
return new NodeHttp2Handler(instanceOrOptions);
|
|
18
|
+
}
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
21
|
+
if (typeof options === "function") {
|
|
22
|
+
options()
|
|
23
|
+
.then((opts) => {
|
|
24
|
+
resolve(opts || {});
|
|
25
|
+
})
|
|
26
|
+
.catch(reject);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
resolve(options || {});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
destroy() {
|
|
34
|
+
this.connectionManager.destroy();
|
|
35
|
+
}
|
|
36
|
+
async handle(request, { abortSignal, requestTimeout, isEventStream } = {}) {
|
|
37
|
+
if (!this.config) {
|
|
38
|
+
this.config = await this.configProvider;
|
|
39
|
+
const { disableConcurrentStreams, maxConcurrentStreams, nodeHttp2ConnectOptions } = this.config;
|
|
40
|
+
this.connectionManager.setDisableConcurrentStreams(disableConcurrentStreams ?? false);
|
|
41
|
+
if (maxConcurrentStreams) {
|
|
42
|
+
this.connectionManager.setMaxConcurrentStreams(maxConcurrentStreams);
|
|
43
|
+
}
|
|
44
|
+
if (nodeHttp2ConnectOptions) {
|
|
45
|
+
this.connectionManager.setNodeHttp2ConnectOptions(nodeHttp2ConnectOptions);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const { requestTimeout: configRequestTimeout, disableConcurrentStreams } = this.config;
|
|
49
|
+
const useIsolatedSession = disableConcurrentStreams || isEventStream;
|
|
50
|
+
const effectiveRequestTimeout = requestTimeout ?? configRequestTimeout;
|
|
51
|
+
return new Promise((_resolve, _reject) => {
|
|
52
|
+
let fulfilled = false;
|
|
53
|
+
let writeRequestBodyPromise = undefined;
|
|
54
|
+
const resolve = async (arg) => {
|
|
55
|
+
await writeRequestBodyPromise;
|
|
56
|
+
_resolve(arg);
|
|
57
|
+
};
|
|
58
|
+
const reject = async (arg) => {
|
|
59
|
+
await writeRequestBodyPromise;
|
|
60
|
+
_reject(arg);
|
|
61
|
+
};
|
|
62
|
+
if (abortSignal?.aborted) {
|
|
63
|
+
fulfilled = true;
|
|
64
|
+
const abortError = buildAbortError(abortSignal);
|
|
65
|
+
reject(abortError);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const { hostname, method, port, protocol, query } = request;
|
|
69
|
+
let auth = "";
|
|
70
|
+
if (request.username != null || request.password != null) {
|
|
71
|
+
const username = request.username ?? "";
|
|
72
|
+
const password = request.password ?? "";
|
|
73
|
+
auth = `${username}:${password}@`;
|
|
74
|
+
}
|
|
75
|
+
const authority = `${protocol}//${auth}${hostname}${port ? `:${port}` : ""}`;
|
|
76
|
+
const requestContext = { destination: new URL(authority) };
|
|
77
|
+
const connectConfig = {
|
|
78
|
+
requestTimeout: this.config?.sessionTimeout,
|
|
79
|
+
isEventStream,
|
|
80
|
+
};
|
|
81
|
+
const ref = useIsolatedSession
|
|
82
|
+
? this.connectionManager.createIsolatedSession(requestContext, connectConfig)
|
|
83
|
+
: this.connectionManager.lease(requestContext, connectConfig);
|
|
84
|
+
const session = ref.deref();
|
|
85
|
+
const rejectWithDestroy = (err) => {
|
|
86
|
+
if (useIsolatedSession) {
|
|
87
|
+
ref.destroy();
|
|
88
|
+
}
|
|
89
|
+
fulfilled = true;
|
|
90
|
+
reject(err);
|
|
91
|
+
};
|
|
92
|
+
const queryString = query ? buildQueryString(query) : "";
|
|
93
|
+
let path = request.path;
|
|
94
|
+
if (queryString) {
|
|
95
|
+
path += `?${queryString}`;
|
|
96
|
+
}
|
|
97
|
+
if (request.fragment) {
|
|
98
|
+
path += `#${request.fragment}`;
|
|
99
|
+
}
|
|
100
|
+
const clientHttp2Stream = session.request({
|
|
101
|
+
...request.headers,
|
|
102
|
+
[constants.HTTP2_HEADER_PATH]: path,
|
|
103
|
+
[constants.HTTP2_HEADER_METHOD]: method,
|
|
104
|
+
});
|
|
105
|
+
if (effectiveRequestTimeout) {
|
|
106
|
+
clientHttp2Stream.setTimeout(effectiveRequestTimeout, () => {
|
|
107
|
+
clientHttp2Stream.close();
|
|
108
|
+
const timeoutError = new Error(`Stream timed out because of no activity for ${effectiveRequestTimeout} ms`);
|
|
109
|
+
timeoutError.name = "TimeoutError";
|
|
110
|
+
rejectWithDestroy(timeoutError);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (abortSignal) {
|
|
114
|
+
const onAbort = () => {
|
|
115
|
+
clientHttp2Stream.close();
|
|
116
|
+
const abortError = buildAbortError(abortSignal);
|
|
117
|
+
rejectWithDestroy(abortError);
|
|
118
|
+
};
|
|
119
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
120
|
+
const signal = abortSignal;
|
|
121
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
122
|
+
clientHttp2Stream.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
abortSignal.onabort = onAbort;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
clientHttp2Stream.on("frameError", (type, code, id) => {
|
|
129
|
+
rejectWithDestroy(new Error(`Frame type id ${type} in stream id ${id} has failed with code ${code}.`));
|
|
130
|
+
});
|
|
131
|
+
clientHttp2Stream.on("error", rejectWithDestroy);
|
|
132
|
+
clientHttp2Stream.on("aborted", () => {
|
|
133
|
+
rejectWithDestroy(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${clientHttp2Stream.rstCode}.`));
|
|
134
|
+
});
|
|
135
|
+
clientHttp2Stream.on("response", (headers) => {
|
|
136
|
+
const httpResponse = new HttpResponse({
|
|
137
|
+
statusCode: headers[":status"] ?? -1,
|
|
138
|
+
headers: getTransformedHeaders(headers),
|
|
139
|
+
body: clientHttp2Stream,
|
|
140
|
+
});
|
|
141
|
+
fulfilled = true;
|
|
142
|
+
resolve({ response: httpResponse });
|
|
143
|
+
if (useIsolatedSession) {
|
|
144
|
+
session.close();
|
|
145
|
+
clientHttp2Stream.on("end", () => {
|
|
146
|
+
ref.destroy();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
clientHttp2Stream.on("close", () => {
|
|
151
|
+
if (useIsolatedSession) {
|
|
152
|
+
ref.destroy();
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.connectionManager.release(requestContext, ref);
|
|
156
|
+
}
|
|
157
|
+
if (!fulfilled) {
|
|
158
|
+
const error = new Error("Unexpected error: http2 request did not get a response");
|
|
159
|
+
if (session.destroyed) {
|
|
160
|
+
error.name = "TimeoutError";
|
|
161
|
+
}
|
|
162
|
+
rejectWithDestroy(error);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
writeRequestBodyPromise = writeRequestBody(clientHttp2Stream, request, effectiveRequestTimeout);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
updateHttpClientConfig(key, value) {
|
|
169
|
+
this.config = undefined;
|
|
170
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
171
|
+
return {
|
|
172
|
+
...config,
|
|
173
|
+
[key]: value,
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
httpHandlerConfigs() {
|
|
178
|
+
return this.config ?? {};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { timing } from "./timing";
|
|
2
|
+
const DEFER_EVENT_LISTENER_TIME = 1000;
|
|
3
|
+
export const setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
4
|
+
if (!timeoutInMs) {
|
|
5
|
+
return -1;
|
|
6
|
+
}
|
|
7
|
+
const registerTimeout = (offset) => {
|
|
8
|
+
const timeoutId = timing.setTimeout(() => {
|
|
9
|
+
request.destroy();
|
|
10
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), {
|
|
11
|
+
name: "TimeoutError",
|
|
12
|
+
}));
|
|
13
|
+
}, timeoutInMs - offset);
|
|
14
|
+
const doWithSocket = (socket) => {
|
|
15
|
+
if (socket?.connecting) {
|
|
16
|
+
socket.on("connect", () => {
|
|
17
|
+
timing.clearTimeout(timeoutId);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
timing.clearTimeout(timeoutId);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
if (request.socket) {
|
|
25
|
+
doWithSocket(request.socket);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
request.on("socket", doWithSocket);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (timeoutInMs < 2000) {
|
|
32
|
+
registerTimeout(0);
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
36
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { timing } from "./timing";
|
|
2
|
+
export const setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger) => {
|
|
3
|
+
if (timeoutInMs) {
|
|
4
|
+
return timing.setTimeout(() => {
|
|
5
|
+
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
6
|
+
if (throwOnRequestTimeout) {
|
|
7
|
+
const error = Object.assign(new Error(msg), {
|
|
8
|
+
name: "TimeoutError",
|
|
9
|
+
code: "ETIMEDOUT",
|
|
10
|
+
});
|
|
11
|
+
req.destroy(error);
|
|
12
|
+
reject(error);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
16
|
+
logger?.warn?.(msg);
|
|
17
|
+
}
|
|
18
|
+
}, timeoutInMs);
|
|
19
|
+
}
|
|
20
|
+
return -1;
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { timing } from "./timing";
|
|
2
|
+
const DEFER_EVENT_LISTENER_TIME = 3000;
|
|
3
|
+
export const setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME) => {
|
|
4
|
+
if (keepAlive !== true) {
|
|
5
|
+
return -1;
|
|
6
|
+
}
|
|
7
|
+
const registerListener = () => {
|
|
8
|
+
if (request.socket) {
|
|
9
|
+
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
request.on("socket", (socket) => {
|
|
13
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
if (deferTimeMs === 0) {
|
|
18
|
+
registerListener();
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
return timing.setTimeout(registerListener, deferTimeMs);
|
|
22
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { timing } from "./timing";
|
|
2
|
+
const DEFER_EVENT_LISTENER_TIME = 3000;
|
|
3
|
+
export const setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
4
|
+
const registerTimeout = (offset) => {
|
|
5
|
+
const timeout = timeoutInMs - offset;
|
|
6
|
+
const onTimeout = () => {
|
|
7
|
+
request.destroy();
|
|
8
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (configured by client requestHandler).`), { name: "TimeoutError" }));
|
|
9
|
+
};
|
|
10
|
+
if (request.socket) {
|
|
11
|
+
request.socket.setTimeout(timeout, onTimeout);
|
|
12
|
+
request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
request.setTimeout(timeout, onTimeout);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
if (0 < timeoutInMs && timeoutInMs < 6000) {
|
|
19
|
+
registerTimeout(0);
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
23
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
import { timing } from "./timing";
|
|
3
|
+
const MIN_WAIT_TIME = 6_000;
|
|
4
|
+
export async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
|
|
5
|
+
const headers = request.headers;
|
|
6
|
+
const expect = headers ? headers.Expect || headers.expect : undefined;
|
|
7
|
+
let timeoutId = -1;
|
|
8
|
+
let sendBody = true;
|
|
9
|
+
if (!externalAgent && expect === "100-continue") {
|
|
10
|
+
sendBody = await Promise.race([
|
|
11
|
+
new Promise((resolve) => {
|
|
12
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
13
|
+
}),
|
|
14
|
+
new Promise((resolve) => {
|
|
15
|
+
httpRequest.on("continue", () => {
|
|
16
|
+
timing.clearTimeout(timeoutId);
|
|
17
|
+
resolve(true);
|
|
18
|
+
});
|
|
19
|
+
httpRequest.on("response", () => {
|
|
20
|
+
timing.clearTimeout(timeoutId);
|
|
21
|
+
resolve(false);
|
|
22
|
+
});
|
|
23
|
+
httpRequest.on("error", () => {
|
|
24
|
+
timing.clearTimeout(timeoutId);
|
|
25
|
+
resolve(false);
|
|
26
|
+
});
|
|
27
|
+
}),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
if (sendBody) {
|
|
31
|
+
writeBody(httpRequest, request.body);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function writeBody(httpRequest, body) {
|
|
35
|
+
if (body instanceof Readable) {
|
|
36
|
+
body.pipe(httpRequest);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (body) {
|
|
40
|
+
const isBuffer = Buffer.isBuffer(body);
|
|
41
|
+
const isString = typeof body === "string";
|
|
42
|
+
if (isBuffer || isString) {
|
|
43
|
+
if (isBuffer && body.byteLength === 0) {
|
|
44
|
+
httpRequest.end();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
httpRequest.end(body);
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const uint8 = body;
|
|
52
|
+
if (typeof uint8 === "object" &&
|
|
53
|
+
uint8.buffer &&
|
|
54
|
+
typeof uint8.byteOffset === "number" &&
|
|
55
|
+
typeof uint8.byteLength === "number") {
|
|
56
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
httpRequest.end(Buffer.from(body));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
httpRequest.end();
|
|
63
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@smithy/node-http-handler",
|
|
3
|
+
"version": "4.12.1",
|
|
4
|
+
"description": "Provides a way to make requests",
|
|
5
|
+
"homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/node-http-handler",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "AWS SDK for JavaScript Team",
|
|
9
|
+
"email": "",
|
|
10
|
+
"url": "https://aws.amazon.com/sdk-for-javascript/"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/smithy-lang/smithy-typescript.git",
|
|
15
|
+
"directory": "packages/node-http-handler"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist-*/**"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"main": "./dist-cjs/index.js",
|
|
22
|
+
"module": "./dist-es/index.js",
|
|
23
|
+
"types": "./dist-types/index.d.ts",
|
|
24
|
+
"typesVersions": {
|
|
25
|
+
"<4.5": {
|
|
26
|
+
"dist-types/*": [
|
|
27
|
+
"dist-types/ts3.4/*"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
|
|
33
|
+
"build:es:cjs": "node ../../scripts/compilation/es_cjs.js",
|
|
34
|
+
"build:types": "premove dist-types && yarn g:tsc -p tsconfig.types.json",
|
|
35
|
+
"build:types:downlevel": "premove dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4",
|
|
36
|
+
"clean": "premove dist-cjs dist-es dist-types",
|
|
37
|
+
"extract:docs": "api-extractor run --local",
|
|
38
|
+
"test": "yarn g:vitest run",
|
|
39
|
+
"test:watch": "yarn g:vitest watch"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@smithy/core": "^3.33.3",
|
|
43
|
+
"@smithy/types": "^4.18.0",
|
|
44
|
+
"tslib": "^2.6.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@smithy/abort-controller": "^4.4.2",
|
|
48
|
+
"@types/node": "^18.11.9",
|
|
49
|
+
"concurrently": "7.0.0",
|
|
50
|
+
"downlevel-dts": "0.10.1",
|
|
51
|
+
"premove": "4.0.0"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18.0.0"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -592,7 +592,7 @@ var ClientModuleRegistry = class extends Service {
|
|
|
592
592
|
constructor(ctx) {
|
|
593
593
|
super(ctx, "clientModules");
|
|
594
594
|
const { version } = createRequire(import.meta.url)("../package.json");
|
|
595
|
-
const commit = "
|
|
595
|
+
const commit = "0e304d9";
|
|
596
596
|
this.release = {
|
|
597
597
|
version,
|
|
598
598
|
commit
|
|
@@ -195,7 +195,7 @@ window.__ModuleLoader__.load({
|
|
|
195
195
|
const SCROLLBAR_LINGER_MS = 2e3;
|
|
196
196
|
/** Format complete-build metadata for the local brand badge. */
|
|
197
197
|
function localBuildVersion() {
|
|
198
|
-
return `0.2.1-rc.3-
|
|
198
|
+
return `0.2.1-rc.3-0e304d9` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
|
|
199
199
|
}
|
|
200
200
|
/** Analytics category of an official panel; other panels are never reported. */
|
|
201
201
|
function officialEntry(id) {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
en: 312d9a3ea1cbb673
|
|
22
22
|
zh: 937ff76d6bdcca22
|
|
23
23
|
/deepseek-ai-dsh-tui-app/use-this-package/the-screen:
|
|
24
|
-
en:
|
|
25
|
-
zh:
|
|
24
|
+
en: 1155765ad37935b7
|
|
25
|
+
zh: e360ed61ff7a0c3f
|
|
26
26
|
/deepseek-ai-dsh-tui-app/use-this-package/keys-and-commands:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
27
|
+
en: 263974603b2a6475
|
|
28
|
+
zh: db75b82e1ba5a739
|
|
29
29
|
/deepseek-ai-dsh-tui-app/use-this-package/background-tool-calls:
|
|
30
30
|
en: 322ae3c6d76383ec
|
|
31
31
|
zh: 8c38eee4b57ed8dd
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
en: 142f04bf29e981dd
|
|
58
58
|
zh: a1689297b06c9ca6
|
|
59
59
|
/deepseek-ai-dsh-tui-app/understand-the-implementation/source-map:
|
|
60
|
-
en:
|
|
61
|
-
zh:
|
|
60
|
+
en: a57dca95a7bb2911
|
|
61
|
+
zh: bd1960aff88d2df4
|
|
62
62
|
/deepseek-ai-dsh-tui-app/understand-the-implementation/invariant-ownership:
|
|
63
63
|
en: 0ddf6de8928026d5
|
|
64
64
|
zh: 24feedcbb9e9d676
|
|
@@ -40,7 +40,7 @@ Once a quit has saved the session, the app prints `dsh: session <id> saved; resu
|
|
|
40
40
|
|
|
41
41
|
### The screen
|
|
42
42
|
|
|
43
|
-
Every frame is drawn one column in from each edge of the terminal, so no line of the conversation or of the docked chrome touches either side. The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), and a prompt steered or injected into a turn that already had a model step draws dim on a darker band so it recedes behind the turn it joined, assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, a bloom spinning beside `Thinking` while it streams, and each tool call is a card with a status glyph — a yellow spinner of that tool family's flowers, blooms, and stars while it runs, a green `◆` once done, a red `◆` on failure — the tool name in bold cyan, the presenter headline in teal — without the tool name a presenter repeated, so `Read src/app.ts` draws as `read src/app.ts`, and for a shell card the call's own summary, never the command, which the card draws once as its `$` row — a loading row while it runs, and a body folded to `toolPreviewLines` rows. A top-level workflow call also draws its own run beside that card: the name, member count, status, and a ten-cell member progress bar with the settled count, then each phase and the members that started. While a live run runs, its `◇` pulses through a diamond animation and each running member's `○` spins in the subagent family's flowers, one phase ahead of the member before it; a run drawn from a replayed log spins only while its background job is still live, and reduced motion draws the static glyphs. Running groups and groups with a failed, cancelled, or interrupted member open; a clean completion stays closed. Space or Enter on a run or phase folds that level, and Enter on a running member opens its child only while that child is a live direct child of this session. The card appears when the model starts the call and flows out row after row, each row left to right, at one pace whatever the card holds: a full-width row takes `toolRevealFrames` frames, a shorter row proportionally less, and the columns just drawn brighten from the terminal background to their own colors. The result rows flow out the same way when the tool answers, behind whatever the card is still drawing; neither the call nor the result waits for the animation. An `edit` or `write` diff card fills each added row edge to edge with a green background and each removed row with a red one, the removed rows above the added ones, and paints the `+` and `-` in their own lighter colour so each sign reads against the fill rather than in it; a wrapped row carries the fill on without a second sign; once the tool applied the change, the applied hunks replace the diff the call carried and lead every row with its file line number, the new file's for added and unchanged rows and the old file's for removed rows. A `subagent` or `subagent_*` card draws folded as one row behind the same status glyph, spinning while it runs and a dim `◆` for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt is omitted. A compaction, from `/compact` or automatic, draws as one context block whose accent `⬡` title names its origin and the estimated tokens it replaced and its summary costs, as in `context compacted by /compact · ~6.4k → ~0.9k tokens` or `context compacted automatically in turn 12 · …`; under the title, `compressed` names the item count and turns the summary replaced, each prompt among them (five at most, one row each), and a count of the replies, tool results by tool, context blocks, and earlier summaries, and `preserved` names the system prompt and what each later turn still holds verbatim; both stay drawn while the summary under them folds to `contextPreviewLines` rows like any context block. The checkpoint message itself is not drawn again. A `/compact` attempt the log closes with an error prints `/compact failed · <error>` when the session is redrawn, since the live command reports its own failure; a failed automatic attempt changes nothing and draws nothing, as in the browser. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use orange, links and inline code use magenta, and quotes stay dim. Every hue is a Tokyo Night (Night) color, drawn exactly when `COLORTERM` declares `truecolor` or `24bit` and as the nearest of the 256 indexed colors otherwise; the background bands keep their 256-color greys and diff tints. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning floats out over the same duration: it appears at a lifted color and recedes to the dim italic it settles in. Each column of a tool card brightens over it from the terminal background to the palette color it settles in; a card redrawn from persisted history carries no flow or fade, and text that has settled is never dimmed again.
|
|
43
|
+
Every frame is drawn one column in from each edge of the terminal, so no line of the conversation or of the docked chrome touches either side. The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), and a prompt steered or injected into a turn that already had a model step draws dim on a darker band so it recedes behind the turn it joined, assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, a bloom spinning beside `Thinking` while it streams, and each tool call is a card with a status glyph — a yellow spinner of that tool family's flowers, blooms, and stars while it runs, a green `◆` once done, a red `◆` on failure — the tool name in bold cyan, the presenter headline in teal — without the tool name a presenter repeated, so `Read src/app.ts` draws as `read src/app.ts`, and for a shell card the call's own summary, never the command, which the card draws once as its `$` row — a loading row while it runs, and a body folded to `toolPreviewLines` rows. Shell output is dimmed apart from the syntax-colored command; a complete JSON object or array result draws as a tree with dim guides, cyan keys, orange array indices, and type-colored scalar values instead of braces, while malformed or mixed output stays unchanged. A top-level workflow call also draws its own run beside that card: the name, member count, status, and a ten-cell member progress bar with the settled count, then each phase and the members that started. While a live run runs, its `◇` pulses through a diamond animation and each running member's `○` spins in the subagent family's flowers, one phase ahead of the member before it; a run drawn from a replayed log spins only while its background job is still live, and reduced motion draws the static glyphs. Running groups and groups with a failed, cancelled, or interrupted member open; a clean completion stays closed. Space or Enter on a run or phase folds that level, and Enter on a running member opens its child only while that child is a live direct child of this session. The card appears when the model starts the call and flows out row after row, each row left to right, at one pace whatever the card holds: a full-width row takes `toolRevealFrames` frames, a shorter row proportionally less, and the columns just drawn brighten from the terminal background to their own colors. The result rows flow out the same way when the tool answers, behind whatever the card is still drawing; neither the call nor the result waits for the animation. An `edit` or `write` diff card fills each added row edge to edge with a green background and each removed row with a red one, the removed rows above the added ones, and paints the `+` and `-` in their own lighter colour so each sign reads against the fill rather than in it; a wrapped row carries the fill on without a second sign; once the tool applied the change, the applied hunks replace the diff the call carried and lead every row with its file line number, the new file's for added and unchanged rows and the old file's for removed rows. A `subagent` or `subagent_*` card draws folded as one row behind the same status glyph, spinning while it runs and a dim `◆` for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt is omitted. A compaction, from `/compact` or automatic, draws as one context block whose accent `⬡` title names its origin and the estimated tokens it replaced and its summary costs, as in `context compacted by /compact · ~6.4k → ~0.9k tokens` or `context compacted automatically in turn 12 · …`; under the title, `compressed` names the item count and turns the summary replaced, each prompt among them (five at most, one row each), and a count of the replies, tool results by tool, context blocks, and earlier summaries, and `preserved` names the system prompt and what each later turn still holds verbatim; both stay drawn while the summary under them folds to `contextPreviewLines` rows like any context block. The checkpoint message itself is not drawn again. A `/compact` attempt the log closes with an error prints `/compact failed · <error>` when the session is redrawn, since the live command reports its own failure; a failed automatic attempt changes nothing and draws nothing, as in the browser. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use orange, links and inline code use magenta, and quotes stay dim. Every hue is a Tokyo Night (Night) color, drawn exactly when `COLORTERM` declares `truecolor` or `24bit` and as the nearest of the 256 indexed colors otherwise; the background bands keep their 256-color greys and diff tints. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning floats out over the same duration: it appears at a lifted color and recedes to the dim italic it settles in. Each column of a tool card brightens over it from the terminal background to the palette color it settles in; a card redrawn from persisted history carries no flow or fade, and text that has settled is never dimmed again.
|
|
44
44
|
|
|
45
45
|
Below the transcript sit a spinner while the agent works — `thinking`, `writing`, `calling <tool>`, a retry, or `compacting`, each beside its own braille animation: circling dots, filling lines, an orbiting dot, a sliding bar, or a settling cell — with a bright highlight sweeping across the word, plus live `↑` send and `↓` receive tokens for the current model call, as compact `k` / `M` / `B` counts, growing as the stream arrives and settling on the provider usage chunk — any open prompt, a boxed follow-ups list while messages wait, an activity board of the open turn's todos and one row per subagent while either has a row — completed todo content scratched out and status glyphs colored green, yellow, or blue, the in-progress one a spinner, at most four todo rows then `+<n> more`, each subagent row its spinner or `✓` / `✗`, its task label — `<name> · <role>` for an Agent Teams teammate — and the last sentence of what it said it was doing, cut to one terminal line, running subagents first and at most three then `+<n> more subagents`, not a focus region, gone on `turn/end` and bind — the editor, the subagent panel, and the footer: a status bar that, unfocused, is one line built from both ends inward. The editor's caret is the terminal's own blinking bar: the app asks for that shape at start, gives your default back on quit, and draws no caret at all while the status bar or the panel holds the keyboard. The model is purple and the entry keys magenta; live turn, context, and todo facts use yellow, magenta, and green. The model is anchored at the left edge and is never dropped — past 20 columns it falls back to the bare model name, and only a label still too wide for that is ellipsized — and the two keys that leave the input are anchored at the right edge as `Shift+↑ read · Shift+↓ status`, or `Shift+↑ select · Shift+↓ status` while follow-ups wait, narrowing to `Shift+↑↓ nav` and dropped below 40 columns. The key facts fill whatever middle is left, in bar order: effort (`effort default` when the selection leaves reasoning to the model), the running turn's elapsed time, the context window percentage, the todo counts, and the workspace path (shortened with `~` and `…/` when long). Every segment that middle cannot hold folds into a trailing `+N`, together with the segments the unfocused line never draws — the permission preset, token usage (session totals plus the in-flight call), the goal and plan-mode markers from the projection seam, and the count of pending attachments. Model-request retries appear as notices, the same facts the browser's markers carry.
|
|
46
46
|
|
|
@@ -169,7 +169,7 @@ Every other key reaching the reader is consumed, and closing it opens the same 7
|
|
|
169
169
|
|
|
170
170
|
Every focused segment expands its most important facts on the second line. `Enter` prints those facts into the transcript for every segment except `todo`, stating what they are and what changes them: the model segment names `/model`, the effort segment names the picker shared by `Shift+Tab` and `/effort`, and the permission segment names its preset and the `/permission` picker, the `turn` segment — drawn as `turn <elapsed>` between the permission and usage segments, and only while a turn runs — gives the turn number, its start time, its elapsed time, and the queued-message counts, while the usage, context, goal, and plan segments print the matching sections of the `/status` report, the workspace segment the full path, and the attachments segment the pending attachments. The `todo` segment expands the counts by status and the item being worked on, or the next pending item when none is in progress, and `Enter` opens the agent's todo list, the same list `/todos` opens.
|
|
171
171
|
|
|
172
|
-
Typing `/` at the start of the editor completes the terminal's own commands and the shared registry's; `@` anywhere completes references. A nonempty `!command` or `!!command` line runs through `ctx.shell` in the session cwd at `danger-full-access`; the draft and the transcript `$ command` row use syntax colours, and the transcript shows
|
|
172
|
+
Typing `/` at the start of the editor completes the terminal's own commands and the shared registry's; `@` anywhere completes references. A nonempty `!command` or `!!command` line runs through `ctx.shell` in the session cwd at `danger-full-access`; the draft and the transcript `$ command` row use syntax colours, and the transcript shows dimmed output or the JSON tree under that row. `!` injects a plugin notice for the next admitted step; `!!` does not. A lone `!` is an ordinary prompt. The editor border turns warning-coloured while the draft starts with `!`.
|
|
173
173
|
|
|
174
174
|
| Command | Effect |
|
|
175
175
|
|---|---|
|
|
@@ -336,6 +336,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
|
|
|
336
336
|
| [`src/toast.ts`](src/toast.ts) | The transient key-feedback line: its overlay, its clock, and the lines it carries |
|
|
337
337
|
| [`src/pinned-prompt.ts`](src/pinned-prompt.ts) | The prompt row the reader pins over a scrolled turn: the glyph, the prompt collapsed to one line, and the band |
|
|
338
338
|
| [`src/transcript.ts`](src/transcript.ts) | Pure text folding of presentation views, usage, and turn-end reasons, the `$ command` span, and the one fold grammar every marker is written in |
|
|
339
|
+
| [`src/json-tree.ts`](src/json-tree.ts) | Complete JSON objects and arrays as tree rows, their semantic token ranges, and the distinction between shell commands and dimmed output |
|
|
339
340
|
| [`src/diff.ts`](src/diff.ts) | Line diff, hunk selection, and the addition and removal marks diff cards box |
|
|
340
341
|
| [`src/style.ts`](src/style.ts) | The palette: the Tokyo Night hues as truecolor or 256-color SGR, the semantic roles drawn in them — including the heading and link hues a Markdown reply uses and the tool-name, call-subject, and model hues — the strikethrough role completed todo content uses, the background band a prompt is drawn on and the darker one a steered or injected prompt is drawn on, the green and red fills and sign colours of a diff card's changed rows, whether key chips are clickable, and the derived pi-tui themes |
|
|
341
342
|
| [`src/highlight.ts`](src/highlight.ts) | Syntax colour for fenced code, file rows, and shell commands: the grammars a block may load, the theme the background picks, and the SGR one token is drawn with |
|
|
@@ -40,7 +40,7 @@ dsh tui --no-open # print sign-in URLs without opening a
|
|
|
40
40
|
|
|
41
41
|
### 屏幕布局
|
|
42
42
|
|
|
43
|
-
每一帧都从终端左右两边各内缩一列绘制,因此对话记录与停靠的界面组件都不会有任何一行贴到两侧边缘。页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),而在已有模型步骤的轮次中被引导或注入的提示以暗色文字铺在更深的背景带上,退到它所加入的轮次之后,assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,流式期间标题旁的绽放符号随之旋转,每次工具调用是一张卡片,含状态符号(运行中为按工具族混合花朵、绽放与星形的黄色旋转指示、完成为绿色 `◆`、失败为红色 `◆`)、粗体青色工具名、以蓝绿色显示的呈现器标题(去掉呈现器重复写出的工具名,因此 `Read src/app.ts` 画成 `read src/app.ts`;shell 卡片取该次调用自身的摘要,绝不取命令,命令只由卡片的 `$` 行绘制一次)、运行中的一行加载标记,以及折叠到 `toolPreviewLines`
|
|
43
|
+
每一帧都从终端左右两边各内缩一列绘制,因此对话记录与停靠的界面组件都不会有任何一行贴到两侧边缘。页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),而在已有模型步骤的轮次中被引导或注入的提示以暗色文字铺在更深的背景带上,退到它所加入的轮次之后,assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,流式期间标题旁的绽放符号随之旋转,每次工具调用是一张卡片,含状态符号(运行中为按工具族混合花朵、绽放与星形的黄色旋转指示、完成为绿色 `◆`、失败为红色 `◆`)、粗体青色工具名、以蓝绿色显示的呈现器标题(去掉呈现器重复写出的工具名,因此 `Read src/app.ts` 画成 `read src/app.ts`;shell 卡片取该次调用自身的摘要,绝不取命令,命令只由卡片的 `$` 行绘制一次)、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。shell 输出以暗色显示,与使用语法着色的命令区分;完整的 JSON 对象或数组结果绘成树,以暗色导引线、青色键、橙色数组下标和按类型着色的标量值取代括号包裹的原始 JSON,格式错误或混合文本的输出保持不变。顶层 workflow 调用还会在该卡片旁另绘一次运行:运行名、成员数、状态,以及一条十格的成员进度条与已结束数,然后是每个阶段和已启动的成员。实时运行进行中时,其 `◇` 以菱形动画脉动,每个运行中成员的 `○` 以子 agent 族的花朵旋转,相位比前一个成员领先一格;从重放日志绘制的运行只在其后台作业仍存活时旋转,减少动效时绘制静态符号。运行中的层级,以及含失败、取消或中断成员的层级会展开;干净完成的层级保持折叠。在运行或阶段上按 Space 或 Enter 折叠该层,在仍在运行的成员上按 Enter 只会在该子会话是本会话的直接子会话且仍在本进程运行时打开它。卡片在模型开始调用时出现,并逐行向外流出,每行从左到右,无论卡片装着什么,速度都一致:一整行宽的内容需 `toolRevealFrames` 帧,较短的行按比例更短,刚画出的列会从终端背景色亮起到各自的颜色。工具回答后,结果行也以同样方式流出,排在卡片尚未画完的内容之后;调用与结果都不会等待动画。`edit` 或 `write` diff 卡片把每一新增行整行铺满绿色背景、每一删除行整行铺满红色背景,删除的旧行在上、新增的新行在下,并把 `+` 与 `-` 画成各自更亮的颜色,使符号从填充色中读得出来;折行续行只延续填充色,不再画第二个符号;工具应用变更后,已应用的 hunk 取代调用时携带的 diff,并在每行前标出文件行号,新增行与未变行用新文件的行号,删除行用旧文件的行号。`subagent` 与 `subagent_*` 卡片折叠时只画一行,行首是同样的状态符号,运行中旋转,交给后台的子 agent 则为暗色 `◆`:运行中显示工具名、任务描述,以及调用指定的模型与 `background`;结束后描述变暗,右端标出 `[done]`,交给后台的子 agent 标 `[started]`,失败标 `[failed]`。在被标记的行上按 `Space`,或按 `Ctrl+O`,即可展开完整卡片。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词则省略。一次压缩(compaction)——无论来自 `/compact` 还是自动触发——绘制为一个上下文块,其强调色 `⬡` 标题写明来源,以及被替换内容与摘要各自的估算 token 数,如 `context compacted by /compact · ~6.4k → ~0.9k tokens` 或 `context compacted automatically in turn 12 · …`;标题之下,`compressed` 写明摘要替换的条目数与轮次、其中的每条提示(最多五条,每条一行),以及回复、按工具分列的工具结果、上下文块与更早摘要的计数,`preserved` 写明系统提示词以及之后每一轮仍逐字保留的内容;这两部分始终绘出,其下的摘要则像其他上下文块一样折叠到 `contextPreviewLines` 行。检查点消息本身不再重复绘制。日志以错误结束的 `/compact` 尝试会在会话重绘时打印 `/compact failed · <error>`,因为实时运行的命令会自己报告失败;失败的自动尝试不改变任何内容,也不绘制任何内容,与浏览器一致。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行、`edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——以及 `!` / `!!` 草稿、用户 shell 的 `$ command` 行(其 `$` 用强调色)与终端工具卡片中的 shell 命令,都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题与列表标记使用橙色,链接与行内代码使用品红色,引用保持暗色。每种色相都是 Tokyo Night(Night)配色,当 `COLORTERM` 声明 `truecolor` 或 `24bit` 时按原色精确绘制,否则取 256 色索引中最接近的一色;背景带保留其 256 色灰阶与 diff 底色。流式推理、回复文字与工具参数到达时先入队,再按帧(默认约每秒 60 帧)分批绘制,因此一次网络突发会分摊到 `streamPaceFrames` 帧里,而不是一次落下,队列也从不拖慢模型调用。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理在同一时长内浮出:以抬高的颜色出现,再退回到稳定时的暗色斜体。工具卡片的每一列则在这段时长内从终端背景色亮起到它稳定时的调色板颜色;从持久化历史重绘的卡片不带流出或淡入,已经稳定下来的文字也不会再被调暗。
|
|
44
44
|
|
|
45
45
|
对话记录下方依次是 agent 工作时的旋转指示——`thinking`、`writing`、`calling <tool>`、重试或 `compacting`,各自旁边是它自己的盲文动画:环绕的点、逐行填满的线、绕行的单点、滑动的横条,或沉降又回满的方格——标签单词上带着一道扫过的高亮,并带着当前这次模型调用的实时 `↑` 发送与 `↓` 接收 token,以紧凑的 `k` / `M` / `B` 计数,随数据流入增长,并在提供方的 usage 块到达后落定——任何打开的提示、有消息等待时的带框 follow-ups 列表、本轮 todo 与每个子 agent 一行的 activity board(有行时才绘制;已完成内容划掉,状态符号以绿色、黄色或蓝色显示,进行中的那一项为旋转指示,todo 最多四行其后 `+<n> more`,每个子 agent 行是其旋转指示或 `✓` / `✗`、任务标签(Agent Teams 的 teammate 为 `<name> · <role>`),以及它自述正在做什么的最后一句话,截成终端的一行,运行中的子 agent 在前,最多三行其后 `+<n> more subagents`,不是焦点区域,在 `turn/end` 与 bind 时消失)、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型为紫色,入口按键为品红色;进行中的轮次、上下文与 todo 信息分别使用黄色、品红色与绿色。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,有 follow-ups 等待时则写作 `Shift+↑ select · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、token 用量(会话合计加上进行中的这次调用)、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
|
|
46
46
|
|
|
@@ -169,7 +169,7 @@ follow-ups 面板持有键盘时:
|
|
|
169
169
|
|
|
170
170
|
每个聚焦的分段都在第二行展开其最重要的事实。除 `todo` 之外,`Enter` 把这些事实打印到对话记录,并指出改变它们的方式:模型分段指出 `/model`,推理强度分段指出 `Shift+Tab` 与 `/effort` 共用的选择器,权限分段指出其预设以及 `/permission` 选择器;`turn` 分段——绘制在权限与用量分段之间、形如 `turn <elapsed>`,且只在轮次进行时出现——给出轮次编号、其开始时间、已用时间与排队消息数量;用量、上下文、目标与计划分段打印 `/status` 报告中对应的小节,workspace 分段显示完整路径,附件分段列出待发送的附件。`todo` 分段展开按状态统计的计数以及正在进行的条目(若无正在进行的条目则为下一条待办),`Enter` 打开 agent 的 todo 列表,与 `/todos` 打开的是同一个列表。
|
|
171
171
|
|
|
172
|
-
在编辑器开头输入 `/` 会补全终端自身的命令与共享注册表的命令;任意位置的 `@` 补全引用。非空的 `!command` 或 `!!command` 行经 `ctx.shell` 在会话 cwd 以 `danger-full-access` 运行;草稿与对话记录中的 `$ command`
|
|
172
|
+
在编辑器开头输入 `/` 会补全终端自身的命令与共享注册表的命令;任意位置的 `@` 补全引用。非空的 `!command` 或 `!!command` 行经 `ctx.shell` 在会话 cwd 以 `danger-full-access` 运行;草稿与对话记录中的 `$ command` 行使用语法高亮,暗色输出或 JSON 树画在该行之下。`!` 会注入一条插件通知供下一步领取;`!!` 不会。单独的 `!` 仍是普通提示。草稿以 `!` 开头时,编辑器边框改为警告色。
|
|
173
173
|
|
|
174
174
|
| 命令 | 效果 |
|
|
175
175
|
|---|---|
|
|
@@ -336,6 +336,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
|
|
|
336
336
|
| [`src/toast.ts`](src/toast.ts) | 临时按键提示行:其浮层、其时钟,以及它承载的各条文字 |
|
|
337
337
|
| [`src/pinned-prompt.ts`](src/pinned-prompt.ts) | 阅读器在轮次面板滚动后固定在顶部的提示行:符号、合并为一行的提示,以及背景带 |
|
|
338
338
|
| [`src/transcript.ts`](src/transcript.ts) | 呈现视图、用量与轮次结束原因的纯文本折叠、`$ command` 的 span,以及每条标记共用的那一套折叠措辞 |
|
|
339
|
+
| [`src/json-tree.ts`](src/json-tree.ts) | 把完整的 JSON 对象与数组绘成树行、提供语义 token 范围,并区分 shell 命令与暗色输出 |
|
|
339
340
|
| [`src/diff.ts`](src/diff.ts) | diff 卡片的行 diff、hunk 选择,以及卡片加框所依据的新增与删除标记 |
|
|
340
341
|
| [`src/style.ts`](src/style.ts) | 调色板:以真彩色或 256 色 SGR 表示的 Tokyo Night 色相,以及用这些色相绘制的语义角色(含 Markdown 回复所用的标题与链接色、工具名、调用对象与模型的色相、已完成 todo 内容所用的划线角色、提示所铺的背景带与被引导或注入的提示所铺的更深背景带、diff 卡片变更行的绿色与红色填充及符号颜色)、按键徽标是否可点击,以及派生的 pi-tui 主题 |
|
|
341
342
|
| [`src/highlight.ts`](src/highlight.ts) | 围栏代码、文件行与 shell 命令的语法高亮:某个块可能加载的语法、由背景选定的配色主题,以及一个 token 所用的 SGR |
|