@sortlist/cli 0.29.0 → 0.31.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/README.md CHANGED
@@ -42,7 +42,6 @@ Every query and mutation from the federated GraphQL schema is available as a CLI
42
42
 
43
43
  ```bash
44
44
  sl atlas <operation> # company and contact enrichment
45
- sl chat <operation> # AI assistant (conversations, messages, configuration)
46
45
  sl marketplace <operation> # agencies, projects, opportunities, quotes
47
46
  sl hermes <operation> # OAuth/auth operations
48
47
  ```
@@ -72,52 +71,6 @@ sl schema refresh
72
71
 
73
72
  The endpoint can be configured via `--endpoint`, `SL_ENDPOINT` env var, or `~/.sortlist/config.json`.
74
73
 
75
- ## Interactive chat
76
-
77
- The `chat conversation` command is a hand-written interactive chat client (not auto-generated). It replaces the auto-generated basic `conversation` sub-command on the `chat` service.
78
-
79
- ### Basic mode
80
-
81
- Plain readline-based chat with streaming responses:
82
-
83
- ```bash
84
- sl chat conversation # new conversation
85
- sl chat conversation --conversation-id <id> # resume existing conversation
86
- sl chat conversation --title "Debug session" # new conversation with title
87
- ```
88
-
89
- ### Interactive mode
90
-
91
- Rich terminal UI with markdown rendering, thinking/tool-call visualization, and spinners:
92
-
93
- ```bash
94
- sl chat conversation -i # new conversation
95
- sl chat conversation -i --conversation-id <id> # resume existing conversation
96
- ```
97
-
98
- Interactive mode features:
99
-
100
- - Markdown rendering of assistant responses
101
- - Thinking box showing tool calls with animated spinners
102
- - Event reordering via sequence buffer (handles out-of-order WebSocket delivery)
103
- - `/quit` or Ctrl+C to exit
104
-
105
- ## Debug logs
106
-
107
- The interactive chat writes debug logs to files in the `cli/` directory (both gitignored):
108
-
109
- | File | Contents |
110
- | ----------------- | ------------------------------------------------------------------------ |
111
- | `debug.log` | Raw WebSocket events, sequence buffer warnings, finalization diagnostics |
112
- | `debug-tools.log` | Tool call arguments and full tool results |
113
-
114
- Logs are cleared automatically when a new conversation starts.
115
-
116
- ```bash
117
- tail -f debug.log # watch WebSocket events in real time
118
- cat debug-tools.log # review tool calls and results
119
- ```
120
-
121
74
  ## Global options
122
75
 
123
76
  | Flag | Description |
@@ -130,7 +83,7 @@ The endpoint can also be set via the `SL_ENDPOINT` environment variable or `~/.s
130
83
 
131
84
  ## Code generation
132
85
 
133
- The only build-time step is `npm run codegen`, which generates TypeScript types for hand-written operations (auth flow, interactive chat) using `graphql-codegen`. It reads the schema from `../backend/supergraph.graphql`.
86
+ The only build-time step is `npm run codegen`, which generates TypeScript types for hand-written operations (auth flow) using `graphql-codegen`. It reads the schema from `../backend/supergraph.graphql`.
134
87
 
135
88
  ```bash
136
89
  npm run generate # alias for npm run codegen
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sortlist/cli",
3
- "version": "0.29.0",
4
- "description": "Sortlist platform CLI — GraphQL federation client and Clara AI chat",
3
+ "version": "0.31.0",
4
+ "description": "Sortlist platform CLI — GraphQL federation client",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -29,14 +29,8 @@
29
29
  "@graphql-codegen/cli": "^6.2.1",
30
30
  "@graphql-codegen/client-preset": "^5.2.4",
31
31
  "@graphql-typed-document-node/core": "^3.2.0",
32
- "@inkjs/ui": "^2.0.0",
33
- "@types/react": "^19.2.14",
34
32
  "commander": "^13.0.0",
35
33
  "graphql": "^16.13.2",
36
- "ink": "^5.2.1",
37
- "marked": "^15.0.12",
38
- "marked-terminal": "^7.3.0",
39
- "react": "^18.3.1",
40
34
  "tsx": "^4.19.0"
