@soat/cli 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -21
- package/dist/index.mjs +280 -58
- package/package.json +3 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025-2026 Terezinha Tech Operations (ttoss)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
3
2
|
import { createServer } from "node:http";
|
|
4
3
|
import * as path from "node:path";
|
|
5
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -11,13 +10,20 @@ import { program } from "commander";
|
|
|
11
10
|
import * as fs from "node:fs";
|
|
12
11
|
import { load } from "js-yaml";
|
|
13
12
|
import * as os from "node:os";
|
|
13
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
14
14
|
|
|
15
15
|
//#region package.json
|
|
16
|
-
var version = "0.
|
|
16
|
+
var version = "0.25.0";
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/cli-wrappers/wrappers/formations.ts
|
|
20
20
|
var FORMATION_COMMANDS = ["validate-formation", "plan-formation", "create-formation", "update-formation"];
|
|
21
|
+
/**
|
|
22
|
+
* The two commands that *deploy*. `validate-formation` and `plan-formation`
|
|
23
|
+
* report on a template without touching a resource, so their outcome is the
|
|
24
|
+
* payload, not an exit code.
|
|
25
|
+
*/
|
|
26
|
+
var DEPLOY_COMMANDS = ["create-formation", "update-formation"];
|
|
21
27
|
var TEMPLATE_PATH_FLAG = "template-path";
|
|
22
28
|
var TEMPLATE_FILE_FLAG = "template-file";
|
|
23
29
|
var ENV_FILE_FLAG = "env-file";
|
|
@@ -121,9 +127,45 @@ var resolveParameterPair = args => {
|
|
|
121
127
|
})
|
|
122
128
|
};
|
|
123
129
|
};
|
|
130
|
+
var isRecord = value => {
|
|
131
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
132
|
+
};
|
|
133
|
+
var readString = value => {
|
|
134
|
+
return typeof value === "string" && value ? value : void 0;
|
|
135
|
+
};
|
|
136
|
+
/** The reason line, from the response's `error` bag when it carries one. */
|
|
137
|
+
var describeDeployReason = args => {
|
|
138
|
+
const reason = readString(args.error?.message);
|
|
139
|
+
if (!reason) return `No reason was reported on the response; run \`soat list-formation-events --formation-id ${args.formationId ?? "<id>"}\` for the operation history.`;
|
|
140
|
+
return `${readString(args.error?.code) ?? "UNKNOWN"}: ${reason}`;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* A deploy whose reconciliation failed, rendered for stderr.
|
|
144
|
+
*
|
|
145
|
+
* The server answers 2xx here on purpose — the operation ran, and partial
|
|
146
|
+
* failure is modelled on the resource — so the body's `status` is the only
|
|
147
|
+
* signal that anything went wrong. Turning it into a non-zero exit is what
|
|
148
|
+
* stops `&&` chains from reporting a deploy that deployed nothing (#1028).
|
|
149
|
+
*/
|
|
150
|
+
var describeFailedDeploy = args => {
|
|
151
|
+
const {
|
|
152
|
+
commandName,
|
|
153
|
+
data
|
|
154
|
+
} = args;
|
|
155
|
+
if (!DEPLOY_COMMANDS.includes(commandName)) return null;
|
|
156
|
+
if (!isRecord(data) || data.status !== "failed") return null;
|
|
157
|
+
const error = isRecord(data.error) ? data.error : void 0;
|
|
158
|
+
const meta = isRecord(error?.meta) ? error.meta : void 0;
|
|
159
|
+
const logicalId = readString(meta?.logical_id);
|
|
160
|
+
return `${commandName}: the deploy failed${logicalId ? ` at resource '${logicalId}'` : ""} — the formation is 'failed'. ${describeDeployReason({
|
|
161
|
+
error,
|
|
162
|
+
formationId: readString(data.id)
|
|
163
|
+
})}`;
|
|
164
|
+
};
|
|
124
165
|
var formationsWrapper = {
|
|
125
166
|
id: "formations-wrapper",
|
|
126
167
|
commands: FORMATION_COMMANDS,
|
|
168
|
+
failureMessage: describeFailedDeploy,
|
|
127
169
|
helpFlags: [{
|
|
128
170
|
name: "template-path",
|
|
129
171
|
description: "Path to template file (JSON or YAML). Alias: --template-file",
|
|
@@ -332,6 +374,18 @@ var applyWrapperForCommand = args => {
|
|
|
332
374
|
}
|
|
333
375
|
});
|
|
334
376
|
};
|
|
377
|
+
/**
|
|
378
|
+
* What to report for a 2xx payload whose own body says the operation failed,
|
|
379
|
+
* or null when there is nothing wrong with it. Drives the CLI's exit code.
|
|
380
|
+
*/
|
|
381
|
+
var resolveFailureMessage = args => {
|
|
382
|
+
return resolveWrapperForCommand({
|
|
383
|
+
commandName: args.commandName
|
|
384
|
+
})?.failureMessage?.({
|
|
385
|
+
commandName: args.commandName,
|
|
386
|
+
data: args.data
|
|
387
|
+
}) ?? null;
|
|
388
|
+
};
|
|
335
389
|
var getWrapperHelpFlags = commandName => {
|
|
336
390
|
return WRAPPERS.find(w => {
|
|
337
391
|
return w.commands.includes(commandName);
|
|
@@ -519,18 +573,6 @@ var routes = {
|
|
|
519
573
|
"required": false,
|
|
520
574
|
"type": "string",
|
|
521
575
|
"in": "body"
|
|
522
|
-
}, {
|
|
523
|
-
"name": "memory_id",
|
|
524
|
-
"description": "Memory ID to link to this actor. Mutually exclusive with auto_create_memory.",
|
|
525
|
-
"required": false,
|
|
526
|
-
"type": "string",
|
|
527
|
-
"in": "body"
|
|
528
|
-
}, {
|
|
529
|
-
"name": "auto_create_memory",
|
|
530
|
-
"description": "When true, automatically creates a new memory container for this actor and links it. Ignored if memory_id is set. With external_id (idempotent), memory is only created on first creation.",
|
|
531
|
-
"required": false,
|
|
532
|
-
"type": "boolean",
|
|
533
|
-
"in": "body"
|
|
534
576
|
}]
|
|
535
577
|
},
|
|
536
578
|
"get-actor": {
|
|
@@ -593,12 +635,6 @@ var routes = {
|
|
|
593
635
|
"required": false,
|
|
594
636
|
"type": "string",
|
|
595
637
|
"in": "body"
|
|
596
|
-
}, {
|
|
597
|
-
"name": "memory_id",
|
|
598
|
-
"description": "Memory ID to link to this actor. Set to null to unlink.",
|
|
599
|
-
"required": false,
|
|
600
|
-
"type": "string",
|
|
601
|
-
"in": "body"
|
|
602
638
|
}, {
|
|
603
639
|
"name": "tags",
|
|
604
640
|
"description": "",
|
|
@@ -1179,7 +1215,7 @@ var routes = {
|
|
|
1179
1215
|
"in": "body"
|
|
1180
1216
|
}, {
|
|
1181
1217
|
"name": "trace_id",
|
|
1182
|
-
"description": "Optional trace ID to group generations",
|
|
1218
|
+
"description": "Optional trace ID to group generations. Each generation appends its own steps to the trace's steps object, and `step_count` covers them all.",
|
|
1183
1219
|
"required": false,
|
|
1184
1220
|
"type": "string",
|
|
1185
1221
|
"in": "body"
|
|
@@ -1590,7 +1626,7 @@ var routes = {
|
|
|
1590
1626
|
"list-ai-provider-models": {
|
|
1591
1627
|
serviceClass: "AIProviders",
|
|
1592
1628
|
operationId: "listAiProviderModels",
|
|
1593
|
-
description: "Asks the provider which models it can run, using this provider record's own credentials and configuration, and returns provider-native model ids — the same strings `default_model` and an agent's `model` carry. Which models are reachable is a property of the credential, not of the provider type: a Vertex provider sees only the publisher models its Google Cloud project and location serve, and a Bedrock provider only the foundation models enabled in its region. Reading the list is how a caller avoids pinning a model that fails at generation time. Not every provider type can answer. `azure` lists deployments an operator named rather than models, and `ollama` lists whatever was pulled onto that host, so both return `400 MODEL_LISTING_UNSUPPORTED`.",
|
|
1629
|
+
description: "Asks the provider which models it can run, using this provider record's own credentials and configuration, and returns provider-native model ids — the same strings `default_model` and an agent's `model` carry. Which models are reachable is a property of the credential, not of the provider type: a Vertex provider sees only the publisher models its Google Cloud project and location serve, and a Bedrock provider only the foundation models enabled in its region. Reading the list is how a caller avoids pinning a model that fails at generation time. Not every provider type can answer. `azure` lists deployments an operator named rather than models, and `ollama` lists whatever was pulled onto that host, so both return `400 MODEL_LISTING_UNSUPPORTED`. Listing resolves credentials the same way generation does, so a record that can generate can list. The API-key types (`openai`, `groq`, `xai`, `gateway`, `custom`, `anthropic`, `google`) use the record's linked secret and cannot list without one. `bedrock` and `vertex` use the linked secret when there is one — IAM keys or a Bedrock API key, a Google service-account key — and otherwise fall back to the server environment (the AWS default credential chain, Google Application Default Credentials), so a record with no `secret_id` can still list. A Vertex record needs no `config.project` when its secret is a service-account key, since the key file names its own project. A Vertex record in express mode (API key) cannot list at all: express mode is a global, project-less endpoint and the publisher-model catalogue is per-project, so it returns `400 MODEL_LISTING_UNSUPPORTED`.",
|
|
1594
1630
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/ai-providers",
|
|
1595
1631
|
httpMethod: "get",
|
|
1596
1632
|
pathParams: ["ai_provider_id"],
|
|
@@ -1644,7 +1680,7 @@ var routes = {
|
|
|
1644
1680
|
"list-api-keys": {
|
|
1645
1681
|
serviceClass: "APIKeys",
|
|
1646
1682
|
operationId: "listApiKeys",
|
|
1647
|
-
description: "Lists API keys accessible to the caller. - JWT admin: returns all API keys. - JWT regular user: returns only the user's own API keys. - API key: returns only API keys scoped to
|
|
1683
|
+
description: "Lists API keys accessible to the caller. - JWT admin: returns all API keys. - JWT regular user: returns only the user's own API keys. - Project-scoped credential (API key or OAuth token): returns only API keys scoped to that project.",
|
|
1648
1684
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/api-keys",
|
|
1649
1685
|
httpMethod: "get",
|
|
1650
1686
|
pathParams: [],
|
|
@@ -1666,7 +1702,7 @@ var routes = {
|
|
|
1666
1702
|
"create-api-key": {
|
|
1667
1703
|
serviceClass: "APIKeys",
|
|
1668
1704
|
operationId: "createApiKey",
|
|
1669
|
-
description: "Creates a new API key for the authenticated user. - `project_id` is optional. When set, the key is scoped to that single project. When omitted or null, the key is **unscoped** and spans every project its owner can reach. - If `policy_ids` is provided, the key's effective permissions are the intersection of the user's policies and the key's policies. - Otherwise the key inherits the user's permissions (confined to the key's project when scoped).",
|
|
1705
|
+
description: "Creates a new API key for the authenticated user. - `project_id` is optional. When set, the key is scoped to that single project. When omitted or null, the key is **unscoped** and spans every project its owner can reach. - If `policy_ids` is provided, the key's effective permissions are the intersection of the user's policies and the key's policies. - Otherwise the key inherits the user's permissions (confined to the key's project when scoped). - When the request is authenticated with a **project-scoped credential**, the new key is confined to that same project: omitting `project_id` defaults to it, naming a different project returns `403 API_KEY_PROJECT_SCOPE`, and `project_id: null` (an unscoped key) is likewise refused. Minting an unscoped key requires an unscoped credential.",
|
|
1670
1706
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/api-keys",
|
|
1671
1707
|
httpMethod: "post",
|
|
1672
1708
|
pathParams: [],
|
|
@@ -1694,7 +1730,7 @@ var routes = {
|
|
|
1694
1730
|
"get-api-key": {
|
|
1695
1731
|
serviceClass: "APIKeys",
|
|
1696
1732
|
operationId: "getApiKey",
|
|
1697
|
-
description: "Returns details of an API key. Only the owner or an admin can access it.",
|
|
1733
|
+
description: "Returns details of an API key. Only the owner or an admin can access it, and a project-scoped credential can only reach keys in its own project.",
|
|
1698
1734
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/api-keys",
|
|
1699
1735
|
httpMethod: "get",
|
|
1700
1736
|
pathParams: ["api_key_id"],
|
|
@@ -1710,7 +1746,7 @@ var routes = {
|
|
|
1710
1746
|
"update-api-key": {
|
|
1711
1747
|
serviceClass: "APIKeys",
|
|
1712
1748
|
operationId: "updateApiKey",
|
|
1713
|
-
description: "Updates an API key's name, project scope, or policies. The project scope can be changed to another project, set (scoping a previously unscoped key), or cleared with null (unscoping the key). Only the owner or an admin can update it.",
|
|
1749
|
+
description: "Updates an API key's name, project scope, or policies. The project scope can be changed to another project, set (scoping a previously unscoped key), or cleared with null (unscoping the key). Only the owner or an admin can update it. A project-scoped credential can only update keys in its own project, and cannot move a key to another project or unscope it.",
|
|
1714
1750
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/api-keys",
|
|
1715
1751
|
httpMethod: "put",
|
|
1716
1752
|
pathParams: ["api_key_id"],
|
|
@@ -1744,7 +1780,7 @@ var routes = {
|
|
|
1744
1780
|
"delete-api-key": {
|
|
1745
1781
|
serviceClass: "APIKeys",
|
|
1746
1782
|
operationId: "deleteApiKey",
|
|
1747
|
-
description: "Deletes an API key. Only the owner or an admin can delete it.",
|
|
1783
|
+
description: "Deletes an API key. Only the owner or an admin can delete it, and a project-scoped credential can only delete keys in its own project.",
|
|
1748
1784
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/api-keys",
|
|
1749
1785
|
httpMethod: "delete",
|
|
1750
1786
|
pathParams: ["api_key_id"],
|
|
@@ -2506,13 +2542,19 @@ var routes = {
|
|
|
2506
2542
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/documents",
|
|
2507
2543
|
httpMethod: "get",
|
|
2508
2544
|
pathParams: [],
|
|
2509
|
-
queryParams: ["project_id", "limit", "offset"],
|
|
2545
|
+
queryParams: ["project_id", "path_prefix", "limit", "offset"],
|
|
2510
2546
|
flags: [{
|
|
2511
2547
|
"name": "project_id",
|
|
2512
2548
|
"description": "Project ID (optional)",
|
|
2513
2549
|
"required": false,
|
|
2514
2550
|
"type": "string",
|
|
2515
2551
|
"in": "query"
|
|
2552
|
+
}, {
|
|
2553
|
+
"name": "path_prefix",
|
|
2554
|
+
"description": "Only documents filed under this directory. The prefix is a path boundary, not a substring: `/reports` returns `/reports/q1.txt` and never `/reports-archive/q1.txt`, and `/` selects the whole project. A leading slash is optional and a trailing one is ignored, so `reports`, `/reports` and `/reports/` are the same filter. `%` and `_` are literal characters, not wildcards.",
|
|
2555
|
+
"required": false,
|
|
2556
|
+
"type": "string",
|
|
2557
|
+
"in": "query"
|
|
2516
2558
|
}, {
|
|
2517
2559
|
"name": "limit",
|
|
2518
2560
|
"description": "Maximum number of results to return",
|
|
@@ -3229,7 +3271,7 @@ var routes = {
|
|
|
3229
3271
|
"in": "body"
|
|
3230
3272
|
}, {
|
|
3231
3273
|
"name": "scorers",
|
|
3232
|
-
"description": "Scorer configs, a discriminated union on `type`. Each type may appear at most once. Every scorer produces `{ score: 0–1, passed: boolean }`; binary scorers emit 0 or 1.\n\n`exact_match` compares the trimmed output text to `expected_output`. `contains` looks for `value` in the output text. `json_logic` evaluates `expression` over `{ input, output, object, expected, item.metadata }`, where `object` is the structured output (absent when the agent has no `output_schema`). `output_schema` validates the structured output against the scorer's own `schema`, falling back to the agent's; it requires the agent to carry an `output_schema`, because without one the platform emits no structured output and every item would score 0.\n\n`llm_judge` grades the output with a model completion, returning a continuous score plus its `reasoning`. Its `pass_threshold` is required: a continuous score says nothing about where \"good enough\" is, and a defaulted cutoff would silently decide the gate.",
|
|
3274
|
+
"description": "Scorer configs, a discriminated union on `type`. Each type may appear at most once. Every scorer produces `{ score: 0–1, passed: boolean }`; binary scorers emit 0 or 1.\n\n`exact_match` compares the trimmed output text to `expected_output`. `contains` looks for `value` in the output text. `json_logic` evaluates `expression` over `{ input, output, object, expected, item.metadata }`, where `object` is the structured output (absent when the agent has no `output_schema`). `output_schema` validates the structured output against the scorer's own `schema`, falling back to the agent's; it requires the agent to carry an `output_schema`, because without one the platform emits no structured output and every item would score 0.\n\n`llm_judge` grades the output with a model completion, returning a continuous score plus its `reasoning`. Its `pass_threshold` is required: a continuous score says nothing about where \"good enough\" is, and a defaulted cutoff would silently decide the gate.\n\n`tool` runs a custom scoring algorithm: a server-callable project tool the engine invokes once per item with the item's context. Unlike the built-in types it may appear several times, each under a distinct `name` — outcomes and aggregates key on the name.",
|
|
3233
3275
|
"required": true,
|
|
3234
3276
|
"type": "array",
|
|
3235
3277
|
"in": "body"
|
|
@@ -3291,7 +3333,7 @@ var routes = {
|
|
|
3291
3333
|
"in": "body"
|
|
3292
3334
|
}, {
|
|
3293
3335
|
"name": "scorers",
|
|
3294
|
-
"description": "Scorer configs, a discriminated union on `type`. Each type may appear at most once. Every scorer produces `{ score: 0–1, passed: boolean }`; binary scorers emit 0 or 1.\n\n`exact_match` compares the trimmed output text to `expected_output`. `contains` looks for `value` in the output text. `json_logic` evaluates `expression` over `{ input, output, object, expected, item.metadata }`, where `object` is the structured output (absent when the agent has no `output_schema`). `output_schema` validates the structured output against the scorer's own `schema`, falling back to the agent's; it requires the agent to carry an `output_schema`, because without one the platform emits no structured output and every item would score 0.\n\n`llm_judge` grades the output with a model completion, returning a continuous score plus its `reasoning`. Its `pass_threshold` is required: a continuous score says nothing about where \"good enough\" is, and a defaulted cutoff would silently decide the gate.",
|
|
3336
|
+
"description": "Scorer configs, a discriminated union on `type`. Each type may appear at most once. Every scorer produces `{ score: 0–1, passed: boolean }`; binary scorers emit 0 or 1.\n\n`exact_match` compares the trimmed output text to `expected_output`. `contains` looks for `value` in the output text. `json_logic` evaluates `expression` over `{ input, output, object, expected, item.metadata }`, where `object` is the structured output (absent when the agent has no `output_schema`). `output_schema` validates the structured output against the scorer's own `schema`, falling back to the agent's; it requires the agent to carry an `output_schema`, because without one the platform emits no structured output and every item would score 0.\n\n`llm_judge` grades the output with a model completion, returning a continuous score plus its `reasoning`. Its `pass_threshold` is required: a continuous score says nothing about where \"good enough\" is, and a defaulted cutoff would silently decide the gate.\n\n`tool` runs a custom scoring algorithm: a server-callable project tool the engine invokes once per item with the item's context. Unlike the built-in types it may appear several times, each under a distinct `name` — outcomes and aggregates key on the name.",
|
|
3295
3337
|
"required": false,
|
|
3296
3338
|
"type": "array",
|
|
3297
3339
|
"in": "body"
|
|
@@ -3996,7 +4038,7 @@ var routes = {
|
|
|
3996
4038
|
"create-formation": {
|
|
3997
4039
|
serviceClass: "Formations",
|
|
3998
4040
|
operationId: "createFormation",
|
|
3999
|
-
description: "Validates the template, creates the formation record, then provisions all declared resources in dependency order.",
|
|
4041
|
+
description: "Validates the template, creates the formation record, then provisions all declared resources in dependency order. A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `201` and `status: \"failed\"`, and `error` explains why (the resources created before the failure are rolled back). Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `soat` CLI exits non-zero on that body so `create-formation && …` does not lie.",
|
|
4000
4042
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/formations",
|
|
4001
4043
|
httpMethod: "post",
|
|
4002
4044
|
pathParams: [],
|
|
@@ -4052,7 +4094,7 @@ var routes = {
|
|
|
4052
4094
|
"update-formation": {
|
|
4053
4095
|
serviceClass: "Formations",
|
|
4054
4096
|
operationId: "updateFormation",
|
|
4055
|
-
description: "Applies a new template to the formation. Resources are created, updated, or deleted to reconcile the current state with the desired state.",
|
|
4097
|
+
description: "Applies a new template to the formation. Resources are created, updated, or deleted to reconcile the current state with the desired state. A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `200` and `status: \"failed\"`, and `error` explains why. Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `soat` CLI exits non-zero on that body so `update-formation && …` does not lie.",
|
|
4056
4098
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/formations",
|
|
4057
4099
|
httpMethod: "put",
|
|
4058
4100
|
pathParams: ["formation_id"],
|
|
@@ -4227,6 +4269,22 @@ var routes = {
|
|
|
4227
4269
|
"in": "path"
|
|
4228
4270
|
}]
|
|
4229
4271
|
},
|
|
4272
|
+
"get-generation-transcript": {
|
|
4273
|
+
serviceClass: "Generations",
|
|
4274
|
+
operationId: "getGenerationTranscript",
|
|
4275
|
+
description: "Returns one generation's turn read back as an ordered sequence of steps: what it was asked, each model step with its tool calls and results, and how it ended. The transcript is assembled at read time from the generation record and the trace's steps object; nothing is stored, so it cannot outlive the content it projects. Requires `traces:GetTrace` in addition to `generations:GetGeneration`, because the response merges content from both resources. A generation whose content is unavailable — never written under zero-retention, or cleared by a purge — returns `200` with the skeleton rather than an error: `input` and `output` are null, `steps` is empty, and the `content_redacted_*` fields say which happened. `content_redacted_by_principal_id` is `zero_retention` when the content was never stored, and the purging principal's ID when it was erased later. A generation that is still running returns the same shape with an empty `steps`; `status` disambiguates the two.",
|
|
4276
|
+
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/generations",
|
|
4277
|
+
httpMethod: "get",
|
|
4278
|
+
pathParams: ["generation_id"],
|
|
4279
|
+
queryParams: [],
|
|
4280
|
+
flags: [{
|
|
4281
|
+
"name": "generation_id",
|
|
4282
|
+
"description": "Public ID of the generation",
|
|
4283
|
+
"required": true,
|
|
4284
|
+
"type": "string",
|
|
4285
|
+
"in": "path"
|
|
4286
|
+
}]
|
|
4287
|
+
},
|
|
4230
4288
|
"list-guardrails": {
|
|
4231
4289
|
serviceClass: "Guardrails",
|
|
4232
4290
|
operationId: "listGuardrails",
|
|
@@ -4749,7 +4807,7 @@ var routes = {
|
|
|
4749
4807
|
"in": "body"
|
|
4750
4808
|
}, {
|
|
4751
4809
|
"name": "min_score",
|
|
4752
|
-
"description": "Minimum
|
|
4810
|
+
"description": "Minimum `score` a result must reach to be returned. Filters on the implementation-defined `score`, not on `similarity_score`, so the cutoff follows the ranking. Only applies when `query` is provided. Because the scale behind `score` is not part of the contract, treat a tuned value as tied to the deployment rather than portable.",
|
|
4753
4811
|
"required": false,
|
|
4754
4812
|
"type": "number",
|
|
4755
4813
|
"in": "body"
|
|
@@ -4926,7 +4984,7 @@ var routes = {
|
|
|
4926
4984
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/memoryEntries",
|
|
4927
4985
|
httpMethod: "get",
|
|
4928
4986
|
pathParams: [],
|
|
4929
|
-
queryParams: ["memory_id", "limit", "offset"],
|
|
4987
|
+
queryParams: ["memory_id", "limit", "offset", "include_invalidated"],
|
|
4930
4988
|
flags: [{
|
|
4931
4989
|
"name": "memory_id",
|
|
4932
4990
|
"description": "Memory container to list entries from (mem_...)",
|
|
@@ -4945,12 +5003,18 @@ var routes = {
|
|
|
4945
5003
|
"required": false,
|
|
4946
5004
|
"type": "integer",
|
|
4947
5005
|
"in": "query"
|
|
5006
|
+
}, {
|
|
5007
|
+
"name": "include_invalidated",
|
|
5008
|
+
"description": "Include invalidated (superseded) entries. They are excluded by default; set this to audit the supersede history.",
|
|
5009
|
+
"required": false,
|
|
5010
|
+
"type": "boolean",
|
|
5011
|
+
"in": "query"
|
|
4948
5012
|
}]
|
|
4949
5013
|
},
|
|
4950
5014
|
"create-memory-entry": {
|
|
4951
5015
|
serviceClass: "MemoryEntries",
|
|
4952
5016
|
operationId: "createMemoryEntry",
|
|
4953
|
-
description: "Creates a new entry in the specified memory container. Automatically generates an embedding for semantic search.",
|
|
5017
|
+
description: "Creates a new entry in the specified memory container. Automatically generates an embedding for semantic search, and skips the write when an existing entry is a near-duplicate (see `duplicate_threshold`). A merely similar fact is stored as its own entry: this path has no agent context and therefore no model to consolidate two facts into one.",
|
|
4954
5018
|
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/memoryEntries",
|
|
4955
5019
|
httpMethod: "post",
|
|
4956
5020
|
pathParams: [],
|
|
@@ -4987,13 +5051,7 @@ var routes = {
|
|
|
4987
5051
|
"in": "body"
|
|
4988
5052
|
}, {
|
|
4989
5053
|
"name": "duplicate_threshold",
|
|
4990
|
-
"description": "Cosine similarity score at or above which the incoming content is considered a duplicate and skipped (default 0.95)",
|
|
4991
|
-
"required": false,
|
|
4992
|
-
"type": "number",
|
|
4993
|
-
"in": "body"
|
|
4994
|
-
}, {
|
|
4995
|
-
"name": "update_threshold",
|
|
4996
|
-
"description": "Cosine similarity score at or above which the incoming content is appended to the existing entry (default 0.75)",
|
|
5054
|
+
"description": "Cosine similarity score at or above which the incoming content is considered a duplicate of an existing entry and skipped (default 0.95). Below it the entry is always created.",
|
|
4997
5055
|
"required": false,
|
|
4998
5056
|
"type": "number",
|
|
4999
5057
|
"in": "body"
|
|
@@ -6475,6 +6533,80 @@ var routes = {
|
|
|
6475
6533
|
"in": "body"
|
|
6476
6534
|
}]
|
|
6477
6535
|
},
|
|
6536
|
+
"fork-session": {
|
|
6537
|
+
serviceClass: "Sessions",
|
|
6538
|
+
operationId: "forkSession",
|
|
6539
|
+
description: "Branches a new session from a point in this session's history: same context, different continuation. The fork gets its own conversation whose messages **reference the same documents** as the parent rather than copying them, so there is one stored copy of the content and a retention purge erases it from both. Recorded tool results ride along on those messages and are **replayed** as model input on the fork's next turn — forking never re-invokes a tool, so exploring a \"what if\" cannot send an email or charge a card a second time. The consequence to accept is that a forked turn sees the tool data as it was, not as it is now. The fork is created **inert**: `auto_generate` is false and no generation is triggered. Drive it with the normal message and generate endpoints. The fork has no actor — attach one only if the branch is meant to be driven by the same end user, since `single_session_per_actor` agents allow one open session per actor.",
|
|
6540
|
+
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/sessions",
|
|
6541
|
+
httpMethod: "post",
|
|
6542
|
+
pathParams: ["session_id"],
|
|
6543
|
+
queryParams: [],
|
|
6544
|
+
flags: [{
|
|
6545
|
+
"name": "session_id",
|
|
6546
|
+
"description": "Session public ID",
|
|
6547
|
+
"required": true,
|
|
6548
|
+
"type": "string",
|
|
6549
|
+
"in": "path"
|
|
6550
|
+
}, {
|
|
6551
|
+
"name": "fork_at_position",
|
|
6552
|
+
"description": "The parent conversation `position` to branch after. Messages at positions 0..N are carried into the fork. Omit it to branch at the tip (the whole history).\n",
|
|
6553
|
+
"required": false,
|
|
6554
|
+
"type": "integer",
|
|
6555
|
+
"in": "body"
|
|
6556
|
+
}, {
|
|
6557
|
+
"name": "agent_id",
|
|
6558
|
+
"description": "Agent the fork runs against. Defaults to the parent session's agent; overriding it is the point of forking — same context, a different agent or agent version. Must belong to the same project as the session being forked.\n",
|
|
6559
|
+
"required": false,
|
|
6560
|
+
"type": "string",
|
|
6561
|
+
"in": "body"
|
|
6562
|
+
}, {
|
|
6563
|
+
"name": "name",
|
|
6564
|
+
"description": "Optional name for the forked session",
|
|
6565
|
+
"required": false,
|
|
6566
|
+
"type": "string",
|
|
6567
|
+
"in": "body"
|
|
6568
|
+
}, {
|
|
6569
|
+
"name": "tags",
|
|
6570
|
+
"description": "Optional tags for the forked session",
|
|
6571
|
+
"required": false,
|
|
6572
|
+
"type": "object",
|
|
6573
|
+
"in": "body"
|
|
6574
|
+
}, {
|
|
6575
|
+
"name": "tool_context",
|
|
6576
|
+
"description": "Overrides the parent's `tool_context` on the fork. Omit it and the fork inherits the parent's, so the branch is faithful to the run it came from.\n",
|
|
6577
|
+
"required": false,
|
|
6578
|
+
"type": "object",
|
|
6579
|
+
"in": "body"
|
|
6580
|
+
}]
|
|
6581
|
+
},
|
|
6582
|
+
"list-session-forks": {
|
|
6583
|
+
serviceClass: "Sessions",
|
|
6584
|
+
operationId: "listSessionForks",
|
|
6585
|
+
description: "Returns the sessions forked directly from this one. One level of lineage: a fork of a fork is listed under its own parent.",
|
|
6586
|
+
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/sessions",
|
|
6587
|
+
httpMethod: "get",
|
|
6588
|
+
pathParams: ["session_id"],
|
|
6589
|
+
queryParams: ["limit", "offset"],
|
|
6590
|
+
flags: [{
|
|
6591
|
+
"name": "session_id",
|
|
6592
|
+
"description": "Session public ID",
|
|
6593
|
+
"required": true,
|
|
6594
|
+
"type": "string",
|
|
6595
|
+
"in": "path"
|
|
6596
|
+
}, {
|
|
6597
|
+
"name": "limit",
|
|
6598
|
+
"description": "",
|
|
6599
|
+
"required": false,
|
|
6600
|
+
"type": "integer",
|
|
6601
|
+
"in": "query"
|
|
6602
|
+
}, {
|
|
6603
|
+
"name": "offset",
|
|
6604
|
+
"description": "",
|
|
6605
|
+
"required": false,
|
|
6606
|
+
"type": "integer",
|
|
6607
|
+
"in": "query"
|
|
6608
|
+
}]
|
|
6609
|
+
},
|
|
6478
6610
|
"get-session-tags": {
|
|
6479
6611
|
serviceClass: "Sessions",
|
|
6480
6612
|
operationId: "getSessionTags",
|
|
@@ -8019,6 +8151,22 @@ var routes = {
|
|
|
8019
8151
|
"in": "path"
|
|
8020
8152
|
}]
|
|
8021
8153
|
},
|
|
8154
|
+
"redeliver-webhook-delivery": {
|
|
8155
|
+
serviceClass: "Webhooks",
|
|
8156
|
+
operationId: "redeliverWebhookDelivery",
|
|
8157
|
+
description: "Queues the stored payload of an existing delivery to be sent again. A new delivery record is created rather than the original being reset, so the original attempt stays in the history. The send happens in the background: poll the returned delivery to observe its outcome.",
|
|
8158
|
+
moduleDocsUrl: "https://soat.ttoss.dev/docs/modules/webhooks",
|
|
8159
|
+
httpMethod: "post",
|
|
8160
|
+
pathParams: ["delivery_id"],
|
|
8161
|
+
queryParams: [],
|
|
8162
|
+
flags: [{
|
|
8163
|
+
"name": "delivery_id",
|
|
8164
|
+
"description": "Delivery to send again (wh_deliv_...)",
|
|
8165
|
+
"required": true,
|
|
8166
|
+
"type": "string",
|
|
8167
|
+
"in": "path"
|
|
8168
|
+
}]
|
|
8169
|
+
},
|
|
8022
8170
|
"get-webhook-secret": {
|
|
8023
8171
|
serviceClass: "Webhooks",
|
|
8024
8172
|
operationId: "getWebhookSecret",
|
|
@@ -8390,6 +8538,76 @@ var findUnknownFlags = args => {
|
|
|
8390
8538
|
}), `Run "soat ${args.commandName} --help" to see the flags this command accepts.`];
|
|
8391
8539
|
};
|
|
8392
8540
|
|
|
8541
|
+
//#endregion
|
|
8542
|
+
//#region src/webhookSignature.ts
|
|
8543
|
+
var digestMatches = args => {
|
|
8544
|
+
const expectedBuffer = Buffer.from(args.expected, "utf8");
|
|
8545
|
+
const actualBuffer = Buffer.from(args.actual, "utf8");
|
|
8546
|
+
if (expectedBuffer.length !== actualBuffer.length) return false;
|
|
8547
|
+
return timingSafeEqual(expectedBuffer, actualBuffer);
|
|
8548
|
+
};
|
|
8549
|
+
/** Deprecated scheme: `sha256=<hex>` over the bare body. */
|
|
8550
|
+
var verifyLegacySignature = args => {
|
|
8551
|
+
const expected = createHmac("sha256", args.secret).update(args.payload).digest("hex");
|
|
8552
|
+
return digestMatches({
|
|
8553
|
+
expected,
|
|
8554
|
+
actual: args.header
|
|
8555
|
+
});
|
|
8556
|
+
};
|
|
8557
|
+
/**
|
|
8558
|
+
* Timestamped scheme: `t=<unix>,v1=<hex>` over `<t>.<body>`.
|
|
8559
|
+
*
|
|
8560
|
+
* The timestamp must be present, but its age is deliberately not enforced here:
|
|
8561
|
+
* this is a local debugging listener, and rejecting a delivery over clock skew
|
|
8562
|
+
* would read as a signing bug. A real subscriber should enforce a tolerance
|
|
8563
|
+
* window — the webhooks module docs show one.
|
|
8564
|
+
*/
|
|
8565
|
+
var verifyTimestampedSignature = args => {
|
|
8566
|
+
const elements = new Map(args.header.split(",").map(part => {
|
|
8567
|
+
const separator = part.indexOf("=");
|
|
8568
|
+
return [part.slice(0, separator).trim(), part.slice(separator + 1)];
|
|
8569
|
+
}));
|
|
8570
|
+
const timestamp = elements.get("t");
|
|
8571
|
+
const digest = elements.get("v1");
|
|
8572
|
+
if (!timestamp || !digest) return false;
|
|
8573
|
+
const expected = createHmac("sha256", args.secret).update(`${timestamp}.${args.payload}`).digest("hex");
|
|
8574
|
+
return digestMatches({
|
|
8575
|
+
expected,
|
|
8576
|
+
actual: digest
|
|
8577
|
+
});
|
|
8578
|
+
};
|
|
8579
|
+
var headerValue = value => {
|
|
8580
|
+
if (Array.isArray(value)) return value[0] ?? "";
|
|
8581
|
+
return value ?? "";
|
|
8582
|
+
};
|
|
8583
|
+
/**
|
|
8584
|
+
* Picks the scheme a delivery used and verifies it, when a secret is supplied.
|
|
8585
|
+
*/
|
|
8586
|
+
var inspectDeliverySignature = args => {
|
|
8587
|
+
const timestamped = headerValue(args.headers["x-soat-signature-v2"]);
|
|
8588
|
+
const legacy = headerValue(args.headers["x-soat-signature"]);
|
|
8589
|
+
const scheme = timestamped ? "v2" : "v1";
|
|
8590
|
+
const signature = timestamped || legacy;
|
|
8591
|
+
if (!args.secret) return {
|
|
8592
|
+
signature,
|
|
8593
|
+
scheme,
|
|
8594
|
+
valid: null
|
|
8595
|
+
};
|
|
8596
|
+
return {
|
|
8597
|
+
signature,
|
|
8598
|
+
scheme,
|
|
8599
|
+
valid: scheme === "v2" ? verifyTimestampedSignature({
|
|
8600
|
+
secret: args.secret,
|
|
8601
|
+
payload: args.payload,
|
|
8602
|
+
header: timestamped
|
|
8603
|
+
}) : verifyLegacySignature({
|
|
8604
|
+
secret: args.secret,
|
|
8605
|
+
payload: args.payload,
|
|
8606
|
+
header: legacy
|
|
8607
|
+
})
|
|
8608
|
+
};
|
|
8609
|
+
};
|
|
8610
|
+
|
|
8393
8611
|
//#endregion
|
|
8394
8612
|
//#region src/index.ts
|
|
8395
8613
|
/**
|
|
@@ -8454,14 +8672,7 @@ var matchesFilter = (eventType, filter) => {
|
|
|
8454
8672
|
return eventType === pattern;
|
|
8455
8673
|
});
|
|
8456
8674
|
};
|
|
8457
|
-
|
|
8458
|
-
const expected = createHmac("sha256", secret).update(payload).digest("hex");
|
|
8459
|
-
const expectedBuffer = Buffer.from(expected, "utf8");
|
|
8460
|
-
const actualBuffer = Buffer.from(signatureHeader, "utf8");
|
|
8461
|
-
if (expectedBuffer.length !== actualBuffer.length) return false;
|
|
8462
|
-
return timingSafeEqual(expectedBuffer, actualBuffer);
|
|
8463
|
-
};
|
|
8464
|
-
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 => {
|
|
8675
|
+
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 the delivery 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 => {
|
|
8465
8676
|
const port = Number(opts.port);
|
|
8466
8677
|
const path = opts.path;
|
|
8467
8678
|
const secret = opts.secret;
|
|
@@ -8489,7 +8700,6 @@ program.command("listen").description("Start a local webhook listener for testin
|
|
|
8489
8700
|
const rawBody = Buffer.concat(chunks).toString("utf8");
|
|
8490
8701
|
const eventType = String(req.headers["x-soat-event"] ?? "unknown");
|
|
8491
8702
|
const deliveryId = String(req.headers["x-soat-delivery"] ?? "unknown");
|
|
8492
|
-
const signature = String(req.headers["x-soat-signature"] ?? "");
|
|
8493
8703
|
if (filter && !matchesFilter(eventType, filter)) {
|
|
8494
8704
|
res.writeHead(200, {
|
|
8495
8705
|
"Content-Type": "application/json"
|
|
@@ -8504,24 +8714,28 @@ program.command("listen").description("Start a local webhook listener for testin
|
|
|
8504
8714
|
try {
|
|
8505
8715
|
parsedPayload = JSON.parse(rawBody);
|
|
8506
8716
|
} catch {}
|
|
8507
|
-
|
|
8508
|
-
|
|
8717
|
+
const inspected = inspectDeliverySignature({
|
|
8718
|
+
secret,
|
|
8719
|
+
payload: rawBody,
|
|
8720
|
+
headers: req.headers
|
|
8721
|
+
});
|
|
8509
8722
|
const record = {
|
|
8510
8723
|
timestamp: (/* @__PURE__ */new Date()).toISOString(),
|
|
8511
8724
|
event_type: eventType,
|
|
8512
8725
|
delivery_id: deliveryId,
|
|
8513
|
-
signature,
|
|
8514
|
-
|
|
8726
|
+
signature: inspected.signature,
|
|
8727
|
+
signature_scheme: inspected.scheme,
|
|
8728
|
+
signature_valid: inspected.valid,
|
|
8515
8729
|
payload: parsedPayload
|
|
8516
8730
|
};
|
|
8517
8731
|
if (asJson) console.log(JSON.stringify(record));else {
|
|
8518
8732
|
console.log("--- webhook received ---");
|
|
8519
8733
|
console.log("event_type:", eventType);
|
|
8520
8734
|
console.log("delivery_id:", deliveryId);
|
|
8521
|
-
if (secret) console.log("signature_valid:",
|
|
8735
|
+
if (secret) console.log("signature_valid:", inspected.valid);
|
|
8522
8736
|
console.log("payload:", JSON.stringify(parsedPayload, null, 2));
|
|
8523
8737
|
}
|
|
8524
|
-
const responseStatus = secret &&
|
|
8738
|
+
const responseStatus = secret && inspected.valid === false ? 401 : 200;
|
|
8525
8739
|
res.writeHead(responseStatus, {
|
|
8526
8740
|
"Content-Type": "application/json"
|
|
8527
8741
|
});
|
|
@@ -8529,7 +8743,7 @@ program.command("listen").description("Start a local webhook listener for testin
|
|
|
8529
8743
|
ok: responseStatus === 200,
|
|
8530
8744
|
event_type: eventType,
|
|
8531
8745
|
delivery_id: deliveryId,
|
|
8532
|
-
signature_valid:
|
|
8746
|
+
signature_valid: inspected.valid
|
|
8533
8747
|
}));
|
|
8534
8748
|
});
|
|
8535
8749
|
});
|
|
@@ -8667,6 +8881,14 @@ program.argument("[command]", "API command in kebab-case (e.g. list-actors)").ar
|
|
|
8667
8881
|
process.exit(1);
|
|
8668
8882
|
}
|
|
8669
8883
|
console.log(await formatResultData(result.data));
|
|
8884
|
+
const failure = resolveFailureMessage({
|
|
8885
|
+
commandName,
|
|
8886
|
+
data: result.data
|
|
8887
|
+
});
|
|
8888
|
+
if (failure) {
|
|
8889
|
+
console.error(failure);
|
|
8890
|
+
process.exit(1);
|
|
8891
|
+
}
|
|
8670
8892
|
});
|
|
8671
8893
|
var runCli = async args => {
|
|
8672
8894
|
const previousArgv = process.argv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soat/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"dependencies": {
|
|
6
7
|
"@inquirer/input": "^5.1.2",
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
"@ttoss/logger": "^0.8.19",
|
|
9
10
|
"commander": "^15.0.0",
|
|
10
11
|
"js-yaml": "^5.2.1",
|
|
11
|
-
"@soat/sdk": "0.
|
|
12
|
+
"@soat/sdk": "0.25.0"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
14
15
|
"@ttoss/config": "^1.37.17",
|