@sortlist/cli 0.26.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.
Files changed (46) hide show
  1. package/.published +1 -0
  2. package/README.md +145 -0
  3. package/bin/sl.mjs +73 -0
  4. package/codegen.ts +36 -0
  5. package/package.json +62 -0
  6. package/src/commands/chat/chat.ts +302 -0
  7. package/src/commands/chat/interactive/App.tsx +119 -0
  8. package/src/commands/chat/interactive/components/ChatInput.tsx +115 -0
  9. package/src/commands/chat/interactive/components/ChoicePrompt.tsx +35 -0
  10. package/src/commands/chat/interactive/components/MessageView.tsx +63 -0
  11. package/src/commands/chat/interactive/components/ThinkingBox.tsx +54 -0
  12. package/src/commands/chat/interactive/connection.ts +111 -0
  13. package/src/commands/chat/interactive/debug-log.ts +19 -0
  14. package/src/commands/chat/interactive/hooks/useChat.ts +440 -0
  15. package/src/commands/chat/interactive/hooks/useTerminalSize.ts +23 -0
  16. package/src/commands/chat/interactive/index.tsx +26 -0
  17. package/src/commands/chat/interactive/markdown.ts +29 -0
  18. package/src/commands/chat/interactive/types.ts +34 -0
  19. package/src/commands/config.ts +94 -0
  20. package/src/commands/dynamic.ts +396 -0
  21. package/src/commands/login.ts +191 -0
  22. package/src/commands/logout.ts +43 -0
  23. package/src/commands/offer.ts +96 -0
  24. package/src/commands/switch.ts +72 -0
  25. package/src/commands/token.ts +23 -0
  26. package/src/commands/whoami.ts +50 -0
  27. package/src/graphql/client.ts +257 -0
  28. package/src/graphql/generated/gql.ts +106 -0
  29. package/src/graphql/generated/graphql.ts +7732 -0
  30. package/src/graphql/generated/index.ts +1 -0
  31. package/src/graphql/introspection.ts +240 -0
  32. package/src/graphql/operations/common.ts +115 -0
  33. package/src/graphql/operations/hermes.ts +54 -0
  34. package/src/graphql/query-builder.ts +236 -0
  35. package/src/index.ts +176 -0
  36. package/src/lib/auth.ts +58 -0
  37. package/src/lib/browser.ts +6 -0
  38. package/src/lib/company.ts +35 -0
  39. package/src/lib/config.ts +73 -0
  40. package/src/lib/env.ts +10 -0
  41. package/src/lib/output.ts +84 -0
  42. package/src/lib/parse.ts +8 -0
  43. package/src/lib/sentry.ts +77 -0
  44. package/src/lib/sequence-buffer.ts +95 -0
  45. package/src/lib/version-check.ts +88 -0
  46. package/src/types/marked-terminal.d.ts +20 -0