41
35
  },
42
36
  "devDependencies": {
@@ -52,8 +46,6 @@
52
46
  "eslint-import-resolver-typescript": "^3.6.1",
53
47
  "eslint-plugin-import": "^2.29.1",
54
48
  "eslint-plugin-prettier": "^5.1.3",
55
- "eslint-plugin-react": "7.35.0",
56
- "eslint-plugin-react-hooks": "^4.6.0",
57
49
  "eslint-plugin-sonarjs": "^0.24.0",
58
50
  "lefthook": "^1.11.5",
59
51
  "prettier": "^3.5.3",
@@ -12,6 +12,8 @@ import {
12
12
  isInterfaceType,
13
13
  isListType,
14
14
  isNonNullType,
15
+ isObjectType,
16
+ isScalarType,
15
17
  isUnionType,
16
18
  type GraphQLArgument,
17
19
  type GraphQLEnumType,
@@ -86,12 +88,13 @@ function getInputFields(field: GraphQLField<unknown, unknown>): CliArg[] | null
86
88
  }
87
89
 
88
90
  /**
89
- * Render a GraphQL input type as its SDL signature, e.g. `String!`,
90
- * `[OrganizationSortInput!]`, `OrganizationFilterInput`.
91
+ * Render a GraphQL type as its SDL signature, e.g. `String!`,
92
+ * `[OrganizationSortInput!]`, `OrganizationFilterInput`. Works for both input
93
+ * and output types (the wrapper structure is identical).
91
94
  */
92
- function renderType(type: GraphQLInputType): string {
93
- if (isNonNullType(type)) return `${renderType(type.ofType as GraphQLInputType)}!`;
94
- if (isListType(type)) return `[${renderType(type.ofType as GraphQLInputType)}]`;
95
+ function renderType(type: GraphQLInputType | GraphQLOutputType): string {
96
+ if (isNonNullType(type)) return `${renderType(type.ofType as GraphQLInputType | GraphQLOutputType)}!`;
97
+ if (isListType(type)) return `[${renderType(type.ofType as GraphQLInputType | GraphQLOutputType)}]`;
95
98
  return (type as GraphQLNamedType).name;
96
99
  }
97
100
 
@@ -152,6 +155,85 @@ function describeStructuredType(named: GraphQLNamedType): string | null {
152
155
  return null;
153
156
  }
154
157
 
158
+ /** A named type worth pointing the user at via `sl schema inspect` — i.e. one with structure. */
159
+ function isInspectable(named: GraphQLNamedType): boolean {
160
+ return isInputObjectType(named) || isEnumType(named) || isObjectType(named);
161
+ }
162
+
163
+ function oneLineDescription(text: string | null | undefined): string {
164
+ return (text ?? '').replace(/\s+/g, ' ').trim();
165
+ }
166
+
167
+ /**
168
+ * Render a full, human-readable description of a named type for
169
+ * `sl schema inspect <Type>`: its kind, description, and one level of
170
+ * structure (object/input fields with their types + descriptions, or enum
171
+ * values). Nested structured types are named so the caller can `inspect` them
172
+ * in turn. Returns null if the type does not exist in the schema.
173
+ */
174
+ export function formatTypeInspection(schema: GraphQLSchema, typeName: string): string | null {
175
+ const named = schema.getType(typeName);
176
+ if (!named) return null;
177
+
178
+ const lines: string[] = [];
179
+ const suffix = oneLineDescription(named.description);
180
+ const header = (kind: string): string => {
181
+ const label = kind ? `${kind} ${named.name}` : named.name;
182
+ return suffix ? `${label} — ${suffix}` : label;
183
+ };
184
+
185
+ const pushFields = (entries: Array<{ name: string; typeSig: string; description?: string | null }>): void => {
186
+ const width = Math.max(...entries.map((entry) => `${entry.name}: ${entry.typeSig}`.length), 0);
187
+ for (const entry of entries) {
188
+ const signature = `${entry.name}: ${entry.typeSig}`;
189
+ const note = oneLineDescription(entry.description);
190
+ lines.push(note ? ` ${signature.padEnd(width)} ${note}` : ` ${signature}`);
191
+ }
192
+ };
193
+
194
+ if (isInputObjectType(named) || isObjectType(named)) {
195
+ lines.push(header(isInputObjectType(named) ? 'input' : 'type'));
196
+ pushFields(
197
+ Object.values(named.getFields()).map((f) => ({
198
+ name: f.name,
199
+ typeSig: renderType(f.type),
200
+ description: f.description,
201
+ })),
202
+ );
203
+ } else if (isEnumType(named)) {
204
+ lines.push(header('enum'));
205
+ for (const value of named.getValues()) {
206
+ const note = oneLineDescription(value.description);
207
+ lines.push(note ? ` ${value.name.padEnd(20)} ${note}` : ` ${value.name}`);
208
+ }
209
+ } else if (isScalarType(named)) {
210
+ lines.push(header('scalar'));
211
+ lines.push(' (scalar — pass a plain value)');
212
+ } else {
213
+ lines.push(header(''));
214
+ }
215
+
216
+ // Point the caller at the nested types they can drill into next.
217
+ const nested = new Set<string>();
218
+ if (isInputObjectType(named) || isObjectType(named)) {
219
+ for (const field of Object.values(named.getFields())) {
220
+ const fieldType = unwrap(field.type);
221
+ if (isInspectable(fieldType) && fieldType.name !== named.name) nested.add(fieldType.name);
222
+ }
223
+ }
224
+ if (nested.size > 0) {
225
+ lines.push('');
226
+ lines.push(
227
+ `Inspect nested types: ${[...nested]
228
+ .sort()
229
+ .map((n) => `sl schema inspect ${n}`)
230
+ .join(', ')}`,
231
+ );
232
+ }
233
+
234
+ return lines.join('\n');
235
+ }
236
+
155
237
  /**
156
238
  * Build the help description for a single CLI option from its GraphQL arg:
157
239
  * the field description (if any), the rendered type with a `(JSON)` marker for
@@ -166,9 +248,16 @@ function describeArg(arg: { name: string; type: GraphQLInputType; description?:
166
248
  parts.push(isStructuredInput(arg.type) ? `${typeSig} (JSON)` : typeSig);
167
249
 
168
250
  // Shape hint applies to enums (raw string) and input objects (JSON) alike.
169
- const shape = describeStructuredType(unwrap(arg.type));
251
+ const named = unwrap(arg.type);
252
+ const shape = describeStructuredType(named);
170
253
  if (shape) parts.push(shape);
171
254
 
255
+ // Point at `schema inspect` so nested input/enum types can be drilled into
256
+ // without resorting to raw introspection.
257
+ if (isInputObjectType(named) || isEnumType(named)) {
258
+ parts.push(`details: sl schema inspect ${named.name}`);
259
+ }
260
+
172
261
  return parts.join(' — ');
173
262
  }
174
263
 
@@ -378,7 +467,6 @@ const SERVICE_DESCRIPTIONS: Record<string, string> = {
378
467
  atlas: 'Atlas service (contacts, orgs)',
379
468
  marketplace: 'Marketplace service',
380
469
  hermes: 'Hermes service',
381
- // chat: 'Chat AI service (conversations)',
382
470
  };
383
471
 
384
472
  function serviceDescription(service: string): string {
@@ -14,26 +14,16 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-
14
14
  * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
15
15
  */
16
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,
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 }\n }\n": typeof types.MeDocument,
22
18
  "\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
19
  "\n query LogoutUrl {\n logoutUrl\n }\n": typeof types.LogoutUrlDocument,
25
20
  "\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
21
  "\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
22
  "\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
23
  };
29
24
  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,
25
+ "\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 }\n }\n": types.MeDocument,
35
26
  "\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
27
  "\n query LogoutUrl {\n logoutUrl\n }\n": types.LogoutUrlDocument,
38
28
  "\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
29
  "\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,
@@ -57,31 +47,11 @@ export function gql(source: string): unknown;
57
47
  /**
58
48
  * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
59
49
  */
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"];
50
+ 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 }\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 }\n }\n"];
77
51
  /**
78
52
  * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
79
53
  */
80
54
  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
55
  /**
86
56
  * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
87
57
  */