@harapter/adapter-pi 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 +228 -0
- package/dist/adapter.d.ts +40 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +1584 -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 +46 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +351 -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,228 @@
|
|
|
1
|
+
# `@harapter/adapter-pi`
|
|
2
|
+
|
|
3
|
+
`@harapter/adapter-pi` maps the official Pi Agent RPC mode to the portable
|
|
4
|
+
Harapter lifecycle.
|
|
5
|
+
|
|
6
|
+
The host installs, configures, authenticates, and operates Pi Agent. Harapter
|
|
7
|
+
starts only the exact adapter-owned command selected by the Profile. It does not
|
|
8
|
+
install a Pi Runtime or SDK, select models, manage credentials, read Session
|
|
9
|
+
files, or change host security policy.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add @harapter/core@next @harapter/adapter-pi@next
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Runtime prerequisites and compatibility
|
|
18
|
+
|
|
19
|
+
Connection requires the current documented `pi --mode rpc` strict LF-delimited
|
|
20
|
+
JSONL interface. The Adapter probes the supplied command with `--version`,
|
|
21
|
+
validates the semantic version response, and fails closed when required RPC
|
|
22
|
+
responses or events are incompatible. The Runtime release is not pinned; a
|
|
23
|
+
non-sensitive version hash participates in diagnostics and capability evidence.
|
|
24
|
+
|
|
25
|
+
The fixture manifest records the upstream source revision inspected for the
|
|
26
|
+
evidence baseline. That revision and Runtime version are provenance, not an
|
|
27
|
+
allowlist. Pi Agent is MIT licensed; Harapter does not redistribute it. See the
|
|
28
|
+
[license record](../../licenses/pi-agent.md).
|
|
29
|
+
|
|
30
|
+
## Profile and process ownership
|
|
31
|
+
|
|
32
|
+
A Pi Profile uses an adapter-owned process. The host provides the base command:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
36
|
+
import { PI_PROVIDER_ID, createPiProviderFactory } from '@harapter/adapter-pi';
|
|
37
|
+
|
|
38
|
+
const registry = new HarnessRegistry();
|
|
39
|
+
registry.register(createPiProviderFactory());
|
|
40
|
+
|
|
41
|
+
const client = await registry.connect({
|
|
42
|
+
profileId: profileId('pi-local'),
|
|
43
|
+
providerId: PI_PROVIDER_ID,
|
|
44
|
+
displayName: 'Pi Agent',
|
|
45
|
+
connection: {
|
|
46
|
+
kind: 'process',
|
|
47
|
+
command: '/opt/harapter-runtimes/bin/pi',
|
|
48
|
+
args: [],
|
|
49
|
+
ownership: 'adapter',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The Adapter appends
|
|
55
|
+
`--no-extensions --no-skills --no-prompt-templates --mode rpc` for each Session.
|
|
56
|
+
The host must provide an absolute executable path. Shell execution, unresolved
|
|
57
|
+
`envRefs`, external process ownership, explicit extensions, and arguments that
|
|
58
|
+
override RPC mode, Session ownership, credentials, system prompts, or resource
|
|
59
|
+
discovery policy are rejected. The Adapter does not inspect or interpolate
|
|
60
|
+
environment entries, but the child process inherits the host-controlled
|
|
61
|
+
environment that Pi may use for model configuration and authentication.
|
|
62
|
+
|
|
63
|
+
Profile `providerOptions` accepts positive bounded values for
|
|
64
|
+
`operationTimeoutMs`, `cancelSettlementTimeoutMs`, `maxRunEvents`,
|
|
65
|
+
`maxPendingInteractions`, `maxPendingRequests`, `maxBufferedMessages`,
|
|
66
|
+
`maxMessageBytes`, `maxPendingWrites`, and `writeTimeoutMs`. `persistSessions`
|
|
67
|
+
defaults to `true`; `false` adds `--no-session` and disables resume. Unknown
|
|
68
|
+
options are rejected. `maxRunEvents` must be between 2 and 4096 so an unread Run
|
|
69
|
+
queue always reserves terminal capacity.
|
|
70
|
+
|
|
71
|
+
## Session and Run lifecycle
|
|
72
|
+
|
|
73
|
+
Each Harapter Session owns a separate Pi RPC process. This permits parallel
|
|
74
|
+
Sessions without sharing Pi's mutable current-Session state, while each Session
|
|
75
|
+
allows one active Run. The child always uses the Profile working directory, so
|
|
76
|
+
version probing and Session execution interpret all Runtime arguments in the
|
|
77
|
+
same directory. The Adapter resolves an omitted or relative Profile working
|
|
78
|
+
directory once before probing. Portable per-Session Workspace selection is
|
|
79
|
+
unsupported.
|
|
80
|
+
|
|
81
|
+
After startup, the Adapter validates `get_state` and binds the native Session
|
|
82
|
+
identifier, persistence mode, Provider, Profile, and compatibility family in
|
|
83
|
+
`SessionRef`. Persisted resume starts a new process with `--session <native-id>`
|
|
84
|
+
and requires the opened Session to report the same identifier. Harapter does not
|
|
85
|
+
store or expose Pi Session-file paths and never implies that a Session reference
|
|
86
|
+
is portable to another Provider or Profile.
|
|
87
|
+
|
|
88
|
+
Session Workspace, system context, model selection, Session Provider options,
|
|
89
|
+
and metadata are unsupported. Portable Runs accept non-empty text only; multiple
|
|
90
|
+
text parts are joined with a newline. Input whose first non-whitespace character
|
|
91
|
+
is `/` is rejected because Pi can interpret it as a slash command or Session
|
|
92
|
+
mutation instead of an Agent Run. Extension, skill, and prompt-template
|
|
93
|
+
discovery are disabled so ordinary portable text cannot be intercepted and
|
|
94
|
+
reported as handled without an Agent lifecycle. Image, file, Provider-native
|
|
95
|
+
input parts, Run metadata, and Run Provider options remain unsupported.
|
|
96
|
+
|
|
97
|
+
Message, reasoning, tool lifecycle, usage, and extension UI observations map to
|
|
98
|
+
portable events. Tool identifiers are hashed, and tool arguments or results are
|
|
99
|
+
never retained in portable events. A successful `prompt` response proves only
|
|
100
|
+
that Pi accepted the command. `agent_end` can precede retry activity and is not
|
|
101
|
+
a stable terminal boundary. The Adapter waits for `agent_settled` and then uses
|
|
102
|
+
the most recent validated Assistant `message_end` as terminal authority:
|
|
103
|
+
|
|
104
|
+
- `stop` maps to `run.completed`;
|
|
105
|
+
- `aborted` maps to `run.cancelled` only after a correlated successful `abort`
|
|
106
|
+
response; an unsolicited aborted terminal fails the Run;
|
|
107
|
+
- `error`, `length`, `toolUse`, `deferred`, or `pending` maps to `run.failed`;
|
|
108
|
+
- a missing or malformed Assistant outcome fails closed;
|
|
109
|
+
- EOF, process loss, Client close, queue overflow, or unconfirmed cancellation
|
|
110
|
+
maps to `connection.aborted`.
|
|
111
|
+
|
|
112
|
+
Events received after the terminal boundary cannot append to or rewrite the
|
|
113
|
+
finished Run. Client and Session close reject with `connection_aborted` when
|
|
114
|
+
child-process exit cannot be confirmed after bounded termination. The Client
|
|
115
|
+
retains ownership records until cleanup succeeds, so a later close cannot report
|
|
116
|
+
success for an unconfirmed child.
|
|
117
|
+
|
|
118
|
+
## Cancellation, timeout, and interactions
|
|
119
|
+
|
|
120
|
+
`run.cancel()` sends the official `abort` command, waits for its response, and
|
|
121
|
+
reports `{ mode: 'native' }` only after an authoritative Assistant
|
|
122
|
+
`stopReason: 'aborted'` followed by `agent_settled`. An abort acknowledgement,
|
|
123
|
+
process termination, or connection loss alone is not cancellation evidence.
|
|
124
|
+
|
|
125
|
+
A positive `RunOptions.timeoutMs` invokes the same abort operation but remains
|
|
126
|
+
an emulated Harapter timer capability. If Pi does not establish the required
|
|
127
|
+
terminal result within the bounded settlement window, the owning connection is
|
|
128
|
+
aborted rather than reopened in an uncertain state.
|
|
129
|
+
|
|
130
|
+
Pi extension UI requests for `select`, `confirm`, `input`, and `editor` map to
|
|
131
|
+
portable Provider interactions. Their responses use the exported
|
|
132
|
+
`PiProviderInteractionResponse` union. This capability starts as `unknown` and
|
|
133
|
+
becomes `native` only after the connected Runtime emits a valid request.
|
|
134
|
+
Portable approval and user-input capabilities remain unsupported because the
|
|
135
|
+
official RPC surface exposes these calls as extension-owned UI methods rather
|
|
136
|
+
than a general permission contract.
|
|
137
|
+
|
|
138
|
+
## Unknown events, extension, and native access
|
|
139
|
+
|
|
140
|
+
Unknown RPC events remain observable as bounded `provider` events and through
|
|
141
|
+
`pi.agent.rpc.observations`. The observation channel limits nesting and
|
|
142
|
+
collection sizes, hashes arbitrary strings, numbers, and identifiers, and does
|
|
143
|
+
not retain prompts, paths, credentials, environment values, tool arguments, tool
|
|
144
|
+
results, or Provider errors. Unknown events never establish success.
|
|
145
|
+
|
|
146
|
+
`client.native()` returns a `PiNativeClient` that exposes the non-sensitive
|
|
147
|
+
Runtime identity, observation subscription, and ownership-preserving read
|
|
148
|
+
commands for an active Session. Arbitrary Run or Session mutation commands are
|
|
149
|
+
rejected. A bounded correlation tombstone consumes a matching late response
|
|
150
|
+
after a local read wait times out or is aborted; exhaustion closes the
|
|
151
|
+
connection rather than accepting an unmatched response. Native access remains
|
|
152
|
+
outside portable lifecycle and compatibility guarantees.
|
|
153
|
+
|
|
154
|
+
## Evidence and limitations
|
|
155
|
+
|
|
156
|
+
Evidence for this experimental Adapter includes:
|
|
157
|
+
|
|
158
|
+
- deterministic synthetic completion, cancellation, failure, interaction, and
|
|
159
|
+
unknown-event fixtures in
|
|
160
|
+
[`fixtures/pi/rpc-current`](../../fixtures/pi/rpc-current/manifest.json);
|
|
161
|
+
- mapping, ownership, resume, cancellation, retry, timeout, interaction,
|
|
162
|
+
disconnect, malformed-input, event-bound, process cleanup, version-probe,
|
|
163
|
+
native-access, and Provider-negative tests;
|
|
164
|
+
- the shared portable Provider conformance suite;
|
|
165
|
+
- an opt-in live lifecycle test for a host-installed Pi Runtime;
|
|
166
|
+
- a trusted live-canary path that installs the current official release on an
|
|
167
|
+
ephemeral runner and exercises a completed text Run, streamed Events, the
|
|
168
|
+
authoritative terminal, persisted Session resume, native cancellation, Session
|
|
169
|
+
close, and Client disposal.
|
|
170
|
+
|
|
171
|
+
The last repository-recorded live lifecycle run passed on 2026-09-03 with
|
|
172
|
+
`@earendil-works/pi-coding-agent@0.84.4` in
|
|
173
|
+
[Provider live canary run 33732602596](https://github.com/yunfeizhu/harapter/actions/runs/33732602596).
|
|
174
|
+
It verified current-package installation, version probing, the model-facing CLI
|
|
175
|
+
safety surface, RPC handshake, an exact completed text response, streamed
|
|
176
|
+
`message.completed` and authoritative `run.completed` Events, persisted Session
|
|
177
|
+
resume, correlated native cancellation with authoritative `run.cancelled`,
|
|
178
|
+
Session close, Client disposal, isolated-state cleanup, and the absence of tool
|
|
179
|
+
or interaction Events. It did not prove image or file input, extension UI
|
|
180
|
+
interactions, or other capabilities outside that path. A production host may pin
|
|
181
|
+
that release for reproducibility. Harapter continues to admit newer releases and
|
|
182
|
+
validates their observed structures instead of using the recorded version as an
|
|
183
|
+
executable allowlist. The Adapter remains experimental because the current RPC
|
|
184
|
+
family does not negotiate a protocol version that can bind an arbitrary
|
|
185
|
+
connected Runtime to this evidence before use.
|
|
186
|
+
|
|
187
|
+
Run live verification only when two synthetic text Prompts, one completed model
|
|
188
|
+
request, and one native cancellation attempt are acceptable to the host. The
|
|
189
|
+
isolated config must define a `harapter-live` model and reference
|
|
190
|
+
`HARAPTER_LIVE_MODEL_API_KEY` rather than storing the credential:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
pi_live_home="$(mktemp -d)"
|
|
194
|
+
trap 'rm -rf "$pi_live_home"' EXIT
|
|
195
|
+
mkdir -p "$pi_live_home/sessions"
|
|
196
|
+
|
|
197
|
+
HARAPTER_LIVE_MODEL_ID=... \
|
|
198
|
+
HARAPTER_LIVE_MODEL_URL=https://model.example/v1 \
|
|
199
|
+
node scripts/prepare-live-canary.mjs \
|
|
200
|
+
write-pi-config "$pi_live_home/config/models.json"
|
|
201
|
+
|
|
202
|
+
PI_CODING_AGENT_DIR="$pi_live_home/config" \
|
|
203
|
+
PI_CODING_AGENT_SESSION_DIR="$pi_live_home/sessions" \
|
|
204
|
+
PI_OFFLINE=1 \
|
|
205
|
+
PI_SKIP_VERSION_CHECK=1 \
|
|
206
|
+
PI_TELEMETRY=0 \
|
|
207
|
+
HARAPTER_LIVE_MODEL_API_KEY=... \
|
|
208
|
+
HARAPTER_PI_LIVE=1 \
|
|
209
|
+
HARAPTER_PI_COMMAND=/opt/harapter-runtimes/bin/pi \
|
|
210
|
+
HARAPTER_PI_MODEL=... \
|
|
211
|
+
pnpm vitest run providers/pi/test/live.test.ts
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The live test requires the exact completed response, a completed message Event,
|
|
215
|
+
and the authoritative completed Run Event. It resumes the same native Session,
|
|
216
|
+
then requires a correlated native cancellation and authoritative cancelled Run.
|
|
217
|
+
The Pi Runtime starts with tools, extensions, skills, prompt templates, and
|
|
218
|
+
context-file discovery disabled; any tool or interaction Event fails the test.
|
|
219
|
+
The test logs no Provider traffic and deletes its isolated Session state. A
|
|
220
|
+
skipped or failed live test is not support evidence. Passing trusted manual and
|
|
221
|
+
scheduled runs refresh evidence for the installed release without creating a
|
|
222
|
+
version allowlist or changing the unnegotiated compatibility boundary.
|
|
223
|
+
|
|
224
|
+
Image and file input, portable model selection, system-context overrides,
|
|
225
|
+
generic approvals, per-Session Workspace selection, Runtime extension loading,
|
|
226
|
+
skills, prompt templates, shared-process Session multiplexing, automatic process
|
|
227
|
+
restart, Session-file access, arbitrary native mutations, and live authenticated
|
|
228
|
+
extension-interaction evidence are outside the current compatibility boundary.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ProviderAdapterFactory, type ProviderSessionId } from '@harapter/core';
|
|
2
|
+
/** Connection limits accepted in a Pi Profile's providerOptions. */
|
|
3
|
+
export interface PiProfileOptions {
|
|
4
|
+
readonly cancelSettlementTimeoutMs?: number;
|
|
5
|
+
readonly maxBufferedMessages?: number;
|
|
6
|
+
readonly maxMessageBytes?: number;
|
|
7
|
+
readonly maxPendingInteractions?: number;
|
|
8
|
+
readonly maxPendingRequests?: number;
|
|
9
|
+
readonly maxPendingWrites?: number;
|
|
10
|
+
readonly maxRunEvents?: number;
|
|
11
|
+
readonly operationTimeoutMs?: number;
|
|
12
|
+
readonly persistSessions?: boolean;
|
|
13
|
+
readonly writeTimeoutMs?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Provider extension for observing bounded, redacted Pi RPC messages. */
|
|
16
|
+
export interface PiObservationExtension {
|
|
17
|
+
onObservation(listener: (event: unknown) => void): () => void;
|
|
18
|
+
}
|
|
19
|
+
/** Typed response accepted for a Pi extension UI interaction. */
|
|
20
|
+
export type PiProviderInteractionResponse = Readonly<{
|
|
21
|
+
cancelled: true;
|
|
22
|
+
}> | Readonly<{
|
|
23
|
+
confirmed: boolean;
|
|
24
|
+
}> | Readonly<{
|
|
25
|
+
value: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** Read-only Provider-native access that cannot mutate Session ownership. */
|
|
28
|
+
export interface PiNativeClient {
|
|
29
|
+
readonly runtimeIdentity: string;
|
|
30
|
+
request<TResult = unknown>(sessionId: ProviderSessionId, command: Readonly<Record<string, unknown>> & {
|
|
31
|
+
readonly type: string;
|
|
32
|
+
}, options?: Readonly<{
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
}>): Promise<TResult>;
|
|
36
|
+
onObservation(listener: (event: unknown) => void): () => void;
|
|
37
|
+
}
|
|
38
|
+
/** Create a fresh Pi Agent RPC Provider Adapter factory. */
|
|
39
|
+
export declare function createPiProviderFactory(): ProviderAdapterFactory;
|
|
40
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAQA,OAAO,EAmBL,KAAK,sBAAsB,EAE3B,KAAK,iBAAiB,EAMvB,MAAM,gBAAgB,CAAC;AAoFxB,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC,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,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/D;AAED,iEAAiE;AACjE,MAAM,MAAM,6BAA6B,GACrC,QAAQ,CAAC;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,GAC7B,QAAQ,CAAC;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,GAChC,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEhC,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,OAAO,CAAC,OAAO,GAAG,OAAO,EACvB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EACtE,OAAO,CAAC,EAAE,QAAQ,CAAC;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAC/D,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/D;AAyCD,4DAA4D;AAC5D,wBAAgB,uBAAuB,IAAI,sBAAsB,CAQhE"}
|