@@ -0,0 +1,96 @@
1
+ import { Command } from 'commander';
2
+
3
+ import { graphql } from '../graphql/client.ts';
4
+ import { CreateSalesOffer } from '../graphql/operations/common.ts';
5
+ import { error, hint, info, isJsonMode, printJson, success } from '../lib/output.ts';
6
+
7
+ interface CreateOptions {
8
+ company: string;
9
+ plan: string;
10
+ periodicity: string;
11
+ website?: string;
12
+ email?: string;
13
+ discountPercent?: string;
14
+ discountAmount?: string;
15
+ extraSeats?: string;
16
+ extraCredits?: string;
17
+ expiresInDays?: string;
18
+ endpoint?: string;
19
+ json?: boolean;
20
+ }
21
+
22
+ const createCommand = new Command('create')
23
+ .summary('Create a sales offer and get the prospect invite link')
24
+ .description(
25
+ 'Pre-provision a sales-led deal and return the invite link to share with the prospect.\n\n' +
26
+ 'Creates the prospect company, its billing customer, and a pending offer (a catalog tier\n' +
27
+ 'at a negotiated discount), then prints the onboarding invite URL. The deal is attributed\n' +
28
+ 'to you. Requires the billing/offer:write and max/company:write scopes (Sortlist admins).\n\n' +
29
+ 'Examples:\n' +
30
+ ' sl offer create --company "Acme" --website acme.com --plan growth --discount-percent 20 --email buyer@acme.com\n' +
31
+ ' sl offer create --company "Acme" --plan scale --periodicity monthly --extra-seats 3 --json',
32
+ )
33
+ .requiredOption('--company <name>', 'Prospect company name')
34
+ .requiredOption('--plan <plan>', 'Catalog tier: starter, growth, or scale')
35
+ .option('--periodicity <period>', 'Billing periodicity: monthly or annual', 'annual')
36
+ .option('--website <url>', 'Prospect company website (seeds onboarding)')
37
+ .option('--email <email>', 'Prospect email (prefills sign-up and is appended to the link)')
38
+ .option('--discount-percent <n>', 'Percentage discount, 0-100 (exclusive with --discount-amount)')
39
+ .option('--discount-amount <eur>', 'Absolute recurring discount in EUR (exclusive with --discount-percent)')
40
+ .option('--extra-seats <n>', 'Extra seats on top of the tier')
41
+ .option('--extra-credits <n>', 'Extra credits each period on top of the tier')
42
+ .option('--expires-in-days <n>', 'Days until the offer expires (default: never)')
43
+ .action(async function (this: Command) {
44
+ const opts = this.optsWithGlobals() as CreateOptions;
45
+
46
+ if (opts.discountPercent != null && opts.discountAmount != null) {
47
+ error('Pass either --discount-percent or --discount-amount, not both.');
48
+ process.exit(1);
49
+ }
50
+
51
+ const expiresAt =
52
+ opts.expiresInDays != null
53
+ ? new Date(Date.now() + Number(opts.expiresInDays) * 24 * 60 * 60 * 1000).toISOString()
54
+ : undefined;
55
+
56
+ const input = {
57
+ name: opts.company,
58
+ plan: opts.plan,
59
+ periodicity: opts.periodicity,
60
+ website: opts.website,
61
+ email: opts.email,
62
+ discountPercent: opts.discountPercent != null ? Number(opts.discountPercent) : undefined,
63
+ discountAmountEur: opts.discountAmount != null ? Number(opts.discountAmount) : undefined,
64
+ extraSeats: opts.extraSeats != null ? Number(opts.extraSeats) : undefined,
65
+ extraCredits: opts.extraCredits != null ? Number(opts.extraCredits) : undefined,
66
+ expiresAt,
67
+ };
68
+
69
+ try {
70
+ const data = await graphql(CreateSalesOffer, { input }, { endpoint: opts.endpoint });
71
+ const offer = data.createSalesOffer;
72
+ if (offer == null) {
73
+ error('The server did not return an offer.');
74
+ process.exit(1);
75
+ }
76
+
77
+ if (isJsonMode(opts)) {
78
+ printJson(offer);
79
+ return;
80
+ }
81
+
82
+ success(`Offer created for ${opts.company}.`);
83
+ info('');
84
+ info('Invite link (share with the prospect):');
85
+ info(` ${offer.inviteUrl}`);
86
+ } catch (caught) {
87
+ error(`Could not create the offer: ${(caught as Error).message}`);
88
+ hint('Check that your account has the billing/offer:write and max/company:write scopes.');
89
+ process.exit(1);
90
+ }
91
+ });
92
+
93
+ export const offerCommand = new Command('offer')
94
+ .summary('Manage sales-led offers')
95
+ .description('Create sales-led offers and get the prospect invite link.')
96
+ .addCommand(createCommand);
@@ -0,0 +1,72 @@
1
+ import { Command } from 'commander';
2
+
3
+ import { graphql } from '../graphql/client.ts';
4
+ import { Me } from '../graphql/operations/common.ts';
5
+ import { loadConfig, saveConfig } from '../lib/config.ts';
6
+ import { error, hint, info, success } from '../lib/output.ts';
7
+
8
+ interface CompanyChoice {
9
+ id: string;
10
+ name: string;
11
+ slug: string;
12
+ }
13
+
14
+ async function fetchCompanies(endpoint?: string): Promise<CompanyChoice[]> {
15
+ const data = await graphql(Me, undefined, { endpoint });
16
+ return (data.me?.companies?.nodes ?? [])
17
+ .filter((c): c is { id: string; name: string; slug: string } => c != null)
18
+ .map((c) => ({ id: c.id, name: c.name ?? c.slug, slug: c.slug }));
19
+ }
20
+
21
+ export const switchCommand = new Command('switch')
22
+ .summary("Switch which company you're working with")
23
+ .description(
24
+ "Switch which company you're working with\n\n" +
25
+ 'Run without arguments to see all available companies.\n' +
26
+ 'Pass a company slug to switch immediately.\n\n' +
27
+ 'Examples:\n' +
28
+ ' sl switch List your companies (active one is marked)\n' +
29
+ " sl switch acme Switch to the 'acme' company",
30
+ )
31
+ .argument('[slug]', 'Company slug to switch to (omit to list)')
32
+ .action(async function (this: Command, slug?: string) {
33
+ const opts = this.optsWithGlobals();
34
+ const config = loadConfig();
35
+ const companies = await fetchCompanies(opts.endpoint);
36
+
37
+ if (companies.length === 0) {
38
+ error('No companies found for your account.');
39
+ hint('Make sure your Sortlist account is linked to at least one company.');
40
+ process.exit(1);
41
+ }
42
+
43
+ // No slug provided — list companies
44
+ if (!slug) {
45
+ for (const c of companies) {
46
+ const marker = c.slug === config.companySlug ? ' ← active' : '';
47
+ info(` ${c.slug} ${c.name}${marker}`);
48
+ }
49
+ return;
50
+ }
51
+
52
+ // Switch to the provided slug
53
+ const selected = companies.find((c) => c.slug === slug);
54
+ if (!selected) {
55
+ error(`Company "${slug}" not found.`);
56
+ info('');
57
+ info(' Available companies:');
58
+ for (const c of companies) {
59
+ info(` ${c.slug} ${c.name}`);
60
+ }
61
+ hint('Run `sl switch <slug>` with one of the slugs above.');
62
+ process.exit(1);
63
+ }
64
+
65
+ saveConfig({
66
+ companyId: selected.id,
67
+ companySlug: selected.slug,
68
+ companyName: selected.name,
69
+ });
70
+
71
+ success(`Switched to ${selected.name} (${selected.slug})`);
72
+ });
@@ -0,0 +1,23 @@
1
+ import { Command } from 'commander';
2
+
3
+ import { ensureAuthenticated, isExpired } from '../lib/auth.ts';
4
+ import { error, hint } from '../lib/output.ts';
5
+
6
+ export const tokenCommand = new Command('token')
7
+ .summary('Print your current access token to stdout')
8
+ .description(
9
+ 'Print your current access token to stdout\n\n' +
10
+ 'Useful for piping into other tools or scripts.\n\n' +
11
+ 'Examples:\n' +
12
+ ' sl token Print the token\n' +
13
+ ' curl -H "Authorization: Bearer $(sl token)" ...',
14
+ )
15
+ .action(() => {
16
+ const creds = ensureAuthenticated();
17
+ if (isExpired(creds)) {
18
+ error('Your access token has expired.');
19
+ hint('Run `sl login` to re-authenticate.');
20
+ process.exit(2);
21
+ }
22
+ process.stdout.write(creds.accessToken);
23
+ });
@@ -0,0 +1,50 @@
1
+ import { Command } from 'commander';
2
+
3
+ import { graphql } from '../graphql/client.ts';
4
+ import { Me } from '../graphql/operations/common.ts';
5
+ import { loadConfig } from '../lib/config.ts';
6
+ import { error, hint, info, isJsonMode, printJson } from '../lib/output.ts';
7
+
8
+ export const whoamiCommand = new Command('whoami')
9
+ .summary("Show who you're currently logged in as")
10
+ .description(
11
+ "Show who you're currently logged in as\n\n" +
12
+ 'Displays your name, email, and the companies you are a member of\n' +
13
+ '(the active one is marked). Use --json for machine-readable output.\n\n' +
14
+ 'Examples:\n' +
15
+ ' sl whoami Show your identity and companies\n' +
16
+ ' sl whoami --json Output full user object as JSON',
17
+ )
18
+ .action(async function (this: Command) {
19
+ const opts = this.optsWithGlobals();
20
+ const data = await graphql(Me, undefined, {
21
+ endpoint: opts.endpoint,
22
+ });
23
+
24
+ const user = data.me;
25
+ if (!user) {
26
+ error('You are not authenticated.');
27
+ hint('Run `sl login` to log in first.');
28
+ process.exit(1);
29
+ }
30
+
31
+ if (isJsonMode(opts)) {
32
+ printJson(user);
33
+ return;
34
+ }
35
+
36
+ info(`${user.firstName} ${user.lastName} <${user.email}> (sub: ${user.sub})`);
37
+
38
+ const companies = (user.companies?.nodes ?? []).filter(
39
+ (c): c is { id: string; name: string; slug: string } => c != null,
40
+ );
41
+ if (companies.length === 0) return;
42
+
43
+ const activeSlug = loadConfig().companySlug;
44
+ info('');
45
+ info('Companies:');
46
+ for (const company of companies) {
47
+ const marker = company.slug === activeSlug ? ' ← active' : '';
48
+ info(` ${company.slug} ${company.name}${marker}`);
49
+ }
50
+ });
@@ -0,0 +1,257 @@
1
+ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { print } from 'graphql';
3
+
4
+ import { ensureAuthenticated, isExpired, saveCredentials, type Credentials } from '../lib/auth.ts';
5
+ import { getEndpoint } from '../lib/config.ts';
6
+ import { error, hint, info, warn } from '../lib/output.ts';
7
+ import { addBreadcrumb, captureException } from '../lib/sentry.ts';
8
+ import { RefreshToken } from './operations/hermes.ts';
9
+
10
+ function extractOperationName(query: string): string {
11
+ const match = query.match(/(?:mutation|query|subscription)\s+(\w+)/);
12
+ return match?.[1] ?? 'UnknownOperation';
13
+ }
14
+
15
+ interface GraphQLResponse<T = Record<string, unknown>> {
16
+ data?: T;
17
+ errors?: Array<{ message: string; extensions?: Record<string, unknown> }>;
18
+ }
19
+
20
+ interface RequestOptions {
21
+ endpoint?: string;
22
+ authenticated?: boolean;
23
+ throwOnError?: boolean;
24
+ }
25
+
26
+ export class GraphQLRequestError extends Error {
27
+ readonly operationName: string;
28
+ readonly httpStatus?: number;
29
+ readonly graphqlErrors?: Array<{ message: string; extensions?: Record<string, unknown> }>;
30
+
31
+ constructor(
32
+ message: string,
33
+ details: {
34
+ operationName: string;
35
+ httpStatus?: number;
36
+ graphqlErrors?: Array<{ message: string; extensions?: Record<string, unknown> }>;
37
+ },
38
+ ) {
39
+ super(message);
40
+ this.name = 'GraphQLRequestError';
41
+ this.operationName = details.operationName;
42
+ this.httpStatus = details.httpStatus;
43
+ this.graphqlErrors = details.graphqlErrors;
44
+ }
45
+ }
46
+
47
+ async function refreshAccessToken(creds: Credentials, endpoint: string): Promise<Credentials | null> {
48
+ const res = await fetch(endpoint, {
49
+ method: 'POST',
50
+ headers: { 'Content-Type': 'application/json', 'X-API-Client': 'sl-cli' },
51
+ body: JSON.stringify({
52
+ query: print(RefreshToken),
53
+ variables: { input: { refreshToken: creds.refreshToken } },
54
+ }),
55
+ });
56
+
57
+ const json = (await res.json()) as GraphQLResponse<{
58
+ refreshToken: {
59
+ accessToken: string;
60
+ refreshToken: string;
61
+ idToken: string;
62
+ expiresIn: number;
63
+ error: string | null;
64
+ };
65
+ }>;
66
+
67
+ const token = json.data?.refreshToken;
68
+ if (!token || token.error) return null;
69
+
70
+ const newCreds: Credentials = {
71
+ accessToken: token.accessToken,
72
+ refreshToken: token.refreshToken,
73
+ idToken: token.idToken,
74
+ expiresAt: Math.floor(Date.now() / 1000) + token.expiresIn,
75
+ };
76
+
77
+ saveCredentials(newCreds);
78
+ return newCreds;
79
+ }
80
+
81
+ /**
82
+ * Internal: execute a raw GraphQL query string.
83
+ */
84
+ async function executeQuery<T = Record<string, unknown>>(
85
+ query: string,
86
+ variables: Record<string, unknown> | undefined,
87
+ options: RequestOptions = {},
88
+ ): Promise<T> {
89
+ const endpoint = getEndpoint(options.endpoint);
90
+ const authenticated = options.authenticated ?? true;
91
+ const throwOnError = options.throwOnError ?? false;
92
+ const operationName = extractOperationName(query);
93
+ const verbose = process.env.SL_DEBUG === '1';
94
+
95
+ addBreadcrumb({
96
+ category: 'graphql',
97
+ message: operationName,
98
+ data: { endpoint, authenticated },
99
+ level: 'info',
100
+ });
101
+
102
+ if (verbose) {
103
+ info(`[debug] ${operationName} → ${endpoint}`);
104
+ info(`[debug] Query:\n${query}`);
105
+ if (variables) {
106
+ info(`[debug] Variables: ${JSON.stringify(variables, null, 2)}`);
107
+ }
108
+ }
109
+
110
+ const headers: Record<string, string> = {
111
+ 'Content-Type': 'application/json',
112
+ 'X-API-Client': 'sl-cli',
113
+ };
114
+
115
+ if (authenticated) {
116
+ let creds = ensureAuthenticated();
117
+
118
+ if (isExpired(creds)) {
119
+ const refreshed = await refreshAccessToken(creds, endpoint);
120
+ if (!refreshed) {
121
+ if (throwOnError) {
122
+ throw new GraphQLRequestError('Session expired and could not be refreshed.', { operationName });
123
+ }
124
+ error('Your session has expired and could not be refreshed.');
125
+ hint('Run `sl login` to re-authenticate.');
126
+ process.exit(2);
127
+ }
128
+ creds = refreshed;
129
+ }
130
+
131
+ headers['Authorization'] = `Bearer ${creds.accessToken}`;
132
+
133
+ if (verbose) {
134
+ info(`[debug] JWT: ${creds.accessToken}`);
135
+ }
136
+ }
137
+
138
+ const res = await fetch(endpoint, {
139
+ method: 'POST',
140
+ headers,
141
+ body: JSON.stringify({ query, variables }),
142
+ });
143
+
144
+ if (!res.ok) {
145
+ const body = await res.text();
146
+ captureException(new Error(`${operationName} failed: HTTP ${res.status}`), {
147
+ operationName,
148
+ httpStatus: res.status,
149
+ endpoint,
150
+ });
151
+ if (throwOnError) {
152
+ throw new GraphQLRequestError(`${operationName} failed: HTTP ${res.status} ${res.statusText}`, {
153
+ operationName,
154
+ httpStatus: res.status,
155
+ });
156
+ }
157
+ error(`${operationName} failed: HTTP ${res.status} ${res.statusText}`);
158
+ hint('Check your network connection and endpoint: sl config show');
159
+ if (verbose) {
160
+ info(`[debug] Response body: ${body}`);
161
+ }
162
+ process.exit(3);
163
+ }
164
+
165
+ const json = (await res.json()) as GraphQLResponse<T>;
166
+
167
+ if (json.errors?.length) {
168
+ // If there's also data, return it — partial success with some field errors
169
+ if (json.data) {
170
+ for (const gqlError of json.errors) {
171
+ warn(gqlError.message);
172
+ }
173
+ const hasFieldError = json.errors.some(
174
+ (e) => e.message.includes('Failed to implement') || e.message.includes('undefined method'),
175
+ );
176
+ if (hasFieldError) {
177
+ hint('Use --fields to select specific fields, or --exclude to skip broken ones.');
178
+ }
179
+ return json.data;
180
+ }
181
+
182
+ captureException(new Error(`${operationName} GraphQL errors`), {
183
+ operationName,
184
+ errors: json.errors.map((e) => e.message),
185
+ });
186
+
187
+ if (throwOnError) {
188
+ throw new GraphQLRequestError(`${operationName} failed: ${json.errors.map((e) => e.message).join('; ')}`, {
189
+ operationName,
190
+ graphqlErrors: json.errors,
191
+ });
192
+ }
193
+
194
+ error(`${operationName} failed:`);
195
+ for (const gqlError of json.errors) {
196
+ info(` ${gqlError.message}`);
197
+ if (verbose && gqlError.extensions) {
198
+ info(`[debug] Extensions: ${JSON.stringify(gqlError.extensions)}`);
199
+ }
200
+ }
201
+
202
+ const hasFieldError = json.errors.some(
203
+ (e) => e.message.includes('Failed to implement') || e.message.includes('undefined method'),
204
+ );
205
+ if (hasFieldError) {
206
+ hint('Use --fields to select specific fields, or --exclude to skip broken ones.');
207
+ hint(`Example: sl ${operationName.toLowerCase()} --fields id,title,status`);
208
+ }
209
+
210
+ process.exit(1);
211
+ }
212
+
213
+ if (!json.data) {
214
+ if (throwOnError) {
215
+ throw new GraphQLRequestError(`${operationName}: no data returned from API.`, { operationName });
216
+ }
217
+ error(`${operationName}: no data returned from API.`);
218
+ hint('This usually means the server returned an empty response.');
219
+ hint('Verify your endpoint: sl config show');
220
+ process.exit(1);
221
+ }
222
+
223
+ return json.data;
224
+ }
225
+
226
+ /**
227
+ * Execute a typed GraphQL operation (for hand-written commands).
228
+ */
229
+ export async function graphql<TData, TVars>(
230
+ document: TypedDocumentNode<TData, TVars>,
231
+ variables?: TVars,
232
+ options: RequestOptions = {},
233
+ ): Promise<TData> {
234
+ return executeQuery<TData>(print(document), variables as Record<string, unknown> | undefined, options);
235
+ }
236
+
237
+ /**
238
+ * Execute a raw GraphQL query string (for generated/dynamic commands).
239
+ */
240
+ export async function graphqlRaw(
241
+ query: string,
242
+ variables?: Record<string, unknown>,
243
+ options: RequestOptions = {},
244
+ ): Promise<Record<string, unknown>> {
245
+ return executeQuery(query, variables, options);
246
+ }
247
+
248
+ /**
249
+ * Execute an unauthenticated typed GraphQL operation.
250
+ */
251
+ export async function graphqlUnauthenticated<TData, TVars>(
252
+ document: TypedDocumentNode<TData, TVars>,
253
+ variables?: TVars,
254
+ endpoint?: string,
255
+ ): Promise<TData> {
256
+ return graphql(document, variables, { endpoint, authenticated: false });
257
+ }
@@ -0,0 +1,106 @@
1
+ /* eslint-disable */
2
+ import * as types from './graphql.js';
3
+ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
4
+
5
+ /**
6
+ * Map of all GraphQL operations in the project.
7
+ *
8
+ * This map has several performance disadvantages:
9
+ * 1. It is not tree-shakeable, so it will include all operations in the project.
10
+ * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
11
+ * 3. It does not support dead code elimination, so it will add unused operations.
12
+ *
13
+ * Therefore it is highly recommended to use the babel or swc plugin for production.
14
+ * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
15
+ */
16
+ type Documents = {
17
+ "\n query Me {\n me {\n sub\n email\n firstName\n lastName\n companies {\n nodes {\n id\n name\n slug\n }\n }\n memberships {\n nodes {\n conversation {\n id\n }\n company {\n id\n }\n }\n }\n }\n }\n": typeof types.MeDocument,
18
+ "\n query Conversation($id: ID!) {\n node(id: $id) {\n ... on Conversation {\n id\n title\n status\n modelId\n createdAt\n updatedAt\n messages(last: 50) {\n nodes {\n id\n role\n content\n modelId\n inputTokens\n outputTokens\n createdAt\n }\n }\n }\n }\n }\n": typeof types.ConversationDocument,
19
+ "\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n id\n role\n content\n createdAt\n }\n }\n": typeof types.SendMessageDocument,
20
+ "\n mutation RespondToToolCall($input: RespondToToolCallInput!) {\n respondToToolCall(input: $input) {\n ok\n }\n }\n": typeof types.RespondToToolCallDocument,
21
+ "\n mutation CancelConversation($input: CancelConversationInput!) {\n cancelConversation(input: $input) {\n ok\n }\n }\n": typeof types.CancelConversationDocument,
22
+ "\n mutation CreateSalesOffer($input: CreateSalesOfferInput!) {\n createSalesOffer(input: $input) {\n inviteUrl\n offerId\n companyId\n }\n }\n": typeof types.CreateSalesOfferDocument,
23
+ "\n subscription ConversationEvent($conversationId: ID!) {\n conversationEvent(conversationId: $conversationId) {\n __typename\n agentLoopId\n agentLoopSequence\n ... on MessageChunkEvent { content }\n ... on ToolCallEvent { toolName toolCallId arguments }\n ... on ToolResultEvent { toolCallId content }\n ... on AgentPickedEvent { agent reason turn }\n ... on SupervisorVerdictEvent { verdict reason turn }\n ... on AgentLoopCompletedEvent { messageId }\n ... on AgentLoopFailedEvent { message }\n }\n }\n": typeof types.ConversationEventDocument,
24
+ "\n query LogoutUrl {\n logoutUrl\n }\n": typeof types.LogoutUrlDocument,
25
+ "\n mutation DeviceAuthorize($input: DeviceAuthorizeInput!) {\n deviceAuthorize(input: $input) {\n deviceCode\n expiresIn\n interval\n userCode\n verificationUri\n verificationUriComplete\n }\n }\n": typeof types.DeviceAuthorizeDocument,
26
+ "\n mutation DeviceToken($input: DeviceTokenInput!) {\n deviceToken(input: $input) {\n accessToken\n error\n expiresIn\n idToken\n refreshToken\n tokenType\n }\n }\n": typeof types.DeviceTokenDocument,
27
+ "\n mutation RefreshToken($input: RefreshTokenInput!) {\n refreshToken(input: $input) {\n accessToken\n error\n expiresIn\n idToken\n refreshToken\n tokenType\n }\n }\n": typeof types.RefreshTokenDocument,
28
+ };
29
+ const documents: Documents = {
30
+ "\n query Me {\n me {\n sub\n email\n firstName\n lastName\n companies {\n nodes {\n id\n name\n slug\n }\n }\n memberships {\n nodes {\n conversation {\n id\n }\n company {\n id\n }\n }\n }\n }\n }\n": types.MeDocument,
31
+ "\n query Conversation($id: ID!) {\n node(id: $id) {\n ... on Conversation {\n id\n title\n status\n modelId\n createdAt\n updatedAt\n messages(last: 50) {\n nodes {\n id\n role\n content\n modelId\n inputTokens\n outputTokens\n createdAt\n }\n }\n }\n }\n }\n": types.ConversationDocument,
32
+ "\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n id\n role\n content\n createdAt\n }\n }\n": types.SendMessageDocument,
33
+ "\n mutation RespondToToolCall($input: RespondToToolCallInput!) {\n respondToToolCall(input: $input) {\n ok\n }\n }\n": types.RespondToToolCallDocument,
34
+ "\n mutation CancelConversation($input: CancelConversationInput!) {\n cancelConversation(input: $input) {\n ok\n }\n }\n": types.CancelConversationDocument,
35
+ "\n mutation CreateSalesOffer($input: CreateSalesOfferInput!) {\n createSalesOffer(input: $input) {\n inviteUrl\n offerId\n companyId\n }\n }\n": types.CreateSalesOfferDocument,
36
+ "\n subscription ConversationEvent($conversationId: ID!) {\n conversationEvent(conversationId: $conversationId) {\n __typename\n agentLoopId\n agentLoopSequence\n ... on MessageChunkEvent { content }\n ... on ToolCallEvent { toolName toolCallId arguments }\n ... on ToolResultEvent { toolCallId content }\n ... on AgentPickedEvent { agent reason turn }\n ... on SupervisorVerdictEvent { verdict reason turn }\n ... on AgentLoopCompletedEvent { messageId }\n ... on AgentLoopFailedEvent { message }\n }\n }\n": types.ConversationEventDocument,
37
+ "\n query LogoutUrl {\n logoutUrl\n }\n": types.LogoutUrlDocument,
38
+ "\n mutation DeviceAuthorize($input: DeviceAuthorizeInput!) {\n deviceAuthorize(input: $input) {\n deviceCode\n expiresIn\n interval\n userCode\n verificationUri\n verificationUriComplete\n }\n }\n": types.DeviceAuthorizeDocument,
39
+ "\n mutation DeviceToken($input: DeviceTokenInput!) {\n deviceToken(input: $input) {\n accessToken\n error\n expiresIn\n idToken\n refreshToken\n tokenType\n }\n }\n": types.DeviceTokenDocument,
40
+ "\n mutation RefreshToken($input: RefreshTokenInput!) {\n refreshToken(input: $input) {\n accessToken\n error\n expiresIn\n idToken\n refreshToken\n tokenType\n }\n }\n": types.RefreshTokenDocument,
41
+ };
42
+
43
+ /**
44
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
45
+ *
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const query = gql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
50
+ * ```
51
+ *
52
+ * The query argument is unknown!
53
+ * Please regenerate the types.
54
+ */
55
+ export function gql(source: string): unknown;
56
+
57
+ /**
58
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
59
+ */
60
+ export function gql(source: "\n query Me {\n me {\n sub\n email\n firstName\n lastName\n companies {\n nodes {\n id\n name\n slug\n }\n }\n memberships {\n nodes {\n conversation {\n id\n }\n company {\n id\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query Me {\n me {\n sub\n email\n firstName\n lastName\n companies {\n nodes {\n id\n name\n slug\n }\n }\n memberships {\n nodes {\n conversation {\n id\n }\n company {\n id\n }\n }\n }\n }\n }\n"];
61
+ /**
62
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
63
+ */
64
+ export function gql(source: "\n query Conversation($id: ID!) {\n node(id: $id) {\n ... on Conversation {\n id\n title\n status\n modelId\n createdAt\n updatedAt\n messages(last: 50) {\n nodes {\n id\n role\n content\n modelId\n inputTokens\n outputTokens\n createdAt\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query Conversation($id: ID!) {\n node(id: $id) {\n ... on Conversation {\n id\n title\n status\n modelId\n createdAt\n updatedAt\n messages(last: 50) {\n nodes {\n id\n role\n content\n modelId\n inputTokens\n outputTokens\n createdAt\n }\n }\n }\n }\n }\n"];
65
+ /**
66
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
67
+ */
68
+ export function gql(source: "\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n id\n role\n content\n createdAt\n }\n }\n"): (typeof documents)["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n id\n role\n content\n createdAt\n }\n }\n"];
69
+ /**
70
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
71
+ */
72
+ export function gql(source: "\n mutation RespondToToolCall($input: RespondToToolCallInput!) {\n respondToToolCall(input: $input) {\n ok\n }\n }\n"): (typeof documents)["\n mutation RespondToToolCall($input: RespondToToolCallInput!) {\n respondToToolCall(input: $input) {\n ok\n }\n }\n"];
73
+ /**
74
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
75
+ */
76
+ export function gql(source: "\n mutation CancelConversation($input: CancelConversationInput!) {\n cancelConversation(input: $input) {\n ok\n }\n }\n"): (typeof documents)["\n mutation CancelConversation($input: CancelConversationInput!) {\n cancelConversation(input: $input) {\n ok\n }\n }\n"];
77
+ /**
78
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
79
+ */
80
+ export function gql(source: "\n mutation CreateSalesOffer($input: CreateSalesOfferInput!) {\n createSalesOffer(input: $input) {\n inviteUrl\n offerId\n companyId\n }\n }\n"): (typeof documents)["\n mutation CreateSalesOffer($input: CreateSalesOfferInput!) {\n createSalesOffer(input: $input) {\n inviteUrl\n offerId\n companyId\n }\n }\n"];
81
+ /**
82
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
83
+ */
84
+ export function gql(source: "\n subscription ConversationEvent($conversationId: ID!) {\n conversationEvent(conversationId: $conversationId) {\n __typename\n agentLoopId\n agentLoopSequence\n ... on MessageChunkEvent { content }\n ... on ToolCallEvent { toolName toolCallId arguments }\n ... on ToolResultEvent { toolCallId content }\n ... on AgentPickedEvent { agent reason turn }\n ... on SupervisorVerdictEvent { verdict reason turn }\n ... on AgentLoopCompletedEvent { messageId }\n ... on AgentLoopFailedEvent { message }\n }\n }\n"): (typeof documents)["\n subscription ConversationEvent($conversationId: ID!) {\n conversationEvent(conversationId: $conversationId) {\n __typename\n agentLoopId\n agentLoopSequence\n ... on MessageChunkEvent { content }\n ... on ToolCallEvent { toolName toolCallId arguments }\n ... on ToolResultEvent { toolCallId content }\n ... on AgentPickedEvent { agent reason turn }\n ... on SupervisorVerdictEvent { verdict reason turn }\n ... on AgentLoopCompletedEvent { messageId }\n ... on AgentLoopFailedEvent { message }\n }\n }\n"];
85
+ /**
86
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
87
+ */
88
+ export function gql(source: "\n query LogoutUrl {\n logoutUrl\n }\n"): (typeof documents)["\n query LogoutUrl {\n logoutUrl\n }\n"];
89
+ /**
90
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
91
+ */
92
+ export function gql(source: "\n mutation DeviceAuthorize($input: DeviceAuthorizeInput!) {\n deviceAuthorize(input: $input) {\n deviceCode\n expiresIn\n interval\n userCode\n verificationUri\n verificationUriComplete\n }\n }\n"): (typeof documents)["\n mutation DeviceAuthorize($input: DeviceAuthorizeInput!) {\n deviceAuthorize(input: $input) {\n deviceCode\n expiresIn\n interval\n userCode\n verificationUri\n verificationUriComplete\n }\n }\n"];
93
+ /**
94
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
95
+ */
96
+ export function gql(source: "\n mutation DeviceToken($input: DeviceTokenInput!) {\n deviceToken(input: $input) {\n accessToken\n error\n expiresIn\n idToken\n refreshToken\n tokenType\n }\n }\n"): (typeof documents)["\n mutation DeviceToken($input: DeviceTokenInput!) {\n deviceToken(input: $input) {\n accessToken\n error\n expiresIn\n idToken\n refreshToken\n tokenType\n }\n }\n"];
97
+ /**
98
+ * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
99
+ */
100
+ export function gql(source: "\n mutation RefreshToken($input: RefreshTokenInput!) {\n refreshToken(input: $input) {\n accessToken\n error\n expiresIn\n idToken\n refreshToken\n tokenType\n }\n }\n"): (typeof documents)["\n mutation RefreshToken($input: RefreshTokenInput!) {\n refreshToken(input: $input) {\n accessToken\n error\n expiresIn\n idToken\n refreshToken\n tokenType\n }\n }\n"];
101
+
102
+ export function gql(source: string) {
103
+ return (documents as any)[source] ?? {};
104
+ }
105
+
106
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;