@tomradex/engine-acp 0.0.0-stage → 0.15.0
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 +204 -0
- package/dist/agent.d.ts +139 -0
- package/dist/catalog.d.ts +37 -0
- package/dist/connection.d.ts +39 -0
- package/dist/index.d.ts +15 -0
- package/dist/local.d.ts +24 -0
- package/dist/runtime.d.ts +68 -0
- package/dist/runtime.js +1 -0
- package/package.json +36 -4
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Copyright 2026 Haoyuan Tang
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Apache License
|
|
5
|
+
Version 2.0, January 2004
|
|
6
|
+
http://www.apache.org/licenses/
|
|
7
|
+
|
|
8
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9
|
+
|
|
10
|
+
1. Definitions.
|
|
11
|
+
|
|
12
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
13
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
14
|
+
|
|
15
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
16
|
+
the copyright owner that is granting the License.
|
|
17
|
+
|
|
18
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
19
|
+
other entities that control, are controlled by, or are under common
|
|
20
|
+
control with that entity. For the purposes of this definition,
|
|
21
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
22
|
+
direction or management of such entity, whether by contract or
|
|
23
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
24
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
25
|
+
|
|
26
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
27
|
+
exercising permissions granted by this License.
|
|
28
|
+
|
|
29
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
30
|
+
including but not limited to software source code, documentation
|
|
31
|
+
source, and configuration files.
|
|
32
|
+
|
|
33
|
+
"Object" form shall mean any form resulting from mechanical
|
|
34
|
+
transformation or translation of a Source form, including but
|
|
35
|
+
not limited to compiled object code, generated documentation,
|
|
36
|
+
and conversions to other media types.
|
|
37
|
+
|
|
38
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
39
|
+
Object form, made available under the License, as indicated by a
|
|
40
|
+
copyright notice that is included in or attached to the work
|
|
41
|
+
(an example is provided in the Appendix below).
|
|
42
|
+
|
|
43
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
44
|
+
form, that is based on (or derived from) the Work and for which the
|
|
45
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
46
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
47
|
+
of this License, Derivative Works shall not include works that remain
|
|
48
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
49
|
+
the Work and Derivative Works thereof.
|
|
50
|
+
|
|
51
|
+
"Contribution" shall mean any work of authorship, including
|
|
52
|
+
the original version of the Work and any modifications or additions
|
|
53
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
54
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
55
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
56
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
57
|
+
means any form of electronic, verbal, or written communication sent
|
|
58
|
+
to the Licensor or its representatives, including but not limited to
|
|
59
|
+
communication on electronic mailing lists, source code control systems,
|
|
60
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
61
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
62
|
+
excluding communication that is conspicuously marked or otherwise
|
|
63
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
64
|
+
|
|
65
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
66
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
67
|
+
subsequently incorporated within the Work.
|
|
68
|
+
|
|
69
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
70
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
71
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
72
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
73
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
74
|
+
Work and such Derivative Works in Source or Object form.
|
|
75
|
+
|
|
76
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
77
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
78
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
79
|
+
(except as stated in this section) patent license to make, have made,
|
|
80
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
81
|
+
where such license applies only to those patent claims licensable
|
|
82
|
+
by such Contributor that are necessarily infringed by their
|
|
83
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
84
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
85
|
+
institute patent litigation against any entity (including a
|
|
86
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
87
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
88
|
+
or contributory patent infringement, then any patent licenses
|
|
89
|
+
granted to You under this License for that Work shall terminate
|
|
90
|
+
as of the date such litigation is filed.
|
|
91
|
+
|
|
92
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
93
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
94
|
+
modifications, and in Source or Object form, provided that You
|
|
95
|
+
meet the following conditions:
|
|
96
|
+
|
|
97
|
+
(a) You must give any other recipients of the Work or
|
|
98
|
+
Derivative Works a copy of this License; and
|
|
99
|
+
|
|
100
|
+
(b) You must cause any modified files to carry prominent notices
|
|
101
|
+
stating that You changed the files; and
|
|
102
|
+
|
|
103
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
104
|
+
that You distribute, all copyright, patent, trademark, and
|
|
105
|
+
attribution notices from the Source form of the Work,
|
|
106
|
+
excluding those notices that do not pertain to any part of
|
|
107
|
+
the Derivative Works; and
|
|
108
|
+
|
|
109
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
110
|
+
distribution, then any Derivative Works that You distribute must
|
|
111
|
+
include a readable copy of the attribution notices contained
|
|
112
|
+
within such NOTICE file, excluding those notices that do not
|
|
113
|
+
pertain to any part of the Derivative Works, in at least one
|
|
114
|
+
of the following places: within a NOTICE text file distributed
|
|
115
|
+
as part of the Derivative Works; within the Source form or
|
|
116
|
+
documentation, if provided along with the Derivative Works; or,
|
|
117
|
+
within a display generated by the Derivative Works, if and
|
|
118
|
+
wherever such third-party notices normally appear. The contents
|
|
119
|
+
of the NOTICE file are for informational purposes only and
|
|
120
|
+
do not modify the License. You may add Your own attribution
|
|
121
|
+
notices within Derivative Works that You distribute, alongside
|
|
122
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
123
|
+
that such additional attribution notices cannot be construed
|
|
124
|
+
as modifying the License.
|
|
125
|
+
|
|
126
|
+
You may add Your own copyright statement to Your modifications and
|
|
127
|
+
may provide additional or different license terms and conditions
|
|
128
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
129
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
130
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
131
|
+
the conditions stated in this License.
|
|
132
|
+
|
|
133
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
134
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
135
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
136
|
+
this License, without any additional terms or conditions.
|
|
137
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
138
|
+
the terms of any separate license agreement you may have executed
|
|
139
|
+
with Licensor regarding such Contributions.
|
|
140
|
+
|
|
141
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
142
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
143
|
+
except as required for reasonable and customary use in describing the
|
|
144
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
145
|
+
|
|
146
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
147
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
148
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
149
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
150
|
+
implied, including, without limitation, any warranties or conditions
|
|
151
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
152
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
153
|
+
appropriateness of using or redistributing the Work and assume any
|
|
154
|
+
risks associated with Your exercise of permissions under this License.
|
|
155
|
+
|
|
156
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
157
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
158
|
+
unless required by applicable law (such as deliberate and grossly
|
|
159
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
160
|
+
liable to You for damages, including any direct, indirect, special,
|
|
161
|
+
incidental, or consequential damages of any character arising as a
|
|
162
|
+
result of this License or out of the use or inability to use the
|
|
163
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
164
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
165
|
+
other commercial damages or losses), even if such Contributor
|
|
166
|
+
has been advised of the possibility of such damages.
|
|
167
|
+
|
|
168
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
169
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
170
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
171
|
+
or other liability obligations and/or rights consistent with this
|
|
172
|
+
License. However, in accepting such obligations, You may act only
|
|
173
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
174
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
175
|
+
defend, and hold each Contributor harmless for any liability
|
|
176
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
177
|
+
of your accepting any such warranty or additional liability.
|
|
178
|
+
|
|
179
|
+
END OF TERMS AND CONDITIONS
|
|
180
|
+
|
|
181
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
182
|
+
|
|
183
|
+
To apply the Apache License to your work, attach the following
|
|
184
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
185
|
+
replaced with your own identifying information. (Don't include
|
|
186
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
187
|
+
comment syntax for the file format. We also recommend that a
|
|
188
|
+
file or class name and description of purpose be included on the
|
|
189
|
+
same "printed page" as the copyright notice for easier
|
|
190
|
+
identification within third-party archives.
|
|
191
|
+
|
|
192
|
+
Copyright [yyyy] [name of copyright owner]
|
|
193
|
+
|
|
194
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
195
|
+
you may not use this file except in compliance with the License.
|
|
196
|
+
You may obtain a copy of the License at
|
|
197
|
+
|
|
198
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
199
|
+
|
|
200
|
+
Unless required by applicable law or agreed to in writing, software
|
|
201
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
202
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
203
|
+
See the License for the specific language governing permissions and
|
|
204
|
+
limitations under the License.
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { EngineNeed, EnginePick, EngineSetup, TurnInput } from "@tomradex/agent";
|
|
3
|
+
import type { CliLocator, DesktopApp } from "@tomradex/engine-claude-code";
|
|
4
|
+
/** How much the agent may do without asking, as Tomrade settles it for one turn. */
|
|
5
|
+
export type Policy = "full-access" | "ask" | "read-only";
|
|
6
|
+
export interface AcpOptions {
|
|
7
|
+
command: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
effort?: string;
|
|
10
|
+
}
|
|
11
|
+
/** One model request's tokens; `input` counts every prompt token, cached ones included. */
|
|
12
|
+
export interface RequestUsage {
|
|
13
|
+
input: number;
|
|
14
|
+
output: number;
|
|
15
|
+
cacheRead?: number;
|
|
16
|
+
cacheWrite?: number;
|
|
17
|
+
}
|
|
18
|
+
/** What the agent offered the last time a session opened, for the Model and Effort picks. */
|
|
19
|
+
export interface Catalog {
|
|
20
|
+
models: EnginePick["choices"];
|
|
21
|
+
efforts: EnginePick["choices"];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* One local agent that speaks the Agent Client Protocol on stdio. The protocol
|
|
25
|
+
* is shared; what differs is how each one starts, how much it asks before it
|
|
26
|
+
* acts, and where it reports the tokens it spent.
|
|
27
|
+
*/
|
|
28
|
+
export interface AcpAgent<O extends AcpOptions = AcpOptions> {
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
cli: CliLocator;
|
|
32
|
+
/** The English tail of "not found — …". */
|
|
33
|
+
install: string;
|
|
34
|
+
options: z.ZodType<O>;
|
|
35
|
+
permissionModes: {
|
|
36
|
+
default: string;
|
|
37
|
+
choices: {
|
|
38
|
+
value: string;
|
|
39
|
+
label: string;
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
/** What starts its ACP server on stdio. */
|
|
43
|
+
args(input: TurnInput, options: O): string[];
|
|
44
|
+
env?(input: TurnInput, options: O): Record<string, string>;
|
|
45
|
+
/** The agent's own session mode for a policy; Tomrade answers whatever it still asks. */
|
|
46
|
+
mode?(policy: Policy): string | undefined;
|
|
47
|
+
/** "always": it registers HTTP MCP servers without advertising that it can. */
|
|
48
|
+
httpMcp?: "advertised" | "always";
|
|
49
|
+
/**
|
|
50
|
+
* How a stored session reopens; by default `session/resume` when offered, else `session/load`.
|
|
51
|
+
* "never": its load replays the history after answering, into the turn that follows, so a cold
|
|
52
|
+
* turn opens a new session with the conversation recapped instead.
|
|
53
|
+
*/
|
|
54
|
+
reopen?: "resume" | "load" | "never";
|
|
55
|
+
/** A tool call's own name, for an agent whose updates carry none but put it in the call's id. */
|
|
56
|
+
callName?(toolCallId: string): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Where tokens are reported: the prompt's answer for this turn alone
|
|
59
|
+
* ("turn"), the prompt's answer as a running session total ("session"), or
|
|
60
|
+
* per model request inside a usage update (a reader). Absent: only the
|
|
61
|
+
* context size is known.
|
|
62
|
+
*/
|
|
63
|
+
usage?: "turn" | "session" | ((update: Record<string, any>) => RequestUsage | null);
|
|
64
|
+
/** The prompt's `inputTokens` leaves out what `cachedReadTokens` and `cachedWriteTokens` count (OpenCode). */
|
|
65
|
+
cacheApart?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* How it takes a message sent while a turn runs, which ACP itself has no word for: its own
|
|
68
|
+
* `session/steer` method ("method", CodeBuddy), or a `/steer` prompt sent alongside ("slash",
|
|
69
|
+
* Hermes). Absent: such messages wait for the turn to end.
|
|
70
|
+
*/
|
|
71
|
+
steer?: "method" | "slash";
|
|
72
|
+
/** Whether its CLI can also be handed a ticket in a terminal (code link has a template for it). */
|
|
73
|
+
terminal?: boolean;
|
|
74
|
+
/** In a terminal it has no per-session MCP flag: its user-level `tomrade` server, named with the session's token, serves. */
|
|
75
|
+
terminalViaLink?: boolean;
|
|
76
|
+
setup?: EngineSetup;
|
|
77
|
+
/** Effort levels to offer before a session has advertised its own. */
|
|
78
|
+
efforts?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* The agent's own words for a turn it ended on "refusal" — some agents end
|
|
81
|
+
* every failed turn that way and put the reason in the answer's `_meta`.
|
|
82
|
+
*/
|
|
83
|
+
failure?(response: Record<string, any>): string | undefined;
|
|
84
|
+
/** What gets a signed-out agent going, said after its own error. */
|
|
85
|
+
signIn?: string;
|
|
86
|
+
/** A run that tells whether the agent can work yet; it may also fill in the model list. */
|
|
87
|
+
probe?: {
|
|
88
|
+
args: string[];
|
|
89
|
+
says(output: string, catalog: Catalog): boolean | null;
|
|
90
|
+
reason: string;
|
|
91
|
+
need?: EngineNeed;
|
|
92
|
+
};
|
|
93
|
+
/** Whether it is signed in, read without running it (its own settings); null: no clear answer, taken as yes. */
|
|
94
|
+
signedIn?: {
|
|
95
|
+
ask(): boolean | null | Promise<boolean | null>;
|
|
96
|
+
reason: string;
|
|
97
|
+
};
|
|
98
|
+
/** The agent's own logs and setup facts, for the troubleshooter; the models it offers are added to the facts. */
|
|
99
|
+
diagnostics?: {
|
|
100
|
+
logs?(): string[];
|
|
101
|
+
facts?(catalog: Catalog): Record<string, string>;
|
|
102
|
+
};
|
|
103
|
+
/** Its desktop app, named when the app is installed without the CLI. */
|
|
104
|
+
desktopApp?: DesktopApp;
|
|
105
|
+
}
|
|
106
|
+
export declare const PERMISSION_CHOICES: {
|
|
107
|
+
readonly "full-access": {
|
|
108
|
+
readonly value: "full-access";
|
|
109
|
+
readonly label: "Full access";
|
|
110
|
+
};
|
|
111
|
+
readonly ask: {
|
|
112
|
+
readonly value: "ask";
|
|
113
|
+
readonly label: "Ask permissions";
|
|
114
|
+
};
|
|
115
|
+
readonly "read-only": {
|
|
116
|
+
readonly value: "read-only";
|
|
117
|
+
readonly label: "Read only";
|
|
118
|
+
};
|
|
119
|
+
readonly local: {
|
|
120
|
+
readonly value: "local";
|
|
121
|
+
readonly label: "Local rules";
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
/** Under "local" the agent's own rules decide what it asks, and whatever it asks goes to the person. */
|
|
125
|
+
export declare function policyOf(input: Pick<TurnInput, "purpose" | "permissionMode">, agent: Pick<AcpAgent, "permissionModes">): Policy;
|
|
126
|
+
/** A call to a deferred tool through a wrapper (CodeBuddy's DeferExecuteTool) names the real tool in its input. */
|
|
127
|
+
export declare const wrappedTool: (args: unknown) => string | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Tomrade's own tools are run-scoped and revertible, so they never wait for a
|
|
130
|
+
* person. Only the tool's own name counts — a title is free text, and a
|
|
131
|
+
* command or path that merely mentions tomrade must still be asked about.
|
|
132
|
+
*/
|
|
133
|
+
export declare const isTomradeTool: (call: {
|
|
134
|
+
name?: unknown;
|
|
135
|
+
title?: unknown;
|
|
136
|
+
kind?: unknown;
|
|
137
|
+
args?: unknown;
|
|
138
|
+
}) => boolean;
|
|
139
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Context } from "cordis";
|
|
2
|
+
import type { AcpAgent, AcpOptions, Catalog } from "./agent.js";
|
|
3
|
+
type Json = Record<string, any>;
|
|
4
|
+
/** Session settings by what they are: agents name them differently but tag them with these categories. */
|
|
5
|
+
export declare const SETTINGS: {
|
|
6
|
+
mode: {
|
|
7
|
+
category: string;
|
|
8
|
+
ids: string[];
|
|
9
|
+
};
|
|
10
|
+
model: {
|
|
11
|
+
category: string;
|
|
12
|
+
ids: string[];
|
|
13
|
+
};
|
|
14
|
+
effort: {
|
|
15
|
+
category: string;
|
|
16
|
+
ids: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type Setting = keyof typeof SETTINGS;
|
|
20
|
+
/** A select's choices, its groups flattened. */
|
|
21
|
+
export declare const choicesOf: (option: Json) => Json[];
|
|
22
|
+
export declare const optionOf: (config: Json[], setting: Setting) => Json | undefined;
|
|
23
|
+
/** The models and efforts a session offers, through its config options or the older `models` field; empty when it offers none. */
|
|
24
|
+
export declare function advertised(config: Json[], models?: Json): Partial<Catalog>;
|
|
25
|
+
/** What each agent's sessions offered, kept across restarts so the picks are there before the first turn. */
|
|
26
|
+
export declare function keptCatalogs(ctx: Context): {
|
|
27
|
+
read(id: string): Partial<Catalog>;
|
|
28
|
+
write(id: string, catalog: Catalog): void;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Opens one session only to read what the agent offers, then stops it. It
|
|
32
|
+
* runs in a folder of Tomrade's own, so no project's history gains the empty
|
|
33
|
+
* session, and hands the agent no MCP server.
|
|
34
|
+
*/
|
|
35
|
+
export declare function askCatalog(ctx: Context, agent: AcpAgent<any>, options: AcpOptions, signal: AbortSignal): Promise<Partial<Catalog>>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
type Json = Record<string, any>;
|
|
3
|
+
/** ACP's error code for "sign in first". */
|
|
4
|
+
export declare const AUTH_REQUIRED = -32000;
|
|
5
|
+
/** An error the agent answered a request with. */
|
|
6
|
+
export declare class AcpError extends Error {
|
|
7
|
+
readonly code?: number | undefined;
|
|
8
|
+
readonly data?: unknown | undefined;
|
|
9
|
+
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
|
10
|
+
}
|
|
11
|
+
export interface AcpPeer {
|
|
12
|
+
/** `session/update` and anything else the agent tells without asking. */
|
|
13
|
+
notification(method: string, params: Json): void;
|
|
14
|
+
/** A request from the agent; what it resolves to is the answer, an AcpError the refusal. */
|
|
15
|
+
request(method: string, params: Json): Promise<unknown>;
|
|
16
|
+
closed(error: Error): void;
|
|
17
|
+
}
|
|
18
|
+
/** JSON-RPC 2.0 over newline-delimited stdio with one ACP agent process. */
|
|
19
|
+
export declare class AcpConnection {
|
|
20
|
+
private child;
|
|
21
|
+
private peer;
|
|
22
|
+
private name;
|
|
23
|
+
private seq;
|
|
24
|
+
private pending;
|
|
25
|
+
private open;
|
|
26
|
+
private stderr;
|
|
27
|
+
constructor(child: ChildProcessWithoutNullStreams, peer: AcpPeer, name: string);
|
|
28
|
+
get alive(): boolean;
|
|
29
|
+
/** What the agent last wrote to stderr, for a failure's details. */
|
|
30
|
+
get stderrTail(): string;
|
|
31
|
+
/** `timeoutMs` 0 waits as long as the agent works — a prompt runs until its turn ends. A null result stays null. */
|
|
32
|
+
request(method: string, params: Json, timeoutMs?: number): Promise<any>;
|
|
33
|
+
notify(method: string, params: Json): void;
|
|
34
|
+
close(error?: Error): void;
|
|
35
|
+
private write;
|
|
36
|
+
private receive;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=connection.d.ts.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Context } from "cordis";
|
|
2
|
+
import type { Engine } from "@tomradex/agent";
|
|
3
|
+
import type { AcpAgent, AcpOptions } from "./agent.js";
|
|
4
|
+
/**
|
|
5
|
+
* An engine for a local agent that speaks ACP: one agent process per hot
|
|
6
|
+
* thread, Tomrade's tools handed to it as an HTTP MCP server, its session
|
|
7
|
+
* resumed from the agent's own store on the next cold turn. What its sessions
|
|
8
|
+
* offer is kept across restarts; with nothing kept, one short session asks.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createAcpEngine<O extends AcpOptions>(ctx: Context, agent: AcpAgent<O>): Engine;
|
|
11
|
+
export { PERMISSION_CHOICES, isTomradeTool, policyOf, wrappedTool, type AcpAgent, type AcpOptions, type Catalog, type Policy, type RequestUsage } from "./agent.js";
|
|
12
|
+
export { AcpConnection, AcpError, AUTH_REQUIRED, type AcpPeer } from "./connection.js";
|
|
13
|
+
export { AcpRuntime } from "./runtime.js";
|
|
14
|
+
export { LocalAgents, LocalAgents as default } from "./local.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/local.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Context, Service } from "cordis";
|
|
2
|
+
import type { LocalAgentInstaller, LocalAgentOptions, LocalAgentSpec } from "@tomradex/plugin-sdk";
|
|
3
|
+
declare module "cordis" {
|
|
4
|
+
interface Context {
|
|
5
|
+
localAgents: LocalAgents;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
type Spec = LocalAgentSpec<LocalAgentOptions>;
|
|
9
|
+
/** An installer script as the command the app runs for the person; the plugin names only its address. */
|
|
10
|
+
export declare const installCommand: (step: string | LocalAgentInstaller) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Coding agents a plugin describes rather than implements: this module finds
|
|
13
|
+
* their CLI, runs them over ACP or hands them a ticket in a terminal, keeps
|
|
14
|
+
* their connection to Tomrade and lends their sign-in to the worker — what the
|
|
15
|
+
* app's own agents get.
|
|
16
|
+
*/
|
|
17
|
+
export declare class LocalAgents extends Service {
|
|
18
|
+
static provide: string;
|
|
19
|
+
constructor(ctx: Context);
|
|
20
|
+
/** Goes with the plugin that registered it, or when the answer is called. */
|
|
21
|
+
register(spec: Spec): () => void;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=local.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Context } from "cordis";
|
|
2
|
+
import { type TurnIO, type TurnInput, type TurnResult } from "@tomradex/agent";
|
|
3
|
+
import { type Runtime } from "@tomradex/engine-claude-code";
|
|
4
|
+
import { type AcpAgent, type Catalog } from "./agent.js";
|
|
5
|
+
type Json = Record<string, any>;
|
|
6
|
+
/**
|
|
7
|
+
* The choice a typed value means: its exact value, its name, or — for agents
|
|
8
|
+
* whose values encode `[provider, model]` — the model or `provider/model`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveChoice(option: Json, value: string): string | undefined;
|
|
11
|
+
/** One ACP agent process owned by Tomrade for one thread; the session itself lives in the agent's own store. */
|
|
12
|
+
export declare class AcpRuntime implements Runtime {
|
|
13
|
+
private ctx;
|
|
14
|
+
private agent;
|
|
15
|
+
private catalog;
|
|
16
|
+
private learned?;
|
|
17
|
+
token: string;
|
|
18
|
+
cwd: string;
|
|
19
|
+
alive: boolean;
|
|
20
|
+
busy: boolean;
|
|
21
|
+
session?: string;
|
|
22
|
+
/** The files index this session was opened with, so a later turn can notice it went stale. */
|
|
23
|
+
indexDigest: string | null;
|
|
24
|
+
private child?;
|
|
25
|
+
private conn?;
|
|
26
|
+
private caps;
|
|
27
|
+
private config;
|
|
28
|
+
private modes?;
|
|
29
|
+
private models?;
|
|
30
|
+
/** A session this process started rather than reopened: its first prompt carries Tomrade's instructions. */
|
|
31
|
+
private brief;
|
|
32
|
+
private io?;
|
|
33
|
+
private policy;
|
|
34
|
+
private calls;
|
|
35
|
+
/** What Tomrade or the person refused this turn, by label and by call; some agents end the turn on a refusal. */
|
|
36
|
+
private refused;
|
|
37
|
+
private refusedCalls;
|
|
38
|
+
private listener?;
|
|
39
|
+
/** The last running totals an agent reported, to tell one turn's share. */
|
|
40
|
+
private sessionUsage?;
|
|
41
|
+
private sessionCost?;
|
|
42
|
+
constructor(ctx: Context, agent: AcpAgent<any>, catalog: Catalog, input: TurnInput, learned?: (() => void) | undefined);
|
|
43
|
+
close(): void;
|
|
44
|
+
private peer;
|
|
45
|
+
/** Tomrade's tools always run; otherwise the turn's policy answers, or the person does. */
|
|
46
|
+
private permission;
|
|
47
|
+
private nameOf;
|
|
48
|
+
private option;
|
|
49
|
+
private setOption;
|
|
50
|
+
/** What the session advertised feeds the picks the next time they are drawn. */
|
|
51
|
+
private learn;
|
|
52
|
+
/** The agent's own mode sets how much it asks. Only a failure that could leave it asking less than wanted stops the turn. */
|
|
53
|
+
private setMode;
|
|
54
|
+
private choose;
|
|
55
|
+
/** The reopened session; null when the agent cannot reopen one, "lost" when it tried and no longer has it. */
|
|
56
|
+
private reopen;
|
|
57
|
+
/** False when the session in `io.resume` is gone; Tomrade then runs the turn again without it. */
|
|
58
|
+
private open;
|
|
59
|
+
private prompt;
|
|
60
|
+
private explain;
|
|
61
|
+
turn(input: TurnInput, io: TurnIO, warm: boolean): Promise<TurnResult>;
|
|
62
|
+
/** A prompt's own usage: this turn's, or the session's running total less what was already counted. */
|
|
63
|
+
private account;
|
|
64
|
+
}
|
|
65
|
+
/** A model API's error passed on as JSON, sometimes JSON in JSON (Gemini CLI): its innermost message. */
|
|
66
|
+
export declare function innermost(message: string): string;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
throw new Error("@tomradex/engine-acp is Tomrade's own code: a full-mode plugin gets the running app's copy, so load the plugin in Tomrade");
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomradex/engine-acp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": "Haoyuan Tang",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"description": "Agent Client Protocol conductor: one ACP agent process per hot thread, Tomrade tools over HTTP MCP, the agent's own session resumed — declarations for full-mode plugins; Tomrade provides the code at run time",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"tomrade",
|
|
16
|
+
"tomrade-plugin",
|
|
17
|
+
"types"
|
|
18
|
+
],
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/runtime.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@tomradex/agent": "0.15.0",
|
|
31
|
+
"@tomradex/engine-claude-code": "0.15.0",
|
|
32
|
+
"@tomradex/llm": "0.15.0",
|
|
33
|
+
"@tomradex/mcp": "0.15.0",
|
|
34
|
+
"@tomradex/plugin-sdk": "0.2.18",
|
|
35
|
+
"cordis": "4.0.0-rc.8",
|
|
36
|
+
"zod": "^4.4.3"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/README.md
DELETED