@cargo-ai/cli 1.0.120 → 1.0.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/build/api.d.ts +6 -1
- package/build/api.d.ts.map +1 -1
- package/build/commands/connection/action.d.ts +1 -1
- package/build/commands/connection/action.d.ts.map +1 -1
- package/build/commands/connection/action.js +4 -2
- package/build/commands/connection/index.d.ts +1 -1
- package/build/commands/connection/index.d.ts.map +1 -1
- package/build/commands/connection/index.js +4 -4
- package/build/commands/connection/integration.d.ts +1 -1
- package/build/commands/connection/integration.d.ts.map +1 -1
- package/build/commands/connection/integration.js +11 -5
- package/build/commands/connection/nativeIntegration.d.ts +1 -1
- package/build/commands/connection/nativeIntegration.d.ts.map +1 -1
- package/build/commands/connection/nativeIntegration.js +4 -2
- package/build/commands/content/file.d.ts.map +1 -1
- package/build/commands/content/file.js +163 -2
- package/build/commands/orchestration/action.d.ts +1 -1
- package/build/commands/orchestration/action.d.ts.map +1 -1
- package/build/commands/orchestration/action.js +100 -4
- package/build/commands/orchestration/index.d.ts +1 -1
- package/build/commands/orchestration/index.d.ts.map +1 -1
- package/build/commands/orchestration/index.js +2 -2
- package/build/commands/signedOutNotice.d.ts +4 -0
- package/build/commands/signedOutNotice.d.ts.map +1 -0
- package/build/commands/signedOutNotice.js +11 -0
- package/build/index.js +18 -3
- package/build/utils/actionDryRun.d.ts +90 -0
- package/build/utils/actionDryRun.d.ts.map +1 -0
- package/build/utils/actionDryRun.js +145 -0
- package/build/utils/sampleFromSchema.d.ts +15 -0
- package/build/utils/sampleFromSchema.d.ts.map +1 -0
- package/build/utils/sampleFromSchema.js +474 -0
- package/package.json +6 -5
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
// A plausible value for a JSON schema, built without running anything.
|
|
2
|
+
//
|
|
3
|
+
// `action execute --dry-run` prints this in place of a provider's answer, so
|
|
4
|
+
// someone with no account can see the exact shape an action returns before
|
|
5
|
+
// they pay for one. Everything here is deterministic: the same schema always
|
|
6
|
+
// yields the same sample, so a dry run can be diffed, cached and tested.
|
|
7
|
+
//
|
|
8
|
+
// The values lean on the property name (an `email` reads as an address, a
|
|
9
|
+
// `linkedin_url` as a profile URL) because most connector output schemas say
|
|
10
|
+
// little beyond `type: "string"`. When nothing matches, the value is a neutral
|
|
11
|
+
// placeholder rather than a guess that could pass for real data.
|
|
12
|
+
/** Deeper than any real connector output; keeps a recursive `$ref` finite. */
|
|
13
|
+
const MAX_DEPTH = 8;
|
|
14
|
+
const SAMPLE_UUID = "123e4567-e89b-42d3-a456-426614174000";
|
|
15
|
+
const SAMPLE_DATE_TIME = "2026-01-15T09:30:00.000Z";
|
|
16
|
+
const SAMPLE_DATE = "2026-01-15";
|
|
17
|
+
const COMPANY_WORDS = ["company", "organization", "organisation", "employer"];
|
|
18
|
+
export function sampleFromSchema(schema, options = {}) {
|
|
19
|
+
const root = isSchemaObject(schema) === true ? schema : {};
|
|
20
|
+
return sampleValue(root, {
|
|
21
|
+
root,
|
|
22
|
+
subject: options.subject === undefined ? "person" : options.subject,
|
|
23
|
+
path: [],
|
|
24
|
+
depth: 0,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether a schema says enough about an output to sample it. `{}`, a bare
|
|
29
|
+
* `{ type: "object" }` and a free-form record all describe "some object", and
|
|
30
|
+
* a sample of one would be `{}` — which reads as "this action returns nothing"
|
|
31
|
+
* rather than "the shape is decided at run time".
|
|
32
|
+
*/
|
|
33
|
+
export function describesOutput(schema) {
|
|
34
|
+
return describes(schema, schema, 0);
|
|
35
|
+
}
|
|
36
|
+
function describes(schema, root, depth) {
|
|
37
|
+
if (isSchemaObject(schema) === false || depth > MAX_DEPTH) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const ref = schema["$ref"];
|
|
41
|
+
if (typeof ref === "string") {
|
|
42
|
+
return describes(resolveRef(ref, root), root, depth + 1);
|
|
43
|
+
}
|
|
44
|
+
if (schema["const"] !== undefined || Array.isArray(schema["enum"])) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
for (const key of ["anyOf", "oneOf", "allOf"]) {
|
|
48
|
+
const branches = schema[key];
|
|
49
|
+
if (Array.isArray(branches) === true &&
|
|
50
|
+
branches.some((branch) => describes(branch, root, depth + 1)) === true) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const properties = schema["properties"];
|
|
55
|
+
if (isSchemaObject(properties) === true) {
|
|
56
|
+
return Object.keys(properties).length > 0;
|
|
57
|
+
}
|
|
58
|
+
const type = pickType(schema["type"]);
|
|
59
|
+
// An object with no declared properties is a free-form record; anything
|
|
60
|
+
// else typed (an array, a scalar) is a shape a sample can show.
|
|
61
|
+
return type !== undefined && type !== "object";
|
|
62
|
+
}
|
|
63
|
+
function sampleValue(schema, ctx) {
|
|
64
|
+
const ref = schema["$ref"];
|
|
65
|
+
if (typeof ref === "string") {
|
|
66
|
+
const target = ctx.depth < MAX_DEPTH ? resolveRef(ref, ctx.root) : {};
|
|
67
|
+
return sampleValue(isSchemaObject(target) === true ? target : {}, {
|
|
68
|
+
...ctx,
|
|
69
|
+
depth: ctx.depth + 1,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const examples = schema["examples"];
|
|
73
|
+
if (Array.isArray(examples) === true && examples.length > 0) {
|
|
74
|
+
return examples[0];
|
|
75
|
+
}
|
|
76
|
+
if (schema["default"] !== undefined) {
|
|
77
|
+
return schema["default"];
|
|
78
|
+
}
|
|
79
|
+
if (schema["const"] !== undefined) {
|
|
80
|
+
return schema["const"];
|
|
81
|
+
}
|
|
82
|
+
const enumValues = schema["enum"];
|
|
83
|
+
if (Array.isArray(enumValues) === true && enumValues.length > 0) {
|
|
84
|
+
const firstNonNull = enumValues.find((value) => value !== null);
|
|
85
|
+
return firstNonNull !== undefined ? firstNonNull : enumValues[0];
|
|
86
|
+
}
|
|
87
|
+
const allOf = schema["allOf"];
|
|
88
|
+
if (Array.isArray(allOf) === true && allOf.length > 0) {
|
|
89
|
+
return sampleAllOf(schema, allOf, ctx);
|
|
90
|
+
}
|
|
91
|
+
for (const key of ["anyOf", "oneOf"]) {
|
|
92
|
+
const branches = schema[key];
|
|
93
|
+
if (Array.isArray(branches) === true && branches.length > 0) {
|
|
94
|
+
const branch = pickBranch(branches);
|
|
95
|
+
return sampleValue(branch, { ...ctx, depth: ctx.depth + 1 });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const type = inferType(schema);
|
|
99
|
+
if (type === "object") {
|
|
100
|
+
return sampleObject(schema, ctx);
|
|
101
|
+
}
|
|
102
|
+
if (type === "array") {
|
|
103
|
+
return sampleArray(schema, ctx);
|
|
104
|
+
}
|
|
105
|
+
if (type === "string") {
|
|
106
|
+
return sampleString(schema, ctx);
|
|
107
|
+
}
|
|
108
|
+
if (type === "integer" || type === "number") {
|
|
109
|
+
return sampleNumber(schema, ctx, type === "integer");
|
|
110
|
+
}
|
|
111
|
+
if (type === "boolean") {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (type === "null") {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
// No type at all (`{}`, `items: {}`): let the name decide, as a string.
|
|
118
|
+
return sampleString(schema, ctx);
|
|
119
|
+
}
|
|
120
|
+
function sampleObject(schema, ctx) {
|
|
121
|
+
const out = {};
|
|
122
|
+
if (ctx.depth >= MAX_DEPTH) {
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
const properties = schema["properties"];
|
|
126
|
+
if (isSchemaObject(properties) === false) {
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
130
|
+
out[key] = sampleValue(isSchemaObject(value) === true ? value : {}, {
|
|
131
|
+
...ctx,
|
|
132
|
+
path: [...ctx.path, key],
|
|
133
|
+
depth: ctx.depth + 1,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
// Declared properties cover every required one in practice; a required name
|
|
137
|
+
// with no declaration still has to be present for the sample to validate.
|
|
138
|
+
const required = schema["required"];
|
|
139
|
+
if (Array.isArray(required) === true) {
|
|
140
|
+
for (const key of required) {
|
|
141
|
+
if (typeof key === "string" && key in out === false) {
|
|
142
|
+
out[key] = sampleValue({}, {
|
|
143
|
+
...ctx,
|
|
144
|
+
path: [...ctx.path, key],
|
|
145
|
+
depth: ctx.depth + 1,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
function sampleArray(schema, ctx) {
|
|
153
|
+
if (ctx.depth >= MAX_DEPTH) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
const prefixItems = schema["prefixItems"];
|
|
157
|
+
const items = schema["items"];
|
|
158
|
+
const tuple = Array.isArray(prefixItems) === true
|
|
159
|
+
? prefixItems
|
|
160
|
+
: Array.isArray(items) === true
|
|
161
|
+
? items
|
|
162
|
+
: undefined;
|
|
163
|
+
if (tuple !== undefined) {
|
|
164
|
+
return tuple.map((item) => sampleValue(isSchemaObject(item) === true ? item : {}, {
|
|
165
|
+
...ctx,
|
|
166
|
+
depth: ctx.depth + 1,
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
// One item: enough to show its shape, and the name of the array (`emails`,
|
|
170
|
+
// `technologies`) is what the item's value is guessed from.
|
|
171
|
+
return [
|
|
172
|
+
sampleValue(isSchemaObject(items) === true ? items : {}, {
|
|
173
|
+
...ctx,
|
|
174
|
+
depth: ctx.depth + 1,
|
|
175
|
+
}),
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
function sampleAllOf(schema, allOf, ctx) {
|
|
179
|
+
const samples = allOf.map((branch) => sampleValue(isSchemaObject(branch) === true ? branch : {}, {
|
|
180
|
+
...ctx,
|
|
181
|
+
depth: ctx.depth + 1,
|
|
182
|
+
}));
|
|
183
|
+
const rest = { ...schema, allOf: undefined };
|
|
184
|
+
const objects = samples.filter((sample) => typeof sample === "object" &&
|
|
185
|
+
sample !== null &&
|
|
186
|
+
Array.isArray(sample) === false);
|
|
187
|
+
if (objects.length === samples.length) {
|
|
188
|
+
const own = isSchemaObject(rest["properties"]) === true
|
|
189
|
+
? sampleObject(rest, ctx)
|
|
190
|
+
: {};
|
|
191
|
+
return Object.assign({}, ...objects, own);
|
|
192
|
+
}
|
|
193
|
+
return samples[0];
|
|
194
|
+
}
|
|
195
|
+
function sampleString(schema, ctx) {
|
|
196
|
+
const format = schema["format"];
|
|
197
|
+
if (typeof format === "string") {
|
|
198
|
+
const formatted = stringForFormat(format);
|
|
199
|
+
if (formatted !== undefined) {
|
|
200
|
+
return formatted;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const hinted = stringForName(ctx);
|
|
204
|
+
return hinted !== undefined ? hinted : "sample";
|
|
205
|
+
}
|
|
206
|
+
function stringForFormat(format) {
|
|
207
|
+
if (format === "email" || format === "idn-email") {
|
|
208
|
+
return "jane.doe@example.com";
|
|
209
|
+
}
|
|
210
|
+
if (format === "uri" || format === "url" || format === "iri") {
|
|
211
|
+
return "https://example.com";
|
|
212
|
+
}
|
|
213
|
+
if (format === "date-time") {
|
|
214
|
+
return SAMPLE_DATE_TIME;
|
|
215
|
+
}
|
|
216
|
+
if (format === "date") {
|
|
217
|
+
return SAMPLE_DATE;
|
|
218
|
+
}
|
|
219
|
+
if (format === "time") {
|
|
220
|
+
return "09:30:00Z";
|
|
221
|
+
}
|
|
222
|
+
if (format === "uuid") {
|
|
223
|
+
return SAMPLE_UUID;
|
|
224
|
+
}
|
|
225
|
+
if (format === "hostname" || format === "idn-hostname") {
|
|
226
|
+
return "example.com";
|
|
227
|
+
}
|
|
228
|
+
if (format === "ipv4") {
|
|
229
|
+
return "192.0.2.1";
|
|
230
|
+
}
|
|
231
|
+
if (format === "ipv6") {
|
|
232
|
+
return "2001:db8::1";
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
/** The nearest property name, with separators dropped: `linkedin_url` → `linkedinurl`. */
|
|
237
|
+
function nameOf(ctx) {
|
|
238
|
+
const last = ctx.path[ctx.path.length - 1];
|
|
239
|
+
return last === undefined ? "" : last.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
240
|
+
}
|
|
241
|
+
function aboutCompany(ctx) {
|
|
242
|
+
const parents = ctx.path.slice(0, -1).map((part) => part.toLowerCase());
|
|
243
|
+
if (parents.some((part) => COMPANY_WORDS.some((word) => part.includes(word))) === true) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
if (parents.some((part) => part.includes("person") ||
|
|
247
|
+
part.includes("contact") ||
|
|
248
|
+
part.includes("employee")) === true) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
return ctx.subject === "company";
|
|
252
|
+
}
|
|
253
|
+
// Ordered: the first match wins, so the specific names (`linkedin_url`,
|
|
254
|
+
// `company_name`) come before the general ones (`url`, `name`).
|
|
255
|
+
function stringForName(ctx) {
|
|
256
|
+
const name = nameOf(ctx);
|
|
257
|
+
if (name === "") {
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
const has = (...words) => words.some((word) => name.includes(word));
|
|
261
|
+
const raw = ctx.path[ctx.path.length - 1];
|
|
262
|
+
// `id`, `companyId`, `person_uuid`: an identifier, whatever it identifies.
|
|
263
|
+
if (raw !== undefined &&
|
|
264
|
+
/(^id$|^uuid$|Id$|ID$|_id$|Uuid$|_uuid$)/.test(raw) === true) {
|
|
265
|
+
return name.endsWith("uuid") === true ? SAMPLE_UUID : "sample-id-1";
|
|
266
|
+
}
|
|
267
|
+
// `createdAt`, `updated_at`.
|
|
268
|
+
if (raw !== undefined && /(At$|_at$)/.test(raw) === true) {
|
|
269
|
+
return SAMPLE_DATE_TIME;
|
|
270
|
+
}
|
|
271
|
+
// `extracted_on`, `publishedOn`.
|
|
272
|
+
if (raw !== undefined && /(On$|_on$)/.test(raw) === true) {
|
|
273
|
+
return SAMPLE_DATE;
|
|
274
|
+
}
|
|
275
|
+
// `company_type`, `email_status`: a label whose values only the provider
|
|
276
|
+
// knows. A placeholder says so; "Example Inc" would read as a real answer.
|
|
277
|
+
if (/(type|kind|category|status)$/.test(name) === true) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
if (has("email", "mail")) {
|
|
281
|
+
return "jane.doe@example.com";
|
|
282
|
+
}
|
|
283
|
+
if (has("linkedin")) {
|
|
284
|
+
return aboutCompany(ctx) === true || has("company")
|
|
285
|
+
? "https://www.linkedin.com/company/example"
|
|
286
|
+
: "https://www.linkedin.com/in/jane-doe";
|
|
287
|
+
}
|
|
288
|
+
if (has("twitter")) {
|
|
289
|
+
return "https://twitter.com/example";
|
|
290
|
+
}
|
|
291
|
+
if (has("logo", "image", "avatar", "photo", "picture")) {
|
|
292
|
+
return "https://example.com/logo.png";
|
|
293
|
+
}
|
|
294
|
+
if (has("domain", "hostname")) {
|
|
295
|
+
return "example.com";
|
|
296
|
+
}
|
|
297
|
+
if (has("website", "url", "uri", "link", "href", "homepage")) {
|
|
298
|
+
return "https://example.com";
|
|
299
|
+
}
|
|
300
|
+
if (has("phone", "mobile")) {
|
|
301
|
+
return "+1 415 555 0100";
|
|
302
|
+
}
|
|
303
|
+
if (has("firstname", "givenname")) {
|
|
304
|
+
return "Jane";
|
|
305
|
+
}
|
|
306
|
+
if (has("lastname", "surname", "familyname")) {
|
|
307
|
+
return "Doe";
|
|
308
|
+
}
|
|
309
|
+
if (has("company", "organization", "organisation", "employer", "account")) {
|
|
310
|
+
return "Example Inc";
|
|
311
|
+
}
|
|
312
|
+
if (has("fullname", "name")) {
|
|
313
|
+
return aboutCompany(ctx) === true ? "Example Inc" : "Jane Doe";
|
|
314
|
+
}
|
|
315
|
+
if (has("jobtitle", "title", "position", "headline", "role")) {
|
|
316
|
+
return "Head of Growth";
|
|
317
|
+
}
|
|
318
|
+
if (has("seniority")) {
|
|
319
|
+
return "director";
|
|
320
|
+
}
|
|
321
|
+
if (has("department", "function")) {
|
|
322
|
+
return "Marketing";
|
|
323
|
+
}
|
|
324
|
+
if (has("countrycode")) {
|
|
325
|
+
return "US";
|
|
326
|
+
}
|
|
327
|
+
if (has("country")) {
|
|
328
|
+
return "United States";
|
|
329
|
+
}
|
|
330
|
+
if (has("city", "locality")) {
|
|
331
|
+
return "San Francisco";
|
|
332
|
+
}
|
|
333
|
+
if (has("state", "region", "province")) {
|
|
334
|
+
return "California";
|
|
335
|
+
}
|
|
336
|
+
if (has("zip", "postal")) {
|
|
337
|
+
return "94105";
|
|
338
|
+
}
|
|
339
|
+
if (has("address", "street")) {
|
|
340
|
+
return "1 Market St, San Francisco, CA 94105";
|
|
341
|
+
}
|
|
342
|
+
if (has("location")) {
|
|
343
|
+
return "San Francisco, California, United States";
|
|
344
|
+
}
|
|
345
|
+
if (has("industr")) {
|
|
346
|
+
return "Software";
|
|
347
|
+
}
|
|
348
|
+
if (has("currency")) {
|
|
349
|
+
return "USD";
|
|
350
|
+
}
|
|
351
|
+
if (has("timezone")) {
|
|
352
|
+
return "America/Los_Angeles";
|
|
353
|
+
}
|
|
354
|
+
if (has("language", "locale")) {
|
|
355
|
+
return "en";
|
|
356
|
+
}
|
|
357
|
+
if (has("revenue")) {
|
|
358
|
+
return "$10M-$50M";
|
|
359
|
+
}
|
|
360
|
+
if (has("employee", "headcount", "size")) {
|
|
361
|
+
return "51-200";
|
|
362
|
+
}
|
|
363
|
+
if (has("year", "founded")) {
|
|
364
|
+
return "2015";
|
|
365
|
+
}
|
|
366
|
+
if (has("description", "summary", "bio", "about")) {
|
|
367
|
+
return "Sample description.";
|
|
368
|
+
}
|
|
369
|
+
if (has("date", "time")) {
|
|
370
|
+
return SAMPLE_DATE_TIME;
|
|
371
|
+
}
|
|
372
|
+
return undefined;
|
|
373
|
+
}
|
|
374
|
+
function sampleNumber(schema, ctx, integer) {
|
|
375
|
+
const hinted = numberForName(ctx);
|
|
376
|
+
let value = hinted !== undefined ? hinted : 1;
|
|
377
|
+
const minimum = schema["minimum"];
|
|
378
|
+
const maximum = schema["maximum"];
|
|
379
|
+
if (typeof minimum === "number" && value < minimum) {
|
|
380
|
+
value = minimum;
|
|
381
|
+
}
|
|
382
|
+
if (typeof maximum === "number" && value > maximum) {
|
|
383
|
+
value = maximum;
|
|
384
|
+
}
|
|
385
|
+
return integer === true ? Math.round(value) : value;
|
|
386
|
+
}
|
|
387
|
+
function numberForName(ctx) {
|
|
388
|
+
const name = nameOf(ctx);
|
|
389
|
+
if (name === "") {
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
const has = (...words) => words.some((word) => name.includes(word));
|
|
393
|
+
if (has("year", "founded")) {
|
|
394
|
+
return 2015;
|
|
395
|
+
}
|
|
396
|
+
if (has("employee", "headcount", "staff")) {
|
|
397
|
+
return 120;
|
|
398
|
+
}
|
|
399
|
+
if (has("revenue", "funding", "amount", "valuation")) {
|
|
400
|
+
return 25000000;
|
|
401
|
+
}
|
|
402
|
+
if (has("score", "confidence", "probability")) {
|
|
403
|
+
return 0.9;
|
|
404
|
+
}
|
|
405
|
+
if (has("latitude")) {
|
|
406
|
+
return 37.7749;
|
|
407
|
+
}
|
|
408
|
+
if (has("longitude")) {
|
|
409
|
+
return -122.4194;
|
|
410
|
+
}
|
|
411
|
+
if (has("count", "total", "number", "size")) {
|
|
412
|
+
return 1;
|
|
413
|
+
}
|
|
414
|
+
return undefined;
|
|
415
|
+
}
|
|
416
|
+
function inferType(schema) {
|
|
417
|
+
const type = pickType(schema["type"]);
|
|
418
|
+
if (type !== undefined) {
|
|
419
|
+
return type;
|
|
420
|
+
}
|
|
421
|
+
if (isSchemaObject(schema["properties"]) === true) {
|
|
422
|
+
return "object";
|
|
423
|
+
}
|
|
424
|
+
if (schema["items"] !== undefined || schema["prefixItems"] !== undefined) {
|
|
425
|
+
return "array";
|
|
426
|
+
}
|
|
427
|
+
return undefined;
|
|
428
|
+
}
|
|
429
|
+
/** `["string", "null"]` samples as a string: null shows nothing about the shape. */
|
|
430
|
+
function pickType(type) {
|
|
431
|
+
if (typeof type === "string") {
|
|
432
|
+
return type;
|
|
433
|
+
}
|
|
434
|
+
if (Array.isArray(type) === true) {
|
|
435
|
+
const nonNull = type.find((value) => typeof value === "string" && value !== "null");
|
|
436
|
+
if (nonNull !== undefined) {
|
|
437
|
+
return nonNull;
|
|
438
|
+
}
|
|
439
|
+
return type.length > 0 && typeof type[0] === "string" ? type[0] : undefined;
|
|
440
|
+
}
|
|
441
|
+
return undefined;
|
|
442
|
+
}
|
|
443
|
+
/** The first branch that is not just `{ type: "null" }`. */
|
|
444
|
+
function pickBranch(branches) {
|
|
445
|
+
const objects = branches.filter((branch) => isSchemaObject(branch));
|
|
446
|
+
const nonNull = objects.find((branch) => branch["type"] !== "null");
|
|
447
|
+
if (nonNull !== undefined) {
|
|
448
|
+
return nonNull;
|
|
449
|
+
}
|
|
450
|
+
const first = objects[0];
|
|
451
|
+
return first !== undefined ? first : {};
|
|
452
|
+
}
|
|
453
|
+
/** Local refs only (`#/$defs/x`, `#/definitions/x`); anything else samples as `{}`. */
|
|
454
|
+
function resolveRef(ref, root) {
|
|
455
|
+
if (ref.startsWith("#") === false) {
|
|
456
|
+
return {};
|
|
457
|
+
}
|
|
458
|
+
let current = root;
|
|
459
|
+
for (const segment of ref.slice(1).split("/")) {
|
|
460
|
+
if (segment === "") {
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (isSchemaObject(current) === false) {
|
|
464
|
+
return {};
|
|
465
|
+
}
|
|
466
|
+
current = current[segment.replace(/~1/g, "/").replace(/~0/g, "~")];
|
|
467
|
+
}
|
|
468
|
+
return current;
|
|
469
|
+
}
|
|
470
|
+
function isSchemaObject(value) {
|
|
471
|
+
return (typeof value === "object" &&
|
|
472
|
+
value !== null &&
|
|
473
|
+
Array.isArray(value) === false);
|
|
474
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cargo-ai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.122",
|
|
4
4
|
"mcpName": "io.github.getcargohq/cargo",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -74,16 +74,17 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@ai-sdk/harness": "^1.0.144",
|
|
76
76
|
"@ai-sdk/harness-claude-code": "^1.0.148",
|
|
77
|
-
"@cargo-ai/api": "^1.0.
|
|
77
|
+
"@cargo-ai/api": "^1.0.101",
|
|
78
78
|
"@cargo-ai/app-sdk": "^1.0.11",
|
|
79
|
-
"@cargo-ai/cdk": "^1.0.
|
|
80
|
-
"@cargo-ai/types": "^1.0.
|
|
81
|
-
"@cargo-ai/utils": "^1.0.
|
|
79
|
+
"@cargo-ai/cdk": "^1.0.117",
|
|
80
|
+
"@cargo-ai/types": "^1.0.101",
|
|
81
|
+
"@cargo-ai/utils": "^1.0.35",
|
|
82
82
|
"@cargo-ai/worker-sdk": "^1.0.21",
|
|
83
83
|
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
84
84
|
"ai": "^7.0.133",
|
|
85
85
|
"ai-sdk-sandbox-local": "^0.1.2",
|
|
86
86
|
"commander": "^12.1.0",
|
|
87
|
+
"jsonschema": "^1.4.1",
|
|
87
88
|
"tsx": "^4.19.2",
|
|
88
89
|
"undici": "^7.29.1",
|
|
89
90
|
"uuid": "^14.0.0"
|