@hy-sde-org/dsh-session-url 0.1.2-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/cordis.patch.yml +19 -0
- package/dist/handler.d.ts +65 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +297 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/vendor/internal-urls/parse.d.ts +43 -0
- package/dist/vendor/internal-urls/parse.d.ts.map +1 -0
- package/dist/vendor/internal-urls/parse.js +100 -0
- package/dist/vendor/internal-urls/parse.js.map +1 -0
- package/dist/vendor/internal-urls/router.d.ts +49 -0
- package/dist/vendor/internal-urls/router.d.ts.map +1 -0
- package/dist/vendor/internal-urls/router.js +119 -0
- package/dist/vendor/internal-urls/router.js.map +1 -0
- package/dist/vendor/internal-urls/types.d.ts +156 -0
- package/dist/vendor/internal-urls/types.d.ts.map +1 -0
- package/dist/vendor/internal-urls/types.js +18 -0
- package/dist/vendor/internal-urls/types.js.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hy-sde
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @hy-sde-org/dsh-session-url
|
|
2
|
+
|
|
3
|
+
`session://` — an internal-URL scheme handler for DeepSeek Harness that makes
|
|
4
|
+
the harness's own session history navigable as **files** through internal-URL
|
|
5
|
+
aware `read` / `grep` tools: directory listings, rendered transcripts, exact
|
|
6
|
+
per-event JSON, and FTS-backed cross-session search.
|
|
7
|
+
|
|
8
|
+
Published standalone as `@hy-sde-org/dsh-session-url`; it mirrors
|
|
9
|
+
`@deepseek-ai/dsh-session-url` in the [hy-sde deepseek-harness fork](https://github.com/hy-sde/deepseek-harness)
|
|
10
|
+
(packages/session-query/session-url) so any stock DeepSeek Harness install can
|
|
11
|
+
mount it without adopting the fork. It depends only on **published** packages
|
|
12
|
+
(`@deepseek-ai/dsh-session-query`, `@deepseek-ai/dsh-session`) — the fork-only
|
|
13
|
+
`@deepseek-ai/dsh-internal-urls` surface it consumes (types + parse + router)
|
|
14
|
+
is **vendored** into `src/vendor/internal-urls/` with a keep-in-sync marker.
|
|
15
|
+
|
|
16
|
+
The handler registers into the shared internal-URL registry (`ctx.internalUrls`)
|
|
17
|
+
and reads the same live-preferred logical corpus the session-query tools read
|
|
18
|
+
(`ctx.sessionQuery`). It adds no tool code: internal-URL-aware `read`/`grep`
|
|
19
|
+
already route any registered scheme through `ctx.internalUrls`.
|
|
20
|
+
|
|
21
|
+
## URL surface
|
|
22
|
+
|
|
23
|
+
| URL | Result |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `session://*` (or `session://list`) | Directory listing of known sessions (newest first). |
|
|
26
|
+
| `session://<id>` | Rendered transcript — per event `seq \| type \| time` plus indented semantic text. |
|
|
27
|
+
| `session://<id>/event` | Directory index of that session's event seqs. |
|
|
28
|
+
| `session://<id>/event/<seq>` | One exact event as JSON. |
|
|
29
|
+
| `session://search?q=<terms>` (or `session://search/<terms>`) | FTS-backed cross-session hits (degraded when content search is disabled). |
|
|
30
|
+
|
|
31
|
+
Example:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
read session://0a1b2c3d4e
|
|
35
|
+
grep tsconfig session://0a1b2c3d4e
|
|
36
|
+
read session://0a1b2c3d4e/event/42
|
|
37
|
+
list session://*
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Behavioral notes
|
|
41
|
+
|
|
42
|
+
- **Immutable:** every resource is read-only history — agents never edit a log through a file-shaped URL.
|
|
43
|
+
- **Bounded:** transcripts cap at 600 events for display (`read`) and 12 000 for search consumers (`grep` via `pathOnly`); listings cap at 200 sessions; one event's JSON caps at 128 KiB (oversized events degrade to a text notice). Every cap is a module export.
|
|
44
|
+
- **Search degradation:** deployments that disable content search (`openAt: 'never'`) make `session://search` return an explanatory note; exact reads (`session://<id>`, `/event`) never depend on the index.
|
|
45
|
+
- **Safety:** session ids are unvalidated branded strings used only as the URL host; they are never treated as filesystem segments, and the handler performs no filesystem access.
|
|
46
|
+
|
|
47
|
+
## Mounting
|
|
48
|
+
|
|
49
|
+
A host-plane row next to the registry it extends, *after* the internal-URL
|
|
50
|
+
registry service (standalone: `@hy-sde-org/dsh-internal-urls`, the sibling
|
|
51
|
+
repo in this plugins workspace):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pnpm add @hy-sde-org/dsh-session-url # (or npm install)
|
|
55
|
+
dsh plugin add @hy-sde-org/dsh-session-url # applies the shipped cordis.patch.yml (inserts the row)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
- id: session-url
|
|
60
|
+
name: '@hy-sde-org/dsh-session-url'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Requires `ctx.internalUrls` and `ctx.sessionQuery`. Both are declared as hard
|
|
64
|
+
injects, so the row stays dormant ("waiting for …") until both services are
|
|
65
|
+
mounted, and the plugin fails loud at apply if either is truly absent.
|
|
66
|
+
|
|
67
|
+
## Package layout
|
|
68
|
+
|
|
69
|
+
- `src/handler.ts` — `SessionProtocolHandler` (the scheme's resolve/complete).
|
|
70
|
+
- `src/index.ts` — plugin `apply` registering the handler into the registry.
|
|
71
|
+
- `src/vendor/internal-urls/` — types/parse/router vendored from fork `@deepseek-ai/dsh-internal-urls` (keep in sync; no unpublished dependency).
|
|
72
|
+
- `cordis.patch.yml` — `insert`-only bundle patch: `dsh plugin add` wires the host-plane row.
|
|
73
|
+
- `tests/handler.spec.ts` — handler + router-integration tests.
|
|
74
|
+
|
|
75
|
+
## Known Limitations and Deferred Work
|
|
76
|
+
|
|
77
|
+
- `session://search` needs a content-search-enabled session-query engine (FTS). A deployment that disables content search (`openAt: 'never'`) receives an explanatory degrade instead of cross-session hits — exact reads (`session://<id>`, `/event`) never depend on the index.
|
|
78
|
+
- Transcripts render the semantic event projection (`extractSessionEventText`); raw per-event payloads are readable only through `/event/<seq>` JSON, one event at a time.
|
|
79
|
+
- Session titles are best-effort: they appear when the title service captured one, and are absent otherwise.
|
|
80
|
+
- The handler requires `ctx.internalUrls` and `ctx.sessionQuery` to be mounted; it fails loud at apply rather than partially serving.
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT. Derived from the DeepSeek Harness codebase; see
|
|
85
|
+
`THIRD-PARTY-NOTICES.md` for provenance.
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @hy-sde-org/dsh-session-url — install surface for the session:// scheme.
|
|
2
|
+
#
|
|
3
|
+
# The `session://` HANDLER is host-plane: it registers a scheme into the
|
|
4
|
+
# internal-URL registry (`ctx.internalUrls`) and reads the session-query
|
|
5
|
+
# service (`ctx.sessionQuery`), both of which cross sessions. This bundle
|
|
6
|
+
# inserts one row into the profile's base composition — it touches no existing
|
|
7
|
+
# row, so `dsh plugin add @hy-sde-org/dsh-session-url` never breaks boot on a
|
|
8
|
+
# stock DeepSeek Harness (0.1.1-rc.2 and later).
|
|
9
|
+
#
|
|
10
|
+
# The row stays dormant ("waiting for …") until a process mounts BOTH
|
|
11
|
+
# `internalUrls` (e.g. `@hy-sde-org/dsh-internal-urls`, the sibling standalone
|
|
12
|
+
# registry) and `sessionQuery` (a session-query engine), so installing this
|
|
13
|
+
# package alone is harmless. It adds no tool code: the internal-URL-aware
|
|
14
|
+
# read/grep tools shipped by the internal-urls companion packages route any
|
|
15
|
+
# registered scheme through the registry.
|
|
16
|
+
|
|
17
|
+
- insert:
|
|
18
|
+
- id: session-url
|
|
19
|
+
name: '@hy-sde-org/dsh-session-url'
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `session://` internal-URL handler: exposes the harness's own recorded
|
|
3
|
+
* history (live + persisted sessions) to the read/grep/write tools as
|
|
4
|
+
* FS-shaped URLs through the shared `ctx.internalUrls` registry.
|
|
5
|
+
*
|
|
6
|
+
* URL surface:
|
|
7
|
+
* - `session://*` (or `session://list`) — directory listing of known sessions.
|
|
8
|
+
* - `session://<id>` — rendered transcript of one session
|
|
9
|
+
* (`seq | type | time` plus indented semantic text per event).
|
|
10
|
+
* - `session://<id>/event` — directory listing of that session's event seqs.
|
|
11
|
+
* - `session://<id>/event/<seq>` — one exact event as JSON.
|
|
12
|
+
* - `session://search?q=<terms>` — FTS-backed cross-session search hits
|
|
13
|
+
* (degrades to an explanatory note when the deployment disables content
|
|
14
|
+
* search via `openAt: 'never'`).
|
|
15
|
+
*
|
|
16
|
+
* Because this registers a scheme in the shared router, internal-URL-aware
|
|
17
|
+
* `read`/`grep` tools reach it without new tool code: `grep session://<id>`
|
|
18
|
+
* materializes the transcript and searches it with the same ripgrep pipeline
|
|
19
|
+
* it uses for any other resource.
|
|
20
|
+
*
|
|
21
|
+
* Every resolved resource is immutable (agents never rewrite history through
|
|
22
|
+
* a file-shaped URL) and is produced from the same live-preferred logical
|
|
23
|
+
* corpus the session-query tools read.
|
|
24
|
+
* @module @hy-sde-org/dsh-session-url/handler
|
|
25
|
+
*/
|
|
26
|
+
import type { InternalResource, ParsedInternalUrl, ProtocolHandler, ResolveContext, UrlCompletion } from './vendor/internal-urls/types.ts';
|
|
27
|
+
import { type SessionQueryEngine } from '@deepseek-ai/dsh-session-query';
|
|
28
|
+
/** Cap on sessions rendered by one `session://*` listing. */
|
|
29
|
+
export declare const SESSION_LISTING_CAP = 200;
|
|
30
|
+
/** Cap on events rendered into a displayed transcript (`read`). */
|
|
31
|
+
export declare const TRANSCRIPT_EVENT_CAP = 600;
|
|
32
|
+
/** Cap on events materialized for a search consumer (`grep`, `pathOnly`). */
|
|
33
|
+
export declare const TRANSCRIPT_PATH_ONLY_EVENT_CAP = 12000;
|
|
34
|
+
/** Per-event semantic text length shown in a displayed transcript. */
|
|
35
|
+
export declare const EVENT_TEXT_MAX_CHARS = 400;
|
|
36
|
+
/** Cap on one event's serialized JSON; oversized events degrade to text. */
|
|
37
|
+
export declare const EVENT_JSON_MAX_BYTES = 128000;
|
|
38
|
+
/** Page size for `session://search?q=…`. */
|
|
39
|
+
export declare const SESSION_SEARCH_LIMIT = 25;
|
|
40
|
+
/** `session://` handler with a bound query engine. */
|
|
41
|
+
export declare class SessionProtocolHandler implements ProtocolHandler {
|
|
42
|
+
private readonly query;
|
|
43
|
+
readonly scheme = "session";
|
|
44
|
+
readonly immutable = true;
|
|
45
|
+
constructor(query: SessionQueryEngine);
|
|
46
|
+
/** Candidate completions for `session://<query>`: `*`, `search`, and session ids. */
|
|
47
|
+
complete(query?: string): Promise<UrlCompletion[]>;
|
|
48
|
+
resolve(url: ParsedInternalUrl, context?: ResolveContext): Promise<InternalResource>;
|
|
49
|
+
/** `session://*` — directory listing of the logical corpus (newest first). */
|
|
50
|
+
private listSessions;
|
|
51
|
+
/** `session://search?q=…` (or `session://search/<terms>`) — FTS-backed hits. */
|
|
52
|
+
private search;
|
|
53
|
+
/** Resolve `session://<id>` / `/event` / `/event/<seq>`; anything else is invalid. */
|
|
54
|
+
private session;
|
|
55
|
+
/** `session://<id>` — rendered transcript of the complete raw event log. */
|
|
56
|
+
private transcript;
|
|
57
|
+
/** `session://<id>/event` — directory of that session's event seqs (ascending). */
|
|
58
|
+
private eventIndex;
|
|
59
|
+
/** `session://<id>/event/<seq>` — one exact event as JSON. */
|
|
60
|
+
private eventJson;
|
|
61
|
+
private readSessionOrThrow;
|
|
62
|
+
private titleOf;
|
|
63
|
+
private titlesOf;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,aAAa,EACd,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAIL,KAAK,kBAAkB,EAExB,MAAM,gCAAgC,CAAA;AAGvC,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB,MAAM,CAAA;AACtC,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,MAAM,CAAA;AACvC,6EAA6E;AAC7E,eAAO,MAAM,8BAA8B,QAAS,CAAA;AACpD,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,MAAM,CAAA;AACvC,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,SAAU,CAAA;AAC3C,4CAA4C;AAC5C,eAAO,MAAM,oBAAoB,KAAK,CAAA;AA6BtC,sDAAsD;AACtD,qBAAa,sBAAuB,YAAW,eAAe;IAIhD,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,QAAQ,CAAC,MAAM,aAAY;IAC3B,QAAQ,CAAC,SAAS,QAAO;gBAEI,KAAK,EAAE,kBAAkB;IAEtD,qFAAqF;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAmBlD,OAAO,CAAC,GAAG,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAU1F,8EAA8E;YAChE,YAAY;IA2B1B,gFAAgF;YAClE,MAAM;IAgDpB,sFAAsF;YACxE,OAAO;IASrB,4EAA4E;YAC9D,UAAU;IA+BxB,mFAAmF;YACrE,UAAU;IAqBxB,8DAA8D;YAChD,SAAS;YA2BT,kBAAkB;YAIlB,OAAO;YAMP,QAAQ;CAcvB"}
|
package/dist/handler.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `session://` internal-URL handler: exposes the harness's own recorded
|
|
3
|
+
* history (live + persisted sessions) to the read/grep/write tools as
|
|
4
|
+
* FS-shaped URLs through the shared `ctx.internalUrls` registry.
|
|
5
|
+
*
|
|
6
|
+
* URL surface:
|
|
7
|
+
* - `session://*` (or `session://list`) — directory listing of known sessions.
|
|
8
|
+
* - `session://<id>` — rendered transcript of one session
|
|
9
|
+
* (`seq | type | time` plus indented semantic text per event).
|
|
10
|
+
* - `session://<id>/event` — directory listing of that session's event seqs.
|
|
11
|
+
* - `session://<id>/event/<seq>` — one exact event as JSON.
|
|
12
|
+
* - `session://search?q=<terms>` — FTS-backed cross-session search hits
|
|
13
|
+
* (degrades to an explanatory note when the deployment disables content
|
|
14
|
+
* search via `openAt: 'never'`).
|
|
15
|
+
*
|
|
16
|
+
* Because this registers a scheme in the shared router, internal-URL-aware
|
|
17
|
+
* `read`/`grep` tools reach it without new tool code: `grep session://<id>`
|
|
18
|
+
* materializes the transcript and searches it with the same ripgrep pipeline
|
|
19
|
+
* it uses for any other resource.
|
|
20
|
+
*
|
|
21
|
+
* Every resolved resource is immutable (agents never rewrite history through
|
|
22
|
+
* a file-shaped URL) and is produced from the same live-preferred logical
|
|
23
|
+
* corpus the session-query tools read.
|
|
24
|
+
* @module @hy-sde-org/dsh-session-url/handler
|
|
25
|
+
*/
|
|
26
|
+
import { SessionQueryError, extractSessionEventText, } from '@deepseek-ai/dsh-session-query';
|
|
27
|
+
/** Cap on sessions rendered by one `session://*` listing. */
|
|
28
|
+
export const SESSION_LISTING_CAP = 200;
|
|
29
|
+
/** Cap on events rendered into a displayed transcript (`read`). */
|
|
30
|
+
export const TRANSCRIPT_EVENT_CAP = 600;
|
|
31
|
+
/** Cap on events materialized for a search consumer (`grep`, `pathOnly`). */
|
|
32
|
+
export const TRANSCRIPT_PATH_ONLY_EVENT_CAP = 12_000;
|
|
33
|
+
/** Per-event semantic text length shown in a displayed transcript. */
|
|
34
|
+
export const EVENT_TEXT_MAX_CHARS = 400;
|
|
35
|
+
/** Cap on one event's serialized JSON; oversized events degrade to text. */
|
|
36
|
+
export const EVENT_JSON_MAX_BYTES = 128_000;
|
|
37
|
+
/** Page size for `session://search?q=…`. */
|
|
38
|
+
export const SESSION_SEARCH_LIMIT = 25;
|
|
39
|
+
/** The `SESSION_QUERY_SEARCH_DISABLED` error code carried by SessionQueryError. */
|
|
40
|
+
const SEARCH_DISABLED_CODE = 'SESSION_QUERY_SEARCH_DISABLED';
|
|
41
|
+
function isoTime(value) {
|
|
42
|
+
return new Date(value).toISOString();
|
|
43
|
+
}
|
|
44
|
+
/** One semantic-text sample for the displays: collapsed whitespace, capped. */
|
|
45
|
+
function eventText(event, maxChars) {
|
|
46
|
+
const text = extractSessionEventText(event).replace(/\s+/g, ' ').trim();
|
|
47
|
+
if (text.length <= maxChars)
|
|
48
|
+
return text;
|
|
49
|
+
return `${text.slice(0, maxChars)}…`;
|
|
50
|
+
}
|
|
51
|
+
function indented(text, prefix) {
|
|
52
|
+
return `${prefix}${text.replaceAll('\n', `\n${prefix}`)}`;
|
|
53
|
+
}
|
|
54
|
+
/** Cap a name for display so one malicious cwd/title cannot break the layout. */
|
|
55
|
+
function capLabel(value, maxChars) {
|
|
56
|
+
return value.length <= maxChars ? value : `${value.slice(0, maxChars)}…`;
|
|
57
|
+
}
|
|
58
|
+
function invalidUrl() {
|
|
59
|
+
return new Error('Invalid session:// URL. Expected session://* (listing), session://<id> (transcript), session://<id>/event (seq index), session://<id>/event/<seq> (exact event), or session://search?q=<terms>.');
|
|
60
|
+
}
|
|
61
|
+
/** `session://` handler with a bound query engine. */
|
|
62
|
+
export class SessionProtocolHandler {
|
|
63
|
+
query;
|
|
64
|
+
scheme = 'session';
|
|
65
|
+
immutable = true;
|
|
66
|
+
constructor(query) {
|
|
67
|
+
this.query = query;
|
|
68
|
+
}
|
|
69
|
+
/** Candidate completions for `session://<query>`: `*`, `search`, and session ids. */
|
|
70
|
+
async complete(query) {
|
|
71
|
+
const needle = (query ?? '').trim();
|
|
72
|
+
const staticCandidates = [
|
|
73
|
+
{ value: '*', label: 'session://*', description: 'List known sessions' },
|
|
74
|
+
{ value: 'search', label: 'session://search?q=…', description: 'Search past session texts' },
|
|
75
|
+
];
|
|
76
|
+
const records = await this.query.listSessions();
|
|
77
|
+
const sessions = records
|
|
78
|
+
.sort((a, b) => b.header.createdAt - a.header.createdAt)
|
|
79
|
+
.slice(0, SESSION_LISTING_CAP)
|
|
80
|
+
.map(record => ({
|
|
81
|
+
value: record.header.id,
|
|
82
|
+
label: `session://${record.header.id}`,
|
|
83
|
+
description: `Created ${isoTime(record.header.createdAt)}`,
|
|
84
|
+
}));
|
|
85
|
+
if (needle === '')
|
|
86
|
+
return [...staticCandidates, ...sessions];
|
|
87
|
+
return [...staticCandidates, ...sessions].filter(candidate => candidate.value.startsWith(needle));
|
|
88
|
+
}
|
|
89
|
+
async resolve(url, context) {
|
|
90
|
+
const host = url.rawHost;
|
|
91
|
+
if (host === '' || host === '*' || host === 'list') {
|
|
92
|
+
if (url.pathSegments.length > 0)
|
|
93
|
+
throw invalidUrl();
|
|
94
|
+
return this.listSessions();
|
|
95
|
+
}
|
|
96
|
+
if (host === 'search')
|
|
97
|
+
return this.search(url, context);
|
|
98
|
+
return this.session(host, url, context);
|
|
99
|
+
}
|
|
100
|
+
/** `session://*` — directory listing of the logical corpus (newest first). */
|
|
101
|
+
async listSessions() {
|
|
102
|
+
const records = (await this.query.listSessions()).slice(0, SESSION_LISTING_CAP);
|
|
103
|
+
const titles = await this.titlesOf(records.map(record => record.header.id));
|
|
104
|
+
const lines = records.length === 0
|
|
105
|
+
? ['No prior sessions found.']
|
|
106
|
+
: [`Session URL listing (${records.length} session${records.length === 1 ? '' : 's'}, newest first):`];
|
|
107
|
+
for (const record of records) {
|
|
108
|
+
const title = capLabel(titles.get(record.header.id) ?? '', 120);
|
|
109
|
+
const cwd = record.header.cwd === undefined ? '' : ` | cwd ${capLabel(record.header.cwd, 120)}`;
|
|
110
|
+
lines.push(`session://${record.header.id} — created ${isoTime(record.header.createdAt)}${cwd}${title === '' ? '' : ` | ${title}`}`);
|
|
111
|
+
}
|
|
112
|
+
if (records.length === SESSION_LISTING_CAP) {
|
|
113
|
+
lines.push('', 'Listing capped. Read session://<id> for a transcript, or search with session://search?q=<terms>.');
|
|
114
|
+
}
|
|
115
|
+
lines.push('', 'Subresources:');
|
|
116
|
+
lines.push('- session://<id> — transcript of one session');
|
|
117
|
+
lines.push('- session://<id>/event — seq index of one session');
|
|
118
|
+
lines.push('- session://<id>/event/<seq> — one exact event as JSON');
|
|
119
|
+
lines.push('- session://search?q=<terms> — FTS-backed cross-session search');
|
|
120
|
+
return {
|
|
121
|
+
url: 'session://*',
|
|
122
|
+
content: lines.join('\n'),
|
|
123
|
+
contentType: 'text/markdown',
|
|
124
|
+
isDirectory: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** `session://search?q=…` (or `session://search/<terms>`) — FTS-backed hits. */
|
|
128
|
+
async search(url, context) {
|
|
129
|
+
const trimmed = (url.searchParams.get('q') ?? url.pathSegments.join(' ')).trim();
|
|
130
|
+
if (trimmed.length === 0) {
|
|
131
|
+
throw new Error('session://search needs a query. Use session://search?q=<terms> (URL-encoded) or session://search/<terms>');
|
|
132
|
+
}
|
|
133
|
+
const request = { query: trimmed.slice(0, 2000), limit: SESSION_SEARCH_LIMIT };
|
|
134
|
+
let result;
|
|
135
|
+
try {
|
|
136
|
+
result = await this.query.searchSessions(request, context?.signal !== undefined ? { signal: context.signal } : undefined);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (error instanceof SessionQueryError && error.code === SEARCH_DISABLED_CODE) {
|
|
140
|
+
return {
|
|
141
|
+
url: url.rawHref,
|
|
142
|
+
content: [
|
|
143
|
+
'session search is disabled in this deployment (the session-query index configures openAt: \'never\').',
|
|
144
|
+
'',
|
|
145
|
+
'The read/list surface still works: session://<id> for a transcript, session://<id>/event/<seq> for one event, session://* for the listing.',
|
|
146
|
+
].join('\n'),
|
|
147
|
+
contentType: 'text/plain',
|
|
148
|
+
immutable: true,
|
|
149
|
+
notes: ['Content search is a deployment choice; exact reads do not depend on it.'],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
const hits = result.items;
|
|
155
|
+
const titles = await this.titlesOf(hits.map(hit => hit.header.id));
|
|
156
|
+
const lines = hits.length === 0
|
|
157
|
+
? [`No prior session matches "${trimmed}".`]
|
|
158
|
+
: [`Session search results (${hits.length}) for "${trimmed}":`];
|
|
159
|
+
for (const [index, hit] of hits.entries()) {
|
|
160
|
+
const title = capLabel(titles.get(hit.header.id) ?? '', 120);
|
|
161
|
+
lines.push('', `${index + 1}. session://${hit.header.id} — ${title}`);
|
|
162
|
+
lines.push(` Created: ${isoTime(hit.header.createdAt)}`);
|
|
163
|
+
lines.push(` Best match: seq ${hit.bestMatch.seq} | ${hit.bestMatch.type} | ${hit.bestMatch.snippet}`);
|
|
164
|
+
}
|
|
165
|
+
if (hits.length === SESSION_SEARCH_LIMIT) {
|
|
166
|
+
lines.push('', 'Result page full. Narrow the query for more hits.');
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
url: url.rawHref,
|
|
170
|
+
content: lines.join('\n'),
|
|
171
|
+
contentType: 'text/markdown',
|
|
172
|
+
immutable: true,
|
|
173
|
+
notes: ['Search hits route through the FTS5 index; exact reads use session://<id>.'],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** Resolve `session://<id>` / `/event` / `/event/<seq>`; anything else is invalid. */
|
|
177
|
+
async session(id, url, context) {
|
|
178
|
+
const [first, seqRaw] = url.pathSegments;
|
|
179
|
+
if (first === undefined)
|
|
180
|
+
return this.transcript(id, url, context);
|
|
181
|
+
if (first !== 'event')
|
|
182
|
+
throw invalidUrl();
|
|
183
|
+
if (seqRaw === undefined)
|
|
184
|
+
return this.eventIndex(id, url);
|
|
185
|
+
if (url.pathSegments.length === 2)
|
|
186
|
+
return this.eventJson(id, seqRaw, url);
|
|
187
|
+
throw invalidUrl();
|
|
188
|
+
}
|
|
189
|
+
/** `session://<id>` — rendered transcript of the complete raw event log. */
|
|
190
|
+
async transcript(id, url, context) {
|
|
191
|
+
const snapshot = await this.readSessionOrThrow(id);
|
|
192
|
+
const events = snapshot.events;
|
|
193
|
+
const cap = context?.pathOnly === true ? TRANSCRIPT_PATH_ONLY_EVENT_CAP : TRANSCRIPT_EVENT_CAP;
|
|
194
|
+
const shown = events.length <= cap ? events : events.slice(0, cap);
|
|
195
|
+
const title = await this.titleOf(id);
|
|
196
|
+
const header = snapshot.session;
|
|
197
|
+
const lines = [
|
|
198
|
+
`Session ${id} — ${capLabel(title, 160)}`,
|
|
199
|
+
`Created: ${isoTime(header.createdAt)}`,
|
|
200
|
+
...header.cwd !== undefined ? [`cwd: ${capLabel(header.cwd, 160)}`] : [],
|
|
201
|
+
...header.parentSession !== undefined ? [`Parent: ${header.parentSession}`] : [],
|
|
202
|
+
`Events (${events.length}, showing ${shown.length}):`,
|
|
203
|
+
];
|
|
204
|
+
for (const event of shown) {
|
|
205
|
+
const text = eventText(event, EVENT_TEXT_MAX_CHARS);
|
|
206
|
+
lines.push('', `seq ${event.seq} | ${event.type} | ${isoTime(event.time)}`);
|
|
207
|
+
if (text.length > 0)
|
|
208
|
+
lines.push(indented(text, ' '));
|
|
209
|
+
}
|
|
210
|
+
if (shown.length < events.length) {
|
|
211
|
+
lines.push('', `(${events.length - shown.length} more events omitted; read session://<id>/event/<seq> for one event at a time)`);
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
url: url.rawHref,
|
|
215
|
+
content: lines.join('\n'),
|
|
216
|
+
contentType: 'text/markdown',
|
|
217
|
+
immutable: true,
|
|
218
|
+
notes: [`Read one event: session://${id}/event/<seq>`, 'grep session://<id> searches this transcript.'],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/** `session://<id>/event` — directory of that session's event seqs (ascending). */
|
|
222
|
+
async eventIndex(id, url) {
|
|
223
|
+
const snapshot = await this.readSessionOrThrow(id);
|
|
224
|
+
const events = snapshot.events;
|
|
225
|
+
const lines = events.length === 0
|
|
226
|
+
? ['No events recorded for this session.']
|
|
227
|
+
: [`Session ${id} — event index (${events.length}):`];
|
|
228
|
+
for (const event of events) {
|
|
229
|
+
const text = eventText(event, 120);
|
|
230
|
+
const suffix = text.length === 0 ? '' : ` | ${text}`;
|
|
231
|
+
lines.push(`session://${id}/event/${event.seq} — seq ${event.seq} | ${event.type} | ${isoTime(event.time)}${suffix}`);
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
url: url.rawHref,
|
|
235
|
+
content: lines.join('\n'),
|
|
236
|
+
contentType: 'text/plain',
|
|
237
|
+
isDirectory: true,
|
|
238
|
+
immutable: true,
|
|
239
|
+
notes: [`Read one: session://${id}/event/<seq>`],
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/** `session://<id>/event/<seq>` — one exact event as JSON. */
|
|
243
|
+
async eventJson(id, seqRaw, url) {
|
|
244
|
+
if (!/^(0|[1-9][0-9]*)$/.test(seqRaw))
|
|
245
|
+
throw invalidUrl();
|
|
246
|
+
const seq = Number.parseInt(seqRaw, 10);
|
|
247
|
+
const snapshot = await this.readSessionOrThrow(id);
|
|
248
|
+
const event = snapshot.events.find(candidate => candidate.seq === seq);
|
|
249
|
+
if (event === undefined) {
|
|
250
|
+
const max = snapshot.events.at(-1)?.seq ?? 0;
|
|
251
|
+
throw new Error(`session://${id}/event/${seqRaw}: no such event. This session has ${snapshot.events.length} event${snapshot.events.length === 1 ? '' : 's'} (max seq ${max}).`);
|
|
252
|
+
}
|
|
253
|
+
const json = JSON.stringify(event);
|
|
254
|
+
if (json.length > EVENT_JSON_MAX_BYTES) {
|
|
255
|
+
return {
|
|
256
|
+
url: url.rawHref,
|
|
257
|
+
content: [
|
|
258
|
+
`Event seq ${seq} serializes to ${json.length} bytes (cap ${EVENT_JSON_MAX_BYTES}); not shown in full.`,
|
|
259
|
+
'',
|
|
260
|
+
`Type: ${event.type}`,
|
|
261
|
+
'Read session://<id> for the surrounding transcript instead.',
|
|
262
|
+
].join('\n'),
|
|
263
|
+
contentType: 'text/plain',
|
|
264
|
+
immutable: true,
|
|
265
|
+
notes: ['Oversized events degrade to text to keep the result bounded.'],
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
return { url: url.rawHref, content: json, contentType: 'application/json', immutable: true };
|
|
269
|
+
}
|
|
270
|
+
async readSessionOrThrow(id) {
|
|
271
|
+
return this.query.readSession(id);
|
|
272
|
+
}
|
|
273
|
+
async titleOf(id) {
|
|
274
|
+
const observation = (await this.query.readTitleSnapshots([id]))[0];
|
|
275
|
+
if (observation === undefined || observation.status === 'rejected')
|
|
276
|
+
return '';
|
|
277
|
+
return observation.value.title?.title ?? '';
|
|
278
|
+
}
|
|
279
|
+
async titlesOf(ids) {
|
|
280
|
+
const titles = new Map();
|
|
281
|
+
if (ids.length === 0)
|
|
282
|
+
return titles;
|
|
283
|
+
const unique = [...new Set(ids)];
|
|
284
|
+
const observations = await this.query.readTitleSnapshots(unique);
|
|
285
|
+
for (let index = 0; index < unique.length; index++) {
|
|
286
|
+
const observation = observations[index];
|
|
287
|
+
// Never let one failed title projection poison the listing.
|
|
288
|
+
if (observation === undefined || observation.status === 'rejected')
|
|
289
|
+
continue;
|
|
290
|
+
const title = observation.value.title?.title;
|
|
291
|
+
if (title !== undefined && title.length > 0)
|
|
292
|
+
titles.set(unique[index], title);
|
|
293
|
+
}
|
|
294
|
+
return titles;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GAIxB,MAAM,gCAAgC,CAAA;AAGvC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AACtC,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;AACvC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAA;AACpD,sEAAsE;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;AACvC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAA;AAC3C,4CAA4C;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAEtC,mFAAmF;AACnF,MAAM,oBAAoB,GAAG,+BAAwC,CAAA;AAErE,SAAS,OAAO,CAAC,KAAa;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YAAE,OAAO,EAAE,CAAA;QAC7E,OAAO,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAAA;IAC7C,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,GAAyB;QAC9C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAqB,CAAA;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,MAAM,CAAA;QACnC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QAChC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;QAChE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;YACvC,4DAA4D;YAC5D,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,CAAC,MAAM,KAAK,UAAU;gBAAE,SAAQ;YAC5E,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAA;YAC5C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAc,EAAE,KAAK,CAAC,CAAA;QAC5F,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `session://` internal-URL scheme, registered into the shared
|
|
3
|
+
* internal-URL registry (`ctx.internalUrls`) so internal-URL-aware read/grep
|
|
4
|
+
* tools can navigate the harness's own session history as files.
|
|
5
|
+
*
|
|
6
|
+
* Host-plane: the handler lives with the registry it extends and reads the
|
|
7
|
+
* live-preferred logical corpus from `ctx.sessionQuery` — an exact-read
|
|
8
|
+
* service that works even when a deployment disables content search
|
|
9
|
+
* (`openAt: 'never'`); only `session://search` degrades there.
|
|
10
|
+
*
|
|
11
|
+
* Standalone port: `@hy-sde-org/dsh-session-url` vendors the small
|
|
12
|
+
* parse/router/types surface of the fork-only `@deepseek-ai/dsh-internal-urls`
|
|
13
|
+
* (see src/vendor/internal-urls) so it can compile and test with no dependency
|
|
14
|
+
* on an unpublished package. At runtime the plugin still consumes the real
|
|
15
|
+
* registry service (`ctx.internalUrls`), e.g. the standalone
|
|
16
|
+
* `@hy-sde-org/dsh-internal-urls` package.
|
|
17
|
+
* @module @hy-sde-org/dsh-session-url
|
|
18
|
+
*/
|
|
19
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
20
|
+
import { SessionProtocolHandler } from './handler.ts';
|
|
21
|
+
import type { ProtocolHandler } from './vendor/internal-urls/types.ts';
|
|
22
|
+
export * from './handler.ts';
|
|
23
|
+
export { SessionProtocolHandler };
|
|
24
|
+
/**
|
|
25
|
+
* The minimal `ctx.internalUrls` surface this plugin consumes (structural).
|
|
26
|
+
* The real service comes from the internal-URL registry package
|
|
27
|
+
* (`@hy-sde-org/dsh-internal-urls`); only the `register` shape is needed here,
|
|
28
|
+
* so the vendored types keep the package dependency-free.
|
|
29
|
+
*/
|
|
30
|
+
export interface InternalUrlRegistry {
|
|
31
|
+
/** Register (or replace) the handler for its scheme. Returns a disposer. */
|
|
32
|
+
register(handler: ProtocolHandler): () => void;
|
|
33
|
+
}
|
|
34
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
35
|
+
export declare const name = "session-url";
|
|
36
|
+
/**
|
|
37
|
+
* Services this row requires to register the scheme handler. Declared as hard
|
|
38
|
+
* injects so Cordis guarantees activation order: the sqlite engine publishes
|
|
39
|
+
* `sessionQuery` synchronously at the start of its own apply, and this plugin
|
|
40
|
+
* must not race ahead of it. When an assembly provides neither `internalUrls`
|
|
41
|
+
* nor `sessionQuery`, the row simply stays dormant ("waiting for …") instead
|
|
42
|
+
* of throwing and failing boot.
|
|
43
|
+
*/
|
|
44
|
+
export declare const inject: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Register the `session://` scheme into the mounted internal-URL registry.
|
|
47
|
+
* Requires both `ctx.internalUrls` and `ctx.sessionQuery` (declared above).
|
|
48
|
+
*/
|
|
49
|
+
export declare function apply(ctx: Context): void;
|
|
50
|
+
/** Cordis plugin object (loader reads `inject` from this shape). */
|
|
51
|
+
declare const _default: {
|
|
52
|
+
name: string;
|
|
53
|
+
inject: string[];
|
|
54
|
+
apply: typeof apply;
|
|
55
|
+
};
|
|
56
|
+
export default _default;
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,sBAAsB,EAAE,CAAA;AAEjC;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,IAAI,CAAA;CAC/C;AAED,qDAAqD;AACrD,eAAO,MAAM,IAAI,gBAAgB,CAAA;AAEjC;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,UAAmC,CAAA;AAEtD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAWxC;AAED,oEAAoE;;;;;;AACpE,wBAAsC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `session://` internal-URL scheme, registered into the shared
|
|
3
|
+
* internal-URL registry (`ctx.internalUrls`) so internal-URL-aware read/grep
|
|
4
|
+
* tools can navigate the harness's own session history as files.
|
|
5
|
+
*
|
|
6
|
+
* Host-plane: the handler lives with the registry it extends and reads the
|
|
7
|
+
* live-preferred logical corpus from `ctx.sessionQuery` — an exact-read
|
|
8
|
+
* service that works even when a deployment disables content search
|
|
9
|
+
* (`openAt: 'never'`); only `session://search` degrades there.
|
|
10
|
+
*
|
|
11
|
+
* Standalone port: `@hy-sde-org/dsh-session-url` vendors the small
|
|
12
|
+
* parse/router/types surface of the fork-only `@deepseek-ai/dsh-internal-urls`
|
|
13
|
+
* (see src/vendor/internal-urls) so it can compile and test with no dependency
|
|
14
|
+
* on an unpublished package. At runtime the plugin still consumes the real
|
|
15
|
+
* registry service (`ctx.internalUrls`), e.g. the standalone
|
|
16
|
+
* `@hy-sde-org/dsh-internal-urls` package.
|
|
17
|
+
* @module @hy-sde-org/dsh-session-url
|
|
18
|
+
*/
|
|
19
|
+
import { SessionProtocolHandler } from "./handler.js";
|
|
20
|
+
export * from "./handler.js";
|
|
21
|
+
export { SessionProtocolHandler };
|
|
22
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
23
|
+
export const name = 'session-url';
|
|
24
|
+
/**
|
|
25
|
+
* Services this row requires to register the scheme handler. Declared as hard
|
|
26
|
+
* injects so Cordis guarantees activation order: the sqlite engine publishes
|
|
27
|
+
* `sessionQuery` synchronously at the start of its own apply, and this plugin
|
|
28
|
+
* must not race ahead of it. When an assembly provides neither `internalUrls`
|
|
29
|
+
* nor `sessionQuery`, the row simply stays dormant ("waiting for …") instead
|
|
30
|
+
* of throwing and failing boot.
|
|
31
|
+
*/
|
|
32
|
+
export const inject = ['internalUrls', 'sessionQuery'];
|
|
33
|
+
/**
|
|
34
|
+
* Register the `session://` scheme into the mounted internal-URL registry.
|
|
35
|
+
* Requires both `ctx.internalUrls` and `ctx.sessionQuery` (declared above).
|
|
36
|
+
*/
|
|
37
|
+
export function apply(ctx) {
|
|
38
|
+
const internalUrls = ctx.get('internalUrls');
|
|
39
|
+
if (internalUrls === undefined) {
|
|
40
|
+
throw new Error('session-url requires ctx.internalUrls (mount the internal-URL registry package first)');
|
|
41
|
+
}
|
|
42
|
+
const disposer = internalUrls.register(new SessionProtocolHandler(ctx.sessionQuery));
|
|
43
|
+
ctx.effect(() => {
|
|
44
|
+
return () => {
|
|
45
|
+
disposer();
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Cordis plugin object (loader reads `inject` from this shape). */
|
|
50
|
+
export default { name, inject, apply };
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAGrD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,sBAAsB,EAAE,CAAA;AAajC,qDAAqD;AACrD,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAA;AAEjC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;AAEtD;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,cAAc,CAAoC,CAAA;IAC/E,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,uFAAuF,CAAC,CAAA;IAC1G,CAAC;IACD,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,sBAAsB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;IACpF,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE;QACd,OAAO,GAAG,EAAE;YACV,QAAQ,EAAE,CAAA;QACZ,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,oEAAoE;AACpE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from fork @deepseek-ai/dsh-internal-urls (packages/fs/internal-urls/src/parse.ts) — keep in sync.
|
|
3
|
+
* The published harness does not ship this package, so @hy-sde-org/dsh-session-url vendors the small
|
|
4
|
+
* internal-URL surface it consumes (types + parse + router) to stay dependency-free and standalone.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* RFC 3986 scheme detection and internal-URL parsing that preserves the raw
|
|
8
|
+
* host/pathname bytes before URL normalization.
|
|
9
|
+
* @module @deepseek-ai/dsh-internal-urls/parse
|
|
10
|
+
*/
|
|
11
|
+
import type { ParsedInternalUrl } from './types.ts';
|
|
12
|
+
/**
|
|
13
|
+
* The scheme of an input that looks like a hierarchical `scheme://` URL, or
|
|
14
|
+
* `undefined` when the input is not of that shape at all (so filesystem paths
|
|
15
|
+
* like `a:/b` or `scheme:x` never count as internal URLs).
|
|
16
|
+
* @param input - the raw model-supplied path.
|
|
17
|
+
* @returns the lowercased scheme, or `undefined`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractUriScheme(input: string): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Parse a hierarchical internal URL preserving the raw host and pathname.
|
|
22
|
+
* Only the `scheme://…` form routes through the registry — opaque inputs
|
|
23
|
+
* (`urn:…`) never parse here.
|
|
24
|
+
*
|
|
25
|
+
* Segment handling follows the router's strictness: an empty, `.`, or `..`
|
|
26
|
+
* path segment throws, and a malformed URL throws with the input echoed back.
|
|
27
|
+
*
|
|
28
|
+
* @param input - the raw model-supplied path (`conflict://3/ours`, `pr://1428`).
|
|
29
|
+
* @returns the parsed URL with raw segments, decoded segments, query params, and exact input.
|
|
30
|
+
* @throws when the input is not a parseable hierarchical `scheme://` URL or contains a bad segment.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseInternalUrl(input: string): ParsedInternalUrl;
|
|
33
|
+
/**
|
|
34
|
+
* Parse the `<path>:conflict://<id>` selector form — a filesystem path glued to
|
|
35
|
+
* a conflict URL by a colon (sibling of the `path:conflicts` read selector).
|
|
36
|
+
* The conflict handler reads `.rawHref` directly and strips the prefix itself,
|
|
37
|
+
* so the returned URL keeps the original bytes as `rawHref` while the rest of
|
|
38
|
+
* the shape describes the conflict URL proper.
|
|
39
|
+
*
|
|
40
|
+
* @returns the parsed conflict URL, or `null` when `input` is not of that shape.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseConflictReference(input: string): ParsedInternalUrl | null;
|
|
43
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/vendor/internal-urls/parse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAKnD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGlE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CA+CjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAM9E"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from fork @deepseek-ai/dsh-internal-urls (packages/fs/internal-urls/src/parse.ts) — keep in sync.
|
|
3
|
+
* The published harness does not ship this package, so @hy-sde-org/dsh-session-url vendors the small
|
|
4
|
+
* internal-URL surface it consumes (types + parse + router) to stay dependency-free and standalone.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* RFC 3986 scheme detection and internal-URL parsing that preserves the raw
|
|
8
|
+
* host/pathname bytes before URL normalization.
|
|
9
|
+
* @module @deepseek-ai/dsh-internal-urls/parse
|
|
10
|
+
*/
|
|
11
|
+
/** A hierarchical `scheme://` prefix with an RFC 3986 scheme (first char alpha, then alnum/+/./-). */
|
|
12
|
+
const URI_SCHEME_RE = /^([a-z][a-z0-9+.-]*):\/\//i;
|
|
13
|
+
/**
|
|
14
|
+
* The scheme of an input that looks like a hierarchical `scheme://` URL, or
|
|
15
|
+
* `undefined` when the input is not of that shape at all (so filesystem paths
|
|
16
|
+
* like `a:/b` or `scheme:x` never count as internal URLs).
|
|
17
|
+
* @param input - the raw model-supplied path.
|
|
18
|
+
* @returns the lowercased scheme, or `undefined`.
|
|
19
|
+
*/
|
|
20
|
+
export function extractUriScheme(input) {
|
|
21
|
+
const match = URI_SCHEME_RE.exec(input);
|
|
22
|
+
return match?.[1]?.toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse a hierarchical internal URL preserving the raw host and pathname.
|
|
26
|
+
* Only the `scheme://…` form routes through the registry — opaque inputs
|
|
27
|
+
* (`urn:…`) never parse here.
|
|
28
|
+
*
|
|
29
|
+
* Segment handling follows the router's strictness: an empty, `.`, or `..`
|
|
30
|
+
* path segment throws, and a malformed URL throws with the input echoed back.
|
|
31
|
+
*
|
|
32
|
+
* @param input - the raw model-supplied path (`conflict://3/ours`, `pr://1428`).
|
|
33
|
+
* @returns the parsed URL with raw segments, decoded segments, query params, and exact input.
|
|
34
|
+
* @throws when the input is not a parseable hierarchical `scheme://` URL or contains a bad segment.
|
|
35
|
+
*/
|
|
36
|
+
export function parseInternalUrl(input) {
|
|
37
|
+
let url;
|
|
38
|
+
try {
|
|
39
|
+
url = new URL(input);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
throw new Error(`Invalid internal URL: ${input}`);
|
|
43
|
+
}
|
|
44
|
+
const scheme = extractUriScheme(input);
|
|
45
|
+
if (scheme === undefined) {
|
|
46
|
+
throw new Error(`Invalid internal URL: ${input}`);
|
|
47
|
+
}
|
|
48
|
+
const afterScheme = input.slice(input.indexOf('://') + 3);
|
|
49
|
+
// The host ends at the first `/`, `?`, or `#` — everything else belongs to it.
|
|
50
|
+
const hostileStart = afterScheme.search(/[/?#]/);
|
|
51
|
+
const rawHost = hostileStart === -1 ? afterScheme : afterScheme.slice(0, hostileStart);
|
|
52
|
+
const tail = hostileStart === -1 ? '' : afterScheme.slice(hostileStart);
|
|
53
|
+
// The raw pathname is everything from the first `/` up to the first `?`/`#`.
|
|
54
|
+
const pathEnd = tail.search(/[?#]/);
|
|
55
|
+
const rawPathname = pathEnd === -1 ? tail : tail.slice(0, pathEnd);
|
|
56
|
+
const stripped = rawPathname.startsWith('/') ? rawPathname.slice(1) : rawPathname;
|
|
57
|
+
const pathSegments = [];
|
|
58
|
+
if (stripped !== '') {
|
|
59
|
+
for (const segment of stripped.split('/')) {
|
|
60
|
+
let decoded;
|
|
61
|
+
try {
|
|
62
|
+
decoded = decodeURIComponent(segment);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
throw new Error(`Invalid internal URL: ${input}`);
|
|
66
|
+
}
|
|
67
|
+
if (decoded === '' || decoded === '.' || decoded === '..') {
|
|
68
|
+
throw new Error(`Invalid internal URL: ${input}`);
|
|
69
|
+
}
|
|
70
|
+
pathSegments.push(decoded);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
scheme,
|
|
75
|
+
rawHost,
|
|
76
|
+
rawPathname,
|
|
77
|
+
pathSegments,
|
|
78
|
+
searchParams: url.searchParams,
|
|
79
|
+
href: url.href,
|
|
80
|
+
rawHref: input,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parse the `<path>:conflict://<id>` selector form — a filesystem path glued to
|
|
85
|
+
* a conflict URL by a colon (sibling of the `path:conflicts` read selector).
|
|
86
|
+
* The conflict handler reads `.rawHref` directly and strips the prefix itself,
|
|
87
|
+
* so the returned URL keeps the original bytes as `rawHref` while the rest of
|
|
88
|
+
* the shape describes the conflict URL proper.
|
|
89
|
+
*
|
|
90
|
+
* @returns the parsed conflict URL, or `null` when `input` is not of that shape.
|
|
91
|
+
*/
|
|
92
|
+
export function parseConflictReference(input) {
|
|
93
|
+
const marker = input.toLowerCase().lastIndexOf(':conflict://');
|
|
94
|
+
if (marker <= 0)
|
|
95
|
+
return null;
|
|
96
|
+
const tail = input.slice(marker + ':conflict://'.length);
|
|
97
|
+
const inner = parseInternalUrl(`conflict://${tail}`);
|
|
98
|
+
return { ...inner, href: `conflict://${tail}`, rawHref: input };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/vendor/internal-urls/parse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;GAIG;AAIH,sGAAsG;AACtG,MAAM,aAAa,GAAG,4BAA4B,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,GAAQ,CAAA;IACZ,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACtC,IAAI,MAAM,KAAK,SAAS,EAAE,C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AAyB,KAAK,EAAE,CAAC,CAAA;YACnD,CAAC;YACD,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBAC1D,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAA;YACnD,CAAC;YACD,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,OAAO;QACP,WAAW;QACX,YAAY;QACZ,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,KAAK;KACf,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAA;IAC9D,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IACxD,MAAM,KAAK,GAAG,gBAAgB,CAAC,cAAc,IAAI,EAAE,CAAC,CAAA;IACpD,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,cAAc,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AACjE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from fork @deepseek-ai/dsh-internal-urls (packages/fs/internal-urls/src/router.ts) — keep in sync.
|
|
3
|
+
* The published harness does not ship this package, so @hy-sde-org/dsh-session-url vendors the small
|
|
4
|
+
* internal-URL surface it consumes (types + parse + router) to stay dependency-free and standalone.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The internal-URL resolver registry: one handler per scheme, reachable by the
|
|
8
|
+
* read/grep/write tools as `ctx.internalUrls`. Handlers are stateless where
|
|
9
|
+
* possible; per-session shared state (ConflictHistory) lives in the service.
|
|
10
|
+
* @module @deepseek-ai/dsh-internal-urls/router
|
|
11
|
+
*/
|
|
12
|
+
import type { InternalResource, ProtocolHandler, ResolveContext, UrlCompletion, WriteContext } from './types.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Validates a handler registration: a non-empty alphabetic scheme, and a
|
|
15
|
+
* conflict with an existing registration is a programming error (each scheme
|
|
16
|
+
* may have exactly one handler).
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateHandler(handler: ProtocolHandler): string;
|
|
19
|
+
/**
|
|
20
|
+
* One resolver registry. `register`/`unregister` manage the handler table;
|
|
21
|
+
* `canHandle` decides whether a model-supplied path routes away from the
|
|
22
|
+
* filesystem; `resolve`/`write` dispatch to the matching handler.
|
|
23
|
+
*/
|
|
24
|
+
export declare class InternalUrlRouter {
|
|
25
|
+
private readonly handlers;
|
|
26
|
+
/** Register (or replace) the handler for its scheme. Returns a disposer. */
|
|
27
|
+
register(handler: ProtocolHandler): () => void;
|
|
28
|
+
/** Remove the handler for `scheme`; returns false when none was registered. */
|
|
29
|
+
unregister(scheme: string): boolean;
|
|
30
|
+
/** The registered handler for a scheme, or `undefined`. */
|
|
31
|
+
getHandler(scheme: string): ProtocolHandler | undefined;
|
|
32
|
+
/** Every registered scheme. */
|
|
33
|
+
schemes(): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Whether `input` is a hierarchical `scheme://` URL (or the `<path>:conflict://`
|
|
36
|
+
* selector form) with a registered handler. This is the single gate the
|
|
37
|
+
* read/grep/write tools consult before touching the filesystem.
|
|
38
|
+
*/
|
|
39
|
+
canHandle(input: string): boolean;
|
|
40
|
+
/** Resolve an internal URL through its registered handler. */
|
|
41
|
+
resolve(input: string, context?: ResolveContext): Promise<InternalResource>;
|
|
42
|
+
/** Write an internal URL through its registered handler. */
|
|
43
|
+
write(input: string, content: string, context?: WriteContext): Promise<void>;
|
|
44
|
+
/** Candidate completions for `scheme://<query>`, or `null` when the scheme has no completer. */
|
|
45
|
+
complete(scheme: string, query: string, context?: ResolveContext): Promise<UrlCompletion[] | null>;
|
|
46
|
+
private route;
|
|
47
|
+
private unknownScheme;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/vendor/internal-urls/router.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;GAKG;AAGH,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,cAAc,EACd,aAAa,EACb,YAAY,EACb,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAMhE;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAE9D,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,IAAI;IAU9C,+EAA+E;IAC/E,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAInC,2DAA2D;IAC3D,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIvD,+BAA+B;IAC/B,OAAO,IAAI,MAAM,EAAE;IAInB;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAMjC,8DAA8D;IACxD,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAYjF,4DAA4D;IACtD,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlF,gGAAgG;IAC1F,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC;IAMxG,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,aAAa;CAItB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from fork @deepseek-ai/dsh-internal-urls (packages/fs/internal-urls/src/router.ts) — keep in sync.
|
|
3
|
+
* The published harness does not ship this package, so @hy-sde-org/dsh-session-url vendors the small
|
|
4
|
+
* internal-URL surface it consumes (types + parse + router) to stay dependency-free and standalone.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The internal-URL resolver registry: one handler per scheme, reachable by the
|
|
8
|
+
* read/grep/write tools as `ctx.internalUrls`. Handlers are stateless where
|
|
9
|
+
* possible; per-session shared state (ConflictHistory) lives in the service.
|
|
10
|
+
* @module @deepseek-ai/dsh-internal-urls/router
|
|
11
|
+
*/
|
|
12
|
+
import { parseInternalUrl, extractUriScheme, parseConflictReference } from "./parse.js";
|
|
13
|
+
/**
|
|
14
|
+
* Validates a handler registration: a non-empty alphabetic scheme, and a
|
|
15
|
+
* conflict with an existing registration is a programming error (each scheme
|
|
16
|
+
* may have exactly one handler).
|
|
17
|
+
*/
|
|
18
|
+
export function validateHandler(handler) {
|
|
19
|
+
const scheme = handler.scheme.toLowerCase();
|
|
20
|
+
if (!/^[a-z][a-z0-9+.-]*$/.test(handler.scheme)) {
|
|
21
|
+
throw new Error(`Internal URL handler: invalid scheme '${handler.scheme}'`);
|
|
22
|
+
}
|
|
23
|
+
return scheme;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One resolver registry. `register`/`unregister` manage the handler table;
|
|
27
|
+
* `canHandle` decides whether a model-supplied path routes away from the
|
|
28
|
+
* filesystem; `resolve`/`write` dispatch to the matching handler.
|
|
29
|
+
*/
|
|
30
|
+
export class InternalUrlRouter {
|
|
31
|
+
handlers = new Map();
|
|
32
|
+
/** Register (or replace) the handler for its scheme. Returns a disposer. */
|
|
33
|
+
register(handler) {
|
|
34
|
+
const scheme = validateHandler(handler);
|
|
35
|
+
const prior = this.handlers.get(scheme);
|
|
36
|
+
this.handlers.set(scheme, handler);
|
|
37
|
+
return () => {
|
|
38
|
+
if (this.handlers.get(scheme) === handler)
|
|
39
|
+
this.handlers.delete(scheme);
|
|
40
|
+
else if (prior !== undefined)
|
|
41
|
+
this.handlers.set(scheme, prior);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Remove the handler for `scheme`; returns false when none was registered. */
|
|
45
|
+
unregister(scheme) {
|
|
46
|
+
return this.handlers.delete(scheme.toLowerCase());
|
|
47
|
+
}
|
|
48
|
+
/** The registered handler for a scheme, or `undefined`. */
|
|
49
|
+
getHandler(scheme) {
|
|
50
|
+
return this.handlers.get(scheme.toLowerCase());
|
|
51
|
+
}
|
|
52
|
+
/** Every registered scheme. */
|
|
53
|
+
schemes() {
|
|
54
|
+
return [...this.handlers.keys()];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Whether `input` is a hierarchical `scheme://` URL (or the `<path>:conflict://`
|
|
58
|
+
* selector form) with a registered handler. This is the single gate the
|
|
59
|
+
* read/grep/write tools consult before touching the filesystem.
|
|
60
|
+
*/
|
|
61
|
+
canHandle(input) {
|
|
62
|
+
const scheme = extractUriScheme(input);
|
|
63
|
+
if (scheme !== undefined)
|
|
64
|
+
return this.handlers.has(scheme);
|
|
65
|
+
return parseConflictReference(input) !== null && this.handlers.has('conflict');
|
|
66
|
+
}
|
|
67
|
+
/** Resolve an internal URL through its registered handler. */
|
|
68
|
+
async resolve(input, context) {
|
|
69
|
+
const parsed = this.route(input);
|
|
70
|
+
const handler = this.handlers.get(parsed.scheme);
|
|
71
|
+
if (handler === undefined)
|
|
72
|
+
throw this.unknownScheme(parsed.scheme);
|
|
73
|
+
const resource = await handler.resolve(parsed, context);
|
|
74
|
+
return {
|
|
75
|
+
...resource,
|
|
76
|
+
// The router stamps immutability so handlers never encode the same fact twice.
|
|
77
|
+
immutable: resource.immutable ?? handler.immutable,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Write an internal URL through its registered handler. */
|
|
81
|
+
async write(input, content, context) {
|
|
82
|
+
const parsed = this.route(input);
|
|
83
|
+
const handler = this.handlers.get(parsed.scheme);
|
|
84
|
+
if (handler === undefined)
|
|
85
|
+
throw this.unknownScheme(parsed.scheme);
|
|
86
|
+
if (handler.write === undefined) {
|
|
87
|
+
throw new Error(`${parsed.scheme}:// URLs are read-only for write; use the protocol-specific tool for mutations.`);
|
|
88
|
+
}
|
|
89
|
+
await handler.write(parsed, content, context);
|
|
90
|
+
}
|
|
91
|
+
/** Candidate completions for `scheme://<query>`, or `null` when the scheme has no completer. */
|
|
92
|
+
async complete(scheme, query, context) {
|
|
93
|
+
const handler = this.handlers.get(scheme.toLowerCase());
|
|
94
|
+
if (handler?.complete === undefined)
|
|
95
|
+
return null;
|
|
96
|
+
return handler.complete(query, context);
|
|
97
|
+
}
|
|
98
|
+
route(input) {
|
|
99
|
+
let parsed = null;
|
|
100
|
+
try {
|
|
101
|
+
parsed = parseInternalUrl(input);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
parsed = parseConflictReference(input);
|
|
105
|
+
}
|
|
106
|
+
if (parsed === null || !this.handlers.has(parsed.scheme)) {
|
|
107
|
+
const scheme = extractUriScheme(input) ?? parsed?.scheme;
|
|
108
|
+
if (scheme === undefined)
|
|
109
|
+
throw new Error(`Not an internal URL: ${input}`);
|
|
110
|
+
throw this.unknownScheme(scheme);
|
|
111
|
+
}
|
|
112
|
+
return parsed;
|
|
113
|
+
}
|
|
114
|
+
unknownScheme(scheme) {
|
|
115
|
+
const available = this.schemes().map(candidate => `${candidate}://`).join(', ');
|
|
116
|
+
return new Error(`Unknown protocol: ${scheme}://\nSupported: ${available || 'none'}`);
|
|
117
|
+
}
|
|
118
|
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,CAAC,IAAI,MAAM,EAAE,MAAM,CAAA;YACxD,IAAI,MAAM,KAAK,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAA;YAC1E,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QAClC,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,aAAa,CAAC,MAAc;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/E,OAAO,IAAI,KAAK,CAAC,qBAAqB,MAAM,mBAAmB,SAAS,IAAI,MAAM,EAAE,CAAC,CAAA;IACvF,CAAC;CACF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from fork @deepseek-ai/dsh-internal-urls (packages/fs/internal-urls/src/types.ts) — keep in sync.
|
|
3
|
+
* The published harness does not ship this package, so @hy-sde-org/dsh-session-url vendors the small
|
|
4
|
+
* internal-URL surface it consumes (types + parse + router) to stay dependency-free and standalone.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Vocabulary for the internal-URL routing system: FS-shaped `scheme://` URLs
|
|
8
|
+
* (`conflict://`, `pr://`, `issue://`, …) resolved by the read/grep/write
|
|
9
|
+
* tools through one resolver registry (`ctx.internalUrls`).
|
|
10
|
+
*
|
|
11
|
+
* A handler resolves a parsed internal URL to an {@link InternalResource}
|
|
12
|
+
* (text content plus optional backing-file materialization), and may opt into
|
|
13
|
+
* write dispatch so the write tool can mutate remote/meta surfaces instead of
|
|
14
|
+
* a literal file.
|
|
15
|
+
* @module @deepseek-ai/dsh-internal-urls/types
|
|
16
|
+
*/
|
|
17
|
+
/** MIME tags the model-facing text may claim. */
|
|
18
|
+
export type InternalContentType = 'text/markdown' | 'application/json' | 'text/plain';
|
|
19
|
+
/**
|
|
20
|
+
* Raw resource payload returned by protocol handlers. The `immutable` flag is
|
|
21
|
+
* applied by the router from {@link ProtocolHandler.immutable}, so handlers do
|
|
22
|
+
* not need to set it themselves.
|
|
23
|
+
*/
|
|
24
|
+
export interface InternalResource {
|
|
25
|
+
/** Canonical URL that was resolved. */
|
|
26
|
+
url: string;
|
|
27
|
+
/** Resolved text content. */
|
|
28
|
+
content: string;
|
|
29
|
+
/** MIME type of `content`. */
|
|
30
|
+
contentType: InternalContentType;
|
|
31
|
+
/** Content size in bytes, when known. */
|
|
32
|
+
size?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Underlying filesystem path, when the resource is backed by a local file
|
|
35
|
+
* (e.g. a future `local://`). The agent-facing display stays `url`; the path
|
|
36
|
+
* is for materializing edits and searches.
|
|
37
|
+
*/
|
|
38
|
+
sourcePath?: string;
|
|
39
|
+
/** Additional notes about resolution, rendered below the content. */
|
|
40
|
+
notes?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* True when the resolved content cannot be edited by the agent (sealed
|
|
43
|
+
* artifacts, harness docs, machine-generated summaries). Mutable resources
|
|
44
|
+
* (conflict regions) behave like editable files.
|
|
45
|
+
*/
|
|
46
|
+
immutable?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* True when the resource is a directory listing rather than file content.
|
|
49
|
+
* `grep` refuses such a resource without a `sourcePath`.
|
|
50
|
+
*/
|
|
51
|
+
isDirectory?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A single autocomplete candidate for the host/path portion of a `scheme://`
|
|
55
|
+
* URL, produced by {@link ProtocolHandler.complete}.
|
|
56
|
+
*/
|
|
57
|
+
export interface UrlCompletion {
|
|
58
|
+
/** The text that follows `scheme://` for this candidate. */
|
|
59
|
+
value: string;
|
|
60
|
+
/** Human-facing label for the dropdown; defaults to {@link value}. */
|
|
61
|
+
label?: string;
|
|
62
|
+
/** Optional one-line description shown beside the candidate. */
|
|
63
|
+
description?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A parsed internal URL (`scheme://host/path?query`). Keeps the raw segments
|
|
67
|
+
* before URL normalization so numeric hosts, casing, and traversal markers
|
|
68
|
+
* survive, and carries the exact input string for byte-exact matching.
|
|
69
|
+
*/
|
|
70
|
+
export interface ParsedInternalUrl {
|
|
71
|
+
/** Scheme without the `:` (already lowercased), e.g. `conflict`, `pr`. */
|
|
72
|
+
scheme: string;
|
|
73
|
+
/** Raw host segment exactly as typed (case preserved, no normalization). */
|
|
74
|
+
rawHost: string;
|
|
75
|
+
/** Raw pathname exactly as typed (leading `/` preserved, no normalization). */
|
|
76
|
+
rawPathname: string;
|
|
77
|
+
/**
|
|
78
|
+
* Decoded non-empty path segments following the leading slash. Rejects
|
|
79
|
+
* empty, `.`, and `..` segments.
|
|
80
|
+
*/
|
|
81
|
+
pathSegments: string[];
|
|
82
|
+
/** Query parameters under `?…` (empty when the input carries none). */
|
|
83
|
+
searchParams: URLSearchParams;
|
|
84
|
+
/** Normalized href (`new URL(input).href`). */
|
|
85
|
+
href: string;
|
|
86
|
+
/** The exact input string, before any normalization. */
|
|
87
|
+
rawHref: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Caller-supplied context threaded into handlers so schemes that resolve
|
|
91
|
+
* against the calling session (default repo, conflict history, cwd-relative
|
|
92
|
+
* files) act on the session that initiated the read/write, never the first
|
|
93
|
+
* session to register.
|
|
94
|
+
*/
|
|
95
|
+
export interface ResolveContext {
|
|
96
|
+
/** Working directory of the calling session. */
|
|
97
|
+
cwd?: string;
|
|
98
|
+
/** The caller's abort signal. */
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
/**
|
|
101
|
+
* Opaque per-session key used for session-scoped handler state (e.g.
|
|
102
|
+
* {@link module:@deepseek-ai/dsh-internal-urls/conflict ConflictHistory}).
|
|
103
|
+
*/
|
|
104
|
+
sessionKey?: string;
|
|
105
|
+
/**
|
|
106
|
+
* When set, handlers that would otherwise materialize expensive content may
|
|
107
|
+
* return the resource shape with `content` empty — callers that only need
|
|
108
|
+
* `sourcePath` (search) pass this so a large resource still resolves without
|
|
109
|
+
* buffering it.
|
|
110
|
+
*/
|
|
111
|
+
pathOnly?: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Caller context for write dispatch to host-owned URI handlers. */
|
|
114
|
+
export interface WriteContext {
|
|
115
|
+
/** Working directory of the calling session. */
|
|
116
|
+
cwd?: string;
|
|
117
|
+
/** The caller's abort signal. */
|
|
118
|
+
signal?: AbortSignal;
|
|
119
|
+
/** Opaque per-session key — see {@link ResolveContext.sessionKey}. */
|
|
120
|
+
sessionKey?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Opaque per-call sandbox policy (the write tool's resolved mode + workspace
|
|
123
|
+
* root) forwarded so a handler that mutates a backing file keeps the same
|
|
124
|
+
* confinement semantics as a plain `write` call. Opaque here; the handler's
|
|
125
|
+
* file bridge applies it when calling `ctx.fs`.
|
|
126
|
+
*/
|
|
127
|
+
sandboxPolicy?: unknown;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A handler for a specific internal URL scheme (e.g. `conflict://`, `pr://`).
|
|
131
|
+
*/
|
|
132
|
+
export interface ProtocolHandler {
|
|
133
|
+
/** The scheme without trailing `://` (e.g. `conflict`). */
|
|
134
|
+
readonly scheme: string;
|
|
135
|
+
/**
|
|
136
|
+
* Whether resources produced by this handler are immutable (never editable
|
|
137
|
+
* by the agent). `true` suppresses write affordances; `false` marks the
|
|
138
|
+
* resource as writable (e.g. conflict regions).
|
|
139
|
+
*/
|
|
140
|
+
readonly immutable: boolean;
|
|
141
|
+
/** Resolve an internal URL to its content. Throws a user-friendly error on failure. */
|
|
142
|
+
resolve(url: ParsedInternalUrl, context?: ResolveContext): Promise<InternalResource>;
|
|
143
|
+
/**
|
|
144
|
+
* Optional write hook. When present, the write tool dispatches
|
|
145
|
+
* `write(url, content)` here instead of writing to a filesystem path.
|
|
146
|
+
* Handlers that omit it are read-only.
|
|
147
|
+
*/
|
|
148
|
+
write?(url: ParsedInternalUrl, content: string, context?: WriteContext): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Optional autocomplete hook — candidate completions for the host/path
|
|
151
|
+
* portion of a `scheme://` URL. Must be fast and local; omitted by network
|
|
152
|
+
* backed schemes.
|
|
153
|
+
*/
|
|
154
|
+
complete?(query?: string, context?: ResolveContext): Promise<UrlCompletion[]>;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vendor/internal-urls/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;;;;GAUG;AAEH,iDAAiD;AACjD,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG,kBAAkB,GAAG,YAAY,CAAA;AAErF;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,8BAA8B;IAC9B,WAAW,EAAE,mBAAmB,CAAA;IAChC,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAA;IACb,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,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AC,CAAA;IACtF;;;;OAIG;IACH,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAA;CAC9E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from fork @deepseek-ai/dsh-internal-urls (packages/fs/internal-urls/src/types.ts) — keep in sync.
|
|
3
|
+
* The published harness does not ship this package, so @hy-sde-org/dsh-session-url vendors the small
|
|
4
|
+
* internal-URL surface it consumes (types + parse + router) to stay dependency-free and standalone.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Vocabulary for the internal-URL routing system: FS-shaped `scheme://` URLs
|
|
8
|
+
* (`conflict://`, `pr://`, `issue://`, …) resolved by the read/grep/write
|
|
9
|
+
* tools through one resolver registry (`ctx.internalUrls`).
|
|
10
|
+
*
|
|
11
|
+
* A handler resolves a parsed internal URL to an {@link InternalResource}
|
|
12
|
+
* (text content plus optional backing-file materialization), and may opt into
|
|
13
|
+
* write dispatch so the write tool can mutate remote/meta surfaces instead of
|
|
14
|
+
* a literal file.
|
|
15
|
+
* @module @deepseek-ai/dsh-internal-urls/types
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/vendor/internal-urls/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;;;;GAUG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hy-sde-org/dsh-session-url",
|
|
3
|
+
"version": "0.1.2-rc.1",
|
|
4
|
+
"description": "session:// internal-URL scheme handler: read a session transcript, read one event as JSON, list sessions, and search past history through internal-URL-aware read/grep tools — standalone for DeepSeek Harness.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./handler": {
|
|
14
|
+
"types": "./dist/handler.d.ts",
|
|
15
|
+
"default": "./dist/handler.js"
|
|
16
|
+
},
|
|
17
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"cordis.patch.yml",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22.19.0"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/hy-sde/dsh-session-url.git"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"dsh": {
|
|
38
|
+
"bundle": {
|
|
39
|
+
"patch": "./cordis.patch.yml"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@deepseek-ai/dsh-session-query": "^0.1.2-rc.1"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
47
|
+
"@deepseek-ai/dsh-session": "^0.1.2-rc.1",
|
|
48
|
+
"@deepseek-ai/dsh-session-query": "^0.1.2-rc.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
52
|
+
"@deepseek-ai/dsh-session": "^0.1.2-rc.1",
|
|
53
|
+
"@deepseek-ai/dsh-session-query": "^0.1.2-rc.1",
|
|
54
|
+
"@deepseek-ai/dsh-session-title": "^0.1.2-rc.1",
|
|
55
|
+
"@types/node": "^24.0.0",
|
|
56
|
+
"typescript": "^5.9.3",
|
|
57
|
+
"vitest": "^3.2.7"
|
|
58
|
+
},
|
|
59
|
+
"keywords": [
|
|
60
|
+
"deepseek",
|
|
61
|
+
"agent",
|
|
62
|
+
"harness",
|
|
63
|
+
"dsh-plugin",
|
|
64
|
+
"internal-urls",
|
|
65
|
+
"session",
|
|
66
|
+
"transcript",
|
|
67
|
+
"search"
|
|
68
|
+
],
|
|
69
|
+
"scripts": {
|
|
70
|
+
"clean": "rm -rf dist",
|
|
71
|
+
"build": "tsc -p tsconfig.build.json",
|
|
72
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
73
|
+
"test": "vitest run"
|
|
74
|
+
}
|
|
75
|
+
}
|