@harapter/adapter-dsh 0.1.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 +201 -0
- package/README.md +262 -0
- package/dist/adapter.d.ts +36 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +1065 -0
- package/dist/adapter.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +93 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +708 -0
- package/dist/protocol.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Harapter contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# `@harapter/adapter-dsh`
|
|
2
|
+
|
|
3
|
+
`@harapter/adapter-dsh` maps the official
|
|
4
|
+
[DeepSeek Harness SDK protocol](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/sdk/protocol/README.md)
|
|
5
|
+
to the portable Harapter lifecycle. It connects to the newline-delimited
|
|
6
|
+
JSON-RPC 2.0 server exposed by the SDK Runtime and does not embed or reproduce
|
|
7
|
+
the DeepSeek Harness Agent Loop.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @harapter/core@next @harapter/adapter-dsh@next
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Runtime prerequisites and compatibility
|
|
16
|
+
|
|
17
|
+
The host installs, configures, and authenticates DeepSeek Harness. This package
|
|
18
|
+
does not install the DSH CLI, Runtime, SDK packages, Cordis application,
|
|
19
|
+
plugins, model adapters, or credentials. None of those packages enter the
|
|
20
|
+
default Harapter Workspace dependency graph or lockfile.
|
|
21
|
+
|
|
22
|
+
The Adapter targets the current official SDK stdio JSON-RPC interface. It
|
|
23
|
+
validates the wire-stable `deepseek-harness-sdk-runtime` handshake identity and
|
|
24
|
+
every required response, notification, event, and terminal structure it uses.
|
|
25
|
+
The runtime supplies a diagnostic version string, but the protocol has no
|
|
26
|
+
version negotiation or compatibility promise, so the Adapter has no executable
|
|
27
|
+
version allowlist. Harapter exposes only its stable diagnostic hash. Protocol
|
|
28
|
+
provenance, redacted fixtures, conformance, and an isolated live-runtime run
|
|
29
|
+
cover the current official SDK Profile, but cannot match an arbitrary connected
|
|
30
|
+
Runtime to that evidence. The Client descriptor therefore remains `experimental`
|
|
31
|
+
and retains a `pre_release_upstream_protocol` warning.
|
|
32
|
+
|
|
33
|
+
The fixture provenance records the official protocol package revision inspected
|
|
34
|
+
for this implementation. That revision and its package version do not pin the
|
|
35
|
+
host Runtime. A future incompatible protocol change requires new fixtures,
|
|
36
|
+
mapping tests, conformance, and compatibility documentation.
|
|
37
|
+
|
|
38
|
+
The last repository-recorded
|
|
39
|
+
[trusted lifecycle run](https://github.com/yunfeizhu/harapter/actions/runs/33735315426)
|
|
40
|
+
passed on 2026-09-03 with `@deepseek-ai/dsh@0.1.2-alpha.5`,
|
|
41
|
+
`@deepseek-ai/dsh-sdk-minimal@0.1.2-rc.1`, and
|
|
42
|
+
`@deepseek-ai/dsh-sdk-app@0.1.2-rc.1`. It verified the exact synthetic response,
|
|
43
|
+
`run.started`, `message.completed`, the final authoritative `run.completed`, and
|
|
44
|
+
the absence of tool or interaction Events. A production host may choose those
|
|
45
|
+
exact versions for a reproducible deployment, while Harapter continues to admit
|
|
46
|
+
newer Runtime versions and validates their observed structures instead of using
|
|
47
|
+
a version allowlist. The trusted scheduled live canary follows the current SDK
|
|
48
|
+
Profile prerelease channel and records the installed CLI, minimal Profile, and
|
|
49
|
+
SDK Runtime versions for every run. It composes `sdk-minimal`, disables every
|
|
50
|
+
model-facing tool in that composition, and verifies the complete effective
|
|
51
|
+
configuration before receiving the real model credential. Any composition drift,
|
|
52
|
+
unexpected response, missing terminal Event, or observed tool or interaction
|
|
53
|
+
Event fails the lifecycle.
|
|
54
|
+
|
|
55
|
+
DeepSeek Harness is MIT licensed. Harapter does not redistribute its Runtime or
|
|
56
|
+
SDK packages; see the [license record](../../licenses/deepseek-harness.md).
|
|
57
|
+
|
|
58
|
+
## Public entrypoints
|
|
59
|
+
|
|
60
|
+
- `DSH_PROVIDER_ID` is `deepseek.harness`.
|
|
61
|
+
- `createDshProviderFactory()` returns an independently registrable Provider
|
|
62
|
+
factory.
|
|
63
|
+
- `DSH_NOTIFICATION_EXTENSION` names the bounded, redacted notification
|
|
64
|
+
observer.
|
|
65
|
+
- `DshNativeClient` exposes initialized native requests and notifications, a
|
|
66
|
+
non-sensitive runtime identity, and bounded unknown-event observation.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
70
|
+
import {
|
|
71
|
+
DSH_PROVIDER_ID,
|
|
72
|
+
createDshProviderFactory,
|
|
73
|
+
} from '@harapter/adapter-dsh';
|
|
74
|
+
|
|
75
|
+
const registry = new HarnessRegistry();
|
|
76
|
+
registry.register(createDshProviderFactory());
|
|
77
|
+
|
|
78
|
+
const client = await registry.connect({
|
|
79
|
+
profileId: profileId('dsh-local'),
|
|
80
|
+
providerId: DSH_PROVIDER_ID,
|
|
81
|
+
displayName: 'Local DeepSeek Harness',
|
|
82
|
+
connection: {
|
|
83
|
+
kind: 'process',
|
|
84
|
+
command: 'dsh',
|
|
85
|
+
args: ['--profile', 'sdk'],
|
|
86
|
+
ownership: 'adapter',
|
|
87
|
+
},
|
|
88
|
+
providerOptions: {
|
|
89
|
+
provider: 'host-configured-provider',
|
|
90
|
+
model: 'host-configured-model',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const session = await client.createSession();
|
|
95
|
+
const run = await session.start({
|
|
96
|
+
parts: [{ type: 'text', text: 'Describe the current project.' }],
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
for await (const event of run.events()) {
|
|
100
|
+
// Render or persist according to the host's data policy.
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const result = await run.result();
|
|
104
|
+
await session.close();
|
|
105
|
+
await client.close();
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Profile and process ownership
|
|
109
|
+
|
|
110
|
+
The Adapter accepts only `process` connections with `ownership: "adapter"`. The
|
|
111
|
+
Profile supplies the complete command, arguments, optional working directory,
|
|
112
|
+
Provider route, and model. Harapter launches the exact command without a shell,
|
|
113
|
+
does not capture stderr, and never appends installation, authentication, plugin,
|
|
114
|
+
or Profile-management commands. `envRefs` are rejected; the child otherwise
|
|
115
|
+
inherits the environment chosen by the host process.
|
|
116
|
+
|
|
117
|
+
`HarnessProfile.providerOptions` requires non-empty `provider` and `model`
|
|
118
|
+
strings for the process-wide handshake. It also accepts:
|
|
119
|
+
|
|
120
|
+
- optional `reasoningEffort` and positive `maxTokens` handshake values;
|
|
121
|
+
- `maxMessageBytes`, `maxBufferedMessages`, `maxPendingRequests`,
|
|
122
|
+
`maxPendingInboundRequests`, and `maxPendingWrites` for the shared JSON-RPC
|
|
123
|
+
transport;
|
|
124
|
+
- `requestTimeoutMs` for outbound JSON-RPC request waits;
|
|
125
|
+
- `shutdownTimeoutMs` for the bounded graceful-shutdown attempt;
|
|
126
|
+
- `maxRunEvents` from 2 through 4096, which bounds unread portable events and
|
|
127
|
+
reserves one terminal event.
|
|
128
|
+
|
|
129
|
+
An unread Run that reaches its event bound closes the connection and settles as
|
|
130
|
+
`connection_aborted` with an event-buffer reason. It never silently drops an
|
|
131
|
+
event or reports native cancellation.
|
|
132
|
+
|
|
133
|
+
## Session and Run lifecycle
|
|
134
|
+
|
|
135
|
+
`createSession()` allocates an SDK-side Session identifier locally. The Runtime
|
|
136
|
+
lazily creates the corresponding Agent and Session when `session/prompt` first
|
|
137
|
+
uses that identifier. Session settings are process-wide: a supplied workspace
|
|
138
|
+
must equal the initialized process working directory, while per-Session model,
|
|
139
|
+
system context, metadata, and Provider options are unsupported. The current
|
|
140
|
+
protocol exposes no resume or native Session-close method. Portable Session
|
|
141
|
+
close only releases the local handle after its active Run has settled.
|
|
142
|
+
|
|
143
|
+
The Adapter permits one active Harapter Run across the entire connection. A Run
|
|
144
|
+
accepts non-empty text parts only. `session/prompt` returns a durable inbox
|
|
145
|
+
`messageId`; it is not a result, Assistant Message identifier, or terminal
|
|
146
|
+
authority. The Adapter buffers bounded notifications that race the response,
|
|
147
|
+
correlates that exact identifier to one `agent/inbox/spliced` insertion, rejects
|
|
148
|
+
another insertion in the owned activity interval, and waits for the following
|
|
149
|
+
whole-Agent `idle` transition.
|
|
150
|
+
|
|
151
|
+
SDK Profile setup events emitted before that exact inbox insertion do not belong
|
|
152
|
+
to the Harapter Run and cannot provide portable or terminal authority. They
|
|
153
|
+
remain visible through the bounded, redacted notification observer. Events in
|
|
154
|
+
the owned interval, including the current `session/title` structure, are
|
|
155
|
+
validated and exposed through the redacted Provider event channel.
|
|
156
|
+
|
|
157
|
+
A request timeout, transport interruption, or malformed prompt response leaves
|
|
158
|
+
acceptance uncertain and quarantines the connection. An explicit JSON-RPC error
|
|
159
|
+
response is an authoritative rejection and leaves the connection reusable.
|
|
160
|
+
Subagent relationships belong only to their active Run; completed relationships
|
|
161
|
+
and every terminal Run release their child Session state. Late child activity
|
|
162
|
+
and subagent notifications received before receipt correlation remain visible
|
|
163
|
+
only through the redacted Provider observer. Root Session events after the
|
|
164
|
+
receipt must keep the upstream contiguous sequence; duplicate, stale, or skipped
|
|
165
|
+
positions fail the Run and quarantine the connection.
|
|
166
|
+
|
|
167
|
+
Exactly one structurally valid `turn/end.data.reason` must occur in the owned
|
|
168
|
+
interval:
|
|
169
|
+
|
|
170
|
+
- `completed` maps to `run.completed`;
|
|
171
|
+
- `aborted` with a recognized cause maps to `run.cancelled` as an observed
|
|
172
|
+
upstream outcome, not as proof that Harapter requested native cancellation;
|
|
173
|
+
- `blocked`, `error`, `max-tokens`, and `interrupted` map to `run.failed`;
|
|
174
|
+
- missing, duplicate, malformed, or unknown terminal reasons map to
|
|
175
|
+
`run.failed`, never success.
|
|
176
|
+
|
|
177
|
+
The last validated Assistant Message supplies `finalMessage`, and validated
|
|
178
|
+
usage records supply the portable usage summary. Whole-Agent `idle`, the last
|
|
179
|
+
Assistant Message, process exit, or JSON-RPC EOF cannot independently establish
|
|
180
|
+
success.
|
|
181
|
+
|
|
182
|
+
## Cancellation, timeout, and cleanup
|
|
183
|
+
|
|
184
|
+
The current official SDK protocol has no prompt-cancel method. The Adapter
|
|
185
|
+
therefore reports `run.cancel` as unsupported. Closing the Client or losing the
|
|
186
|
+
process settles an active Run as `connection_aborted`; neither path is described
|
|
187
|
+
as native cancellation.
|
|
188
|
+
|
|
189
|
+
A positive `RunOptions.timeoutMs` is an Adapter-controlled connection deadline.
|
|
190
|
+
When it expires, Harapter closes the owning Runtime connection and reports
|
|
191
|
+
`connection_aborted` with a local timeout reason. Client close first attempts
|
|
192
|
+
the official `shutdown` request within `shutdownTimeoutMs`, then terminates the
|
|
193
|
+
adapter-owned child process with a bounded forced-cleanup fallback.
|
|
194
|
+
|
|
195
|
+
## Events, redaction, and native access
|
|
196
|
+
|
|
197
|
+
Assistant text, reasoning, Tool lifecycle, usage, final Assistant Message, and
|
|
198
|
+
turn outcome events map to the portable vocabulary. Known structural events and
|
|
199
|
+
ignorable unknown Session events remain observable as `provider` events. Unknown
|
|
200
|
+
required Session event types fail the Run and quarantine the connection because
|
|
201
|
+
their lifecycle meaning cannot be guessed.
|
|
202
|
+
|
|
203
|
+
Raw notifications are bounded by depth, entry count, node count, and collection
|
|
204
|
+
length. Prompt text, Assistant content, Tool arguments and results, identifiers,
|
|
205
|
+
paths, failure messages, unknown keys, credentials, and arbitrary scalar values
|
|
206
|
+
are redacted. Runtime versions and unknown structural names use bounded, stable
|
|
207
|
+
diagnostic hashes rather than their original values.
|
|
208
|
+
`deepseek.harness.notifications` observes every safe notification;
|
|
209
|
+
`DshNativeClient.onUnknownEvent()` observes safe Provider-local activity that
|
|
210
|
+
does not map directly to a portable event. Observer failures cannot break Run
|
|
211
|
+
lifecycle processing.
|
|
212
|
+
|
|
213
|
+
`DshNativeClient.request()` and `notify()` are explicit escape hatches. Native
|
|
214
|
+
traffic does not gain portable ordering, lifecycle, ownership, redaction, or
|
|
215
|
+
authorization guarantees, and must not inject competing work into an active
|
|
216
|
+
owned Session interval.
|
|
217
|
+
|
|
218
|
+
## Errors, evidence, and limitations
|
|
219
|
+
|
|
220
|
+
Errors use fixed Harapter messages and stable categories without Provider
|
|
221
|
+
message bodies, prompts, file content, credentials, environment values, or host
|
|
222
|
+
paths. Runtime absence is `runtime_not_found`; malformed handshake, response, or
|
|
223
|
+
required event structures are `provider_api_incompatible`; request wait expiry
|
|
224
|
+
is `timeout`; an unexpected process or stream loss after connect is
|
|
225
|
+
`connection_aborted`; and an operation-local upstream rejection is
|
|
226
|
+
`provider_error`.
|
|
227
|
+
|
|
228
|
+
Evidence for this experimental source Adapter includes:
|
|
229
|
+
|
|
230
|
+
- official protocol provenance and deterministic synthetic traces in
|
|
231
|
+
[`fixtures/dsh/sdk-jsonrpc-current`](../../fixtures/dsh/sdk-jsonrpc-current/manifest.json);
|
|
232
|
+
- mapping, redaction, malformed input, receipt-order race, exclusive interval,
|
|
233
|
+
terminal reason, timeout, process-loss, buffer overflow, and forced-cleanup
|
|
234
|
+
tests;
|
|
235
|
+
- the shared portable Provider conformance suite;
|
|
236
|
+
- an opt-in live-runtime test verified against the current official SDK Profile
|
|
237
|
+
with an empty temporary working directory and isolated Runtime home. It logs
|
|
238
|
+
and stores no Provider traffic, credentials, environment values, or host
|
|
239
|
+
paths;
|
|
240
|
+
- a trusted scheduled live canary that installs the current SDK Profile
|
|
241
|
+
prerelease on an ephemeral runner, validates its tool-disabled effective
|
|
242
|
+
composition, records its actual package versions, and executes the same
|
|
243
|
+
minimal lifecycle when enabled.
|
|
244
|
+
|
|
245
|
+
Run live verification only in a host environment with an installed and
|
|
246
|
+
authenticated Runtime plus a Provider route and model:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
HARAPTER_DSH_LIVE=1 \
|
|
250
|
+
HARAPTER_DSH_PROVIDER=host-provider \
|
|
251
|
+
HARAPTER_DSH_MODEL=host-model \
|
|
252
|
+
pnpm vitest run providers/dsh/test/live.test.ts
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
`HARAPTER_DSH_COMMAND` can replace the default `dsh` executable, and
|
|
256
|
+
`HARAPTER_DSH_ARGS_JSON` can replace the default `["--profile","sdk"]`
|
|
257
|
+
arguments. A skipped or unrecorded live test is not support evidence.
|
|
258
|
+
|
|
259
|
+
Native prompt cancellation, Session resume, Session deletion, portable image or
|
|
260
|
+
file input, interactions, plugin management, shared Runtime Profiles with
|
|
261
|
+
competing Session work, and host-owned process streams are outside this source
|
|
262
|
+
baseline.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ProviderAdapterFactory } from '@harapter/core';
|
|
2
|
+
import { type DshRawEvent } from './protocol.js';
|
|
3
|
+
/** Connection settings accepted by the DeepSeek Harness Provider Adapter. */
|
|
4
|
+
export interface DshProfileOptions {
|
|
5
|
+
readonly provider: string;
|
|
6
|
+
readonly model: string;
|
|
7
|
+
readonly reasoningEffort?: string;
|
|
8
|
+
readonly maxTokens?: number;
|
|
9
|
+
readonly maxBufferedMessages?: number;
|
|
10
|
+
readonly maxMessageBytes?: number;
|
|
11
|
+
readonly maxPendingInboundRequests?: number;
|
|
12
|
+
readonly maxPendingRequests?: number;
|
|
13
|
+
readonly maxPendingWrites?: number;
|
|
14
|
+
readonly maxRunEvents?: number;
|
|
15
|
+
readonly requestTimeoutMs?: number;
|
|
16
|
+
readonly shutdownTimeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Request options for explicit Provider-native SDK protocol calls. */
|
|
19
|
+
export interface DshNativeRequestOptions {
|
|
20
|
+
readonly signal?: AbortSignal;
|
|
21
|
+
readonly timeoutMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/** Provider extension for observing every bounded, redacted notification. */
|
|
24
|
+
export interface DshNotificationObserver {
|
|
25
|
+
onNotification(listener: (event: DshRawEvent) => void): () => void;
|
|
26
|
+
}
|
|
27
|
+
/** Explicit Provider-native escape hatch for initialized SDK protocol traffic. */
|
|
28
|
+
export interface DshNativeClient {
|
|
29
|
+
readonly runtimeIdentity: string;
|
|
30
|
+
request<TResult = unknown>(method: string, params?: unknown, options?: DshNativeRequestOptions): Promise<TResult>;
|
|
31
|
+
notify(method: string, params?: unknown): Promise<void>;
|
|
32
|
+
onUnknownEvent(listener: (event: DshRawEvent) => void): () => void;
|
|
33
|
+
}
|
|
34
|
+
/** Create a fresh DeepSeek Harness SDK Runtime Adapter factory. */
|
|
35
|
+
export declare function createDshProviderFactory(): ProviderAdapterFactory;
|
|
36
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAkBL,KAAK,sBAAsB,EAQ5B,MAAM,gBAAgB,CAAC;AASxB,OAAO,EAgBL,KAAK,WAAW,EAIjB,MAAM,eAAe,CAAC;AAgBvB,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,uEAAuE;AACvE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,6EAA6E;AAC7E,MAAM,WAAW,uBAAuB;IACtC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACpE;AAED,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,OAAO,CAAC,OAAO,GAAG,OAAO,EACvB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACpE;AAmBD,mEAAmE;AACnE,wBAAgB,wBAAwB,IAAI,sBAAsB,CAQjE"}
|