@cotal-ai/linear 0.0.0-bootstrap.0 → 0.76.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 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 LinearMode } from "./origin.js";
2
+ export type LinearAccount = {
3
+ name: string;
4
+ mode: LinearMode;
5
+ auth: "token"; /** Absolute path of the 0600 file holding the bearer. */
6
+ tokenFile: string;
7
+ } | {
8
+ name: string;
9
+ mode: LinearMode;
10
+ auth: "oauth";
11
+ };
12
+ export declare function assertAccountName(name: string): void;
13
+ export declare function linearDir(): string;
14
+ export declare function oauthStatePath(name: string): string;
15
+ export declare function storedTokenPath(name: string): string;
16
+ /** Refuse a credential file that another user could read or that is not a regular file. */
17
+ export declare function assertPrivateFile(path: string): void;
18
+ export declare function saveAccount(account: LinearAccount, token?: string): void;
19
+ export declare function loadAccount(name: string): LinearAccount;
20
+ /** Read the bearer fresh each time, so a rotated token file is picked up without a restart. */
21
+ export declare function readAccountToken(account: Extract<LinearAccount, {
22
+ auth: "token";
23
+ }>): string;
24
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC,CAAC,yDAAyD;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC9H;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAItD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEpD;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGnD;AAOD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIpD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAaxE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAavD;AAED,+FAA+F;AAC/F,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,MAAM,CAK3F"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Linear accounts: one named, explicit upstream identity per entry. An account fixes the mode
3
+ * (`write` → `/mcp`, `readonly` → `/mcp/readonly`) and its credential, sent as
4
+ * `Authorization: Bearer`, which the Linear MCP docs accept for API keys and OAuth tokens alike.
5
+ * `token` accounts read a Linear API key (or an access token obtained elsewhere) from a private
6
+ * file at use. `oauth` accounts hold the state of `cotal linear account login` (see `oauth.ts`).
7
+ * Credentials never come from argv or the environment, are never logged, and are only sent to the
8
+ * pinned Linear MCP origin.
9
+ *
10
+ * Layout under the cotal machine home: `linear/<name>.json` (0600, no secret), plus
11
+ * `linear/<name>.token` when `--token-stdin` stored the token, or `linear/<name>.oauth.json` for an
12
+ * OAuth login. All 0600.
13
+ */
14
+ import { readFileSync, statSync } from "node:fs";
15
+ import { join } from "node:path";
16
+ import { mkSecretDir, writeSecretFileAtomic } from "@cotal-ai/core";
17
+ import { homeCotalDir } from "@cotal-ai/workspace";
18
+ import { isLinearMode } from "./origin.js";
19
+ const NAME = /^[a-z0-9][a-z0-9-]{0,31}$/;
20
+ export function assertAccountName(name) {
21
+ if (!NAME.test(name))
22
+ throw new Error(`account name "${name}" must match ${NAME.source}`);
23
+ }
24
+ export function linearDir() {
25
+ return join(homeCotalDir(), "linear");
26
+ }
27
+ export function oauthStatePath(name) {
28
+ assertAccountName(name);
29
+ return join(linearDir(), `${name}.oauth.json`);
30
+ }
31
+ function accountPath(name) {
32
+ assertAccountName(name);
33
+ return join(linearDir(), `${name}.json`);
34
+ }
35
+ export function storedTokenPath(name) {
36
+ assertAccountName(name);
37
+ return join(linearDir(), `${name}.token`);
38
+ }
39
+ /** Refuse a credential file that another user could read or that is not a regular file. */
40
+ export function assertPrivateFile(path) {
41
+ const st = statSync(path);
42
+ if (!st.isFile())
43
+ throw new Error(`${path} is not a regular file`);
44
+ if ((st.mode & 0o077) !== 0)
45
+ throw new Error(`${path} is readable by other users (mode ${(st.mode & 0o777).toString(8)}); chmod 600 it`);
46
+ }
47
+ export function saveAccount(account, token) {
48
+ assertAccountName(account.name);
49
+ if (!isLinearMode(account.mode))
50
+ throw new Error(`mode must be "write" or "readonly"`);
51
+ mkSecretDir(linearDir());
52
+ if (account.auth === "token") {
53
+ if (token !== undefined) {
54
+ const trimmed = token.trim();
55
+ if (!trimmed || /\s/.test(trimmed))
56
+ throw new Error("the token must be one non-empty line");
57
+ writeSecretFileAtomic(account.tokenFile, `${trimmed}\n`);
58
+ }
59
+ assertPrivateFile(account.tokenFile);
60
+ }
61
+ else if (token !== undefined)
62
+ throw new Error("an oauth account takes no token");
63
+ writeSecretFileAtomic(accountPath(account.name), `${JSON.stringify(account, null, 2)}\n`);
64
+ }
65
+ export function loadAccount(name) {
66
+ const path = accountPath(name);
67
+ let raw;
68
+ try {
69
+ raw = JSON.parse(readFileSync(path, "utf8"));
70
+ }
71
+ catch (e) {
72
+ throw new Error(`no Linear account "${name}" (${path}): ${e.message}. Add one with \`cotal linear account add\``);
73
+ }
74
+ const a = raw;
75
+ if (a.name !== name || !isLinearMode(a.mode))
76
+ throw new Error(`${path} is not a valid Linear account record`);
77
+ if (a.auth === "token" && typeof a.tokenFile === "string")
78
+ return { name, mode: a.mode, auth: "token", tokenFile: a.tokenFile };
79
+ if (a.auth === "oauth")
80
+ return { name, mode: a.mode, auth: "oauth" };
81
+ throw new Error(`${path} is not a valid Linear account record`);
82
+ }
83
+ /** Read the bearer fresh each time, so a rotated token file is picked up without a restart. */
84
+ export function readAccountToken(account) {
85
+ assertPrivateFile(account.tokenFile);
86
+ const token = readFileSync(account.tokenFile, "utf8").trim();
87
+ if (!token || /\s/.test(token))
88
+ throw new Error(`${account.tokenFile} must hold one non-empty token line`);
89
+ return token;
90
+ }
91
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAM5D,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,gBAAgB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,IAAI,CAAC,YAAY,EAAE,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,iBAAiB,CAAC,IAAI,CAAC,CA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AAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;IAChI,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACrE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,uCAAuC,CAAC,CAAC;AAClE,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,gBAAgB,CAAC,OAAkD;IACjF,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,SAAS,qCAAqC,CAAC,CAAC;IAC3G,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { type ParsedArgs } from "@cotal-ai/core";
2
+ export declare const USAGE = "cotal linear account add <name> --mode <write|readonly> (--token-stdin | --token-file <path>)\ncotal linear account login <name> --mode <write|readonly>\ncotal linear account show <name>\ncotal linear inventory <account> [--json]\ncotal linear call <account> <tool> [--args <json>] [--inventory <digest>] [--timeout <ms>]\ncotal linear resource <account> <uri> [--inventory <digest>] [--timeout <ms>]\ncotal linear prompt <account> <name> [--args <json>] [--inventory <digest>] [--timeout <ms>]\ncotal linear serve <account> --endpoint <reverse-dns-name> [--space <s>] [--server <url>]\ncotal linear caller <name> --endpoint <reverse-dns-name> --out <path> [--channels <a,b>] [--expires-in <s>] [--space <s>] [--server <url>]";
3
+ export declare function linear(args: ParsedArgs): Promise<void>;
4
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,EAA6B,KAAK,UAAU,EAAkB,MAAM,gBAAgB,CAAC;AAQ5F,eAAO,MAAM,KAAK,0tBAQyH,CAAC;AA+I5I,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAoF5D"}
package/dist/cli.js ADDED
@@ -0,0 +1,270 @@
1
+ /**
2
+ * `cotal linear …`: operator commands over {@link LinearUpstream}. Every reply is printed as JSON so
3
+ * the upstream's content, `structuredContent` and `isError` reach the reader unchanged; what the
4
+ * server sent is untrusted data and is never interpreted here. Exit status: 0 for an MCP result
5
+ * (including a tool result with `isError: true`), 2 for a refusal before dispatch, 3 for a protocol
6
+ * error or a failure after dispatch.
7
+ */
8
+ import { resolve } from "node:path";
9
+ import { writeSecretFileCreateOnly } from "@cotal-ai/core";
10
+ import { getSpaceAuth, hasUserAuthState, resolveMeshTarget, workspaceSecretStore } from "@cotal-ai/workspace";
11
+ import { assertAccountName, loadAccount, saveAccount, storedTokenPath } from "./account.js";
12
+ import { loginAccount } from "./oauth.js";
13
+ import { isLinearMode } from "./origin.js";
14
+ import { LinearUpstream } from "./upstream.js";
15
+ import { provisionLinearCaller, registerLinearEndpoint, renewalDelayMs, runLinearEndpoint } from "./serve.js";
16
+ export const USAGE = `cotal linear account add <name> --mode <write|readonly> (--token-stdin | --token-file <path>)
17
+ cotal linear account login <name> --mode <write|readonly>
18
+ cotal linear account show <name>
19
+ cotal linear inventory <account> [--json]
20
+ cotal linear call <account> <tool> [--args <json>] [--inventory <digest>] [--timeout <ms>]
21
+ cotal linear resource <account> <uri> [--inventory <digest>] [--timeout <ms>]
22
+ cotal linear prompt <account> <name> [--args <json>] [--inventory <digest>] [--timeout <ms>]
23
+ cotal linear serve <account> --endpoint <reverse-dns-name> [--space <s>] [--server <url>]
24
+ cotal linear caller <name> --endpoint <reverse-dns-name> --out <path> [--channels <a,b>] [--expires-in <s>] [--space <s>] [--server <url>]`;
25
+ function fail(msg) {
26
+ console.error(msg);
27
+ process.exit(1);
28
+ }
29
+ async function readStdin() {
30
+ if (process.stdin.isTTY)
31
+ fail("--token-stdin reads the token from a pipe, for example `cotal linear account add ro --mode readonly --token-stdin < token.txt`");
32
+ const chunks = [];
33
+ for await (const c of process.stdin)
34
+ chunks.push(c);
35
+ return Buffer.concat(chunks).toString("utf8");
36
+ }
37
+ function jsonArgs(raw) {
38
+ if (raw === undefined)
39
+ return undefined;
40
+ let v;
41
+ try {
42
+ v = JSON.parse(String(raw));
43
+ }
44
+ catch (e) {
45
+ fail(`--args is not JSON: ${e.message}`);
46
+ }
47
+ if (!v || typeof v !== "object" || Array.isArray(v))
48
+ fail("--args must be a JSON object");
49
+ return v;
50
+ }
51
+ function timeout(raw) {
52
+ if (raw === undefined)
53
+ return undefined;
54
+ const n = Number(raw);
55
+ if (!Number.isSafeInteger(n) || n <= 0)
56
+ fail("--timeout must be a positive integer of milliseconds");
57
+ return n;
58
+ }
59
+ function emit(reply) {
60
+ console.log(JSON.stringify(reply, null, 2));
61
+ process.exitCode = reply.kind === "result" ? 0 : reply.kind === "refused" ? 2 : 3;
62
+ }
63
+ /** Run one request; SIGINT cancels it (reported as `unknown` once dispatched) and closes the session. */
64
+ async function withUpstream(account, fn) {
65
+ const upstream = new LinearUpstream(loadAccount(account));
66
+ const ctl = new AbortController();
67
+ const onSignal = () => ctl.abort();
68
+ process.once("SIGINT", onSignal);
69
+ process.once("SIGTERM", onSignal);
70
+ try {
71
+ return await fn(upstream, ctl.signal);
72
+ }
73
+ finally {
74
+ process.off("SIGINT", onSignal);
75
+ process.off("SIGTERM", onSignal);
76
+ await upstream.close();
77
+ }
78
+ }
79
+ /** The static-auth mesh and the operator's own space authority, or a loud refusal. A per-user-auth
80
+ * mesh issues endpoint credentials through its remote auth service, which this package has no
81
+ * client for, so it is refused rather than signed locally. */
82
+ async function staticAuthority(v) {
83
+ const target = resolveMeshTarget(process.cwd(), { space: v.space, server: v.server });
84
+ if (target.mode === "user" || hasUserAuthState(target.root, target.space))
85
+ fail(`"${target.space}" is a per-user-auth mesh: its endpoint credentials come from the remote auth service, which \`cotal linear\` does not support yet. Nothing was registered or minted.`);
86
+ if (target.mode !== "auth")
87
+ fail(`"${target.space}" is an open mesh: there is no credential system to scope a Linear endpoint or its callers. Use a static-auth mesh.`);
88
+ const auth = await getSpaceAuth(workspaceSecretStore(target.root), target.space);
89
+ if (!auth)
90
+ fail(`no space authority for "${target.space}" under ${target.root}; run this where the mesh was set up`);
91
+ return { target, auth };
92
+ }
93
+ /** Register and serve until SIGINT/SIGTERM, renewing the serve credential at 75% of its life. */
94
+ async function serve(account, endpoint, v) {
95
+ const { target, auth } = await staticAuthority(v);
96
+ const upstream = new LinearUpstream(loadAccount(account));
97
+ // Read the inventory first, so a broken account never becomes a registered endpoint.
98
+ const inv = await upstream.inventory().catch(async (e) => {
99
+ await upstream.close();
100
+ fail(`the Linear account "${account}" did not answer discovery: ${e.message}`);
101
+ });
102
+ const reg = await registerLinearEndpoint({ auth, servers: target.server, space: target.space, tls: target.tlsRequired, endpoint }).catch(async (e) => {
103
+ await upstream.close();
104
+ fail(`registering ${endpoint} failed: ${e.message}`);
105
+ });
106
+ // The record is READY from registration on, so a start that fails after it must take the record
107
+ // back down rather than leave an advertised endpoint nobody serves.
108
+ const handle = await runLinearEndpoint(reg.bundle, upstream).catch(async (e) => {
109
+ // Reported as it happened: removed, failed, or still pending when the 10-second wait ran out.
110
+ const removal = await Promise.race([
111
+ reg.deregister().then(() => "its registration was removed", (d) => `its registration could not be removed (${d.message}) and still advertises this instance`),
112
+ new Promise((r) => setTimeout(() => r("its deregistration did not complete within 10 seconds and may still be pending; the record may still advertise this instance"), 10_000).unref()),
113
+ ]);
114
+ await upstream.close();
115
+ fail(`${endpoint} did not start serving: ${e.message}; ${removal}`);
116
+ });
117
+ console.log(`serving ${handle.endpoint} (instance ${handle.instanceId}, epoch ${handle.epoch}) for Linear account ${account} (${inv.mode}, ${inv.tools.length} tools, inventory ${inv.digest})`);
118
+ let timer;
119
+ const schedule = (ms) => {
120
+ if (ms === undefined)
121
+ return;
122
+ timer = setTimeout(() => {
123
+ reg.renew().then((creds) => schedule(renewalDelayMs(creds)), (e) => {
124
+ console.error(`serve credential renewal failed (${e.message}); retrying in 30s`);
125
+ schedule(30_000);
126
+ });
127
+ }, ms);
128
+ };
129
+ schedule(renewalDelayMs(reg.bundle.creds()));
130
+ let stopping = false;
131
+ const stop = async (code) => {
132
+ if (stopping)
133
+ return;
134
+ stopping = true;
135
+ if (timer)
136
+ clearTimeout(timer);
137
+ await handle.stop(10_000);
138
+ await Promise.race([reg.deregister(), new Promise((r) => setTimeout(r, 10_000).unref())]).catch((e) => console.error(`deregistration failed (${e.message}); the record stays until the instance is registered again`));
139
+ process.exit(code);
140
+ };
141
+ process.once("SIGINT", () => void stop(0));
142
+ process.once("SIGTERM", () => void stop(0));
143
+ const err = await handle.closed;
144
+ if (!stopping) {
145
+ console.error(`the serve connection closed${err ? `: ${err.message}` : ""}`);
146
+ await stop(1);
147
+ }
148
+ }
149
+ async function caller(name, endpoint, v) {
150
+ if (v.out === undefined)
151
+ fail("--out <path> is required: the credential is written there 0600 and never printed");
152
+ const { target, auth } = await staticAuthority(v);
153
+ const channels = v.channels === undefined ? [] : String(v.channels).split(",").map((c) => c.trim()).filter(Boolean);
154
+ const expires = v["expires-in"] === undefined ? undefined : Number(v["expires-in"]);
155
+ if (expires !== undefined && (!Number.isSafeInteger(expires) || expires <= 0))
156
+ fail("--expires-in must be a positive integer of seconds");
157
+ const out = resolve(String(v.out));
158
+ const minted = await provisionLinearCaller(auth, { servers: target.server, space: target.space, tls: target.tlsRequired }, endpoint, {
159
+ channels, ...(expires !== undefined ? { expiresInSeconds: expires } : {}),
160
+ });
161
+ writeSecretFileCreateOnly(out, minted.creds);
162
+ console.log(`minted Linear caller "${name}" for ${endpoint} on ${target.space}: identity ${minted.identity}`);
163
+ console.log(` credential ${out} (0600)`);
164
+ console.log(` lifecycle ${minted.lifecycleUid}`);
165
+ console.log(` launch a hand-driven seat with COTAL_SERVERS=${target.server} COTAL_SPACE=${target.space} COTAL_NAME=${name} COTAL_CREDS=${out} COTAL_LIFECYCLE_UID=${minted.lifecycleUid}`);
166
+ console.log(" a Claude Code or jcode seat also needs COTAL_CONTROL_SOCKET=<socket path> and COTAL_CONTROL_TOKEN=<random secret>");
167
+ }
168
+ export async function linear(args) {
169
+ const [sub, ...rest] = args.positionals;
170
+ const v = args.values;
171
+ switch (sub) {
172
+ case "account": {
173
+ const [action, name] = rest;
174
+ if (!name)
175
+ fail(USAGE);
176
+ assertAccountName(name);
177
+ if (action === "show") {
178
+ console.log(JSON.stringify(loadAccount(name), null, 2));
179
+ return;
180
+ }
181
+ if (action === "login") {
182
+ const mode = v.mode;
183
+ if (!isLinearMode(mode))
184
+ fail("--mode must be write or readonly");
185
+ await loginAccount(name, mode);
186
+ console.log(`saved Linear account ${name} (${mode}, oauth)`);
187
+ return;
188
+ }
189
+ if (action !== "add")
190
+ fail(USAGE);
191
+ const mode = v.mode;
192
+ if (!isLinearMode(mode))
193
+ fail("--mode must be write or readonly");
194
+ if (Boolean(v["token-stdin"]) === (v["token-file"] !== undefined))
195
+ fail("give exactly one of --token-stdin or --token-file");
196
+ if (v["token-stdin"])
197
+ saveAccount({ name, mode, auth: "token", tokenFile: storedTokenPath(name) }, await readStdin());
198
+ else
199
+ saveAccount({ name, mode, auth: "token", tokenFile: resolve(String(v["token-file"])) });
200
+ console.log(`saved Linear account ${name} (${mode})`);
201
+ return;
202
+ }
203
+ case "inventory": {
204
+ const [account] = rest;
205
+ if (!account)
206
+ fail(USAGE);
207
+ const inv = await withUpstream(account, (u) => u.inventory());
208
+ if (v.json) {
209
+ console.log(JSON.stringify(inv, null, 2));
210
+ return;
211
+ }
212
+ console.log(`endpoint ${inv.endpoint} (${inv.mode})`);
213
+ console.log(`server ${inv.server.name ?? "?"} ${inv.server.version ?? ""}`.trimEnd());
214
+ console.log(`digest ${inv.digest}`);
215
+ console.log(`tools ${inv.tools.length}`);
216
+ if (inv.resources)
217
+ console.log(`resources ${inv.resources.length} (+${inv.resourceTemplates?.length ?? 0} templates)`);
218
+ if (inv.prompts)
219
+ console.log(`prompts ${inv.prompts.length}`);
220
+ console.log(`discovery ${inv.pages} pages, ${inv.bytes} bytes`);
221
+ if (inv.unsupported.length)
222
+ console.log(`unsupported ${inv.unsupported.join(", ")}`);
223
+ for (const t of inv.tools)
224
+ console.log(` ${String(t.name)}`);
225
+ return;
226
+ }
227
+ case "call": {
228
+ const [account, tool] = rest;
229
+ if (!account || !tool)
230
+ fail(USAGE);
231
+ const req = { name: tool, arguments: jsonArgs(v.args), inventoryDigest: v.inventory, timeoutMs: timeout(v.timeout) };
232
+ emit(await withUpstream(account, (u, signal) => u.callTool({ ...req, signal })));
233
+ return;
234
+ }
235
+ case "resource": {
236
+ const [account, uri] = rest;
237
+ if (!account || !uri)
238
+ fail(USAGE);
239
+ emit(await withUpstream(account, (u, signal) => u.readResource({ uri, inventoryDigest: v.inventory, timeoutMs: timeout(v.timeout), signal })));
240
+ return;
241
+ }
242
+ case "prompt": {
243
+ const [account, name] = rest;
244
+ if (!account || !name)
245
+ fail(USAGE);
246
+ const a = jsonArgs(v.args);
247
+ if (a && Object.values(a).some((x) => typeof x !== "string"))
248
+ fail("prompt --args values must be strings");
249
+ emit(await withUpstream(account, (u, signal) => u.getPrompt({ name, arguments: a, inventoryDigest: v.inventory, timeoutMs: timeout(v.timeout), signal })));
250
+ return;
251
+ }
252
+ case "serve": {
253
+ const [account] = rest;
254
+ if (!account || typeof v.endpoint !== "string")
255
+ fail(USAGE);
256
+ await serve(account, v.endpoint, v);
257
+ return;
258
+ }
259
+ case "caller": {
260
+ const [name] = rest;
261
+ if (!name || typeof v.endpoint !== "string")
262
+ fail(USAGE);
263
+ await caller(name, v.endpoint, v);
264
+ return;
265
+ }
266
+ default:
267
+ fail(USAGE);
268
+ }
269
+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