@soat/cli 0.0.1 → 0.4.4

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025, Terezinha Tech Operations (ttoss)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/soat CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require('../dist/index.js');
2
+ import('../dist/esm/index.js');
package/dist/esm/index.js CHANGED
@@ -1,33 +1,1161 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
2
7
 
3
8
  // src/index.ts
9
+ import { createHmac, timingSafeEqual } from "crypto";
10
+ import { createServer } from "http";
11
+ import input from "@inquirer/input";
12
+ import password from "@inquirer/password";
13
+ import * as sdk from "@soat/sdk";
4
14
  import { program } from "commander";
5
15
 
6
16
  // package.json
7
17
  var package_default = {
8
- name: "soat",
9
- version: "0.0.1",
18
+ name: "@soat/cli",
19
+ version: "0.4.4",
20
+ type: "module",
10
21
  scripts: {
11
- build: "tsup",
12
- test: "jest --projects tests/unit"
22
+ generate: "tsx scripts/generate.ts",
23
+ lint: "eslint src",
24
+ typecheck: "tsc --noEmit",
25
+ build: "pnpm generate && tsup"
13
26
  },
14
27
  dependencies: {
15
- commander: "^14.0.2"
28
+ "@inquirer/input": "^5.0.12",
29
+ "@inquirer/password": "^5.0.12",
30
+ "@soat/sdk": "workspace:*",
31
+ "@ttoss/logger": "^0.8.10",
32
+ commander: "^14.0.3"
16
33
  },
17
34
  devDependencies: {
18
- "@ttoss/config": "^1.35.12",
35
+ "@ttoss/config": "^1.37.10",
19
36
  "@types/jest": "^30.0.0",
20
- jest: "^30.2.0",
37
+ "@types/js-yaml": "^4.0.9",
38
+ jest: "^30.3.0",
39
+ "js-yaml": "^4.1.1",
21
40
  tsup: "^8.5.1",
22
41
  tsx: "^4.21.0"
23
42
  },
24
- files: ["dist"],
25
- bin: "./bin/soat"
43
+ files: ["dist", "bin"],
44
+ repository: {
45
+ type: "git",
46
+ url: "https://github.com/ttoss/soat"
47
+ },
48
+ bin: "./bin/soat",
49
+ publishConfig: {
50
+ access: "public",
51
+ provenance: true
52
+ }
53
+ };
54
+
55
+ // src/config.ts
56
+ import * as fs from "fs";
57
+ import * as os from "os";
58
+ import * as path from "path";
59
+ import { createClient, createConfig } from "@soat/sdk";
60
+ var CONFIG_FILE = path.join(os.homedir(), ".soat", "config.json");
61
+ var readConfig = /* @__PURE__ */__name(() => {
62
+ try {
63
+ return JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));
64
+ } catch {
65
+ return {};
66
+ }
67
+ }, "readConfig");
68
+ var writeProfile = /* @__PURE__ */__name((name, profile) => {
69
+ const config = readConfig();
70
+ config[name] = profile;
71
+ fs.mkdirSync(path.dirname(CONFIG_FILE), {
72
+ recursive: true
73
+ });
74
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
75
+ }, "writeProfile");
76
+ var resolveClient = /* @__PURE__ */__name(profileName => {
77
+ const envBaseUrl = process.env["SOAT_BASE_URL"];
78
+ const envToken = process.env["SOAT_TOKEN"];
79
+ if (envBaseUrl && envToken) {
80
+ return createClient(createConfig({
81
+ baseUrl: envBaseUrl,
82
+ headers: {
83
+ Authorization: `Bearer ${envToken}`
84
+ }
85
+ }));
86
+ }
87
+ if (envBaseUrl && !envToken) {
88
+ return createClient(createConfig({
89
+ baseUrl: envBaseUrl
90
+ }));
91
+ }
92
+ const name = profileName ?? process.env["SOAT_PROFILE"] ?? "default";
93
+ const config = readConfig();
94
+ const profile = config[name];
95
+ if (!profile) {
96
+ console.error(`Profile "${name}" not found. Run: soat configure${name !== "default" ? ` --profile ${name}` : ""}`);
97
+ process.exit(1);
98
+ }
99
+ return createClient(createConfig({
100
+ baseUrl: profile.baseUrl,
101
+ headers: {
102
+ Authorization: `Bearer ${profile.token}`
103
+ }
104
+ }));
105
+ }, "resolveClient");
106
+
107
+ // src/generated/routes.ts
108
+ var routes = {
109
+ "list-actors": {
110
+ serviceClass: "Actors",
111
+ operationId: "listActors",
112
+ description: "List actors",
113
+ pathParams: [],
114
+ queryParams: ["project_id", "external_id", "limit", "offset"]
115
+ },
116
+ "create-actor": {
117
+ serviceClass: "Actors",
118
+ operationId: "createActor",
119
+ description: "Create an actor",
120
+ pathParams: [],
121
+ queryParams: []
122
+ },
123
+ "get-actor": {
124
+ serviceClass: "Actors",
125
+ operationId: "getActor",
126
+ description: "Get an actor by ID",
127
+ pathParams: ["id"],
128
+ queryParams: []
129
+ },
130
+ "update-actor": {
131
+ serviceClass: "Actors",
132
+ operationId: "updateActor",
133
+ description: "Update an actor",
134
+ pathParams: ["id"],
135
+ queryParams: []
136
+ },
137
+ "delete-actor": {
138
+ serviceClass: "Actors",
139
+ operationId: "deleteActor",
140
+ description: "Delete an actor",
141
+ pathParams: ["id"],
142
+ queryParams: []
143
+ },
144
+ "get-actor-tags": {
145
+ serviceClass: "Actors",
146
+ operationId: "getActorTags",
147
+ description: "Get actor tags",
148
+ pathParams: ["id"],
149
+ queryParams: []
150
+ },
151
+ "replace-actor-tags": {
152
+ serviceClass: "Actors",
153
+ operationId: "replaceActorTags",
154
+ description: "Replace actor tags",
155
+ pathParams: ["id"],
156
+ queryParams: []
157
+ },
158
+ "merge-actor-tags": {
159
+ serviceClass: "Actors",
160
+ operationId: "mergeActorTags",
161
+ description: "Merge actor tags",
162
+ pathParams: ["id"],
163
+ queryParams: []
164
+ },
165
+ "list-agent-tools": {
166
+ serviceClass: "AgentTools",
167
+ operationId: "listAgentTools",
168
+ description: "List agent tools",
169
+ pathParams: [],
170
+ queryParams: ["project_id"]
171
+ },
172
+ "create-agent-tool": {
173
+ serviceClass: "AgentTools",
174
+ operationId: "createAgentTool",
175
+ description: "Create an agent tool",
176
+ pathParams: [],
177
+ queryParams: []
178
+ },
179
+ "get-agent-tool": {
180
+ serviceClass: "AgentTools",
181
+ operationId: "getAgentTool",
182
+ description: "Get an agent tool",
183
+ pathParams: ["tool_id"],
184
+ queryParams: []
185
+ },
186
+ "update-agent-tool": {
187
+ serviceClass: "AgentTools",
188
+ operationId: "updateAgentTool",
189
+ description: "Update an agent tool",
190
+ pathParams: ["tool_id"],
191
+ queryParams: []
192
+ },
193
+ "delete-agent-tool": {
194
+ serviceClass: "AgentTools",
195
+ operationId: "deleteAgentTool",
196
+ description: "Delete an agent tool",
197
+ pathParams: ["tool_id"],
198
+ queryParams: []
199
+ },
200
+ "list-agent-traces": {
201
+ serviceClass: "AgentTraces",
202
+ operationId: "listAgentTraces",
203
+ description: "List agent traces",
204
+ pathParams: [],
205
+ queryParams: ["project_id", "limit", "offset"]
206
+ },
207
+ "get-agent-trace": {
208
+ serviceClass: "AgentTraces",
209
+ operationId: "getAgentTrace",
210
+ description: "Get a trace",
211
+ pathParams: ["trace_id"],
212
+ queryParams: []
213
+ },
214
+ "list-agents": {
215
+ serviceClass: "Agents",
216
+ operationId: "listAgents",
217
+ description: "List agents",
218
+ pathParams: [],
219
+ queryParams: ["project_id"]
220
+ },
221
+ "create-agent": {
222
+ serviceClass: "Agents",
223
+ operationId: "createAgent",
224
+ description: "Create an agent",
225
+ pathParams: [],
226
+ queryParams: []
227
+ },
228
+ "get-agent": {
229
+ serviceClass: "Agents",
230
+ operationId: "getAgent",
231
+ description: "Get an agent",
232
+ pathParams: ["agent_id"],
233
+ queryParams: []
234
+ },
235
+ "update-agent": {
236
+ serviceClass: "Agents",
237
+ operationId: "updateAgent",
238
+ description: "Update an agent",
239
+ pathParams: ["agent_id"],
240
+ queryParams: []
241
+ },
242
+ "delete-agent": {
243
+ serviceClass: "Agents",
244
+ operationId: "deleteAgent",
245
+ description: "Delete an agent",
246
+ pathParams: ["agent_id"],
247
+ queryParams: []
248
+ },
249
+ "create-agent-generation": {
250
+ serviceClass: "Agents",
251
+ operationId: "createAgentGeneration",
252
+ description: "Run an agent generation",
253
+ pathParams: ["agent_id"],
254
+ queryParams: []
255
+ },
256
+ "submit-agent-tool-outputs": {
257
+ serviceClass: "Agents",
258
+ operationId: "submitAgentToolOutputs",
259
+ description: "Submit tool outputs for a paused generation",
260
+ pathParams: ["agent_id", "generation_id"],
261
+ queryParams: []
262
+ },
263
+ "create-agent-actor": {
264
+ serviceClass: "Agents",
265
+ operationId: "createAgentActor",
266
+ description: "Create an actor for an agent",
267
+ pathParams: ["agent_id"],
268
+ queryParams: []
269
+ },
270
+ "list-ai-providers": {
271
+ serviceClass: "AIProviders",
272
+ operationId: "listAiProviders",
273
+ description: "List AI providers",
274
+ pathParams: [],
275
+ queryParams: ["project_id", "limit", "offset"]
276
+ },
277
+ "create-ai-provider": {
278
+ serviceClass: "AIProviders",
279
+ operationId: "createAiProvider",
280
+ description: "Create an AI provider",
281
+ pathParams: [],
282
+ queryParams: []
283
+ },
284
+ "get-ai-provider": {
285
+ serviceClass: "AIProviders",
286
+ operationId: "getAiProvider",
287
+ description: "Get an AI provider",
288
+ pathParams: ["ai_provider_id"],
289
+ queryParams: []
290
+ },
291
+ "update-ai-provider": {
292
+ serviceClass: "AIProviders",
293
+ operationId: "updateAiProvider",
294
+ description: "Update an AI provider",
295
+ pathParams: ["ai_provider_id"],
296
+ queryParams: []
297
+ },
298
+ "delete-ai-provider": {
299
+ serviceClass: "AIProviders",
300
+ operationId: "deleteAiProvider",
301
+ description: "Delete an AI provider",
302
+ pathParams: ["ai_provider_id"],
303
+ queryParams: []
304
+ },
305
+ "create-api-key": {
306
+ serviceClass: "APIKeys",
307
+ operationId: "createApiKey",
308
+ description: "Create an API key",
309
+ pathParams: [],
310
+ queryParams: []
311
+ },
312
+ "get-api-key": {
313
+ serviceClass: "APIKeys",
314
+ operationId: "getApiKey",
315
+ description: "Get an API key",
316
+ pathParams: ["id"],
317
+ queryParams: []
318
+ },
319
+ "update-api-key": {
320
+ serviceClass: "APIKeys",
321
+ operationId: "updateApiKey",
322
+ description: "Update an API key",
323
+ pathParams: ["id"],
324
+ queryParams: []
325
+ },
326
+ "delete-api-key": {
327
+ serviceClass: "APIKeys",
328
+ operationId: "deleteApiKey",
329
+ description: "Delete an API key",
330
+ pathParams: ["id"],
331
+ queryParams: []
332
+ },
333
+ "list-chats": {
334
+ serviceClass: "Chats",
335
+ operationId: "listChats",
336
+ description: "List chats",
337
+ pathParams: [],
338
+ queryParams: ["project_id"]
339
+ },
340
+ "create-chat": {
341
+ serviceClass: "Chats",
342
+ operationId: "createChat",
343
+ description: "Create a chat",
344
+ pathParams: [],
345
+ queryParams: []
346
+ },
347
+ "get-chat": {
348
+ serviceClass: "Chats",
349
+ operationId: "getChat",
350
+ description: "Get a chat",
351
+ pathParams: ["chat_id"],
352
+ queryParams: []
353
+ },
354
+ "delete-chat": {
355
+ serviceClass: "Chats",
356
+ operationId: "deleteChat",
357
+ description: "Delete a chat",
358
+ pathParams: ["chat_id"],
359
+ queryParams: []
360
+ },
361
+ "create-chat-completion-for-chat": {
362
+ serviceClass: "Chats",
363
+ operationId: "createChatCompletionForChat",
364
+ description: "Create a chat completion for a stored chat",
365
+ pathParams: ["chat_id"],
366
+ queryParams: []
367
+ },
368
+ "create-chat-completion": {
369
+ serviceClass: "Chats",
370
+ operationId: "createChatCompletion",
371
+ description: "Create a chat completion (stateless)",
372
+ pathParams: [],
373
+ queryParams: []
374
+ },
375
+ "create-chat-actor": {
376
+ serviceClass: "Chats",
377
+ operationId: "createChatActor",
378
+ description: "Create an actor for a chat",
379
+ pathParams: ["chat_id"],
380
+ queryParams: []
381
+ },
382
+ "list-conversations": {
383
+ serviceClass: "Conversations",
384
+ operationId: "listConversations",
385
+ description: "List conversations",
386
+ pathParams: [],
387
+ queryParams: ["project_id", "actor_id", "limit", "offset"]
388
+ },
389
+ "create-conversation": {
390
+ serviceClass: "Conversations",
391
+ operationId: "createConversation",
392
+ description: "Create a conversation",
393
+ pathParams: [],
394
+ queryParams: []
395
+ },
396
+ "get-conversation": {
397
+ serviceClass: "Conversations",
398
+ operationId: "getConversation",
399
+ description: "Get a conversation by ID",
400
+ pathParams: ["id"],
401
+ queryParams: []
402
+ },
403
+ "update-conversation": {
404
+ serviceClass: "Conversations",
405
+ operationId: "updateConversation",
406
+ description: "Update a conversation",
407
+ pathParams: ["id"],
408
+ queryParams: []
409
+ },
410
+ "delete-conversation": {
411
+ serviceClass: "Conversations",
412
+ operationId: "deleteConversation",
413
+ description: "Delete a conversation",
414
+ pathParams: ["id"],
415
+ queryParams: []
416
+ },
417
+ "list-conversation-messages": {
418
+ serviceClass: "Conversations",
419
+ operationId: "listConversationMessages",
420
+ description: "List conversation messages",
421
+ pathParams: ["id"],
422
+ queryParams: ["limit", "offset"]
423
+ },
424
+ "add-conversation-message": {
425
+ serviceClass: "Conversations",
426
+ operationId: "addConversationMessage",
427
+ description: "Add a message to a conversation",
428
+ pathParams: ["id"],
429
+ queryParams: []
430
+ },
431
+ "generate-conversation-message": {
432
+ serviceClass: "Conversations",
433
+ operationId: "generateConversationMessage",
434
+ description: "Generate the next message in a conversation",
435
+ pathParams: ["id"],
436
+ queryParams: []
437
+ },
438
+ "list-conversation-actors": {
439
+ serviceClass: "Conversations",
440
+ operationId: "listConversationActors",
441
+ description: "List actors in a conversation",
442
+ pathParams: ["id"],
443
+ queryParams: []
444
+ },
445
+ "remove-conversation-message": {
446
+ serviceClass: "Conversations",
447
+ operationId: "removeConversationMessage",
448
+ description: "Remove a message from a conversation",
449
+ pathParams: ["id", "document_id"],
450
+ queryParams: []
451
+ },
452
+ "get-conversation-tags": {
453
+ serviceClass: "Conversations",
454
+ operationId: "getConversationTags",
455
+ description: "Get conversation tags",
456
+ pathParams: ["id"],
457
+ queryParams: []
458
+ },
459
+ "replace-conversation-tags": {
460
+ serviceClass: "Conversations",
461
+ operationId: "replaceConversationTags",
462
+ description: "Replace conversation tags",
463
+ pathParams: ["id"],
464
+ queryParams: []
465
+ },
466
+ "merge-conversation-tags": {
467
+ serviceClass: "Conversations",
468
+ operationId: "mergeConversationTags",
469
+ description: "Merge conversation tags",
470
+ pathParams: ["id"],
471
+ queryParams: []
472
+ },
473
+ "list-documents": {
474
+ serviceClass: "Documents",
475
+ operationId: "listDocuments",
476
+ description: "List documents",
477
+ pathParams: [],
478
+ queryParams: ["project_id"]
479
+ },
480
+ "create-document": {
481
+ serviceClass: "Documents",
482
+ operationId: "createDocument",
483
+ description: "Create a document",
484
+ pathParams: [],
485
+ queryParams: []
486
+ },
487
+ "get-document": {
488
+ serviceClass: "Documents",
489
+ operationId: "getDocument",
490
+ description: "Get a document by ID",
491
+ pathParams: ["id"],
492
+ queryParams: []
493
+ },
494
+ "update-document": {
495
+ serviceClass: "Documents",
496
+ operationId: "updateDocument",
497
+ description: "Update a document",
498
+ pathParams: ["id"],
499
+ queryParams: []
500
+ },
501
+ "delete-document": {
502
+ serviceClass: "Documents",
503
+ operationId: "deleteDocument",
504
+ description: "Delete a document",
505
+ pathParams: ["id"],
506
+ queryParams: []
507
+ },
508
+ "get-document-tags": {
509
+ serviceClass: "Documents",
510
+ operationId: "getDocumentTags",
511
+ description: "Get document tags",
512
+ pathParams: ["id"],
513
+ queryParams: []
514
+ },
515
+ "replace-document-tags": {
516
+ serviceClass: "Documents",
517
+ operationId: "replaceDocumentTags",
518
+ description: "Replace document tags",
519
+ pathParams: ["id"],
520
+ queryParams: []
521
+ },
522
+ "merge-document-tags": {
523
+ serviceClass: "Documents",
524
+ operationId: "mergeDocumentTags",
525
+ description: "Merge document tags",
526
+ pathParams: ["id"],
527
+ queryParams: []
528
+ },
529
+ "search-documents": {
530
+ serviceClass: "Documents",
531
+ operationId: "searchDocuments",
532
+ description: "Semantic search over documents",
533
+ pathParams: [],
534
+ queryParams: []
535
+ },
536
+ "list-files": {
537
+ serviceClass: "Files",
538
+ operationId: "listFiles",
539
+ description: "List all files",
540
+ pathParams: [],
541
+ queryParams: ["project_id", "limit", "offset"]
542
+ },
543
+ "create-file": {
544
+ serviceClass: "Files",
545
+ operationId: "createFile",
546
+ description: "Create a file",
547
+ pathParams: [],
548
+ queryParams: []
549
+ },
550
+ "upload-file": {
551
+ serviceClass: "Files",
552
+ operationId: "uploadFile",
553
+ description: "Upload a file",
554
+ pathParams: [],
555
+ queryParams: []
556
+ },
557
+ "upload-file-base64": {
558
+ serviceClass: "Files",
559
+ operationId: "uploadFileBase64",
560
+ description: "Upload a file using base64 encoding",
561
+ pathParams: [],
562
+ queryParams: []
563
+ },
564
+ "get-file": {
565
+ serviceClass: "Files",
566
+ operationId: "getFile",
567
+ description: "Get a file by ID",
568
+ pathParams: ["id"],
569
+ queryParams: []
570
+ },
571
+ "delete-file": {
572
+ serviceClass: "Files",
573
+ operationId: "deleteFile",
574
+ description: "Delete a file",
575
+ pathParams: ["id"],
576
+ queryParams: []
577
+ },
578
+ "download-file": {
579
+ serviceClass: "Files",
580
+ operationId: "downloadFile",
581
+ description: "Download a file",
582
+ pathParams: ["id"],
583
+ queryParams: []
584
+ },
585
+ "update-file-metadata": {
586
+ serviceClass: "Files",
587
+ operationId: "updateFileMetadata",
588
+ description: "Update file metadata",
589
+ pathParams: ["id"],
590
+ queryParams: []
591
+ },
592
+ "download-file-base64": {
593
+ serviceClass: "Files",
594
+ operationId: "downloadFileBase64",
595
+ description: "Download file as base64",
596
+ pathParams: ["id"],
597
+ queryParams: []
598
+ },
599
+ "get-file-tags": {
600
+ serviceClass: "Files",
601
+ operationId: "getFileTags",
602
+ description: "Get file tags",
603
+ pathParams: ["id"],
604
+ queryParams: []
605
+ },
606
+ "replace-file-tags": {
607
+ serviceClass: "Files",
608
+ operationId: "replaceFileTags",
609
+ description: "Replace file tags",
610
+ pathParams: ["id"],
611
+ queryParams: []
612
+ },
613
+ "merge-file-tags": {
614
+ serviceClass: "Files",
615
+ operationId: "mergeFileTags",
616
+ description: "Merge file tags",
617
+ pathParams: ["id"],
618
+ queryParams: []
619
+ },
620
+ "list-policies": {
621
+ serviceClass: "Policies",
622
+ operationId: "listPolicies",
623
+ description: "List all policies",
624
+ pathParams: [],
625
+ queryParams: []
626
+ },
627
+ "create-policy": {
628
+ serviceClass: "Policies",
629
+ operationId: "createPolicy",
630
+ description: "Create a policy",
631
+ pathParams: [],
632
+ queryParams: []
633
+ },
634
+ "get-policy": {
635
+ serviceClass: "Policies",
636
+ operationId: "getPolicy",
637
+ description: "Get a policy",
638
+ pathParams: ["policy_id"],
639
+ queryParams: []
640
+ },
641
+ "update-policy": {
642
+ serviceClass: "Policies",
643
+ operationId: "updatePolicy",
644
+ description: "Update a policy",
645
+ pathParams: ["policy_id"],
646
+ queryParams: []
647
+ },
648
+ "delete-policy": {
649
+ serviceClass: "Policies",
650
+ operationId: "deletePolicy",
651
+ description: "Delete a policy",
652
+ pathParams: ["policy_id"],
653
+ queryParams: []
654
+ },
655
+ "create-project": {
656
+ serviceClass: "Projects",
657
+ operationId: "createProject",
658
+ description: "Create a project",
659
+ pathParams: [],
660
+ queryParams: []
661
+ },
662
+ "get-project": {
663
+ serviceClass: "Projects",
664
+ operationId: "getProject",
665
+ description: "Get a project",
666
+ pathParams: ["project_id"],
667
+ queryParams: []
668
+ },
669
+ "delete-project": {
670
+ serviceClass: "Projects",
671
+ operationId: "deleteProject",
672
+ description: "Delete a project",
673
+ pathParams: ["project_id"],
674
+ queryParams: []
675
+ },
676
+ "list-secrets": {
677
+ serviceClass: "Secrets",
678
+ operationId: "listSecrets",
679
+ description: "List secrets",
680
+ pathParams: [],
681
+ queryParams: ["project_id", "limit", "offset"]
682
+ },
683
+ "create-secret": {
684
+ serviceClass: "Secrets",
685
+ operationId: "createSecret",
686
+ description: "Create a secret",
687
+ pathParams: [],
688
+ queryParams: []
689
+ },
690
+ "get-secret": {
691
+ serviceClass: "Secrets",
692
+ operationId: "getSecret",
693
+ description: "Get a secret",
694
+ pathParams: ["secret_id"],
695
+ queryParams: []
696
+ },
697
+ "update-secret": {
698
+ serviceClass: "Secrets",
699
+ operationId: "updateSecret",
700
+ description: "Update a secret",
701
+ pathParams: ["secret_id"],
702
+ queryParams: []
703
+ },
704
+ "delete-secret": {
705
+ serviceClass: "Secrets",
706
+ operationId: "deleteSecret",
707
+ description: "Delete a secret",
708
+ pathParams: ["secret_id"],
709
+ queryParams: []
710
+ },
711
+ "list-agent-sessions": {
712
+ serviceClass: "Sessions",
713
+ operationId: "listAgentSessions",
714
+ description: "List sessions",
715
+ pathParams: ["agent_id"],
716
+ queryParams: ["actor_id", "status", "limit", "offset"]
717
+ },
718
+ "create-agent-session": {
719
+ serviceClass: "Sessions",
720
+ operationId: "createAgentSession",
721
+ description: "Create a session",
722
+ pathParams: ["agent_id"],
723
+ queryParams: []
724
+ },
725
+ "get-agent-session": {
726
+ serviceClass: "Sessions",
727
+ operationId: "getAgentSession",
728
+ description: "Get a session",
729
+ pathParams: ["agent_id", "session_id"],
730
+ queryParams: []
731
+ },
732
+ "update-session": {
733
+ serviceClass: "Sessions",
734
+ operationId: "updateSession",
735
+ description: "Update a session",
736
+ pathParams: ["agent_id", "session_id"],
737
+ queryParams: []
738
+ },
739
+ "delete-agent-session": {
740
+ serviceClass: "Sessions",
741
+ operationId: "deleteAgentSession",
742
+ description: "Delete a session",
743
+ pathParams: ["agent_id", "session_id"],
744
+ queryParams: []
745
+ },
746
+ "list-agent-session-messages": {
747
+ serviceClass: "Sessions",
748
+ operationId: "listAgentSessionMessages",
749
+ description: "List session messages",
750
+ pathParams: ["agent_id", "session_id"],
751
+ queryParams: ["limit", "offset"]
752
+ },
753
+ "add-session-message": {
754
+ serviceClass: "Sessions",
755
+ operationId: "addSessionMessage",
756
+ description: "Add a user message",
757
+ pathParams: ["agent_id", "session_id"],
758
+ queryParams: []
759
+ },
760
+ "generate-session-response": {
761
+ serviceClass: "Sessions",
762
+ operationId: "generateSessionResponse",
763
+ description: "Trigger agent generation",
764
+ pathParams: ["agent_id", "session_id"],
765
+ queryParams: ["async"]
766
+ },
767
+ "submit-session-tool-outputs": {
768
+ serviceClass: "Sessions",
769
+ operationId: "submitSessionToolOutputs",
770
+ description: "Submit tool outputs",
771
+ pathParams: ["agent_id", "session_id"],
772
+ queryParams: []
773
+ },
774
+ "get-session-tags": {
775
+ serviceClass: "Sessions",
776
+ operationId: "getSessionTags",
777
+ description: "Get session tags",
778
+ pathParams: ["agent_id", "session_id"],
779
+ queryParams: []
780
+ },
781
+ "replace-session-tags": {
782
+ serviceClass: "Sessions",
783
+ operationId: "replaceSessionTags",
784
+ description: "Replace session tags",
785
+ pathParams: ["agent_id", "session_id"],
786
+ queryParams: []
787
+ },
788
+ "merge-session-tags": {
789
+ serviceClass: "Sessions",
790
+ operationId: "mergeSessionTags",
791
+ description: "Merge session tags",
792
+ pathParams: ["agent_id", "session_id"],
793
+ queryParams: []
794
+ },
795
+ "list-users": {
796
+ serviceClass: "Users",
797
+ operationId: "listUsers",
798
+ description: "List all users",
799
+ pathParams: [],
800
+ queryParams: []
801
+ },
802
+ "create-user": {
803
+ serviceClass: "Users",
804
+ operationId: "createUser",
805
+ description: "Create a user",
806
+ pathParams: [],
807
+ queryParams: []
808
+ },
809
+ "get-user": {
810
+ serviceClass: "Users",
811
+ operationId: "getUser",
812
+ description: "Get a user by ID",
813
+ pathParams: ["id"],
814
+ queryParams: []
815
+ },
816
+ "delete-user": {
817
+ serviceClass: "Users",
818
+ operationId: "deleteUser",
819
+ description: "Delete a user by ID",
820
+ pathParams: ["id"],
821
+ queryParams: []
822
+ },
823
+ "bootstrap-user": {
824
+ serviceClass: "Users",
825
+ operationId: "bootstrapUser",
826
+ description: "Create the first admin user",
827
+ pathParams: [],
828
+ queryParams: []
829
+ },
830
+ "login-user": {
831
+ serviceClass: "Users",
832
+ operationId: "loginUser",
833
+ description: "Login user",
834
+ pathParams: [],
835
+ queryParams: []
836
+ },
837
+ "get-user-policies": {
838
+ serviceClass: "Users",
839
+ operationId: "getUserPolicies",
840
+ description: "Get policies attached to a user",
841
+ pathParams: ["user_id"],
842
+ queryParams: []
843
+ },
844
+ "attach-user-policies": {
845
+ serviceClass: "Users",
846
+ operationId: "attachUserPolicies",
847
+ description: "Attach policies to a user",
848
+ pathParams: ["user_id"],
849
+ queryParams: []
850
+ },
851
+ "list-webhooks": {
852
+ serviceClass: "Webhooks",
853
+ operationId: "listWebhooks",
854
+ description: "List webhooks for a project",
855
+ pathParams: ["project_id"],
856
+ queryParams: []
857
+ },
858
+ "create-webhook": {
859
+ serviceClass: "Webhooks",
860
+ operationId: "createWebhook",
861
+ description: "Create a webhook",
862
+ pathParams: ["project_id"],
863
+ queryParams: []
864
+ },
865
+ "get-webhook": {
866
+ serviceClass: "Webhooks",
867
+ operationId: "getWebhook",
868
+ description: "Get a webhook",
869
+ pathParams: ["project_id", "webhook_id"],
870
+ queryParams: []
871
+ },
872
+ "update-webhook": {
873
+ serviceClass: "Webhooks",
874
+ operationId: "updateWebhook",
875
+ description: "Update a webhook",
876
+ pathParams: ["project_id", "webhook_id"],
877
+ queryParams: []
878
+ },
879
+ "delete-webhook": {
880
+ serviceClass: "Webhooks",
881
+ operationId: "deleteWebhook",
882
+ description: "Delete a webhook",
883
+ pathParams: ["project_id", "webhook_id"],
884
+ queryParams: []
885
+ },
886
+ "list-webhook-deliveries": {
887
+ serviceClass: "Webhooks",
888
+ operationId: "listWebhookDeliveries",
889
+ description: "List deliveries for a webhook",
890
+ pathParams: ["project_id", "webhook_id"],
891
+ queryParams: ["limit", "offset"]
892
+ },
893
+ "get-webhook-delivery": {
894
+ serviceClass: "Webhooks",
895
+ operationId: "getWebhookDelivery",
896
+ description: "Get a delivery",
897
+ pathParams: ["project_id", "webhook_id", "delivery_id"],
898
+ queryParams: []
899
+ },
900
+ "rotate-webhook-secret": {
901
+ serviceClass: "Webhooks",
902
+ operationId: "rotateWebhookSecret",
903
+ description: "Rotate webhook secret",
904
+ pathParams: ["project_id", "webhook_id"],
905
+ queryParams: []
906
+ }
26
907
  };
