@harapter/core 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 +111 -0
- package/dist/contracts.d.ts +258 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +2 -0
- package/dist/contracts.js.map +1 -0
- package/dist/errors.d.ts +37 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +36 -0
- package/dist/errors.js.map +1 -0
- package/dist/extensions.d.ts +29 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +59 -0
- package/dist/extensions.js.map +1 -0
- package/dist/identifiers.d.ts +38 -0
- package/dist/identifiers.d.ts.map +1 -0
- package/dist/identifiers.js +45 -0
- package/dist/identifiers.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/ownership.d.ts +18 -0
- package/dist/ownership.d.ts.map +1 -0
- package/dist/ownership.js +34 -0
- package/dist/ownership.js.map +1 -0
- package/dist/registry.d.ts +27 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +234 -0
- package/dist/registry.js.map +1 -0
- package/package.json +46 -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,111 @@
|
|
|
1
|
+
# `@harapter/core`
|
|
2
|
+
|
|
3
|
+
`@harapter/core` is the provider-agnostic TypeScript API for Harapter. It owns
|
|
4
|
+
portable contracts and the runtime checks that can be applied without knowing a
|
|
5
|
+
Provider identity.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @harapter/core@next
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Public entrypoints
|
|
14
|
+
|
|
15
|
+
- `HarnessRegistry` dynamically registers Adapter factories and connects host
|
|
16
|
+
Profiles.
|
|
17
|
+
- `HarnessClient`, `HarnessSession`, and `HarnessRun` define the portable
|
|
18
|
+
lifecycle.
|
|
19
|
+
- `HarnessEvent` and `RunResult` define ordered events and one terminal result.
|
|
20
|
+
- `CapabilityManifest` distinguishes `native`, `emulated`, `adapter_controlled`,
|
|
21
|
+
`unsupported`, and `unknown`; a missing key means the active Adapter does not
|
|
22
|
+
recognize that capability name.
|
|
23
|
+
- `HarnessError` carries a stable category and an explicit retry decision.
|
|
24
|
+
- `ExtensionRegistry` provides typed, Provider-bound extension lookup.
|
|
25
|
+
- `native()` exposes an explicit Provider-bound escape hatch.
|
|
26
|
+
- `assertSessionOwnership()` rejects a Session reference whose Provider or
|
|
27
|
+
Profile differs from the active Client before resume traffic is sent.
|
|
28
|
+
- `assertSessionCompatibility()` rejects a Session reference whose runtime or
|
|
29
|
+
protocol fingerprint differs from the active Client.
|
|
30
|
+
|
|
31
|
+
`HarnessRegistry.connect()` checks the registered connection kind, Client
|
|
32
|
+
descriptor identity, and Capability Manifest identity on every connection, then
|
|
33
|
+
checks any requested capability modes. `CapabilityRequirement.acceptedModes`
|
|
34
|
+
defaults to `native`; a host must opt in to weaker modes explicitly. Registry
|
|
35
|
+
validation uses an isolated Profile snapshot so an Adapter cannot rewrite the
|
|
36
|
+
requested identity or requirements. Once a Client exists, descriptor or
|
|
37
|
+
capability probe failures close it before a safe portable error is returned.
|
|
38
|
+
|
|
39
|
+
## Lifecycle
|
|
40
|
+
|
|
41
|
+
A `SessionRef` remains bound to the Provider and Profile that created it. Core
|
|
42
|
+
does not inspect `providerState`, parse Provider-native identifiers, migrate
|
|
43
|
+
checkpoints, or infer resume support.
|
|
44
|
+
|
|
45
|
+
A Run event sequence is monotonic and ends in exactly one of `run.completed`,
|
|
46
|
+
`run.cancelled`, `run.failed`, or `connection.aborted`. A connection or process
|
|
47
|
+
abort is not native Run cancellation. Native, emulated, and Adapter-controlled
|
|
48
|
+
cancellation return distinct results. Adapters own event production and
|
|
49
|
+
terminal-result mapping; the shared conformance package checks these obligations
|
|
50
|
+
through the public interfaces.
|
|
51
|
+
|
|
52
|
+
`close()` is asynchronous and must be idempotent. A Client rejected during
|
|
53
|
+
Registry validation is closed before the validation error is returned. Cleanup
|
|
54
|
+
failure is reported as `connection_failed` without attaching an unredacted
|
|
55
|
+
cause.
|
|
56
|
+
|
|
57
|
+
## Errors and sensitive data
|
|
58
|
+
|
|
59
|
+
Every `HarnessError` requires callers to state `retryable`; Core does not infer
|
|
60
|
+
retry behavior from a Provider name or error message. Provider causes and
|
|
61
|
+
details must be redacted before an Adapter attaches them. Hosts should not log
|
|
62
|
+
`cause`, `providerState`, raw events, or Provider results by default.
|
|
63
|
+
|
|
64
|
+
Profiles carry Secret references, not credential values. Credential resolution,
|
|
65
|
+
runtime installation, authentication, process policy, and product persistence
|
|
66
|
+
remain host or Provider responsibilities.
|
|
67
|
+
|
|
68
|
+
## Example
|
|
69
|
+
|
|
70
|
+
The deterministic Fake Provider gives the Core flow executable evidence without
|
|
71
|
+
introducing a Provider dependency:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { HarnessRegistry } from '@harapter/core';
|
|
75
|
+
import {
|
|
76
|
+
createFakeProfile,
|
|
77
|
+
createFakeProviderFactory,
|
|
78
|
+
} from '@harapter/conformance';
|
|
79
|
+
|
|
80
|
+
const registry = new HarnessRegistry();
|
|
81
|
+
registry.register(createFakeProviderFactory());
|
|
82
|
+
|
|
83
|
+
const client = await registry.connect(createFakeProfile());
|
|
84
|
+
const session = await client.createSession();
|
|
85
|
+
const run = await session.start({
|
|
86
|
+
parts: [{ type: 'text', text: 'synthetic input' }],
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
for await (const event of run.events()) {
|
|
90
|
+
console.log(event.type);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const result = await run.result();
|
|
94
|
+
await session.close();
|
|
95
|
+
await client.close();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Limitations
|
|
99
|
+
|
|
100
|
+
- No Provider Adapter, transport, canonical wire schema, persistence layer, or
|
|
101
|
+
runtime installer is included.
|
|
102
|
+
- Core defines event ordering and terminality but does not buffer, redact, or
|
|
103
|
+
reinterpret Provider streams. Each Adapter and transport must prove bounded
|
|
104
|
+
buffering, redaction, and terminal mapping.
|
|
105
|
+
- Interaction, artifact, usage, resume, cancellation, and other optional
|
|
106
|
+
behavior depend on the active Capability Manifest.
|
|
107
|
+
- The public API remains pre-alpha. Published packages use the opt-in `next`
|
|
108
|
+
dist-tag and may contain breaking changes before 1.0.
|
|
109
|
+
|
|
110
|
+
The complete target contract remains in the
|
|
111
|
+
[API design](../../docs/design/api-design.md).
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import type { ProfileId, ProviderId, ProviderSessionId, RunId } from './identifiers.js';
|
|
2
|
+
/** Supported connection ownership and transport families. */
|
|
3
|
+
export type ConnectionKind = 'sdk' | 'process' | 'endpoint' | 'local_socket';
|
|
4
|
+
/** Reference resolved by a host-controlled secret store. */
|
|
5
|
+
export interface SecretRef {
|
|
6
|
+
readonly scheme: string;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
}
|
|
9
|
+
/** Provider connection selected by a host Profile. */
|
|
10
|
+
export type ProviderConnection = {
|
|
11
|
+
kind: 'sdk';
|
|
12
|
+
client?: unknown;
|
|
13
|
+
factory?: unknown;
|
|
14
|
+
ownership: 'host' | 'adapter';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'process';
|
|
17
|
+
command: string;
|
|
18
|
+
args?: readonly string[];
|
|
19
|
+
cwd?: string;
|
|
20
|
+
envRefs?: Readonly<Record<string, SecretRef>>;
|
|
21
|
+
ownership: 'host' | 'adapter' | 'external';
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'endpoint';
|
|
24
|
+
url: string;
|
|
25
|
+
transport?: 'http' | 'sse' | 'websocket' | 'acp';
|
|
26
|
+
authRef?: SecretRef;
|
|
27
|
+
ownership: 'host' | 'external';
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'local_socket';
|
|
30
|
+
path: string;
|
|
31
|
+
transport: 'http' | 'jsonrpc' | 'acp';
|
|
32
|
+
authRef?: SecretRef;
|
|
33
|
+
ownership: 'host' | 'external';
|
|
34
|
+
};
|
|
35
|
+
/** Host-owned selectable configuration for one Provider connection. */
|
|
36
|
+
export interface HarnessProfile {
|
|
37
|
+
readonly profileId: ProfileId;
|
|
38
|
+
readonly displayName: string;
|
|
39
|
+
readonly providerId: ProviderId;
|
|
40
|
+
readonly connection: ProviderConnection;
|
|
41
|
+
readonly providerOptions?: Readonly<Record<string, unknown>>;
|
|
42
|
+
readonly requiredCapabilities?: readonly CapabilityRequirement[];
|
|
43
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
44
|
+
}
|
|
45
|
+
/** Static Adapter metadata used for dynamic discovery. */
|
|
46
|
+
export interface ProviderDescriptor {
|
|
47
|
+
providerId: ProviderId;
|
|
48
|
+
displayName: string;
|
|
49
|
+
connectionKinds: readonly ConnectionKind[];
|
|
50
|
+
documentationUrl?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Factory implemented by one independently versioned Provider package. */
|
|
53
|
+
export interface ProviderAdapterFactory {
|
|
54
|
+
descriptor(): ProviderDescriptor;
|
|
55
|
+
connect(profile: HarnessProfile): Promise<HarnessClient>;
|
|
56
|
+
}
|
|
57
|
+
/** Runtime description of an active Profile connection. */
|
|
58
|
+
export interface ClientDescriptor {
|
|
59
|
+
providerId: ProviderId;
|
|
60
|
+
profileId: ProfileId;
|
|
61
|
+
displayName: string;
|
|
62
|
+
connectionKind: ConnectionKind;
|
|
63
|
+
runtime?: {
|
|
64
|
+
name?: string;
|
|
65
|
+
version?: string;
|
|
66
|
+
protocol?: string;
|
|
67
|
+
protocolVersion?: string;
|
|
68
|
+
};
|
|
69
|
+
compatibility: 'supported' | 'experimental' | 'unsupported';
|
|
70
|
+
warnings?: readonly CompatibilityWarning[];
|
|
71
|
+
}
|
|
72
|
+
/** Non-sensitive compatibility diagnostic. */
|
|
73
|
+
export interface CompatibilityWarning {
|
|
74
|
+
code: string;
|
|
75
|
+
message: string;
|
|
76
|
+
}
|
|
77
|
+
/** Capability implementation strength observed for the active connection. */
|
|
78
|
+
export type CapabilityMode = 'native' | 'emulated' | 'adapter_controlled' | 'unsupported' | 'unknown';
|
|
79
|
+
/** Runtime evidence for one portable or Provider-namespaced capability. */
|
|
80
|
+
export interface CapabilityStatus {
|
|
81
|
+
mode: CapabilityMode;
|
|
82
|
+
reason?: string;
|
|
83
|
+
limits?: Readonly<Record<string, number | string | boolean>>;
|
|
84
|
+
source?: 'handshake' | 'schema' | 'version_profile' | 'configuration';
|
|
85
|
+
}
|
|
86
|
+
/** Capability observations for one active Profile connection. */
|
|
87
|
+
export interface CapabilityManifest {
|
|
88
|
+
providerId: ProviderId;
|
|
89
|
+
profileId: ProfileId;
|
|
90
|
+
capabilities: Readonly<Record<string, CapabilityStatus>>;
|
|
91
|
+
observedAt: string;
|
|
92
|
+
runtimeIdentity?: string;
|
|
93
|
+
}
|
|
94
|
+
/** Host requirement checked before a Registry returns a connected Client. */
|
|
95
|
+
export interface CapabilityRequirement {
|
|
96
|
+
readonly name: string;
|
|
97
|
+
readonly acceptedModes?: readonly CapabilityMode[];
|
|
98
|
+
}
|
|
99
|
+
/** Options for refreshing or reusing capability observations. */
|
|
100
|
+
export interface CapabilityProbeOptions {
|
|
101
|
+
refresh?: boolean;
|
|
102
|
+
}
|
|
103
|
+
/** Portable Client bound to one Provider and Profile. */
|
|
104
|
+
export interface HarnessClient {
|
|
105
|
+
descriptor(): Promise<ClientDescriptor>;
|
|
106
|
+
capabilities(options?: CapabilityProbeOptions): Promise<CapabilityManifest>;
|
|
107
|
+
createSession(input?: CreateSessionInput): Promise<HarnessSession>;
|
|
108
|
+
resumeSession(ref: SessionRef): Promise<HarnessSession>;
|
|
109
|
+
extensions(): ProviderExtensionRegistry;
|
|
110
|
+
native<T = unknown>(guard?: (value: unknown) => value is T): T | undefined;
|
|
111
|
+
close(): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
/** Optional settings applied while creating a Provider session. */
|
|
114
|
+
export interface CreateSessionInput {
|
|
115
|
+
workspace?: WorkspaceRef;
|
|
116
|
+
systemContext?: string;
|
|
117
|
+
model?: ModelSelection;
|
|
118
|
+
providerOptions?: Readonly<Record<string, unknown>>;
|
|
119
|
+
metadata?: Readonly<Record<string, string>>;
|
|
120
|
+
}
|
|
121
|
+
/** Portable Session bound to the Client that created it. */
|
|
122
|
+
export interface HarnessSession {
|
|
123
|
+
ref(): SessionRef;
|
|
124
|
+
capabilities(): Promise<CapabilityManifest>;
|
|
125
|
+
start(input: HarnessInput, options?: RunOptions): Promise<HarnessRun>;
|
|
126
|
+
respond(requestId: string, response: InteractionResponse): Promise<void>;
|
|
127
|
+
close(): Promise<void>;
|
|
128
|
+
}
|
|
129
|
+
/** Persistable opaque reference that only its owning Adapter may interpret. */
|
|
130
|
+
export interface SessionRef {
|
|
131
|
+
providerId: ProviderId;
|
|
132
|
+
profileId: ProfileId;
|
|
133
|
+
providerSessionId: ProviderSessionId;
|
|
134
|
+
compatibilityRef?: string;
|
|
135
|
+
providerState?: unknown;
|
|
136
|
+
}
|
|
137
|
+
/** One active execution on a Session. */
|
|
138
|
+
export interface HarnessRun {
|
|
139
|
+
ref(): RunRef;
|
|
140
|
+
events(): AsyncIterable<HarnessEvent>;
|
|
141
|
+
cancel(): Promise<CancelResult>;
|
|
142
|
+
result(): Promise<RunResult>;
|
|
143
|
+
}
|
|
144
|
+
/** Stable reference for one Client-scoped Run. */
|
|
145
|
+
export interface RunRef {
|
|
146
|
+
providerId: ProviderId;
|
|
147
|
+
profileId: ProfileId;
|
|
148
|
+
sessionId: ProviderSessionId;
|
|
149
|
+
runId: RunId;
|
|
150
|
+
providerRunId?: string;
|
|
151
|
+
}
|
|
152
|
+
/** Portable run controls and Provider-local options. */
|
|
153
|
+
export interface RunOptions {
|
|
154
|
+
timeoutMs?: number;
|
|
155
|
+
providerOptions?: Readonly<Record<string, unknown>>;
|
|
156
|
+
metadata?: Readonly<Record<string, string>>;
|
|
157
|
+
}
|
|
158
|
+
/** Observable result of a cancellation request. */
|
|
159
|
+
export interface CancelResult {
|
|
160
|
+
mode: 'native' | 'emulated' | 'connection_aborted' | 'already_terminal';
|
|
161
|
+
}
|
|
162
|
+
/** Portable user input. */
|
|
163
|
+
export interface HarnessInput {
|
|
164
|
+
parts: readonly InputPart[];
|
|
165
|
+
metadata?: Readonly<Record<string, string>>;
|
|
166
|
+
}
|
|
167
|
+
/** One Provider-independent or explicit Provider-native input part. */
|
|
168
|
+
export type InputPart = {
|
|
169
|
+
type: 'text';
|
|
170
|
+
text: string;
|
|
171
|
+
} | {
|
|
172
|
+
type: 'file_ref';
|
|
173
|
+
uri: string;
|
|
174
|
+
mediaType?: string;
|
|
175
|
+
} | {
|
|
176
|
+
type: 'image_ref';
|
|
177
|
+
uri: string;
|
|
178
|
+
mediaType?: string;
|
|
179
|
+
} | {
|
|
180
|
+
type: 'provider';
|
|
181
|
+
name: string;
|
|
182
|
+
value: unknown;
|
|
183
|
+
};
|
|
184
|
+
/** URI reference to the workspace a Provider may use. */
|
|
185
|
+
export interface WorkspaceRef {
|
|
186
|
+
uri: string;
|
|
187
|
+
}
|
|
188
|
+
/** Provider-owned model identifier plus Provider-local selection options. */
|
|
189
|
+
export interface ModelSelection {
|
|
190
|
+
id: string;
|
|
191
|
+
providerOptions?: Readonly<Record<string, unknown>>;
|
|
192
|
+
}
|
|
193
|
+
/** Stable portable event vocabulary. */
|
|
194
|
+
export type HarnessEventType = 'run.started' | 'message.delta' | 'message.completed' | 'reasoning.delta' | 'reasoning.completed' | 'tool.started' | 'tool.updated' | 'tool.completed' | 'interaction.requested' | 'interaction.resolved' | 'artifact.created' | 'usage.updated' | 'run.completed' | 'run.cancelled' | 'run.failed' | 'connection.aborted' | 'provider';
|
|
195
|
+
/** One ordered event emitted by a Run. */
|
|
196
|
+
export interface HarnessEvent<T = unknown> {
|
|
197
|
+
id: string;
|
|
198
|
+
type: HarnessEventType;
|
|
199
|
+
providerId: ProviderId;
|
|
200
|
+
profileId: ProfileId;
|
|
201
|
+
sessionId: ProviderSessionId;
|
|
202
|
+
runId: RunId;
|
|
203
|
+
sequence: number;
|
|
204
|
+
timestamp: string;
|
|
205
|
+
data: T;
|
|
206
|
+
providerEventType?: string;
|
|
207
|
+
raw?: unknown;
|
|
208
|
+
}
|
|
209
|
+
/** Portable interaction requested by a Provider. */
|
|
210
|
+
export interface InteractionRequest {
|
|
211
|
+
requestId: string;
|
|
212
|
+
kind: 'approval' | 'user_input' | 'provider';
|
|
213
|
+
title?: string;
|
|
214
|
+
prompt?: string;
|
|
215
|
+
schema?: unknown;
|
|
216
|
+
providerState?: unknown;
|
|
217
|
+
}
|
|
218
|
+
/** Host response to a pending interaction. */
|
|
219
|
+
export type InteractionResponse = {
|
|
220
|
+
kind: 'approval';
|
|
221
|
+
decision: 'approve' | 'deny';
|
|
222
|
+
providerOptions?: unknown;
|
|
223
|
+
} | {
|
|
224
|
+
kind: 'user_input';
|
|
225
|
+
parts: readonly InputPart[];
|
|
226
|
+
} | {
|
|
227
|
+
kind: 'provider';
|
|
228
|
+
value: unknown;
|
|
229
|
+
};
|
|
230
|
+
/** Token accounting when the Provider exposes it. */
|
|
231
|
+
export interface UsageSummary {
|
|
232
|
+
inputTokens?: number;
|
|
233
|
+
outputTokens?: number;
|
|
234
|
+
totalTokens?: number;
|
|
235
|
+
}
|
|
236
|
+
/** Exactly one terminal outcome for a Run. */
|
|
237
|
+
export interface RunResult {
|
|
238
|
+
status: 'completed' | 'cancelled' | 'failed' | 'connection_aborted';
|
|
239
|
+
finalMessage?: string;
|
|
240
|
+
usage?: UsageSummary;
|
|
241
|
+
providerResult?: unknown;
|
|
242
|
+
}
|
|
243
|
+
/** Read-only Provider extension lookup. */
|
|
244
|
+
export interface ProviderExtensionRegistry {
|
|
245
|
+
list(): readonly ProviderExtensionDescriptor[];
|
|
246
|
+
has(name: string): boolean;
|
|
247
|
+
get<T>(name: string, guard?: (value: unknown) => value is T): T | undefined;
|
|
248
|
+
}
|
|
249
|
+
/** Discoverable metadata for one typed Provider extension. */
|
|
250
|
+
export interface ProviderExtensionDescriptor {
|
|
251
|
+
name: string;
|
|
252
|
+
providerId: ProviderId;
|
|
253
|
+
displayName: string;
|
|
254
|
+
description?: string;
|
|
255
|
+
documentationUrl?: string;
|
|
256
|
+
stability?: 'stable' | 'experimental';
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,KAAK,EACN,MAAM,kBAAkB,CAAC;AAE1B,6DAA6D;AAC7D,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,cAAc,CAAC;AAE7E,4DAA4D;AAC5D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,sDAAsD;AACtD,MAAM,MAAM,kBAAkB,GAC1B;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,GACD;IACE,IAAI,EA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EzC,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,8CAA8C;AAC9C,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,oBAAoB,CAAC;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,2CAA2C;AAC3C,MAAM,WAAW,yBAAyB;IACxC,IAAI,IAAI,SAAS,2BAA2B,EAAE,CAAC;IAC/C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;CAC7E;AAED,8DAA8D;AAC9D,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,QAAQ,GAAG,cAAc,CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":""}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ProfileId, ProviderId } from './identifiers.js';
|
|
2
|
+
/** Stable portable error categories. */
|
|
3
|
+
export type HarnessErrorCode = 'provider_not_found' | 'profile_invalid' | 'runtime_not_found' | 'connection_failed' | 'authentication_failed' | 'provider_api_incompatible' | 'unsupported_capability' | 'invalid_request' | 'session_not_found' | 'session_provider_mismatch' | 'run_conflict' | 'timeout' | 'provider_error' | 'connection_aborted';
|
|
4
|
+
/** Explicit diagnostics supplied when constructing a portable error. */
|
|
5
|
+
export interface HarnessErrorOptions {
|
|
6
|
+
retryable: boolean;
|
|
7
|
+
providerId?: ProviderId;
|
|
8
|
+
profileId?: ProfileId;
|
|
9
|
+
providerCode?: string;
|
|
10
|
+
details?: Readonly<Record<string, unknown>>;
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Portable failure with an explicit stable category and retry decision.
|
|
15
|
+
* Provider causes must be redacted before they are attached.
|
|
16
|
+
*/
|
|
17
|
+
export declare class HarnessError extends Error {
|
|
18
|
+
readonly code: HarnessErrorCode;
|
|
19
|
+
readonly retryable: boolean;
|
|
20
|
+
readonly providerId: ProviderId | undefined;
|
|
21
|
+
readonly profileId: ProfileId | undefined;
|
|
22
|
+
readonly providerCode: string | undefined;
|
|
23
|
+
readonly details: Readonly<Record<string, unknown>> | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* @param code - Stable portable category.
|
|
26
|
+
* @param message - Safe human-readable summary.
|
|
27
|
+
* @param options - Explicit retry and redacted Provider diagnostics.
|
|
28
|
+
*/
|
|
29
|
+
constructor(code: HarnessErrorCode, message: string, options: HarnessErrorOptions);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Narrow an unknown failure to {@link HarnessError}.
|
|
33
|
+
* @param error - Unknown thrown value.
|
|
34
|
+
* @returns Whether the value is a portable Harapter error.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isHarnessError(error: unknown): error is HarnessError;
|
|
37
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable failure with an explicit stable category and retry decision.
|
|
3
|
+
* Provider causes must be redacted before they are attached.
|
|
4
|
+
*/
|
|
5
|
+
export class HarnessError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
retryable;
|
|
8
|
+
providerId;
|
|
9
|
+
profileId;
|
|
10
|
+
providerCode;
|
|
11
|
+
details;
|
|
12
|
+
/**
|
|
13
|
+
* @param code - Stable portable category.
|
|
14
|
+
* @param message - Safe human-readable summary.
|
|
15
|
+
* @param options - Explicit retry and redacted Provider diagnostics.
|
|
16
|
+
*/
|
|
17
|
+
constructor(code, message, options) {
|
|
18
|
+
super(message, { cause: options.cause });
|
|
19
|
+
this.name = 'HarnessError';
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.retryable = options.retryable;
|
|
22
|
+
this.providerId = options.providerId;
|
|
23
|
+
this.profileId = options.profileId;
|
|
24
|
+
this.providerCode = options.providerCode;
|
|
25
|
+
this.details = options.details;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Narrow an unknown failure to {@link HarnessError}.
|
|
30
|
+
* @param error - Unknown thrown value.
|
|
31
|
+
* @returns Whether the value is a portable Harapter error.
|
|
32
|
+
*/
|
|
33
|
+
export function isHarnessError(error) {
|
|
34
|
+
return error instanceof HarnessError;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=errors.js.map
|