@cotal-ai/core 0.1.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 +202 -0
- package/dist/agent-file.d.ts +24 -0
- package/dist/agent-file.d.ts.map +1 -0
- package/dist/agent-file.js +106 -0
- package/dist/agent-file.js.map +1 -0
- package/dist/command.d.ts +15 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +2 -0
- package/dist/command.js.map +1 -0
- package/dist/connector.d.ts +43 -0
- package/dist/connector.d.ts.map +1 -0
- package/dist/connector.js +2 -0
- package/dist/connector.js.map +1 -0
- package/dist/endpoint.d.ts +193 -0
- package/dist/endpoint.d.ts.map +1 -0
- package/dist/endpoint.js +628 -0
- package/dist/endpoint.js.map +1 -0
- package/dist/identity.d.ts +26 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +29 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/link.d.ts +37 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +39 -0
- package/dist/link.js.map +1 -0
- package/dist/provision.d.ts +68 -0
- package/dist/provision.d.ts.map +1 -0
- package/dist/provision.js +204 -0
- package/dist/provision.js.map +1 -0
- package/dist/registry.d.ts +24 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +26 -0
- package/dist/registry.js.map +1 -0
- package/dist/streams.d.ts +47 -0
- package/dist/streams.d.ts.map +1 -0
- package/dist/streams.js +97 -0
- package/dist/streams.js.map +1 -0
- package/dist/subjects.d.ts +83 -0
- package/dist/subjects.d.ts.map +1 -0
- package/dist/subjects.js +186 -0
- package/dist/subjects.js.map +1 -0
- package/dist/types.d.ts +117 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +31 -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.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { EndpointKind } from "./types.js";
|
|
2
|
+
export interface AgentDef {
|
|
3
|
+
name: string;
|
|
4
|
+
role?: string;
|
|
5
|
+
kind?: EndpointKind;
|
|
6
|
+
description?: string;
|
|
7
|
+
tags?: string[];
|
|
8
|
+
channels?: string[];
|
|
9
|
+
/** Channels this agent is allowed to publish to (auth mode → minted into pub-allow ACLs).
|
|
10
|
+
* Entries may be wildcard subtrees (`team.>`), symmetric with `channels`. Omitted means
|
|
11
|
+
* no explicit restriction beyond identity (the provisioner falls back to `channels`). */
|
|
12
|
+
publish?: string[];
|
|
13
|
+
/** Model override handed to the agent CLI (e.g. `claude --model`). */
|
|
14
|
+
model?: string;
|
|
15
|
+
/** Markdown body — the agent's persona / appended system prompt. */
|
|
16
|
+
persona?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Load and parse an agent definition file (Markdown + `---` frontmatter). */
|
|
19
|
+
export declare function loadAgentFile(path: string): AgentDef;
|
|
20
|
+
/** Resolve a name-or-path to an agent file. A path (absolute, contains a slash,
|
|
21
|
+
* or ends in `.md`) is used as given; a bare name maps to the directory
|
|
22
|
+
* convention `<root>/.cotal/agents/<name>.md`. */
|
|
23
|
+
export declare function agentFilePath(root: string, nameOrPath: string): string;
|
|
24
|
+
//# sourceMappingURL=agent-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-file.d.ts","sourceRoot":"","sources":["../src/agent-file.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;8FAE0F;IAC1F,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAmCD,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAmCpD;AAED;;mDAEmD;AACnD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAItE"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent definition files — the persisted form of an agent's identity + persona.
|
|
3
|
+
*
|
|
4
|
+
* .cotal/agents/<name>.md
|
|
5
|
+
* ---
|
|
6
|
+
* name: builder # AgentCard-shaped identity in the frontmatter
|
|
7
|
+
* role: builder
|
|
8
|
+
* description: …
|
|
9
|
+
* tags: [edit, test]
|
|
10
|
+
* channels: [general] # channels this agent subscribes to (read)
|
|
11
|
+
* publish: [general] # channels this agent may post to (write); omit = same as channels
|
|
12
|
+
* model: opus # optional CLI/model override
|
|
13
|
+
* ---
|
|
14
|
+
* <the Markdown body is the persona — an appended system prompt>
|
|
15
|
+
*
|
|
16
|
+
* A launcher resolves a name (or path) to one of these, hands the persona/model
|
|
17
|
+
* to the agent process at spawn, and passes the file through so the joined
|
|
18
|
+
* session reads its own card from it. Part of the wire contract's onboarding
|
|
19
|
+
* half, alongside the join link.
|
|
20
|
+
*/
|
|
21
|
+
import { readFileSync } from "node:fs";
|
|
22
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
23
|
+
/** Strip wrapping quotes from a scalar value. */
|
|
24
|
+
function unquote(v) {
|
|
25
|
+
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'")))
|
|
26
|
+
return v.slice(1, -1);
|
|
27
|
+
return v;
|
|
28
|
+
}
|
|
29
|
+
/** Parse the frontmatter subset we support: `key: value` scalars and inline
|
|
30
|
+
* `key: [a, b]` string lists. Throws on anything fancier — block lists, nested
|
|
31
|
+
* maps and multi-doc YAML are deliberately unsupported (no silent fallback). */
|
|
32
|
+
function parseFrontmatter(src) {
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const raw of src.split("\n")) {
|
|
35
|
+
const line = raw.trim();
|
|
36
|
+
if (!line || line.startsWith("#"))
|
|
37
|
+
continue;
|
|
38
|
+
const colon = line.indexOf(":");
|
|
39
|
+
if (colon < 1)
|
|
40
|
+
throw new Error(`agent file: unparseable frontmatter line "${raw}"`);
|
|
41
|
+
const key = line.slice(0, colon).trim();
|
|
42
|
+
const val = line.slice(colon + 1).trim();
|
|
43
|
+
if (val.startsWith("[")) {
|
|
44
|
+
if (!val.endsWith("]"))
|
|
45
|
+
throw new Error(`agent file: unterminated list for "${key}"`);
|
|
46
|
+
out[key] = val
|
|
47
|
+
.slice(1, -1)
|
|
48
|
+
.split(",")
|
|
49
|
+
.map((s) => unquote(s.trim()))
|
|
50
|
+
.filter(Boolean);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
out[key] = unquote(val);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/** Load and parse an agent definition file (Markdown + `---` frontmatter). */
|
|
59
|
+
export function loadAgentFile(path) {
|
|
60
|
+
const src = readFileSync(path, "utf8");
|
|
61
|
+
const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(src);
|
|
62
|
+
if (!m)
|
|
63
|
+
throw new Error(`agent file ${path}: missing "---" frontmatter block`);
|
|
64
|
+
const fm = parseFrontmatter(m[1]);
|
|
65
|
+
const persona = m[2].trim();
|
|
66
|
+
const str = (k) => {
|
|
67
|
+
const v = fm[k];
|
|
68
|
+
if (Array.isArray(v))
|
|
69
|
+
throw new Error(`agent file ${path}: "${k}" must be a scalar`);
|
|
70
|
+
return v;
|
|
71
|
+
};
|
|
72
|
+
const list = (k) => {
|
|
73
|
+
const v = fm[k];
|
|
74
|
+
if (v === undefined)
|
|
75
|
+
return undefined;
|
|
76
|
+
return Array.isArray(v) ? v : [v];
|
|
77
|
+
};
|
|
78
|
+
const name = str("name");
|
|
79
|
+
if (!name)
|
|
80
|
+
throw new Error(`agent file ${path}: "name" is required`);
|
|
81
|
+
const kind = str("kind");
|
|
82
|
+
if (kind && kind !== "agent" && kind !== "endpoint")
|
|
83
|
+
throw new Error(`agent file ${path}: "kind" must be "agent" or "endpoint"`);
|
|
84
|
+
return {
|
|
85
|
+
name,
|
|
86
|
+
role: str("role"),
|
|
87
|
+
kind: kind,
|
|
88
|
+
description: str("description"),
|
|
89
|
+
tags: list("tags"),
|
|
90
|
+
channels: list("channels"),
|
|
91
|
+
publish: list("publish"),
|
|
92
|
+
model: str("model"),
|
|
93
|
+
persona: persona || undefined,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** Resolve a name-or-path to an agent file. A path (absolute, contains a slash,
|
|
97
|
+
* or ends in `.md`) is used as given; a bare name maps to the directory
|
|
98
|
+
* convention `<root>/.cotal/agents/<name>.md`. */
|
|
99
|
+
export function agentFilePath(root, nameOrPath) {
|
|
100
|
+
if (isAbsolute(nameOrPath))
|
|
101
|
+
return nameOrPath;
|
|
102
|
+
if (nameOrPath.includes("/") || nameOrPath.endsWith(".md"))
|
|
103
|
+
return resolve(root, nameOrPath);
|
|
104
|
+
return join(root, ".cotal", "agents", `${nameOrPath}.md`);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I,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC7F,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,UAAU,KAAK,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Extension } from "./registry.js";
|
|
2
|
+
/**
|
|
3
|
+
* The contract for a composable CLI command — an {@link Extension} of kind
|
|
4
|
+
* `"command"`. An implementation (the mesh CLI, the manager …) self-registers its
|
|
5
|
+
* commands on import; the `cotal` binary resolves them from the registry.
|
|
6
|
+
*/
|
|
7
|
+
export interface Command extends Extension {
|
|
8
|
+
readonly kind: "command";
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly summary: string;
|
|
11
|
+
/** Help grouping header (e.g. "Mesh", "Control plane"). Defaults to "Commands". */
|
|
12
|
+
readonly group?: string;
|
|
13
|
+
run(argv: string[]): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,OAAQ,SAAQ,SAAS;IACxC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mFAAmF;IACnF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC"}
|
package/dist/command.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Extension } from "./registry.js";
|
|
2
|
+
/** Identity + mesh coordinates the manager hands a connector to launch an agent. */
|
|
3
|
+
export interface LaunchOpts {
|
|
4
|
+
space: string;
|
|
5
|
+
name: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
/** Stable agent id (the nkey public key). When set, the launched session adopts it
|
|
8
|
+
* as its `card.id` instead of generating a random one — so the id the launcher
|
|
9
|
+
* provisioned is the id the agent presents, and later ACLs key on it. */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Path to a minted creds file (auth mode). Passed to the session so it authenticates
|
|
12
|
+
* as `id`; absent when the mesh runs open. */
|
|
13
|
+
creds?: string;
|
|
14
|
+
servers?: string;
|
|
15
|
+
/** Path to an agent definition file (`.cotal/agents/<name>.md`). The connector
|
|
16
|
+
* passes it through (`COTAL_AGENT_FILE`) so the joined session reads its own
|
|
17
|
+
* card from it, and applies the file's persona/model at launch. */
|
|
18
|
+
configPath?: string;
|
|
19
|
+
}
|
|
20
|
+
/** A recipe for starting an agent as a mesh node — command, args, and extra env. */
|
|
21
|
+
export interface LaunchSpec {
|
|
22
|
+
command: string;
|
|
23
|
+
args: string[];
|
|
24
|
+
env?: Record<string, string>;
|
|
25
|
+
/** Auto-clear a one-time spawn prompt: when this text appears in the agent's
|
|
26
|
+
* early output, the runtime presses Enter once so a supervised launch stays
|
|
27
|
+
* non-interactive. Matched after stripping ANSI + whitespace (TUIs position
|
|
28
|
+
* text with cursor moves, not spaces). */
|
|
29
|
+
confirm?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A bridge that knows how to launch one agent type (Claude Code, Codex, the CLI
|
|
33
|
+
* peer …) as a Cotal mesh node — an {@link Extension} of kind `"connector"`.
|
|
34
|
+
* `name` is the agent type it handles — the key the manager resolves by.
|
|
35
|
+
* Connectors self-register on import; the manager resolves them from the registry,
|
|
36
|
+
* and core stays ignorant of which ones exist.
|
|
37
|
+
*/
|
|
38
|
+
export interface Connector extends Extension {
|
|
39
|
+
readonly kind: "connector";
|
|
40
|
+
readonly name: string;
|
|
41
|
+
buildLaunch(opts: LaunchOpts): LaunchSpec;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,oFAAoF;AACpF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;8EAE0E;IAC1E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;mDAC+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;wEAEoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B;;;+CAG2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import type { AgentCard, ControlReply, ControlRequest, EndpointRef, Part, Presence, PresenceStatus, CotalMessage } from "./types.js";
|
|
3
|
+
export declare const DEFAULT_SERVER = "nats://127.0.0.1:4222";
|
|
4
|
+
export interface EndpointOptions {
|
|
5
|
+
/** The collaboration to join. */
|
|
6
|
+
space: string;
|
|
7
|
+
/** Identity. `id` is generated if omitted. */
|
|
8
|
+
card: Omit<AgentCard, "id"> & {
|
|
9
|
+
id?: string;
|
|
10
|
+
};
|
|
11
|
+
servers?: string;
|
|
12
|
+
/** Connection token (soft-shared auth). Mutually exclusive with user/pass. */
|
|
13
|
+
token?: string;
|
|
14
|
+
/** Username/password auth (both required together). */
|
|
15
|
+
user?: string;
|
|
16
|
+
pass?: string;
|
|
17
|
+
/** NATS user creds file *content* (JWT + nkey seed). When set, the endpoint
|
|
18
|
+
* authenticates as that user and adopts the creds' identity as its card.id. */
|
|
19
|
+
creds?: string;
|
|
20
|
+
/** Require a TLS connection to the server. */
|
|
21
|
+
tls?: boolean;
|
|
22
|
+
/** Channels to subscribe to; the first is the default broadcast target. */
|
|
23
|
+
channels?: string[];
|
|
24
|
+
/** Presence heartbeat interval (ms). */
|
|
25
|
+
heartbeatMs?: number;
|
|
26
|
+
/** Presence liveness window (ms); a peer is considered gone after this. */
|
|
27
|
+
ttlMs?: number;
|
|
28
|
+
/** Publish our own presence (default true). */
|
|
29
|
+
registerPresence?: boolean;
|
|
30
|
+
/** Track the roster of peers (default true). */
|
|
31
|
+
watchPresence?: boolean;
|
|
32
|
+
/** Create inbound stream consumers (DM / chat / anycast). Default true; a pure observer sets false. */
|
|
33
|
+
consume?: boolean;
|
|
34
|
+
/** How long an unacked (un-surfaced) message waits before redelivery (ms). */
|
|
35
|
+
ackWaitMs?: number;
|
|
36
|
+
/** Retire this instance's durable consumers after it's been gone this long (ms). */
|
|
37
|
+
inactiveThresholdMs?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Events: "message" (CotalMessage), "presence" (PresenceEvent), "roster" (Presence[]), "error" (Error).
|
|
41
|
+
*
|
|
42
|
+
* Callers MUST attach an "error" listener before `start()`: async faults (incl. NATS
|
|
43
|
+
* permission denials, surfaced via `watchStatus`) are emitted as "error", and Node throws
|
|
44
|
+
* synchronously on an unhandled "error" — a missing listener turns any such fault into a
|
|
45
|
+
* process crash instead of a logged denial.
|
|
46
|
+
*/
|
|
47
|
+
export declare class CotalEndpoint extends EventEmitter {
|
|
48
|
+
readonly card: AgentCard;
|
|
49
|
+
readonly space: string;
|
|
50
|
+
readonly channels: string[];
|
|
51
|
+
private readonly servers;
|
|
52
|
+
private readonly token?;
|
|
53
|
+
private readonly user?;
|
|
54
|
+
private readonly pass?;
|
|
55
|
+
private readonly creds?;
|
|
56
|
+
private readonly tls;
|
|
57
|
+
private readonly heartbeatMs;
|
|
58
|
+
private readonly ttlMs;
|
|
59
|
+
private readonly doRegister;
|
|
60
|
+
private readonly doWatch;
|
|
61
|
+
private readonly doConsume;
|
|
62
|
+
private readonly ackWaitMs;
|
|
63
|
+
private readonly inactiveThresholdMs;
|
|
64
|
+
private nc?;
|
|
65
|
+
private js?;
|
|
66
|
+
private jsm?;
|
|
67
|
+
private kv?;
|
|
68
|
+
private readonly subs;
|
|
69
|
+
private readonly streamMsgs;
|
|
70
|
+
private heartbeatTimer?;
|
|
71
|
+
private sweepTimer?;
|
|
72
|
+
private readonly roster;
|
|
73
|
+
private status;
|
|
74
|
+
private activity?;
|
|
75
|
+
private stopped;
|
|
76
|
+
constructor(opts: EndpointOptions);
|
|
77
|
+
ref(): EndpointRef;
|
|
78
|
+
start(): Promise<void>;
|
|
79
|
+
stop(): Promise<void>;
|
|
80
|
+
/** Multicast: broadcast to everyone on a channel. */
|
|
81
|
+
multicast(text: string, opts?: {
|
|
82
|
+
channel?: string;
|
|
83
|
+
parts?: Part[];
|
|
84
|
+
replyTo?: string;
|
|
85
|
+
contextId?: string;
|
|
86
|
+
mentions?: string[];
|
|
87
|
+
}): Promise<CotalMessage>;
|
|
88
|
+
/** Unicast: direct message to one specific instance. */
|
|
89
|
+
unicast(instanceId: string, text: string, opts?: {
|
|
90
|
+
parts?: Part[];
|
|
91
|
+
replyTo?: string;
|
|
92
|
+
contextId?: string;
|
|
93
|
+
}): Promise<CotalMessage>;
|
|
94
|
+
/** Anycast: deliver to ANY one instance of a service (role) — queue-group load balancing. */
|
|
95
|
+
anycast(service: string, text: string, opts?: {
|
|
96
|
+
parts?: Part[];
|
|
97
|
+
replyTo?: string;
|
|
98
|
+
contextId?: string;
|
|
99
|
+
}): Promise<CotalMessage>;
|
|
100
|
+
/** Subscribe to a read-only observer feed. Defaults to the whole space; an observer under
|
|
101
|
+
* auth must pass `chatWildcard(space)` since its `sub.allow` only covers chat (DM/anycast
|
|
102
|
+
* stay confidential), otherwise the space-wildcard subscribe is denied and the feed dies. */
|
|
103
|
+
tap(handler: (subject: string, msg: CotalMessage | undefined) => void, opts?: {
|
|
104
|
+
subject?: string;
|
|
105
|
+
}): void;
|
|
106
|
+
/** Serve control requests for a service (manager side). */
|
|
107
|
+
serveControl(service: string, handler: (req: ControlRequest) => Promise<ControlReply> | ControlReply): void;
|
|
108
|
+
/** Send a control request to a service and await its reply (client side). */
|
|
109
|
+
requestControl(service: string, req: ControlRequest, timeoutMs?: number): Promise<ControlReply>;
|
|
110
|
+
getRoster(): Presence[];
|
|
111
|
+
setActivity(activity: string): Promise<void>;
|
|
112
|
+
setStatus(status: PresenceStatus): Promise<void>;
|
|
113
|
+
/** List channels that have messages in the chat stream, with message counts.
|
|
114
|
+
* Works even on observer endpoints (no consumers needed). */
|
|
115
|
+
listChannels(): Promise<{
|
|
116
|
+
channel: string;
|
|
117
|
+
messages: number;
|
|
118
|
+
}[]>;
|
|
119
|
+
/** Fetch recent messages from a channel's JetStream backlog. */
|
|
120
|
+
channelHistory(channel: string, opts?: {
|
|
121
|
+
limit?: number;
|
|
122
|
+
}): Promise<CotalMessage[]>;
|
|
123
|
+
/** Fetch recent DMs (any sender→any recipient) from the space's DM backlog. God-view only:
|
|
124
|
+
* a normal agent/observer's ACL denies CONSUMER.CREATE on DM_<space>, so this throws-and-
|
|
125
|
+
* skips for them — only an `admin`-profile cred can read it. */
|
|
126
|
+
dmHistory(opts?: {
|
|
127
|
+
limit?: number;
|
|
128
|
+
}): Promise<CotalMessage[]>;
|
|
129
|
+
/** Drain up to `limit` recent messages matching `subject` from a stream's backlog via a
|
|
130
|
+
* throwaway consumer. Fetches exactly the pending count (from consumer info) so it returns
|
|
131
|
+
* the moment the backlog is delivered — a plain `fetch({max_messages: limit})` would instead
|
|
132
|
+
* block for the pull's full expiry (~30s) whenever the backlog is smaller than `limit`. */
|
|
133
|
+
private streamHistory;
|
|
134
|
+
/**
|
|
135
|
+
* Surface the connection's async status errors on our `error` event. NATS reports
|
|
136
|
+
* publish permission violations *only* here (subscription/request ones too), never on
|
|
137
|
+
* the failing call — so without this an over-tight ACL silently drops the agent's
|
|
138
|
+
* traffic and it just looks "absent". We annotate permission denials explicitly so a
|
|
139
|
+
* denial is never mistaken for absence (which already has a benign cause: MCP reconnect).
|
|
140
|
+
*/
|
|
141
|
+
private watchStatus;
|
|
142
|
+
private publishMsg;
|
|
143
|
+
/** Create the three backing streams for this space (idempotent). Open-mode lazy create;
|
|
144
|
+
* the same definitions are used by `cotal up` at privileged setup. */
|
|
145
|
+
private ensureStreams;
|
|
146
|
+
/**
|
|
147
|
+
* Privileged: pre-create an agent's DM inbox durable (auth mode), so the agent can BIND
|
|
148
|
+
* it without holding CONSUMER.CREATE on DM_<space>. The creator sets the filter to
|
|
149
|
+
* inst.<targetId>.* — the agent never gets to choose it, which is what stops a peer from
|
|
150
|
+
* creating a durable filtered to someone else's inbox. Idempotent (byte-identical config),
|
|
151
|
+
* safe to call again on manager restart. The caller must be permissive on DM_<space>.
|
|
152
|
+
*/
|
|
153
|
+
provisionDmInbox(targetId: string): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Privileged: pre-create a role's shared TASK work-queue durable (auth mode), so agents
|
|
156
|
+
* of that role can BIND it without holding CONSUMER.CREATE on TASK_<space>. The creator
|
|
157
|
+
* sets the filter to svc.<role>.* — agents never choose it, which stops cross-role drain.
|
|
158
|
+
* Idempotent per role. The caller must be permissive on TASK_<space>.
|
|
159
|
+
*/
|
|
160
|
+
provisionTaskQueue(role: string): Promise<void>;
|
|
161
|
+
/** Lazily obtain a JetStream manager — so a non-consuming endpoint (e.g. the supervisor,
|
|
162
|
+
* consume:false) can still pre-create others' durables. */
|
|
163
|
+
private manager;
|
|
164
|
+
/** Bind this endpoint's durable consumers: DM inbox, chat, and (if a role) the task queue. */
|
|
165
|
+
private startConsumers;
|
|
166
|
+
/** Drive one consumer: decode, drop our own echo, and hand each message to listeners with ack control. */
|
|
167
|
+
private pump;
|
|
168
|
+
private publishPresence;
|
|
169
|
+
private startPresenceWatch;
|
|
170
|
+
private handleKvEntry;
|
|
171
|
+
private applyPresence;
|
|
172
|
+
/** Mark a known peer offline (on KV delete/purge), keeping it in the roster. */
|
|
173
|
+
private markOffline;
|
|
174
|
+
private sweep;
|
|
175
|
+
}
|
|
176
|
+
/** Auth subset of connect() options, shared by the endpoint and isReachable. */
|
|
177
|
+
interface AuthOpts {
|
|
178
|
+
token?: string;
|
|
179
|
+
user?: string;
|
|
180
|
+
pass?: string;
|
|
181
|
+
creds?: string;
|
|
182
|
+
tls?: boolean;
|
|
183
|
+
}
|
|
184
|
+
/** Whether a NATS server is *running* at `servers`. True on a successful connect AND on an
|
|
185
|
+
* auth rejection — an auth error means a server is there, just refusing these creds (so the
|
|
186
|
+
* caller should surface the real auth failure, not a misleading "server down", and `up`
|
|
187
|
+
* must not try to start a duplicate on the bound port). Only a genuine connection failure
|
|
188
|
+
* (refused / timeout / no server) returns false. */
|
|
189
|
+
export declare function isReachable(servers?: string, opts?: AuthOpts & {
|
|
190
|
+
timeoutMs?: number;
|
|
191
|
+
}): Promise<boolean>;
|
|
192
|
+
export {};
|
|
193
|
+
//# sourceMappingURL=endpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../src/endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAyB3C,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,cAAc,EAEd,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,YAAY,EACb,MAAM,YAAY,CAAC;AAqBpB,eAAO,MAAM,cAAc,0BAA0B,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;oFACgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uGAAuG;IACvG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8E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