27
908
 
28
909
  // src/index.ts
29
- program.name("soat").description("SOAT CLI - Command Line Interface for SOAT").version(package_default.version);
30
- program.action(() => {
31
- console.log("Work is in progress");
910
+ var toCanonical = /* @__PURE__ */__name(s => {
911
+ return s.replace(/[-_]([a-z0-9])/g, (_, c) => {
912
+ return c.toUpperCase();
913
+ });
914
+ }, "toCanonical");
915
+ var kebabToSnake = /* @__PURE__ */__name(s => {
916
+ return s.replace(/-/g, "_");
917
+ }, "kebabToSnake");
918
+ var parseUnknown = /* @__PURE__ */__name(args => {
919
+ const result = {};
920
+ for (let i = 0; i < args.length; i++) {
921
+ const arg = args[i];
922
+ if (arg?.startsWith("--")) {
923
+ const key = arg.slice(2);
924
+ const val = args[i + 1];
925
+ if (val !== void 0 && !val.startsWith("--")) {
926
+ result[key] = val;
927
+ i++;
928
+ } else {
929
+ result[key] = "true";
930
+ }
931
+ }
932
+ }
933
+ return result;
934
+ }, "parseUnknown");
935
+ var parseFlagValue = /* @__PURE__ */__name(value => {
936
+ const trimmed = value.trim();
937
+ if (trimmed.startsWith("{") || trimmed.startsWith("[") || trimmed === "true" || trimmed === "false" || trimmed === "null" || /^-?\d+(\.\d+)?$/.test(trimmed)) {
938
+ try {
939
+ return JSON.parse(trimmed);
940
+ } catch {
941
+ return value;
942
+ }
943
+ }
944
+ return value;
945
+ }, "parseFlagValue");
946
+ var normalizeSymbol = /* @__PURE__ */__name(name => {
947
+ return name.toLowerCase().replace(/[^a-z0-9]/g, "");
948
+ }, "normalizeSymbol");
949
+ var resolveServiceClass = /* @__PURE__ */__name(serviceClassName => {
950
+ const sdkExports = sdk;
951
+ const exactMatch = sdkExports[serviceClassName];
952
+ if (exactMatch) return exactMatch;
953
+ const normalizedTarget = normalizeSymbol(serviceClassName);
954
+ const fuzzyMatches = Object.entries(sdkExports).filter(([exportName, value]) => {
955
+ return Boolean(value) && normalizeSymbol(exportName) === normalizedTarget;
956
+ });
957
+ if (fuzzyMatches.length === 1) {
958
+ return fuzzyMatches[0][1];
959
+ }
960
+ return void 0;
961
+ }, "resolveServiceClass");
962
+ program.name("soat").description("SOAT CLI").version(package_default.version).option("-p, --profile <name>", "config profile to use");
963
+ program.command("configure").description("Save credentials to a named profile (~/.soat/config.json)").option("-p, --profile <name>", "profile name", "default").action(async opts => {
964
+ const baseUrl = await input({
965
+ message: "Base URL:"
966
+ });
967
+ const token = await password({
968
+ message: "Token (hidden):"
969
+ });
970
+ writeProfile(opts.profile, {
971
+ baseUrl,
972
+ token
973
+ });
974
+ console.log(`Profile "${opts.profile}" saved.`);
975
+ });
976
+ program.command("list-commands").description("List all available API commands").action(() => {
977
+ const pad = Math.max(...Object.keys(routes).map(k => {
978
+ return k.length;
979
+ }));
980
+ for (const [cmd, r] of Object.entries(routes).sort()) {
981
+ console.log(` ${cmd.padEnd(pad)} ${r.description}`);
982
+ }
983
+ });
984
+ var matchesFilter = /* @__PURE__ */__name((eventType, filter) => {
985
+ const patterns = filter.split(",").map(part => {
986
+ return part.trim();
987
+ }).filter(Boolean);
988
+ if (patterns.length === 0) return true;
989
+ return patterns.some(pattern => {
990
+ if (pattern === "*") return true;
991
+ if (pattern.endsWith("*")) {
992
+ return eventType.startsWith(pattern.slice(0, -1));
993
+ }
994
+ return eventType === pattern;
995
+ });
996
+ }, "matchesFilter");
997
+ var verifySignature = /* @__PURE__ */__name((secret, payload, signatureHeader) => {
998
+ const expected = createHmac("sha256", secret).update(payload).digest("hex");
999
+ const expectedBuffer = Buffer.from(expected, "utf8");
1000
+ const actualBuffer = Buffer.from(signatureHeader, "utf8");
1001
+ if (expectedBuffer.length !== actualBuffer.length) return false;
1002
+ return timingSafeEqual(expectedBuffer, actualBuffer);
1003
+ }, "verifySignature");
1004
+ program.command("listen").description("Start a local webhook listener for testing deliveries").option("--port <number>", "port to listen on", "8787").option("--path <path>", "request path to accept", "/webhook").option("--secret <secret>", "verify X-Soat-Signature with this webhook secret").option("--filter <pattern>", "filter event type(s), supports prefix wildcard and comma separation (e.g. sessions.generation.*,files.*)").option("--json", "print one JSON object per line").action(opts => {
1005
+ const port = Number(opts.port);
1006
+ const path2 = opts.path;
1007
+ const secret = opts.secret;
1008
+ const filter = opts.filter;
1009
+ const asJson = Boolean(opts.json);
1010
+ if (!Number.isInteger(port) || port <= 0) {
1011
+ console.error("Invalid port. Use a positive integer.");
1012
+ process.exit(1);
1013
+ }
1014
+ const server = createServer((req, res) => {
1015
+ if (req.method !== "POST" || req.url !== path2) {
1016
+ res.writeHead(404, {
1017
+ "Content-Type": "application/json"
1018
+ });
1019
+ res.end(JSON.stringify({
1020
+ error: "not found"
1021
+ }));
1022
+ return;
1023
+ }
1024
+ const chunks = [];
1025
+ req.on("data", chunk => {
1026
+ chunks.push(chunk);
1027
+ });
1028
+ req.on("end", () => {
1029
+ const rawBody = Buffer.concat(chunks).toString("utf8");
1030
+ const eventType = String(req.headers["x-soat-event"] ?? "unknown");
1031
+ const deliveryId = String(req.headers["x-soat-delivery"] ?? "unknown");
1032
+ const signature = String(req.headers["x-soat-signature"] ?? "");
1033
+ if (filter && !matchesFilter(eventType, filter)) {
1034
+ res.writeHead(200, {
1035
+ "Content-Type": "application/json"
1036
+ });
1037
+ res.end(JSON.stringify({
1038
+ ok: true,
1039
+ skipped: true
1040
+ }));
1041
+ return;
1042
+ }
1043
+ let parsedPayload = rawBody;
1044
+ try {
1045
+ parsedPayload = JSON.parse(rawBody);
1046
+ } catch {}
1047
+ let isSignatureValid = null;
1048
+ if (secret) {
1049
+ isSignatureValid = verifySignature(secret, rawBody, signature);
1050
+ }
1051
+ const record = {
1052
+ timestamp: (/* @__PURE__ */new Date()).toISOString(),
1053
+ event_type: eventType,
1054
+ delivery_id: deliveryId,
1055
+ signature,
1056
+ signature_valid: isSignatureValid,
1057
+ payload: parsedPayload
1058
+ };
1059
+ if (asJson) {
1060
+ console.log(JSON.stringify(record));
1061
+ } else {
1062
+ console.log("--- webhook received ---");
1063
+ console.log("event_type:", eventType);
1064
+ console.log("delivery_id:", deliveryId);
1065
+ if (secret) {
1066
+ console.log("signature_valid:", isSignatureValid);
1067
+ }
1068
+ console.log("payload:", JSON.stringify(parsedPayload, null, 2));
1069
+ }
1070
+ const responseStatus = secret && isSignatureValid === false ? 401 : 200;
1071
+ res.writeHead(responseStatus, {
1072
+ "Content-Type": "application/json"
1073
+ });
1074
+ res.end(JSON.stringify({
1075
+ ok: responseStatus === 200,
1076
+ event_type: eventType,
1077
+ delivery_id: deliveryId,
1078
+ signature_valid: isSignatureValid
1079
+ }));
1080
+ });
1081
+ });
1082
+ server.listen(port, () => {
1083
+ console.log(`Listening for SOAT webhooks on http://localhost:${port}${path2}`);
1084
+ if (filter) {
1085
+ console.log(`Filter: ${filter}`);
1086
+ }
1087
+ if (secret) {
1088
+ console.log("Signature verification: enabled");
1089
+ }
1090
+ });
1091
+ process.on("SIGINT", () => {
1092
+ server.close(() => {
1093
+ process.exit(0);
1094
+ });
1095
+ });
1096
+ });
1097
+ program.argument("[command]", "API command in kebab-case (e.g. list-actors)").argument("[args...]").allowUnknownOption().action(async commandName => {
1098
+ if (!commandName) {
1099
+ program.help();
1100
+ return;
1101
+ }
1102
+ const route = routes[commandName];
1103
+ if (!route) {
1104
+ console.error(`Unknown command: ${commandName}`);
1105
+ console.error(`Run "soat list-commands" to see all available commands.`);
1106
+ process.exit(1);
1107
+ }
1108
+ const rawIdx = process.argv.indexOf(commandName);
1109
+ const rawArgs = rawIdx >= 0 ? process.argv.slice(rawIdx + 1) : [];
1110
+ const flags = parseUnknown(rawArgs);
1111
+ const pathArgs = {};
1112
+ const queryArgs = {};
1113
+ const bodyArgs = {};
1114
+ for (const [flagKey, val] of Object.entries(flags)) {
1115
+ if (flagKey === "profile") continue;
1116
+ const canonical = toCanonical(flagKey);
1117
+ const parsedValue = parseFlagValue(val);
1118
+ const pathParam = route.pathParams.find(p => {
1119
+ return toCanonical(p) === canonical;
1120
+ });
1121
+ const queryParam = route.queryParams.find(p => {
1122
+ return toCanonical(p) === canonical;
1123
+ });
1124
+ if (pathParam) {
1125
+ pathArgs[pathParam] = parsedValue;
1126
+ } else if (queryParam) {
1127
+ queryArgs[queryParam] = parsedValue;
1128
+ } else {
1129
+ bodyArgs[kebabToSnake(flagKey)] = parsedValue;
1130
+ }
1131
+ }
1132
+ const profileOpt = flags["profile"] ?? program.opts().profile;
1133
+ const client = resolveClient(profileOpt);
1134
+ const serviceClass = resolveServiceClass(route.serviceClass);
1135
+ if (!serviceClass) {
1136
+ console.error(`SDK class "${route.serviceClass}" not found.`);
1137
+ process.exit(1);
1138
+ }
1139
+ const method = serviceClass[route.operationId];
1140
+ if (typeof method !== "function") {
1141
+ console.error(`Method "${route.operationId}" not found on ${route.serviceClass}.`);
1142
+ process.exit(1);
1143
+ }
1144
+ const callOpts = {
1145
+ client
1146
+ };
1147
+ if (Object.keys(pathArgs).length) callOpts["path"] = pathArgs;
1148
+ if (Object.keys(queryArgs).length) callOpts["query"] = queryArgs;
1149
+ if (Object.keys(bodyArgs).length) callOpts["body"] = bodyArgs;
1150
+ const result = await method(callOpts);
1151
+ if (result.error) {
1152
+ const status = result.response && "status" in result.response ? result.response.status : void 0;
1153
+ console.error(JSON.stringify({
1154
+ status,
1155
+ error: result.error
1156
+ }, null, 2));
1157
+ process.exit(1);
1158
+ }
1159
+ console.log(JSON.stringify(result.data, null, 2));
32
1160
  });
33
1161
  program.parse();
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "@soat/cli",
3
- "version": "0.0.1",
4
- "scripts": {
5
- "build": "tsup",
6
- "test": "jest --projects tests/unit"
7
- },
3
+ "version": "0.4.4",
4
+ "type": "module",
8
5
  "dependencies": {
9
- "@ttoss/logger": "^0.7.1",
10
- "commander": "^14.0.2"
6
+ "@inquirer/input": "^5.0.12",
7
+ "@inquirer/password": "^5.0.12",
8
+ "@ttoss/logger": "^0.8.10",
9
+ "commander": "^14.0.3",
10
+ "@soat/sdk": "0.4.4"
11
11
  },
12
12
  "devDependencies": {
13
- "@ttoss/config": "^1.35.12",
13
+ "@ttoss/config": "^1.37.10",
14
14
  "@types/jest": "^30.0.0",
15
- "jest": "^30.2.0",
15
+ "@types/js-yaml": "^4.0.9",
16
+ "jest": "^30.3.0",
17
+ "js-yaml": "^4.1.1",
16
18
  "tsup": "^8.5.1",
17
19
  "tsx": "^4.21.0"
18
20
  },
@@ -20,8 +22,19 @@
20
22
  "dist",
21
23
  "bin"
22
24
  ],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/ttoss/soat"
28
+ },
23
29
  "bin": "./bin/soat",
