@xiaoso/dsh-tool-plus 0.1.7 → 0.1.8-beta.3
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/lib/{abort-Caqff3M6.mjs → abort-BtBy5Svf.mjs} +1 -1
- package/lib/{alibaba-coding-plan-DTupMiAi.mjs → alibaba-coding-plan-oxHCHJtG.mjs} +2 -2
- package/lib/{alibaba-token-plan-Dj3OZhEE.mjs → alibaba-token-plan-B0WzvYnB.mjs} +2 -2
- package/lib/{amazon-bedrock-DbFSYXfJ.mjs → amazon-bedrock-BvfYGhrD.mjs} +6 -6
- package/lib/{anthropic-CXfWlp-x.mjs → anthropic-C6-vdduI.mjs} +1 -1
- package/lib/{anthropic-CTJ3IQVa.mjs → anthropic-Id561lwb.mjs} +13 -13
- package/lib/{anthropic-wire-CKuhDwZ1.mjs → anthropic-wire-Cb8AQ1tS.mjs} +13 -13
- package/lib/{api-key-validation-CGCJFbFr.mjs → api-key-validation-BXJKlsJg.mjs} +1 -1
- package/lib/{azure-openai-responses-ChFbWaGj.mjs → azure-openai-responses-CGws_ijz.mjs} +8 -8
- package/lib/{browser-render-9o0Rknop.mjs → browser-render-i7uYOl4f.mjs} +2 -2
- package/lib/client.js +2205 -19
- package/lib/{cloudflare-ai-gateway-BupNXyKK.mjs → cloudflare-ai-gateway-BK6eadm9.mjs} +2 -2
- package/lib/{cloudflare-ai-gateway-EWo0VkP5.mjs → cloudflare-ai-gateway-B_kWnF30.mjs} +1 -1
- package/lib/{collapse-DOR8sOGf.mjs → collapse-DU3g7d3B.mjs} +1 -1
- package/lib/{coreweave-Ct8cF-da.mjs → coreweave-CkR_FlQi.mjs} +2 -2
- package/lib/{cursor-LKGjucn2.mjs → cursor-BXx_5h4a.mjs} +2 -2
- package/lib/{cursor-DJV_dcgB.mjs → cursor-BcHwv8qq.mjs} +10 -10
- package/lib/{cursor-B95LzVWV.mjs → cursor-BjWbJJLe.mjs} +1 -1
- package/lib/{cursor-proto-B8Wj8bv9.mjs → cursor-proto-DPXXYx8S.mjs} +1 -1
- package/lib/{devin-DSp0Rw_E.mjs → devin-BZBfzyIz.mjs} +6 -6
- package/lib/{devin-BMTdx_hx.mjs → devin-Ce3Wz8_E.mjs} +5 -5
- package/lib/{devin-proto-Br8fdyNl.mjs → devin-proto-B6HwDwHK.mjs} +1 -1
- package/lib/{error-CORgGg5a.mjs → error-DdCn4m1q.mjs} +3 -3
- package/lib/{event-stream-ulcDenZD.mjs → event-stream-ldcUvOA0.mjs} +1 -1
- package/lib/{github-copilot-Dstq1D3s.mjs → github-copilot-BT5dkIJl.mjs} +2 -2
- package/lib/{github-copilot-headers-DOh1gt_w.mjs → github-copilot-headers-BGL8JO5c.mjs} +2 -2
- package/lib/{gitlab-duo-DSCMrU0m.mjs → gitlab-duo-B0qSYCa3.mjs} +1 -1
- package/lib/{google-CtsKkOQK.mjs → google-6cRgRmh0.mjs} +3 -3
- package/lib/{google-antigravity-z-5KsEci.mjs → google-antigravity-D1llOVad.mjs} +3 -3
- package/lib/{google-auth-ieLBaneO.mjs → google-auth-DYhqX1rJ.mjs} +5 -5
- package/lib/{google-gemini-cli-CAIPSl7e.mjs → google-gemini-cli-ByQUuKp9.mjs} +7 -7
- package/lib/{google-gemini-cli-C6NE5mWz.mjs → google-gemini-cli-CjHy6mFG.mjs} +3 -3
- package/lib/{google-oauth-shared-DhMllAkt.mjs → google-oauth-shared-CSwCT0Yl.mjs} +1 -1
- package/lib/{google-shared-B0aNCYEH.mjs → google-shared-DYjJp0mQ.mjs} +5 -5
- package/lib/{google-vertex-Bbd1tYNc.mjs → google-vertex-CbOvlE5j.mjs} +4 -4
- package/lib/{idle-iterator-DlUkEfzW.mjs → idle-iterator-DTBaEIbM.mjs} +2 -2
- package/lib/index.mjs +1278 -184
- package/lib/{kilo-ChJL54wq.mjs → kilo-cVG1aNZM.mjs} +1 -1
- package/lib/{kimi-C2c_Zq8A.mjs → kimi-BFfnFDhu.mjs} +4 -4
- package/lib/{launch-DKDH71En.mjs → launch-Uq7920ng.mjs} +7 -7
- package/lib/{markit-CmRfm4E2.mjs → markit-BmsfOFVh.mjs} +18 -18
- package/lib/{muse-code-Di1VZmB1.mjs → muse-code-CtcevJab.mjs} +1 -1
- package/lib/{ollama-B8ic3sEp.mjs → ollama-B5hR1P1p.mjs} +8 -8
- package/lib/{openai-codex-DuJNC99x.mjs → openai-codex-CxkPyvyt.mjs} +2 -2
- package/lib/{openai-codex-responses-BL29nh9K.mjs → openai-codex-responses-BbM3Q7nJ.mjs} +9 -9
- package/lib/{openai-completions-BK2f2dBv.mjs → openai-completions-CffXVOCL.mjs} +13 -13
- package/lib/{openai-reasoning-fallback-BdB3RCbj.mjs → openai-reasoning-fallback-DFdD1ok5.mjs} +2 -2
- package/lib/{openai-responses-CGQPlIIy.mjs → openai-responses-DgqOvSn_.mjs} +9 -9
- package/lib/{perplexity-TBjz3VMB.mjs → perplexity-JFp3knZN.mjs} +2 -2
- package/lib/{protobuf-aab1UGVn.mjs → protobuf-BJHNU9-E.mjs} +1 -1
- package/lib/{proxy-5nWqRL1f.mjs → proxy-B51IWEMt.mjs} +2 -2
- package/lib/{scrapers-CtQrQ5kG.mjs → scrapers-DU4u4-Co.mjs} +7 -7
- package/lib/{src-BwW51vA5.mjs → src-DUUqyo9y.mjs} +42 -42
- package/lib/{stream-B_7qN-bA.mjs → stream-DHdFrAG4.mjs} +54 -54
- package/lib/{stream-markup-healing-DKT1lnkW.mjs → stream-markup-healing-DlJ9abTw.mjs} +2 -2
- package/lib/{thinking-CiLa2LFB.mjs → thinking-D6LJxkz_.mjs} +1 -1
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/config/settings.d.ts +8 -0
- package/lib/types/tools/ast-grep/adapter/index.d.ts +23 -0
- package/lib/types/tools/edit/adapter/index.d.ts +3 -0
- package/lib/types/tools/glob/adapter/index.d.ts +2 -0
- package/lib/types/tools/grep/adapter/index.d.ts +4 -0
- package/lib/types/tools/read/adapter/index.d.ts +18 -0
- package/lib/types/tools/write/adapter/index.d.ts +2 -0
- package/lib/types/web/client/ToolCardShell.d.ts +111 -0
- package/lib/types/web/client/labels.d.ts +36 -0
- package/lib/types/web/client/registerToolCards.d.ts +35 -0
- package/lib/types/web/client/row-utils.d.ts +177 -0
- package/lib/types/web/client/rows/AstEditRow.d.ts +22 -0
- package/lib/types/web/client/rows/FileMutationRow.d.ts +23 -0
- package/lib/types/web/client/rows/ReadRow.d.ts +31 -0
- package/lib/types/web/client/rows/SearchRow.d.ts +21 -0
- package/lib/types/web/client/rows/TerminalRow.d.ts +24 -0
- package/lib/types/web/client/rows/WriteRow.d.ts +22 -0
- package/lib/types/web/client/rows/command-card-facts.d.ts +45 -0
- package/lib/types/web/client/rows/image-card.d.ts +60 -0
- package/lib/types/web/client/rows/read-card-facts.d.ts +33 -0
- package/lib/types/web/client/rows/search-card-facts.d.ts +37 -0
- package/lib/types/web/contract.d.ts +249 -0
- package/lib/types/web/host/ast-edit.d.ts +10 -0
- package/lib/types/web/host/bash.d.ts +30 -0
- package/lib/types/web/host/edit.d.ts +33 -0
- package/lib/types/web/host/read.d.ts +48 -0
- package/lib/types/web/host/search.d.ts +41 -0
- package/lib/types/web/host/write.d.ts +13 -0
- package/lib/{types-PVueGi9S.mjs → types-DT9vgZ3S.mjs} +1 -1
- package/lib/{utils-CUPhpw9A.mjs → utils-BMmwLB0f.mjs} +2 -2
- package/lib/{utils-ECAwvaPQ.mjs → utils-C-Lo_JC6.mjs} +41 -41
- package/lib/{utils-DeWqNWV8.mjs → utils-D31VFael.mjs} +1 -1
- package/lib/{vision-guard-_XwsL1DF.mjs → vision-guard-BlAAqGUC.mjs} +1 -1
- package/lib/{xai-oauth-CXhnz0gO.mjs → xai-oauth-QPyScm4X.mjs} +1 -1
- package/lib/{xiaomi-psoUItal.mjs → xiaomi-CLzjxHAi.mjs} +1 -1
- package/lib/{zai-ApJ8HBgT.mjs → zai-wDp0g7VC.mjs} +1 -1
- package/lib/{zip-Kd602XNe.mjs → zip-CNtIFfyV.mjs} +7 -7
- package/package.json +3 -1
- package/presets/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image material for the `read` card, as a pure derivation.
|
|
3
|
+
*
|
|
4
|
+
* A `read` that resolves to an image settles with the reference in the
|
|
5
|
+
* result's own image block, never in `meta`: metadata rides the 256 KiB
|
|
6
|
+
* lossless-JSON budget and is the wrong carrier for a session-authorized
|
|
7
|
+
* resource, so the image branch of the read row is exactly the case where the
|
|
8
|
+
* text card declines (`narrowReadCardMeta` returns `null`).
|
|
9
|
+
*
|
|
10
|
+
* The derivation is deliberately strict — one block of an unknown type, one
|
|
11
|
+
* malformed reference, or a missing path declines the whole card — because the
|
|
12
|
+
* alternative is a card that draws a picture while silently dropping whatever
|
|
13
|
+
* else the result carried.
|
|
14
|
+
* @module @xiaoso/dsh-tool-plus/web/client/rows/image-card
|
|
15
|
+
*/
|
|
16
|
+
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
17
|
+
import { type CardBlockView } from '../row-utils.ts';
|
|
18
|
+
/** What the read row needs to draw a result's images, and nothing more. */
|
|
19
|
+
export interface CardImageMaterial {
|
|
20
|
+
/** Display label for the card header: the request path, workspace-shortened. */
|
|
21
|
+
label: string;
|
|
22
|
+
/** The requested path, verbatim — the absolute path the file viewer opens. */
|
|
23
|
+
path: string;
|
|
24
|
+
/** The result's durable references, in result order. */
|
|
25
|
+
images: ImageAttachmentRef[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Display box for a lone image — DSH's own rule, copied from
|
|
29
|
+
* `ui-attachment/src/MessageImage.tsx::singleFit` so a tool-card image and a
|
|
30
|
+
* message image of the same file occupy the same box: long edge 240px, the
|
|
31
|
+
* rendered aspect ratio clamped to [0.25, 4] (the clamped overflow is cropped
|
|
32
|
+
* by `object-fit: cover`), never upscaled past the natural size, and the crop
|
|
33
|
+
* anchored to the top of very tall images / the left of very wide ones, where
|
|
34
|
+
* the informative content usually starts.
|
|
35
|
+
*
|
|
36
|
+
* The clamp is deliberately not strict: an exactly 4:1 image stays centred.
|
|
37
|
+
* @param size - the reference's intrinsic dimensions, in pixels.
|
|
38
|
+
* @returns the rendered box and the crop anchor.
|
|
39
|
+
*/
|
|
40
|
+
export declare function imageFitBox(size: {
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
}): {
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
objectPosition: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Derive the read card's image material from a settled result.
|
|
50
|
+
*
|
|
51
|
+
* Declines — rather than guessing — whenever the result would not be fully
|
|
52
|
+
* representable: a running call, a failed call, a result whose content carries
|
|
53
|
+
* a block that is neither text nor image, an image whose reference is
|
|
54
|
+
* malformed, a text-only result (the text card owns those), or a call whose
|
|
55
|
+
* arguments name no path.
|
|
56
|
+
* @param block - the frozen call node.
|
|
57
|
+
* @param cwd - the session workspace root, for shortening the label.
|
|
58
|
+
* @returns the material, or `null` to leave the row on its existing path.
|
|
59
|
+
*/
|
|
60
|
+
export declare function imageCardMaterial(block: CardBlockView, cwd: string | undefined): CardImageMaterial | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapsed-summary facts for the `read` card.
|
|
3
|
+
*
|
|
4
|
+
* The Host projection strips the inline selector off the path
|
|
5
|
+
* (`stripReadSelector` in `web/host/read.ts`) because the card's *link* must
|
|
6
|
+
* point at a real file, and it keeps only the file's own window. The collapsed
|
|
7
|
+
* head is then the one place where the question the model actually asked is
|
|
8
|
+
* still readable — and the projected path cannot answer it: a windowed read of
|
|
9
|
+
* `package.json:22-25,31-34` and a whole-file read of `package.json` project to
|
|
10
|
+
* the very same string, so the card hides the difference.
|
|
11
|
+
*
|
|
12
|
+
* The summary is therefore built from the call's own argument, selector and
|
|
13
|
+
* all, with the projected path kept as the fallback for a result whose call
|
|
14
|
+
* head fell outside the session window (a truncated window carries no
|
|
15
|
+
* `tool/call` event, so no argument survives). That fallback states a fact the
|
|
16
|
+
* card already holds; nothing is invented.
|
|
17
|
+
* @module @xiaoso/dsh-tool-plus/web/client/rows/read-card-facts
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* The `read` card's collapsed summary: the path the model asked for, keeping
|
|
21
|
+
* whatever inline selector it carried (`:22-25`, `:raw`, `:conflicts`, `:28-`,
|
|
22
|
+
* a sqlite row, an archive member) and shortened against the workspace root.
|
|
23
|
+
*
|
|
24
|
+
* The selector is deliberately not validated against the read grammar: the head
|
|
25
|
+
* reports the call verbatim, and a selector this plugin does not recognize is
|
|
26
|
+
* still what the model typed — substituting the projection's stripped path
|
|
27
|
+
* would erase the evidence that two calls differ.
|
|
28
|
+
* @param args - the call's parsed arguments, or `null` when its head is gone.
|
|
29
|
+
* @param metaPath - the Host-projected path (already selector-free).
|
|
30
|
+
* @param cwd - the session workspace root, when known.
|
|
31
|
+
* @returns the workspace-shortened argument path, or the projected path.
|
|
32
|
+
*/
|
|
33
|
+
export declare function readCardSummary(args: Record<string, unknown> | null, metaPath: string, cwd: string | undefined): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapsed-summary facts for the `grep` / `ast_grep` / `glob` cards.
|
|
3
|
+
*
|
|
4
|
+
* The row's summary is the search's *subject* — `pattern` for grep, `pat` for
|
|
5
|
+
* ast_grep, the path pattern for glob — so the one question the collapsed head
|
|
6
|
+
* could not answer is "which tree was searched?", and the counts sat in the
|
|
7
|
+
* folded body. That reads worst on an empty result: a bare `Grep · zzz` looks
|
|
8
|
+
* like a bad pattern rather than like a search of the wrong directory.
|
|
9
|
+
*
|
|
10
|
+
* Two facts therefore ride the head as a trailing fragment, after the summary
|
|
11
|
+
* and outside its ellipsis, because they are the parts a narrow row must never
|
|
12
|
+
* clip:
|
|
13
|
+
* - the scope, taken from the call's own `path` argument. Only `matches`
|
|
14
|
+
* shapes take it: a glob's `path` argument *is* its pattern, which the
|
|
15
|
+
* summary already shows, so repeating it as a scope would claim a second
|
|
16
|
+
* fact out of one argument. A call without `path` searched the workspace
|
|
17
|
+
* root — naming no scope is honest, inventing one is not;
|
|
18
|
+
* - the count, or "no results" instead of a zero count (a zero count is what
|
|
19
|
+
* the empty-state failure reads as, not what it says).
|
|
20
|
+
*
|
|
21
|
+
* The counting labels are the {@link searchBlockLabels} adapter the block body
|
|
22
|
+
* already uses, so the head and the body say the same thing in the same words,
|
|
23
|
+
* including the "showing N of M" wording of a capped payload.
|
|
24
|
+
* @module @xiaoso/dsh-tool-plus/web/client/rows/search-card-facts
|
|
25
|
+
*/
|
|
26
|
+
import type { SearchCardMeta } from '../../contract.ts';
|
|
27
|
+
import type { CardTranslate } from '../row-utils.ts';
|
|
28
|
+
/**
|
|
29
|
+
* The search card's collapsed trailing fragment: the scope the call searched,
|
|
30
|
+
* then what the search found.
|
|
31
|
+
* @param args - the call's parsed arguments, or `null` when its head is gone.
|
|
32
|
+
* @param meta - the Host-projected search metadata (already narrowed).
|
|
33
|
+
* @param cwd - the session workspace root, for shortening an absolute scope.
|
|
34
|
+
* @param t - the card translate seat.
|
|
35
|
+
* @returns the joined fragment, or `null` when there is no fact to add.
|
|
36
|
+
*/
|
|
37
|
+
export declare function searchCardSuffix(args: Record<string, unknown> | null, meta: SearchCardMeta, cwd: string | undefined, t: CardTranslate): string | null;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web tool-card contract: the payload this plugin's Host half projects into
|
|
3
|
+
* `output.presentationMeta` and its browser half narrows back before drawing.
|
|
4
|
+
*
|
|
5
|
+
* Dependency-free by design (no React, no cordis, no Node built-ins): the Node
|
|
6
|
+
* half imports it to build metadata, the browser half imports it to validate
|
|
7
|
+
* it, and because it carries no React import it can never drag the browser
|
|
8
|
+
* bundle into the Node build.
|
|
9
|
+
*
|
|
10
|
+
* `edit` / `read` / `search` mirror the exact shapes the shipped
|
|
11
|
+
* `@deepseek-ai/dsh-client-ui-tool` card models accept — a `kind` tag rides on
|
|
12
|
+
* top, and those models ignore unknown keys — so the same payload stays
|
|
13
|
+
* readable if this plugin ever stops shadowing those rows. `write`,
|
|
14
|
+
* `ast_edit` and `terminal` are this plugin's own shapes: the shipped rows have
|
|
15
|
+
* no equivalent (their write card is a diff card; ours is a content preview,
|
|
16
|
+
* matching the OMP card the model already sees).
|
|
17
|
+
*
|
|
18
|
+
* Everything here is defensive: a card never throws. The browser half turns any
|
|
19
|
+
* malformed, oversized or foreign payload into `null`, and the row falls back
|
|
20
|
+
* to the generic shell.
|
|
21
|
+
*
|
|
22
|
+
* @module @xiaoso/dsh-tool-plus/web/contract
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Cell-shadowing rank of every card entry this plugin registers.
|
|
26
|
+
*
|
|
27
|
+
* The shipped `tool.call.toolview` entries all register at the default
|
|
28
|
+
* priority 0, and the lowest live entry of a cell renders. A large negative
|
|
29
|
+
* constant keeps this plugin first even if a future release starts ranking its
|
|
30
|
+
* own rows below zero — the gap is deliberate, not a tuned value.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CARD_TAKEOVER_PRIORITY = -1000;
|
|
33
|
+
/**
|
|
34
|
+
* Wire tool names whose `tool.call.toolview` cell this plugin renders.
|
|
35
|
+
*
|
|
36
|
+
* `ast_grep` / `ast_edit` are this plugin's own tool names (no shipped entry
|
|
37
|
+
* claims those keys), so registering them is purely additive; the other six
|
|
38
|
+
* shadow a shipped row.
|
|
39
|
+
*/
|
|
40
|
+
export declare const CARD_TOOL_KEYS: readonly ["bash", "read", "write", "edit", "grep", "glob", "ast_grep", "ast_edit"];
|
|
41
|
+
/** One of {@link CARD_TOOL_KEYS}. */
|
|
42
|
+
export type CardToolKey = (typeof CARD_TOOL_KEYS)[number];
|
|
43
|
+
/**
|
|
44
|
+
* Cap on the serialized `edit` metadata. The engine's unified diff is already
|
|
45
|
+
* bounded per file but unbounded across files; past this budget whole trailing
|
|
46
|
+
* files are dropped, and once nothing is left the call falls back to the
|
|
47
|
+
* generic shell rather than writing an oversized session entry.
|
|
48
|
+
*/
|
|
49
|
+
export declare const EDIT_META_MAX_BYTES: number;
|
|
50
|
+
/** Cap on the `ast_edit` change preview (the engine's own display text). */
|
|
51
|
+
export declare const AST_EDIT_META_MAX_BYTES: number;
|
|
52
|
+
/** Cap on the serialized `read` metadata (the returned window's lines). */
|
|
53
|
+
export declare const READ_META_MAX_BYTES: number;
|
|
54
|
+
/**
|
|
55
|
+
* Cap on the serialized search metadata. Same value and meaning as the shipped
|
|
56
|
+
* search card's own `searchMetaMaxBytes`.
|
|
57
|
+
*/
|
|
58
|
+
export declare const SEARCH_META_MAX_BYTES: number;
|
|
59
|
+
/** UTF-8 byte length of `text`, without allocating an encoder. */
|
|
60
|
+
export declare function utf8ByteLength(text: string): number;
|
|
61
|
+
/** UTF-8 byte length of a value's JSON form; the unit every cap above uses. */
|
|
62
|
+
export declare function jsonByteLength(value: unknown): number;
|
|
63
|
+
/**
|
|
64
|
+
* Longest prefix of `text` that fits in `cap` UTF-8 bytes, never splitting a
|
|
65
|
+
* surrogate pair.
|
|
66
|
+
* @param text - the text to bound.
|
|
67
|
+
* @param cap - the byte budget.
|
|
68
|
+
* @returns `text` when it already fits, otherwise its longest fitting prefix.
|
|
69
|
+
*/
|
|
70
|
+
export declare function capText(text: string, cap: number): string;
|
|
71
|
+
/**
|
|
72
|
+
* Drop entries from the tail until the payload `wrap(retained)` serializes
|
|
73
|
+
* within `cap`.
|
|
74
|
+
*
|
|
75
|
+
* `wrap` receives the retained slice only, so the caller measures the real
|
|
76
|
+
* payload — including its fixed fields — and a single oversized entry ends as
|
|
77
|
+
* an empty list rather than an oversized one.
|
|
78
|
+
* @param items - the ordered entries to bound.
|
|
79
|
+
* @param cap - byte budget for `wrap`'s result.
|
|
80
|
+
* @param wrap - builds the payload that would be emitted for a retained slice.
|
|
81
|
+
* @returns the retained head, in input order.
|
|
82
|
+
*/
|
|
83
|
+
export declare function capTail<T>(items: readonly T[], cap: number, wrap: (retained: readonly T[]) => unknown): T[];
|
|
84
|
+
/** One file's change, in the shape the shipped diff card consumes. */
|
|
85
|
+
export type CardDiffHunk = {
|
|
86
|
+
path: string;
|
|
87
|
+
/** Prior content, or `null` for a new file / an overwrite. */
|
|
88
|
+
oldText: string | null;
|
|
89
|
+
/** Content after the change. */
|
|
90
|
+
newText: string;
|
|
91
|
+
};
|
|
92
|
+
/** One line of a read window, in the shape `ReadBlock` consumes. */
|
|
93
|
+
export type CardReadLine = {
|
|
94
|
+
number: number;
|
|
95
|
+
/** The line's text, without its newline. */
|
|
96
|
+
text: string;
|
|
97
|
+
};
|
|
98
|
+
/** One matched line inside a {@link CardSearchFileGroup}. */
|
|
99
|
+
export type CardSearchMatchLine = {
|
|
100
|
+
/** 1-based line number of the match within its file. */
|
|
101
|
+
lineNumber: number;
|
|
102
|
+
/** The matched line's text. */
|
|
103
|
+
line: string;
|
|
104
|
+
};
|
|
105
|
+
/** One file's grouped matches, in first-seen order. */
|
|
106
|
+
export type CardSearchFileGroup = {
|
|
107
|
+
/** The file the matches belong to (display path). */
|
|
108
|
+
path: string;
|
|
109
|
+
/** The file's matched lines, in output order. */
|
|
110
|
+
matches: CardSearchMatchLine[];
|
|
111
|
+
};
|
|
112
|
+
/** `write` card metadata: a content preview, so only the header needs data. */
|
|
113
|
+
export type WriteCardMeta = {
|
|
114
|
+
kind: 'write';
|
|
115
|
+
/** The written file's model-facing path. */
|
|
116
|
+
path: string;
|
|
117
|
+
/** Grammar hint for the preview; omitted when the path names no language. */
|
|
118
|
+
lang?: string;
|
|
119
|
+
/** The write set the file's executable bit; omitted otherwise. */
|
|
120
|
+
madeExecutable?: boolean;
|
|
121
|
+
};
|
|
122
|
+
/** `edit` card metadata: the engine's own unified diff, already computed. */
|
|
123
|
+
export type EditCardMeta = {
|
|
124
|
+
kind: 'edit';
|
|
125
|
+
/** One entry per applied hunk, in file order; never empty. */
|
|
126
|
+
diffs: CardDiffHunk[];
|
|
127
|
+
};
|
|
128
|
+
/** `ast_edit` card metadata: the engine's change preview plus its counters. */
|
|
129
|
+
export type AstEditCardMeta = {
|
|
130
|
+
kind: 'ast_edit';
|
|
131
|
+
/** The engine's display text for the applied replacements. */
|
|
132
|
+
preview: string;
|
|
133
|
+
/** Files touched, with their replacement counts. */
|
|
134
|
+
files: {
|
|
135
|
+
path: string;
|
|
136
|
+
count: number;
|
|
137
|
+
}[];
|
|
138
|
+
/** Total replacements applied. */
|
|
139
|
+
replacements: number;
|
|
140
|
+
/** Whether the edit was applied (`false` previews a dry run). */
|
|
141
|
+
applied: boolean;
|
|
142
|
+
};
|
|
143
|
+
/** `read` card metadata, in the shape the shipped read card consumes. */
|
|
144
|
+
export type ReadCardMeta = {
|
|
145
|
+
kind: 'read';
|
|
146
|
+
/** The read file's path, selector already stripped. */
|
|
147
|
+
path: string;
|
|
148
|
+
/** 1-based first line of the returned window. */
|
|
149
|
+
offset: number;
|
|
150
|
+
/** The returned window's lines, strictly increasing by number. */
|
|
151
|
+
lines: CardReadLine[];
|
|
152
|
+
/** Total line count in the file (the window's last line when unknown). */
|
|
153
|
+
totalLines: number;
|
|
154
|
+
/** Grammar hint for the file; omitted when the path names no language. */
|
|
155
|
+
lang?: string;
|
|
156
|
+
};
|
|
157
|
+
/** `grep` / `ast_grep` search metadata. */
|
|
158
|
+
export type SearchMatchesCardMeta = {
|
|
159
|
+
kind: 'search';
|
|
160
|
+
shape: 'matches';
|
|
161
|
+
/** Matched lines grouped by file, in first-seen order. */
|
|
162
|
+
files: CardSearchFileGroup[];
|
|
163
|
+
/** Whether the payload was capped (the counts below are pre-cap totals). */
|
|
164
|
+
truncated: boolean;
|
|
165
|
+
/** Total matches the search found before capping. */
|
|
166
|
+
total: number;
|
|
167
|
+
};
|
|
168
|
+
/** `glob` search metadata. */
|
|
169
|
+
export type SearchPathsCardMeta = {
|
|
170
|
+
kind: 'search';
|
|
171
|
+
shape: 'paths';
|
|
172
|
+
/** The discovered paths, in result order. */
|
|
173
|
+
paths: string[];
|
|
174
|
+
/** Whether the payload was capped (the counts below are pre-cap totals). */
|
|
175
|
+
truncated: boolean;
|
|
176
|
+
/** Total paths the search found before capping. */
|
|
177
|
+
total: number;
|
|
178
|
+
};
|
|
179
|
+
/** Search metadata: one card, two `shape`-discriminated forms. */
|
|
180
|
+
export type SearchCardMeta = SearchMatchesCardMeta | SearchPathsCardMeta;
|
|
181
|
+
/** `bash` metadata for a foreground call that ran to completion. */
|
|
182
|
+
export type TerminalForegroundCardMeta = {
|
|
183
|
+
kind: 'terminal';
|
|
184
|
+
mode: 'foreground';
|
|
185
|
+
/** Settled exit code; `null` when the process died from a timeout/abort. */
|
|
186
|
+
exitCode: number | null;
|
|
187
|
+
/** The command hit its deadline. */
|
|
188
|
+
timedOut: boolean;
|
|
189
|
+
/** The call was cancelled before the command settled. */
|
|
190
|
+
aborted: boolean;
|
|
191
|
+
/** The working directory the command actually ran in, when known. */
|
|
192
|
+
workingDir?: string;
|
|
193
|
+
};
|
|
194
|
+
/** `bash` metadata for a call handed off to a background job. */
|
|
195
|
+
export type TerminalBackgroundCardMeta = {
|
|
196
|
+
kind: 'terminal';
|
|
197
|
+
mode: 'background';
|
|
198
|
+
/** The managed job's id. */
|
|
199
|
+
jobId: string;
|
|
200
|
+
};
|
|
201
|
+
/** `bash` metadata: the run state the terminal card's status pill needs. */
|
|
202
|
+
export type TerminalCardMeta = TerminalForegroundCardMeta | TerminalBackgroundCardMeta;
|
|
203
|
+
/** Any card metadata this plugin emits. */
|
|
204
|
+
export type CardMeta = WriteCardMeta | EditCardMeta | AstEditCardMeta | ReadCardMeta | SearchCardMeta | TerminalCardMeta;
|
|
205
|
+
/**
|
|
206
|
+
* Narrow opaque metadata to a {@link WriteCardMeta}.
|
|
207
|
+
* @param meta - the result node's `meta` field.
|
|
208
|
+
* @returns the narrowed metadata, or `null` when it is not a usable write card.
|
|
209
|
+
*/
|
|
210
|
+
export declare function narrowWriteCardMeta(meta: unknown): WriteCardMeta | null;
|
|
211
|
+
/**
|
|
212
|
+
* Narrow opaque metadata to an {@link EditCardMeta}.
|
|
213
|
+
*
|
|
214
|
+
* Mirrors the shipped diff card's own validation (a hunk needs a non-blank
|
|
215
|
+
* `path`, an explicit `null` or string `oldText`, and a string `newText`) and
|
|
216
|
+
* additionally rejects a payload past {@link EDIT_META_MAX_BYTES}.
|
|
217
|
+
* @param meta - the result node's `meta` field.
|
|
218
|
+
* @returns the narrowed metadata, or `null` when it is not a usable diff card.
|
|
219
|
+
*/
|
|
220
|
+
export declare function narrowEditCardMeta(meta: unknown): EditCardMeta | null;
|
|
221
|
+
/**
|
|
222
|
+
* Narrow opaque metadata to an {@link AstEditCardMeta}.
|
|
223
|
+
* @param meta - the result node's `meta` field.
|
|
224
|
+
* @returns the narrowed metadata, or `null` when it is not a usable preview.
|
|
225
|
+
*/
|
|
226
|
+
export declare function narrowAstEditCardMeta(meta: unknown): AstEditCardMeta | null;
|
|
227
|
+
/**
|
|
228
|
+
* Narrow opaque metadata to a {@link ReadCardMeta}.
|
|
229
|
+
*
|
|
230
|
+
* Mirrors the shipped read card's own validation: a 1-based `offset`, lines
|
|
231
|
+
* strictly increasing in `number` and never past `totalLines`. A window whose
|
|
232
|
+
* lines were all elided therefore narrows to a card with an empty body, not to
|
|
233
|
+
* a malformed one.
|
|
234
|
+
* @param meta - the result node's `meta` field.
|
|
235
|
+
* @returns the narrowed metadata, or `null` when it is not a usable read card.
|
|
236
|
+
*/
|
|
237
|
+
export declare function narrowReadCardMeta(meta: unknown): ReadCardMeta | null;
|
|
238
|
+
/**
|
|
239
|
+
* Narrow opaque metadata to a {@link SearchCardMeta}.
|
|
240
|
+
* @param meta - the result node's `meta` field.
|
|
241
|
+
* @returns the narrowed metadata, or `null` when it is not a usable search card.
|
|
242
|
+
*/
|
|
243
|
+
export declare function narrowSearchCardMeta(meta: unknown): SearchCardMeta | null;
|
|
244
|
+
/**
|
|
245
|
+
* Narrow opaque metadata to a {@link TerminalCardMeta}.
|
|
246
|
+
* @param meta - the result node's `meta` field.
|
|
247
|
+
* @returns the narrowed metadata, or `null` when it is not a usable terminal card.
|
|
248
|
+
*/
|
|
249
|
+
export declare function narrowTerminalCardMeta(meta: unknown): TerminalCardMeta | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AstEditCardMeta } from '../contract.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Project the ast_edit engine's result into card metadata.
|
|
4
|
+
* @param details - the engine's `displayContent` / `fileReplacements` /
|
|
5
|
+
* `totalReplacements` / `applied` fields (the adapter's value carries the
|
|
6
|
+
* same names).
|
|
7
|
+
* @returns the ast_edit card metadata, or `null` when the call previews no
|
|
8
|
+
* replacement or produced no preview text.
|
|
9
|
+
*/
|
|
10
|
+
export declare function projectAstEditCardMeta(details: unknown): AstEditCardMeta | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host projection for the `bash` terminal card.
|
|
3
|
+
*
|
|
4
|
+
* The call's output value is already the structured shape this card needs, so
|
|
5
|
+
* nothing is read back from the session and nothing is recomputed: the
|
|
6
|
+
* presentation metadata is a lossless narrowing of that value.
|
|
7
|
+
*
|
|
8
|
+
* Two properties matter to the card:
|
|
9
|
+
* - a `timeoutMs: 0` call (the documented way to disable the deadline) is a
|
|
10
|
+
* perfectly valid call; the shipped terminal card treats the option as
|
|
11
|
+
* illegal and drops the whole card, so the run state cannot come from the
|
|
12
|
+
* arguments;
|
|
13
|
+
* - a timed-out or aborted run has no exit code of its own, and its result text
|
|
14
|
+
* (`[timed out after …]`, `[exit code: null]`) is not something the shipped
|
|
15
|
+
* card parses — the run state has to travel as data.
|
|
16
|
+
*
|
|
17
|
+
* @module @xiaoso/dsh-tool-plus/web/host/bash
|
|
18
|
+
*/
|
|
19
|
+
import type { TerminalCardMeta } from '../contract.ts';
|
|
20
|
+
/**
|
|
21
|
+
* Project a bash result value into terminal-card metadata.
|
|
22
|
+
*
|
|
23
|
+
* Every emitted field is a plain JSON scalar and no key is ever set to
|
|
24
|
+
* `undefined`: the metadata rides `presentationMeta`, where a non-lossless
|
|
25
|
+
* payload turns a successful call into a failed one. An unrecognized value
|
|
26
|
+
* yields `null`, which simply leaves the row on the generic shell.
|
|
27
|
+
* @param value - the tool's own output value (foreground or background arm).
|
|
28
|
+
* @returns the card metadata, or `null` when the value is not a usable bash result.
|
|
29
|
+
*/
|
|
30
|
+
export declare function bashCardMeta(value: unknown): TerminalCardMeta | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { EditCardMeta } from '../contract.ts';
|
|
2
|
+
/** One hunk of a numbered diff, gutter stripped. */
|
|
3
|
+
export interface ParsedDiffHunk {
|
|
4
|
+
/** Removed rows plus context rows, in diff order. */
|
|
5
|
+
oldLines: string[];
|
|
6
|
+
/** Added rows plus context rows, in diff order. */
|
|
7
|
+
newLines: string[];
|
|
8
|
+
/** Whether the hunk carries at least one removed or added row. */
|
|
9
|
+
changed: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse an engine diff body into display hunks.
|
|
13
|
+
*
|
|
14
|
+
* Boundaries: a `@@ … @@` header, a blank gap row (the engine's own
|
|
15
|
+
* non-contiguity marker), or a line-number break after a change (how joined
|
|
16
|
+
* per-entry diffs and skipped context regions read). Hunks without a change are
|
|
17
|
+
* dropped — they would render as an empty diff.
|
|
18
|
+
* @param diff - `details.diff` / `details.perFileResults[].diff`.
|
|
19
|
+
* @returns the hunks, in diff order; empty when nothing parses.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseNumberedDiffHunks(diff: string): ParsedDiffHunk[];
|
|
22
|
+
/**
|
|
23
|
+
* Project the edit engine's result details into card metadata.
|
|
24
|
+
*
|
|
25
|
+
* Multi-file results (`perFileResults`) are read file by file; single-file
|
|
26
|
+
* results use `path` + `diff`. The payload is capped at
|
|
27
|
+
* {@link EDIT_META_MAX_BYTES} by dropping whole trailing files; when nothing is
|
|
28
|
+
* left the call projects to `null` and falls back to the generic shell rather
|
|
29
|
+
* than writing an oversized session entry.
|
|
30
|
+
* @param details - the engine's `EditToolDetails` (or the adapter's value).
|
|
31
|
+
* @returns the edit card metadata, or `null` when there is no usable diff.
|
|
32
|
+
*/
|
|
33
|
+
export declare function projectEditCardMeta(details: unknown): EditCardMeta | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host projection for the `read` card: the OMP engine already hands the renderer
|
|
3
|
+
* a prefix-free window (`details.displayContent` —
|
|
4
|
+
* `{text, startLine, lineNumbers?}`) exactly so the UI can draw its own gutter,
|
|
5
|
+
* and that is what the shipped read card consumes
|
|
6
|
+
* (`{kind:'read', path, offset, lines, totalLines, lang?}`).
|
|
7
|
+
*
|
|
8
|
+
* Three details drive the projection:
|
|
9
|
+
* - the card path must be the file, never the model-facing argument: the OMP
|
|
10
|
+
* argument carries an inline selector (`src/foo.ts:5-16,40-80`, `:raw`), so
|
|
11
|
+
* the selector is stripped from whatever path source wins;
|
|
12
|
+
* - `lineNumbers[i] === null` marks an elided span (the body renders `…`); such
|
|
13
|
+
* entries carry no file line number and must be dropped, or the card's
|
|
14
|
+
* "strictly increasing" rule breaks;
|
|
15
|
+
* - only local, text-like reads take the card. Images, directories, internal
|
|
16
|
+
* URLs (`skill://`, `conflict://N`, …), web URLs, SQLite, archives and
|
|
17
|
+
* converted documents all fall back to the generic shell.
|
|
18
|
+
*
|
|
19
|
+
* The projection is bounded: past {@link READ_META_MAX_BYTES} whole trailing
|
|
20
|
+
* lines are dropped, and an empty window projects to `null` rather than to an
|
|
21
|
+
* empty card.
|
|
22
|
+
*
|
|
23
|
+
* @module @xiaoso/dsh-tool-plus/web/host/read
|
|
24
|
+
*/
|
|
25
|
+
import type { ReadCardMeta } from '../contract.ts';
|
|
26
|
+
/**
|
|
27
|
+
* Strip the model-facing inline selector from a read target, leaving the file
|
|
28
|
+
* path the card should show.
|
|
29
|
+
*
|
|
30
|
+
* Handles `:5-16,40-80`, `:raw`, `:50+150`, `:conflicts` and the SQLite/archive
|
|
31
|
+
* sub-selectors (`db.sqlite:table:key`), plus the `file://` form the engine
|
|
32
|
+
* itself expands. Windows drive letters survive.
|
|
33
|
+
* @param target - the raw read target (`args.path`, or a resolved path).
|
|
34
|
+
* @returns the path without its selector.
|
|
35
|
+
*/
|
|
36
|
+
export declare function stripReadSelector(target: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Project a read result value into read-card metadata.
|
|
39
|
+
*
|
|
40
|
+
* Every emitted field is plain JSON and no key is ever `undefined`: the metadata
|
|
41
|
+
* rides `presentationMeta`, where a non-lossless payload turns a successful call
|
|
42
|
+
* into a failed one. A non-text read, or a window without a single numbered
|
|
43
|
+
* line, yields `null` and leaves the row on the generic shell.
|
|
44
|
+
* @param args - the tool's arguments (only `path` is read).
|
|
45
|
+
* @param value - the tool's output value, as the adapter projects it.
|
|
46
|
+
* @returns the card metadata, or `null` when this read does not take the card.
|
|
47
|
+
*/
|
|
48
|
+
export declare function readCardMeta(args: unknown, value: unknown): ReadCardMeta | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host projection for the `grep` / `ast_grep` / `glob` search cards.
|
|
3
|
+
*
|
|
4
|
+
* The engines already render the display text the TUI used to read: the grouped
|
|
5
|
+
* file output (`# dir/` / `## file.ts#<tag>` headers) followed by code-frame
|
|
6
|
+
* body lines (`*12│text` for a match, ` 12│text` for context, `…` for a gap).
|
|
7
|
+
* That text is the only place the matched *line numbers* live — `details` only
|
|
8
|
+
* carries per-file counts — so the card is rebuilt by parsing it with the same
|
|
9
|
+
* `classifyGroupedLines` helper the TUI renderers used, then reading each
|
|
10
|
+
* `formatCodeFrameLine` gutter back.
|
|
11
|
+
*
|
|
12
|
+
* Everything is defensive and bounded:
|
|
13
|
+
* - an engine that explicitly reports zero (a `matchCount` of `0`, or an empty
|
|
14
|
+
* `paths` array backed by a zero count) is a *known empty result*: it projects
|
|
15
|
+
* to the empty card the client already renders, so the same tool never shows
|
|
16
|
+
* two different shells;
|
|
17
|
+
* - a display that yields no file group at all projects to `null` unless that
|
|
18
|
+
* zero was reported (the row then falls back to the generic shell — the result
|
|
19
|
+
* text stays fully visible);
|
|
20
|
+
* - the payload is capped at {@link SEARCH_META_MAX_BYTES} by dropping trailing
|
|
21
|
+
* groups/paths, with `truncated` raised and `total` left at its pre-cap value.
|
|
22
|
+
*
|
|
23
|
+
* @module @xiaoso/dsh-tool-plus/web/host/search
|
|
24
|
+
*/
|
|
25
|
+
import type { SearchMatchesCardMeta, SearchPathsCardMeta } from '../contract.ts';
|
|
26
|
+
/**
|
|
27
|
+
* Project a `grep` / `ast_grep` result value into grouped-matches card metadata.
|
|
28
|
+
*
|
|
29
|
+
* @param input - the tool's output value: `displayContent`, `cwd`, `files`,
|
|
30
|
+
* `matchCount` and `truncated` as the adapters project them.
|
|
31
|
+
* @returns the card metadata, or `null` when no file group could be parsed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function searchMatchesCardMeta(input: unknown): SearchMatchesCardMeta | null;
|
|
34
|
+
/**
|
|
35
|
+
* Project a `glob` result value into path-list card metadata.
|
|
36
|
+
*
|
|
37
|
+
* @param input - the tool's output value: `paths`, `fileCount`, `total` and `truncated`.
|
|
38
|
+
* @returns the card metadata, or `null` when the value is not a glob result (no
|
|
39
|
+
* `paths` key, or an empty one the engine never backed with a zero count).
|
|
40
|
+
*/
|
|
41
|
+
export declare function searchPathsCardMeta(input: unknown): SearchPathsCardMeta | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WriteCardMeta } from '../contract.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Project the write tool's result (and its call arguments) into card metadata.
|
|
4
|
+
*
|
|
5
|
+
* The path is the engine's resolved target when it has one, falling back to the
|
|
6
|
+
* authored `args.path` (matching the value the adapter already emits). A blank
|
|
7
|
+
* or missing path projects to `null`; an unrecognized extension omits `lang`
|
|
8
|
+
* instead of writing `undefined`.
|
|
9
|
+
* @param details - the engine's `resolvedPath` / the adapter's value (`path`).
|
|
10
|
+
* @param args - the tool call arguments (`path`), used only as a fallback.
|
|
11
|
+
* @returns the write card metadata, or `null` when no usable path is present.
|
|
12
|
+
*/
|
|
13
|
+
export declare function projectWriteCardMeta(details: unknown, args?: unknown): WriteCardMeta | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { c as combineSignals } from "./src-
|
|
3
|
+
import { c as combineSignals } from "./src-DUUqyo9y.mjs";
|
|
4
4
|
import { t as ToolAbortError } from "./tool-errors-DoyxivAR.mjs";
|
|
5
5
|
import { scheduler } from "node:timers/promises";
|
|
6
6
|
//#region src/tools/omp/web/scrapers/types.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { F as $flag, N as $env, _ as parseStreamingJson, b as debug, g as parseJsonWithRepair } from "./src-
|
|
4
|
-
import { r as ValidationError } from "./error-
|
|
3
|
+
import { F as $flag, N as $env, _ as parseStreamingJson, b as debug, g as parseJsonWithRepair } from "./src-DUUqyo9y.mjs";
|
|
4
|
+
import { r as ValidationError } from "./error-DdCn4m1q.mjs";
|
|
5
5
|
import { n as classifyModel } from "./taxonomy-DSIM99rS.mjs";
|
|
6
6
|
import { i as getBundledProviders, r as getBundledModels } from "./models-DnXMYGcJ.mjs";
|
|
7
7
|
import { t as buildModelReferenceIndex } from "./reference-CtvM4zLU.mjs";
|