@tellagen/mcp-server 0.4.1 → 0.5.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 +21 -0
- package/README.md +335 -102
- package/SKILL.md +183 -27
- package/contracts/mcp-protocol.json +155 -0
- package/contracts/runbooks/manifest.json +26 -6
- package/contracts/runbooks/v2/cause-lead.guidance.json +37 -0
- package/contracts/runbooks/v2/client-protocol.json +926 -0
- package/contracts/runbooks/v2/client-writes.guidance.json +42 -0
- package/contracts/runbooks/v2/fixtures/timeline-event-blocks-rejected.json +30 -5
- package/contracts/runbooks/v2/result-summary.guidance.json +21 -0
- package/contracts/runbooks/v2/timeline-event-blocks.schema.json +18 -11
- package/contracts/tellagen-runbook-contracts.json +4 -4
- package/dist/active-run.d.ts +29 -0
- package/dist/active-run.js +67 -0
- package/dist/active-run.js.map +1 -0
- package/dist/bootstrap.d.ts +20 -0
- package/dist/bootstrap.js +29 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cause-lead.d.ts +25 -0
- package/dist/cause-lead.js +145 -0
- package/dist/cause-lead.js.map +1 -0
- package/dist/cli/auth.d.ts +22 -0
- package/dist/cli/auth.js +207 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/io.d.ts +16 -0
- package/dist/cli/io.js +53 -0
- package/dist/cli/io.js.map +1 -0
- package/dist/cli/listen-guard.d.ts +12 -0
- package/dist/cli/listen-guard.js +50 -0
- package/dist/cli/listen-guard.js.map +1 -0
- package/dist/cli/listen.d.ts +28 -0
- package/dist/cli/listen.js +205 -0
- package/dist/cli/listen.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +53 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/trace-hook.d.ts +23 -0
- package/dist/cli/trace-hook.js +99 -0
- package/dist/cli/trace-hook.js.map +1 -0
- package/dist/client.d.ts +92 -6
- package/dist/client.js +300 -23
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +17 -0
- package/dist/config.js +38 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +120 -0
- package/dist/credentials.js +363 -0
- package/dist/credentials.js.map +1 -0
- package/dist/diagnosis-structure.d.ts +207 -147
- package/dist/diagnosis-structure.js +143 -2
- package/dist/diagnosis-structure.js.map +1 -1
- package/dist/diff-figure.d.ts +56 -0
- package/dist/diff-figure.js +276 -0
- package/dist/diff-figure.js.map +1 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +60 -0
- package/dist/errors.js.map +1 -1
- package/dist/figures.d.ts +281 -201
- package/dist/figures.js +189 -47
- package/dist/figures.js.map +1 -1
- package/dist/guide-resources.d.ts +28 -0
- package/dist/guide-resources.js +81 -0
- package/dist/guide-resources.js.map +1 -0
- package/dist/heartbeat.d.ts +24 -0
- package/dist/heartbeat.js +94 -0
- package/dist/heartbeat.js.map +1 -0
- package/dist/home.d.ts +8 -0
- package/dist/home.js +14 -0
- package/dist/home.js.map +1 -0
- package/dist/identity.d.ts +32 -0
- package/dist/identity.js +83 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.js +46 -14
- package/dist/index.js.map +1 -1
- package/dist/listen-config.d.ts +67 -0
- package/dist/listen-config.js +83 -0
- package/dist/listen-config.js.map +1 -0
- package/dist/listen-probe.d.ts +57 -0
- package/dist/listen-probe.js +158 -0
- package/dist/listen-probe.js.map +1 -0
- package/dist/listen-rules.d.ts +88 -0
- package/dist/listen-rules.js +252 -0
- package/dist/listen-rules.js.map +1 -0
- package/dist/listen-settings.d.ts +18 -0
- package/dist/listen-settings.js +50 -0
- package/dist/listen-settings.js.map +1 -0
- package/dist/listen-wrap.d.ts +21 -0
- package/dist/listen-wrap.js +52 -0
- package/dist/listen-wrap.js.map +1 -0
- package/dist/listener.d.ts +195 -0
- package/dist/listener.js +600 -0
- package/dist/listener.js.map +1 -0
- package/dist/open-run.d.ts +2 -0
- package/dist/open-run.js +5 -0
- package/dist/open-run.js.map +1 -0
- package/dist/prompts.d.ts +12 -0
- package/dist/prompts.js +37 -0
- package/dist/prompts.js.map +1 -0
- package/dist/redact.d.ts +13 -0
- package/dist/redact.js +76 -0
- package/dist/redact.js.map +1 -0
- package/dist/run-events.d.ts +54 -0
- package/dist/run-events.js +210 -0
- package/dist/run-events.js.map +1 -0
- package/dist/run-state.d.ts +184 -0
- package/dist/run-state.js +207 -0
- package/dist/run-state.js.map +1 -0
- package/dist/server.d.ts +22 -2
- package/dist/server.js +137 -29
- package/dist/server.js.map +1 -1
- package/dist/session.d.ts +86 -0
- package/dist/session.js +155 -0
- package/dist/session.js.map +1 -0
- package/dist/shell-rules.d.ts +49 -0
- package/dist/shell-rules.js +335 -0
- package/dist/shell-rules.js.map +1 -0
- package/dist/signin-index.d.ts +164 -0
- package/dist/signin-index.js +116 -0
- package/dist/signin-index.js.map +1 -0
- package/dist/signin.d.ts +169 -0
- package/dist/signin.js +541 -0
- package/dist/signin.js.map +1 -0
- package/dist/start.d.ts +7 -6
- package/dist/start.js +14 -7
- package/dist/start.js.map +1 -1
- package/dist/tools/catalog.d.ts +44 -0
- package/dist/tools/catalog.js +105 -0
- package/dist/tools/catalog.js.map +1 -0
- package/dist/tools/causes.d.ts +6 -6
- package/dist/tools/causes.js +4 -5
- package/dist/tools/causes.js.map +1 -1
- package/dist/tools/context.js +5 -5
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/datasources.js +1 -1
- package/dist/tools/datasources.js.map +1 -1
- package/dist/tools/diagnostics.js +2 -2
- package/dist/tools/diagnostics.js.map +1 -1
- package/dist/tools/figures.d.ts +3 -2
- package/dist/tools/figures.js +38 -13
- package/dist/tools/figures.js.map +1 -1
- package/dist/tools/findings.d.ts +28 -0
- package/dist/tools/findings.js +88 -24
- package/dist/tools/findings.js.map +1 -1
- package/dist/tools/incidents.js +5 -5
- package/dist/tools/incidents.js.map +1 -1
- package/dist/tools/index.d.ts +19 -2
- package/dist/tools/index.js +115 -14
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/investigations.d.ts +54 -0
- package/dist/tools/investigations.js +370 -69
- package/dist/tools/investigations.js.map +1 -1
- package/dist/tools/next.d.ts +20 -0
- package/dist/tools/next.js +136 -0
- package/dist/tools/next.js.map +1 -0
- package/dist/tools/postmortem-runbooks.d.ts +52 -52
- package/dist/tools/postmortem-runbooks.js +3 -10
- package/dist/tools/postmortem-runbooks.js.map +1 -1
- package/dist/tools/resume.d.ts +5 -0
- package/dist/tools/resume.js +136 -0
- package/dist/tools/resume.js.map +1 -0
- package/dist/tools/signin.d.ts +12 -0
- package/dist/tools/signin.js +54 -0
- package/dist/tools/signin.js.map +1 -0
- package/dist/tools/source-links.js +5 -3
- package/dist/tools/source-links.js.map +1 -1
- package/dist/tools/timeline.js +57 -11
- package/dist/tools/timeline.js.map +1 -1
- package/dist/trace-record.d.ts +36 -0
- package/dist/trace-record.js +283 -0
- package/dist/trace-record.js.map +1 -0
- package/dist/version.d.ts +10 -2
- package/dist/version.js +20 -1
- package/dist/version.js.map +1 -1
- package/package.json +23 -3
- package/server.json +5 -5
- package/contracts/runbooks/v1/fixtures/global-runbook.json +0 -7
- package/contracts/runbooks/v1/runbook-definition.schema.json +0 -25
- package/dist/auth.d.ts +0 -7
- package/dist/auth.js +0 -19
- package/dist/auth.js.map +0 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* What this computer knows about its sign-ins, apart from the keys: which
|
|
4
|
+
* workspace, until when, and where the key is kept. The file holds no key.
|
|
5
|
+
* One sign-in is kept for each workspace address, and one of them is the
|
|
6
|
+
* current one.
|
|
7
|
+
*/
|
|
8
|
+
declare const entrySchema: z.ZodObject<{
|
|
9
|
+
api_url: z.ZodString;
|
|
10
|
+
workspace_name: z.ZodOptional<z.ZodString>;
|
|
11
|
+
workspace_url: z.ZodOptional<z.ZodString>;
|
|
12
|
+
signed_in_at: z.ZodString;
|
|
13
|
+
/** When the key stops working; empty when Tellagen sent no date. */
|
|
14
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
15
|
+
storage: z.ZodEnum<["macos-keychain", "libsecret", "windows-vault", "file"]>;
|
|
16
|
+
/** Seen at a pickup: this server is older than the workspace wants. */
|
|
17
|
+
update_available: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
your_version: z.ZodString;
|
|
19
|
+
current_version: z.ZodString;
|
|
20
|
+
seen_at: z.ZodString;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
your_version: string;
|
|
23
|
+
current_version: string;
|
|
24
|
+
seen_at: string;
|
|
25
|
+
}, {
|
|
26
|
+
your_version: string;
|
|
27
|
+
current_version: string;
|
|
28
|
+
seen_at: string;
|
|
29
|
+
}>>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
api_url: string;
|
|
32
|
+
signed_in_at: string;
|
|
33
|
+
storage: "macos-keychain" | "libsecret" | "windows-vault" | "file";
|
|
34
|
+
workspace_name?: string | undefined;
|
|
35
|
+
workspace_url?: string | undefined;
|
|
36
|
+
expires_at?: string | undefined;
|
|
37
|
+
update_available?: {
|
|
38
|
+
your_version: string;
|
|
39
|
+
current_version: string;
|
|
40
|
+
seen_at: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
api_url: string;
|
|
44
|
+
signed_in_at: string;
|
|
45
|
+
storage: "macos-keychain" | "libsecret" | "windows-vault" | "file";
|
|
46
|
+
workspace_name?: string | undefined;
|
|
47
|
+
workspace_url?: string | undefined;
|
|
48
|
+
expires_at?: string | undefined;
|
|
49
|
+
update_available?: {
|
|
50
|
+
your_version: string;
|
|
51
|
+
current_version: string;
|
|
52
|
+
seen_at: string;
|
|
53
|
+
} | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
declare const indexSchema: z.ZodObject<{
|
|
56
|
+
version: z.ZodLiteral<1>;
|
|
57
|
+
current: z.ZodOptional<z.ZodString>;
|
|
58
|
+
workspaces: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
59
|
+
api_url: z.ZodString;
|
|
60
|
+
workspace_name: z.ZodOptional<z.ZodString>;
|
|
61
|
+
workspace_url: z.ZodOptional<z.ZodString>;
|
|
62
|
+
signed_in_at: z.ZodString;
|
|
63
|
+
/** When the key stops working; empty when Tellagen sent no date. */
|
|
64
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
65
|
+
storage: z.ZodEnum<["macos-keychain", "libsecret", "windows-vault", "file"]>;
|
|
66
|
+
/** Seen at a pickup: this server is older than the workspace wants. */
|
|
67
|
+
update_available: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
your_version: z.ZodString;
|
|
69
|
+
current_version: z.ZodString;
|
|
70
|
+
seen_at: z.ZodString;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
your_version: string;
|
|
73
|
+
current_version: string;
|
|
74
|
+
seen_at: string;
|
|
75
|
+
}, {
|
|
76
|
+
your_version: string;
|
|
77
|
+
current_version: string;
|
|
78
|
+
seen_at: string;
|
|
79
|
+
}>>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
api_url: string;
|
|
82
|
+
signed_in_at: string;
|
|
83
|
+
storage: "macos-keychain" | "libsecret" | "windows-vault" | "file";
|
|
84
|
+
workspace_name?: string | undefined;
|
|
85
|
+
workspace_url?: string | undefined;
|
|
86
|
+
expires_at?: string | undefined;
|
|
87
|
+
update_available?: {
|
|
88
|
+
your_version: string;
|
|
89
|
+
current_version: string;
|
|
90
|
+
seen_at: string;
|
|
91
|
+
} | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
api_url: string;
|
|
94
|
+
signed_in_at: string;
|
|
95
|
+
storage: "macos-keychain" | "libsecret" | "windows-vault" | "file";
|
|
96
|
+
workspace_name?: string | undefined;
|
|
97
|
+
workspace_url?: string | undefined;
|
|
98
|
+
expires_at?: string | undefined;
|
|
99
|
+
update_available?: {
|
|
100
|
+
your_version: string;
|
|
101
|
+
current_version: string;
|
|
102
|
+
seen_at: string;
|
|
103
|
+
} | undefined;
|
|
104
|
+
}>>;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
version: 1;
|
|
107
|
+
workspaces: Record<string, {
|
|
108
|
+
api_url: string;
|
|
109
|
+
signed_in_at: string;
|
|
110
|
+
storage: "macos-keychain" | "libsecret" | "windows-vault" | "file";
|
|
111
|
+
workspace_name?: string | undefined;
|
|
112
|
+
workspace_url?: string | undefined;
|
|
113
|
+
expires_at?: string | undefined;
|
|
114
|
+
update_available?: {
|
|
115
|
+
your_version: string;
|
|
116
|
+
current_version: string;
|
|
117
|
+
seen_at: string;
|
|
118
|
+
} | undefined;
|
|
119
|
+
}>;
|
|
120
|
+
current?: string | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
version: 1;
|
|
123
|
+
workspaces: Record<string, {
|
|
124
|
+
api_url: string;
|
|
125
|
+
signed_in_at: string;
|
|
126
|
+
storage: "macos-keychain" | "libsecret" | "windows-vault" | "file";
|
|
127
|
+
workspace_name?: string | undefined;
|
|
128
|
+
workspace_url?: string | undefined;
|
|
129
|
+
expires_at?: string | undefined;
|
|
130
|
+
update_available?: {
|
|
131
|
+
your_version: string;
|
|
132
|
+
current_version: string;
|
|
133
|
+
seen_at: string;
|
|
134
|
+
} | undefined;
|
|
135
|
+
}>;
|
|
136
|
+
current?: string | undefined;
|
|
137
|
+
}>;
|
|
138
|
+
export type SignInEntry = z.infer<typeof entrySchema> & {
|
|
139
|
+
account?: never;
|
|
140
|
+
};
|
|
141
|
+
export type SignInIndexData = z.infer<typeof indexSchema>;
|
|
142
|
+
export declare class SignInIndex {
|
|
143
|
+
#private;
|
|
144
|
+
private readonly dir;
|
|
145
|
+
constructor(dir?: string | undefined);
|
|
146
|
+
filePath(): string | undefined;
|
|
147
|
+
read(): SignInIndexData;
|
|
148
|
+
private write;
|
|
149
|
+
/** Records a sign-in and makes it the current one. */
|
|
150
|
+
save(account: string, entry: SignInEntry): boolean;
|
|
151
|
+
update(account: string, change: Partial<SignInEntry>): void;
|
|
152
|
+
remove(account: string): void;
|
|
153
|
+
/** The entry of an account, or the current one when none is named. */
|
|
154
|
+
find(account?: string): {
|
|
155
|
+
account: string;
|
|
156
|
+
entry: SignInEntry;
|
|
157
|
+
} | undefined;
|
|
158
|
+
list(): Array<{
|
|
159
|
+
account: string;
|
|
160
|
+
entry: SignInEntry;
|
|
161
|
+
current: boolean;
|
|
162
|
+
}>;
|
|
163
|
+
}
|
|
164
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { chmodSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { randomBytes } from "node:crypto";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { tellagenHome } from "./home.js";
|
|
6
|
+
/**
|
|
7
|
+
* What this computer knows about its sign-ins, apart from the keys: which
|
|
8
|
+
* workspace, until when, and where the key is kept. The file holds no key.
|
|
9
|
+
* One sign-in is kept for each workspace address, and one of them is the
|
|
10
|
+
* current one.
|
|
11
|
+
*/
|
|
12
|
+
const entrySchema = z.object({
|
|
13
|
+
api_url: z.string().max(300),
|
|
14
|
+
workspace_name: z.string().max(200).optional(),
|
|
15
|
+
workspace_url: z.string().max(300).optional(),
|
|
16
|
+
signed_in_at: z.string().max(40),
|
|
17
|
+
/** When the key stops working; empty when Tellagen sent no date. */
|
|
18
|
+
expires_at: z.string().max(40).optional(),
|
|
19
|
+
storage: z.enum(["macos-keychain", "libsecret", "windows-vault", "file"]),
|
|
20
|
+
/** Seen at a pickup: this server is older than the workspace wants. */
|
|
21
|
+
update_available: z
|
|
22
|
+
.object({ your_version: z.string().max(40), current_version: z.string().max(40), seen_at: z.string().max(40) })
|
|
23
|
+
.optional(),
|
|
24
|
+
});
|
|
25
|
+
const indexSchema = z.object({
|
|
26
|
+
version: z.literal(1),
|
|
27
|
+
current: z.string().max(220).optional(),
|
|
28
|
+
workspaces: z.record(z.string().max(220), entrySchema),
|
|
29
|
+
});
|
|
30
|
+
const MAX_BYTES = 64 * 1024;
|
|
31
|
+
const MAX_WORKSPACES = 50;
|
|
32
|
+
export class SignInIndex {
|
|
33
|
+
dir;
|
|
34
|
+
#path;
|
|
35
|
+
constructor(dir = tellagenHome()) {
|
|
36
|
+
this.dir = dir;
|
|
37
|
+
this.#path = dir ? join(dir, "signin.json") : undefined;
|
|
38
|
+
}
|
|
39
|
+
filePath() {
|
|
40
|
+
return this.#path;
|
|
41
|
+
}
|
|
42
|
+
read() {
|
|
43
|
+
const empty = { version: 1, workspaces: {} };
|
|
44
|
+
if (!this.#path)
|
|
45
|
+
return empty;
|
|
46
|
+
try {
|
|
47
|
+
const stat = lstatSync(this.#path);
|
|
48
|
+
if (!stat.isFile() || stat.size > MAX_BYTES)
|
|
49
|
+
return empty;
|
|
50
|
+
const parsed = indexSchema.safeParse(JSON.parse(readFileSync(this.#path, "utf8")));
|
|
51
|
+
return parsed.success ? parsed.data : empty;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return empty;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
write(data) {
|
|
58
|
+
if (!this.#path || !this.dir)
|
|
59
|
+
return false;
|
|
60
|
+
const temp = `${this.#path}.${randomBytes(6).toString("hex")}.tmp`;
|
|
61
|
+
try {
|
|
62
|
+
mkdirSync(this.dir, { recursive: true, mode: 0o700 });
|
|
63
|
+
writeFileSync(temp, `${JSON.stringify(indexSchema.parse(data), null, 2)}\n`, { mode: 0o600, flag: "wx" });
|
|
64
|
+
chmodSync(temp, 0o600);
|
|
65
|
+
renameSync(temp, this.#path);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
rmSync(temp, { force: true });
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Records a sign-in and makes it the current one. */
|
|
74
|
+
save(account, entry) {
|
|
75
|
+
const data = this.read();
|
|
76
|
+
if (!(account in data.workspaces) && Object.keys(data.workspaces).length >= MAX_WORKSPACES)
|
|
77
|
+
return false;
|
|
78
|
+
data.workspaces[account] = entry;
|
|
79
|
+
data.current = account;
|
|
80
|
+
return this.write(data);
|
|
81
|
+
}
|
|
82
|
+
update(account, change) {
|
|
83
|
+
const data = this.read();
|
|
84
|
+
const entry = data.workspaces[account];
|
|
85
|
+
if (!entry)
|
|
86
|
+
return;
|
|
87
|
+
data.workspaces[account] = { ...entry, ...change };
|
|
88
|
+
this.write(data);
|
|
89
|
+
}
|
|
90
|
+
remove(account) {
|
|
91
|
+
const data = this.read();
|
|
92
|
+
delete data.workspaces[account];
|
|
93
|
+
if (data.current === account)
|
|
94
|
+
data.current = Object.keys(data.workspaces)[0];
|
|
95
|
+
if (Object.keys(data.workspaces).length === 0) {
|
|
96
|
+
if (this.#path)
|
|
97
|
+
rmSync(this.#path, { force: true });
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.write(data);
|
|
101
|
+
}
|
|
102
|
+
/** The entry of an account, or the current one when none is named. */
|
|
103
|
+
find(account) {
|
|
104
|
+
const data = this.read();
|
|
105
|
+
const key = account ?? data.current;
|
|
106
|
+
if (!key)
|
|
107
|
+
return undefined;
|
|
108
|
+
const entry = data.workspaces[key];
|
|
109
|
+
return entry ? { account: key, entry } : undefined;
|
|
110
|
+
}
|
|
111
|
+
list() {
|
|
112
|
+
const data = this.read();
|
|
113
|
+
return Object.entries(data.workspaces).map(([account, entry]) => ({ account, entry, current: account === data.current }));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=signin-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signin-index.js","sourceRoot":"","sources":["../src/signin-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;A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K,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,CAAC;IAED,IAAI;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5H,CAAC;CACF"}
|
package/dist/signin.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { TellagenClient } from "./client.js";
|
|
2
|
+
import { type CredentialVault } from "./credentials.js";
|
|
3
|
+
import { SignInIndex, type SignInEntry } from "./signin-index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Browser sign-in for a client (the device-code flow).
|
|
6
|
+
*
|
|
7
|
+
* 1. Start: Tellagen answers with a short code to show and a secret device
|
|
8
|
+
* code that only this process keeps.
|
|
9
|
+
* 2. The person opens the address, signs in and approves the code.
|
|
10
|
+
* 3. Poll: Tellagen creates a personal key when this client collects it, and
|
|
11
|
+
* shows it once. It goes to the keychain at once.
|
|
12
|
+
*
|
|
13
|
+
* The device code and the key never leave this file's variables except
|
|
14
|
+
* to Tellagen and to the keychain. They are not logged, not returned from a
|
|
15
|
+
* tool and not part of an error message.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_SIGN_IN_URL = "https://api.tellagen.com";
|
|
18
|
+
export declare const EXPIRY_WARNING_DAYS = 7;
|
|
19
|
+
export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
20
|
+
export declare class SignInError extends Error {
|
|
21
|
+
readonly code: "expired" | "denied" | "invalid_device_code" | "rate_limited" | "busy" | "network" | "bad_answer" | "storage";
|
|
22
|
+
/** For `denied`: the reason Tellagen gave, such as responder_seat_required. */
|
|
23
|
+
readonly reason?: string | undefined;
|
|
24
|
+
constructor(code: "expired" | "denied" | "invalid_device_code" | "rate_limited" | "busy" | "network" | "bad_answer" | "storage", message: string,
|
|
25
|
+
/** For `denied`: the reason Tellagen gave, such as responder_seat_required. */
|
|
26
|
+
reason?: string | undefined);
|
|
27
|
+
}
|
|
28
|
+
/** A secret that prints as a placeholder, so a log line or JSON dump cannot leak it. */
|
|
29
|
+
export declare class Secret {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(value: string);
|
|
32
|
+
reveal(): string;
|
|
33
|
+
toString(): string;
|
|
34
|
+
toJSON(): string;
|
|
35
|
+
}
|
|
36
|
+
/** A URL that may receive a key or be opened: https, or http on this computer. */
|
|
37
|
+
export declare function safeUrl(value: unknown): URL | undefined;
|
|
38
|
+
/** The domain a host is registered under, such as `tellagen.com` for `acme.api.tellagen.com`. */
|
|
39
|
+
export declare function registrableDomain(host: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether an address from Tellagen's answer is on the same registered domain
|
|
42
|
+
* as the address the sign-in started at. A page to open and a host to send a
|
|
43
|
+
* key to must both pass: otherwise a server that was told to start a sign-in
|
|
44
|
+
* could send the person, and the key, anywhere.
|
|
45
|
+
*/
|
|
46
|
+
export declare function sameRegistrableDomain(candidate: URL, expected: URL): boolean;
|
|
47
|
+
export declare function signInBaseUrl(env: Record<string, string | undefined>, override?: string): string;
|
|
48
|
+
export interface DeviceStart {
|
|
49
|
+
deviceCode: Secret;
|
|
50
|
+
userCode: string;
|
|
51
|
+
verificationUri: string;
|
|
52
|
+
verificationUriComplete: string;
|
|
53
|
+
expiresInSeconds: number;
|
|
54
|
+
intervalSeconds: number;
|
|
55
|
+
}
|
|
56
|
+
export interface ClientFacts {
|
|
57
|
+
name: string;
|
|
58
|
+
version: string;
|
|
59
|
+
}
|
|
60
|
+
/** Step 1. Asks Tellagen for a code, naming this client and computer. */
|
|
61
|
+
export declare function startDeviceSignIn(baseUrl: string, client: ClientFacts, fetchFn?: FetchLike): Promise<DeviceStart>;
|
|
62
|
+
export interface ApprovedSignIn {
|
|
63
|
+
apiKey: Secret;
|
|
64
|
+
apiUrl: string;
|
|
65
|
+
keyExpiresAt?: string;
|
|
66
|
+
workspaceName?: string;
|
|
67
|
+
workspaceUrl?: string;
|
|
68
|
+
}
|
|
69
|
+
export type PollResult = {
|
|
70
|
+
state: "pending";
|
|
71
|
+
intervalSeconds: number;
|
|
72
|
+
} | {
|
|
73
|
+
state: "approved";
|
|
74
|
+
signIn: ApprovedSignIn;
|
|
75
|
+
};
|
|
76
|
+
/** Step 3. One poll. A pending answer carries the interval to wait. */
|
|
77
|
+
export declare function pollDeviceToken(baseUrl: string, deviceCode: Secret, fetchFn?: FetchLike): Promise<PollResult>;
|
|
78
|
+
/** Whether this process can show a browser to the person. */
|
|
79
|
+
export declare function canOpenBrowser(env?: Record<string, string | undefined>, platform?: NodeJS.Platform): boolean;
|
|
80
|
+
/** Opens an address in the browser. It never throws and shows nothing. */
|
|
81
|
+
export declare function openInBrowser(address: string, platform?: NodeJS.Platform): boolean;
|
|
82
|
+
export interface ResolvedCredentials {
|
|
83
|
+
apiUrl: string;
|
|
84
|
+
apiKey: string;
|
|
85
|
+
source: "environment" | "sign-in" | "none";
|
|
86
|
+
/** The sign-in this came from, when it came from one. */
|
|
87
|
+
account?: string;
|
|
88
|
+
entry?: SignInEntry;
|
|
89
|
+
/** Why a stored key could not be read; a plain sentence. */
|
|
90
|
+
problem?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* TELLAGEN_API_KEY and TELLAGEN_API_URL win over a stored sign-in. If only
|
|
94
|
+
* the address is set, the stored sign-in for that address is used. If
|
|
95
|
+
* neither is set, the current sign-in is used.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveCredentials(env: Record<string, string | undefined>, vault: CredentialVault | undefined, index: SignInIndex): Promise<ResolvedCredentials>;
|
|
98
|
+
/** The days until a date, rounded up; negative when it is past. */
|
|
99
|
+
export declare function daysUntil(iso: string | undefined, now?: number): number | undefined;
|
|
100
|
+
/** The line for a key that is about to expire or has expired, or nothing. */
|
|
101
|
+
export declare function expiryLine(entry: SignInEntry | undefined, now?: number): string | undefined;
|
|
102
|
+
export interface SignInOptions {
|
|
103
|
+
env?: Record<string, string | undefined>;
|
|
104
|
+
vault: CredentialVault | undefined;
|
|
105
|
+
index: SignInIndex;
|
|
106
|
+
fetch?: FetchLike;
|
|
107
|
+
sleep?: (ms: number) => Promise<void>;
|
|
108
|
+
now?: () => number;
|
|
109
|
+
openBrowser?: (address: string) => boolean;
|
|
110
|
+
canOpenBrowser?: () => boolean;
|
|
111
|
+
}
|
|
112
|
+
export type FlowStatus = "waiting" | "signed_in" | "denied" | "expired" | "failed";
|
|
113
|
+
export interface FlowView {
|
|
114
|
+
status: FlowStatus;
|
|
115
|
+
user_code?: string;
|
|
116
|
+
verification_uri?: string;
|
|
117
|
+
verification_uri_complete?: string;
|
|
118
|
+
expires_in_seconds?: number;
|
|
119
|
+
opened_browser?: boolean;
|
|
120
|
+
workspace?: string;
|
|
121
|
+
api_url?: string;
|
|
122
|
+
key_expires_at?: string;
|
|
123
|
+
storage?: string;
|
|
124
|
+
storage_notice?: string;
|
|
125
|
+
reason?: string;
|
|
126
|
+
message: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Runs one sign-in at a time for a client. `begin` returns at once with the
|
|
130
|
+
* code to show; the polling goes on in the background and stores the key when
|
|
131
|
+
* the person approves. A later call asks how it went.
|
|
132
|
+
*/
|
|
133
|
+
export declare class SignInManager {
|
|
134
|
+
private readonly client;
|
|
135
|
+
private readonly options;
|
|
136
|
+
private flow;
|
|
137
|
+
private cancelled;
|
|
138
|
+
constructor(client: TellagenClient, options: SignInOptions);
|
|
139
|
+
private env;
|
|
140
|
+
/** Stops the polling. The server calls it when the client disconnects. */
|
|
141
|
+
cancel(): void;
|
|
142
|
+
/** The state of the sign-in without starting one. */
|
|
143
|
+
current(): FlowView | undefined;
|
|
144
|
+
private view;
|
|
145
|
+
/**
|
|
146
|
+
* Starts a sign-in, or reports the one that runs. With `waitMs` it waits
|
|
147
|
+
* that long for the person to approve before it answers.
|
|
148
|
+
*/
|
|
149
|
+
begin(args: {
|
|
150
|
+
restart?: boolean;
|
|
151
|
+
waitMs?: number;
|
|
152
|
+
baseUrl?: string;
|
|
153
|
+
openBrowser?: boolean;
|
|
154
|
+
}): Promise<FlowView>;
|
|
155
|
+
private start;
|
|
156
|
+
private poll;
|
|
157
|
+
private finish;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Signs out: the key leaves the keychain and the index, and the client keeps
|
|
161
|
+
* nothing. Tellagen's API does not let a key revoke itself, so the key stays
|
|
162
|
+
* valid on the server until a person revokes it in Tellagen. The answer says
|
|
163
|
+
* so.
|
|
164
|
+
*/
|
|
165
|
+
export declare function signOut(vault: CredentialVault | undefined, index: SignInIndex, account?: string): Promise<{
|
|
166
|
+
signedOut: string[];
|
|
167
|
+
remaining: string[];
|
|
168
|
+
}>;
|
|
169
|
+
export declare const KEY_NOT_REVOKED_NOTE = "The key was removed from this computer. Tellagen keeps it valid until it expires or a person revokes it: in Tellagen, open Settings > Local diagnosis, find the client under Connected clients, and use Sign out there. That revokes the key.";
|