24
30
  "publishConfig": {
25
- "access": "public"
31
+ "access": "public",
32
+ "provenance": true
33
+ },
34
+ "scripts": {
35
+ "generate": "tsx scripts/generate.ts",
36
+ "lint": "eslint src",
37
+ "typecheck": "tsc --noEmit",
38
+ "build": "pnpm generate && tsup"
26
39
  }
27
- }
40
+ }
package/dist/index.d.mts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/index.js DELETED
@@ -1,34 +0,0 @@
1
- /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- "use strict";
3
-
4
- // src/index.ts
5
- var import_commander = require("commander");
6
-
7
- // package.json
8
- var package_default = {
9
- name: "soat",
10
- version: "0.0.1",
11
- scripts: {
12
- build: "tsup",
13
- test: "jest --projects tests/unit"
14
- },
15
- dependencies: {
16
- commander: "^14.0.2"
17
- },
18
- devDependencies: {
19
- "@ttoss/config": "^1.35.12",
20
- "@types/jest": "^30.0.0",
21
- jest: "^30.2.0",
22
- tsup: "^8.5.1",
23
- tsx: "^4.21.0"
24
- },
25
- files: ["dist"],
26
- bin: "./bin/soat"
27
- };
28
-
29
- // src/index.ts
30
- import_commander.program.name("soat").description("SOAT CLI - Command Line Interface for SOAT").version(package_default.version);
31
- import_commander.program.action(() => {
32
- console.log("Work is in progress");
33
- });
34
- import_commander.program.parse();