@cotal-ai/pi 0.11.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 +202 -0
- package/README.md +66 -0
- package/dist/connector.d.ts +3 -0
- package/dist/connector.d.ts.map +1 -0
- package/dist/connector.js +98 -0
- package/dist/connector.js.map +1 -0
- package/dist/driver.d.ts +74 -0
- package/dist/driver.d.ts.map +1 -0
- package/dist/driver.js +347 -0
- package/dist/driver.js.map +1 -0
- package/dist/extension.d.ts +4 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +135 -0
- package/dist/extension.js.map +1 -0
- package/dist/inbox-turn.d.ts +43 -0
- package/dist/inbox-turn.d.ts.map +1 -0
- package/dist/inbox-turn.js +108 -0
- package/dist/inbox-turn.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/standalone.d.ts +2 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/standalone.js +48299 -0
- package/dist/standalone.js.map +1 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +113 -0
- package/dist/tools.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @cotal-ai/pi
|
|
2
|
+
|
|
3
|
+
Cotal as an extension for the operator's own [Pi coding agent](https://github.com/earendil-works/pi).
|
|
4
|
+
The package does not bundle Pi.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
- Cotal and this package: Node 20 or newer.
|
|
9
|
+
- The Pi host: exactly `@earendil-works/pi-coding-agent@0.79.10` for this release.
|
|
10
|
+
- `pi` on `PATH` for managed spawning.
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
The published `cotal-ai` binary registers the connector:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g cotal-ai @earendil-works/pi-coding-agent@0.79.10
|
|
18
|
+
cotal up
|
|
19
|
+
cotal spawn default --detach --agent pi
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
To make ordinary interactive Pi sessions mesh-capable, copy the standalone artifact once:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
mkdir -p ~/.pi/agent/extensions
|
|
26
|
+
cp node_modules/@cotal-ai/pi/dist/standalone.js ~/.pi/agent/extensions/cotal.js
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The copied file has no repository-local or sibling-file imports. It activates only when a real
|
|
30
|
+
Cotal identity (`COTAL_NAME`, `COTAL_AGENT_FILE`, or `COTAL_LINK`) is present. Unrelated operator
|
|
31
|
+
settings such as `COTAL_HOME` and `COTAL_DEFAULT_AGENT` leave it inert. Pi SDK embedders using its
|
|
32
|
+
default resource loader discover the same file; embedders must bind extension lifecycle events as
|
|
33
|
+
required by Pi's SDK if they expect proactive delivery into an idle session.
|
|
34
|
+
|
|
35
|
+
## Delivery
|
|
36
|
+
|
|
37
|
+
Inbound traffic is injected as a `cotal-inbox` custom message. Its opaque batch details must appear
|
|
38
|
+
in Pi's `message_start` and in the exact provider `context`. A successful `after_provider_response`
|
|
39
|
+
confirms the batch early when the transport exposes an HTTP response; transports such as the Codex
|
|
40
|
+
subscription may omit that hook, so an exact context is confirmed instead by its following clean
|
|
41
|
+
terminal boundary. Acknowledgement waits for that boundary and drains only an exact current inbox
|
|
42
|
+
prefix.
|
|
43
|
+
|
|
44
|
+
- Crash or quit before a terminal boundary: acknowledge nothing; durable traffic redelivers.
|
|
45
|
+
- Non-aborted `stop`, `toolUse`, and non-overflow `length` (positive output) are terminal and may
|
|
46
|
+
commit confirmed work. Error, abort, zero/missing-output `length`, and unknown stop reasons retain
|
|
47
|
+
the association in observable `waiting`; Pi exposes no retry-finality event, so retained work waits
|
|
48
|
+
for a later proven terminal boundary.
|
|
49
|
+
- Overflow compaction with `willRetry`: retain the batch through Pi's automatic continuation.
|
|
50
|
+
- Watchdog or headless abort: never timer-replay while the original provider call may still run;
|
|
51
|
+
managed restart is the safe recovery path.
|
|
52
|
+
|
|
53
|
+
The custom delivery path bypasses Pi's operator `input` transformation chain, because peer traffic
|
|
54
|
+
is attributed context rather than a human prompt. Provider hooks, tool hooks, and Pi's normal
|
|
55
|
+
permission/sandbox extensions still run. Replies remain deliberate model actions through
|
|
56
|
+
`cotal_dm`, `cotal_send`, or `cotal_anycast`; chat output alone is not sent to peers.
|
|
57
|
+
|
|
58
|
+
Pi resume, model variants, MCP sharing, and raw launch options are not implemented and fail loudly.
|
|
59
|
+
Persona files and `--model` are supported; an explicit spawn model wins over the persona file.
|
|
60
|
+
|
|
61
|
+
## Credits
|
|
62
|
+
|
|
63
|
+
The original Pi integration and inbox-turn design were contributed by
|
|
64
|
+
[Lanzelot1](https://github.com/Lanzelot1). Persona and model forwarding were contributed by
|
|
65
|
+
[TheReaperJay](https://github.com/TheReaperJay). Their authored commits remain in the integration
|
|
66
|
+
history; this package keeps the resulting Pi-specific code and behavior.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,SAAS,EAGf,MAAM,gBAAgB,CAAC;AA+CxB,eAAO,MAAM,WAAW,EAAE,SAqDzB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { mkdtempSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { hardenPrivate, loadAgentFile, registry, writeSecretFile, } from "@cotal-ai/core";
|
|
6
|
+
import { aclEnv, connectorLaunchOptions, controlEndpoint, launchEnv, userAuthEnv, } from "@cotal-ai/connector-core";
|
|
7
|
+
const STANDALONE = fileURLToPath(import.meta.url.includes("/dist/") ? new URL("./standalone.js", import.meta.url) : new URL("../dist/standalone.js", import.meta.url));
|
|
8
|
+
/** Provider environment names recognized by the pinned Pi 0.79.10 host. Kept Pi-local so adding a
|
|
9
|
+
* provider here never expands the secret surface of sibling connectors. */
|
|
10
|
+
const PI_PROVIDER_KEYS = [
|
|
11
|
+
"ANTHROPIC_OAUTH_TOKEN",
|
|
12
|
+
"ANTHROPIC_API_KEY",
|
|
13
|
+
"OPENAI_API_KEY",
|
|
14
|
+
"OPENROUTER_API_KEY",
|
|
15
|
+
"OPENCODE_API_KEY",
|
|
16
|
+
"GEMINI_API_KEY",
|
|
17
|
+
"GOOGLE_CLOUD_API_KEY",
|
|
18
|
+
"GROQ_API_KEY",
|
|
19
|
+
"CEREBRAS_API_KEY",
|
|
20
|
+
"DEEPSEEK_API_KEY",
|
|
21
|
+
"MISTRAL_API_KEY",
|
|
22
|
+
"XAI_API_KEY",
|
|
23
|
+
"ZAI_API_KEY",
|
|
24
|
+
"ZAI_CODING_CN_API_KEY",
|
|
25
|
+
"MINIMAX_API_KEY",
|
|
26
|
+
"MINIMAX_CN_API_KEY",
|
|
27
|
+
"MOONSHOT_API_KEY",
|
|
28
|
+
"FIREWORKS_API_KEY",
|
|
29
|
+
"TOGETHER_API_KEY",
|
|
30
|
+
"NVIDIA_API_KEY",
|
|
31
|
+
"KIMI_API_KEY",
|
|
32
|
+
"HF_TOKEN",
|
|
33
|
+
"COPILOT_GITHUB_TOKEN",
|
|
34
|
+
"AI_GATEWAY_API_KEY",
|
|
35
|
+
"CLOUDFLARE_API_KEY",
|
|
36
|
+
"XIAOMI_API_KEY",
|
|
37
|
+
"XIAOMI_TOKEN_PLAN_CN_API_KEY",
|
|
38
|
+
"XIAOMI_TOKEN_PLAN_AMS_API_KEY",
|
|
39
|
+
"XIAOMI_TOKEN_PLAN_SGP_API_KEY",
|
|
40
|
+
];
|
|
41
|
+
export const piConnector = {
|
|
42
|
+
kind: "connector",
|
|
43
|
+
name: "pi",
|
|
44
|
+
requires: ["pi"],
|
|
45
|
+
buildLaunch(opts) {
|
|
46
|
+
if (opts.resume)
|
|
47
|
+
throw new Error("pi connector: resuming an existing session (resume) is not implemented");
|
|
48
|
+
if (opts.variant)
|
|
49
|
+
throw new Error("pi connector: model variants (variant) are not implemented");
|
|
50
|
+
if (opts.mcpServers && Object.keys(opts.mcpServers).length > 0)
|
|
51
|
+
throw new Error("pi connector: MCP tool-sharing is not implemented");
|
|
52
|
+
if (connectorLaunchOptions("pi", opts.launchOptions).length > 0)
|
|
53
|
+
throw new Error("pi connector: launch options (--opt / launchOptions) are not implemented");
|
|
54
|
+
let model = opts.model;
|
|
55
|
+
let persona;
|
|
56
|
+
if (opts.configPath) {
|
|
57
|
+
const definition = loadAgentFile(opts.configPath);
|
|
58
|
+
model ??= definition.model;
|
|
59
|
+
persona = definition.persona;
|
|
60
|
+
}
|
|
61
|
+
const env = {
|
|
62
|
+
...launchEnv({ providerKeys: PI_PROVIDER_KEYS }),
|
|
63
|
+
...aclEnv(opts),
|
|
64
|
+
...userAuthEnv(opts),
|
|
65
|
+
COTAL_SPACE: opts.space,
|
|
66
|
+
COTAL_NAME: opts.name,
|
|
67
|
+
};
|
|
68
|
+
if (opts.role)
|
|
69
|
+
env.COTAL_ROLE = opts.role;
|
|
70
|
+
if (opts.id)
|
|
71
|
+
env.COTAL_ID = opts.id;
|
|
72
|
+
if (opts.creds)
|
|
73
|
+
env.COTAL_CREDS = opts.creds;
|
|
74
|
+
if (opts.servers)
|
|
75
|
+
env.COTAL_SERVERS = opts.servers;
|
|
76
|
+
if (opts.configPath)
|
|
77
|
+
env.COTAL_AGENT_FILE = opts.configPath;
|
|
78
|
+
const args = ["--extension", STANDALONE];
|
|
79
|
+
if (persona) {
|
|
80
|
+
const dir = mkdtempSync(join(tmpdir(), "cotal-persona-"));
|
|
81
|
+
hardenPrivate(dir, "dir");
|
|
82
|
+
const file = join(dir, "persona.md");
|
|
83
|
+
writeSecretFile(file, persona);
|
|
84
|
+
env.COTAL_PI_PERSONA_FILE = file;
|
|
85
|
+
args.push("--append-system-prompt", file);
|
|
86
|
+
}
|
|
87
|
+
if (model) {
|
|
88
|
+
env.COTAL_MODEL = model;
|
|
89
|
+
args.push("--model", model);
|
|
90
|
+
}
|
|
91
|
+
const control = controlEndpoint(opts.space, opts.name);
|
|
92
|
+
env.COTAL_CONTROL_SOCKET = control.path;
|
|
93
|
+
env.COTAL_CONTROL_TOKEN = control.token;
|
|
94
|
+
return { command: "pi", args, env, control };
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
registry.register(piConnector);
|
|
98
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,aAAa,EACb,aAAa,EACb,QAAQ,EACR,eAAe,GAIhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,eAAe,EACf,SAAS,EACT,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAElC,MAAM,UAAU,GAAG,aAAa,CAC9B,MAAM,CAAC,IAAI,CAAC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,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YACrC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC/B,GAAG,CAAC,qBAAqB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACV,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;QAED,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,GAAG,CAAC,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;QACxC,GAAG,CAAC,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC;QACxC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;IAC/C,CAAC;CACF,CAAC;AAEF,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/driver.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { InboxItem, MeshAgent } from "@cotal-ai/connector-core";
|
|
2
|
+
export type DriverState = "idle" | "dispatching" | "streaming" | "held" | "shuttingDown";
|
|
3
|
+
export interface CotalBatchDetails {
|
|
4
|
+
version: 1;
|
|
5
|
+
batchId: string;
|
|
6
|
+
ids: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface PiContextLike {
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
isIdle(): boolean;
|
|
11
|
+
hasUI: boolean;
|
|
12
|
+
ui: {
|
|
13
|
+
notify(message: string, level?: "info" | "warning" | "error"): void;
|
|
14
|
+
};
|
|
15
|
+
shutdown(): void;
|
|
16
|
+
}
|
|
17
|
+
export interface PiHost {
|
|
18
|
+
sendMessage(message: {
|
|
19
|
+
customType: string;
|
|
20
|
+
content: string;
|
|
21
|
+
display: boolean;
|
|
22
|
+
details: CotalBatchDetails;
|
|
23
|
+
}, options: {
|
|
24
|
+
triggerTurn: true;
|
|
25
|
+
deliverAs: "steer";
|
|
26
|
+
}): void;
|
|
27
|
+
}
|
|
28
|
+
/** Serialized Pi-owned delivery driver. No event callback calls the host send API outside this class. */
|
|
29
|
+
export declare class PiDriver {
|
|
30
|
+
private readonly mesh;
|
|
31
|
+
private readonly startTimeoutMs;
|
|
32
|
+
private readonly inbox;
|
|
33
|
+
private host?;
|
|
34
|
+
private context?;
|
|
35
|
+
private batches;
|
|
36
|
+
private contextBatchIds;
|
|
37
|
+
private requestBatchIds;
|
|
38
|
+
private terminalEvidenceBatchIds;
|
|
39
|
+
private nudges;
|
|
40
|
+
private presence;
|
|
41
|
+
private activeSignal?;
|
|
42
|
+
private pendingContinuation;
|
|
43
|
+
private overflowRetry;
|
|
44
|
+
private _state;
|
|
45
|
+
private heldReason?;
|
|
46
|
+
constructor(mesh: MeshAgent, startTimeoutMs?: number);
|
|
47
|
+
get state(): DriverState;
|
|
48
|
+
get reason(): string | undefined;
|
|
49
|
+
bind(host: PiHost): void;
|
|
50
|
+
onSessionStart(context: PiContextLike): void;
|
|
51
|
+
onSessionShutdown(): void;
|
|
52
|
+
onIncoming(): void;
|
|
53
|
+
onWake(): void;
|
|
54
|
+
onMentionWake(item: InboxItem): void;
|
|
55
|
+
onAgentStart(context: PiContextLike): void;
|
|
56
|
+
onMessageStart(message: unknown): void;
|
|
57
|
+
onContext(messages: readonly unknown[]): void;
|
|
58
|
+
onProviderResponse(status: number): void;
|
|
59
|
+
onToolStart(name: string): void;
|
|
60
|
+
onToolEnd(): void;
|
|
61
|
+
onAgentEnd(messages: readonly unknown[], context: PiContextLike): void;
|
|
62
|
+
onBeforeCompact(reason: string, willRetry: boolean): void;
|
|
63
|
+
requestShutdown(): void;
|
|
64
|
+
quit(): Promise<void>;
|
|
65
|
+
flushPresence(): Promise<void>;
|
|
66
|
+
private pump;
|
|
67
|
+
private finalizeEnd;
|
|
68
|
+
private hold;
|
|
69
|
+
private publishIdleWhenSettled;
|
|
70
|
+
private enqueuePresence;
|
|
71
|
+
private clearWatchdogs;
|
|
72
|
+
private clearTimers;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAQrE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,cAAc,CAAC;AAEzF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,IAAI,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,EAAE,EAAE;QAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAAA;KAAE,CAAC;IAC5E,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,WAAW,CACT,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,iBAAiB,CAAA;KAAE,EAC9F,OAAO,EAAE;QAAE,WAAW,EAAE,IAAI,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,GACjD,IAAI,CAAC;CAC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