@doist/automations-cli 1.8.0 → 1.9.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/dist/index.js +846 -603
- package/dist/index.js.map +4 -4
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { fileURLToPath } from "node:url";
|
|
|
15
15
|
// package.json
|
|
16
16
|
var package_default = {
|
|
17
17
|
name: "@doist/automations-cli",
|
|
18
|
-
version: "1.
|
|
18
|
+
version: "1.9.0",
|
|
19
19
|
description: "Command-line client for Todoist Automations",
|
|
20
20
|
type: "module",
|
|
21
21
|
bin: {
|
|
@@ -64,8 +64,7 @@ var package_default = {
|
|
|
64
64
|
ai: "7.0.77",
|
|
65
65
|
commander: "15.0.0",
|
|
66
66
|
oauth4webapi: "3.8.8",
|
|
67
|
-
open: "11.0.
|
|
68
|
-
"p-limit": "3.1.0"
|
|
67
|
+
open: "11.0.3"
|
|
69
68
|
},
|
|
70
69
|
devDependencies: {
|
|
71
70
|
"@doist/automations-core": "*",
|
|
@@ -1829,10 +1828,10 @@ function node(obj, key, make) {
|
|
|
1829
1828
|
}
|
|
1830
1829
|
return obj[key];
|
|
1831
1830
|
}
|
|
1832
|
-
function flattenError(
|
|
1831
|
+
function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
1833
1832
|
const fieldErrors = {};
|
|
1834
1833
|
const formErrors = [];
|
|
1835
|
-
for (const sub of
|
|
1834
|
+
for (const sub of error62.issues) {
|
|
1836
1835
|
if (sub.path.length > 0) {
|
|
1837
1836
|
node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
1838
1837
|
} else {
|
|
@@ -1841,10 +1840,10 @@ function flattenError(error61, mapper = (issue2) => issue2.message) {
|
|
|
1841
1840
|
}
|
|
1842
1841
|
return { formErrors, fieldErrors };
|
|
1843
1842
|
}
|
|
1844
|
-
function formatError(
|
|
1843
|
+
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
1845
1844
|
const fieldErrors = { _errors: [] };
|
|
1846
|
-
const processError = (
|
|
1847
|
-
for (const issue2 of
|
|
1845
|
+
const processError = (error63, path = []) => {
|
|
1846
|
+
for (const issue2 of error63.issues) {
|
|
1848
1847
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1849
1848
|
issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
|
|
1850
1849
|
} else if (issue2.code === "invalid_key") {
|
|
@@ -1886,14 +1885,14 @@ function formatError(error61, mapper = (issue2) => issue2.message) {
|
|
|
1886
1885
|
}
|
|
1887
1886
|
}
|
|
1888
1887
|
};
|
|
1889
|
-
processError(
|
|
1888
|
+
processError(error62);
|
|
1890
1889
|
return fieldErrors;
|
|
1891
1890
|
}
|
|
1892
|
-
function treeifyError(
|
|
1891
|
+
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
1893
1892
|
const result = { errors: [] };
|
|
1894
|
-
const processError = (
|
|
1893
|
+
const processError = (error63, path = []) => {
|
|
1895
1894
|
var _a3;
|
|
1896
|
-
for (const issue2 of
|
|
1895
|
+
for (const issue2 of error63.issues) {
|
|
1897
1896
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1898
1897
|
issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
|
|
1899
1898
|
} else if (issue2.code === "invalid_key") {
|
|
@@ -1935,7 +1934,7 @@ function treeifyError(error61, mapper = (issue2) => issue2.message) {
|
|
|
1935
1934
|
}
|
|
1936
1935
|
}
|
|
1937
1936
|
};
|
|
1938
|
-
processError(
|
|
1937
|
+
processError(error62);
|
|
1939
1938
|
return result;
|
|
1940
1939
|
}
|
|
1941
1940
|
function toDotPath(_path) {
|
|
@@ -1956,9 +1955,9 @@ function toDotPath(_path) {
|
|
|
1956
1955
|
}
|
|
1957
1956
|
return segs.join("");
|
|
1958
1957
|
}
|
|
1959
|
-
function prettifyError(
|
|
1958
|
+
function prettifyError(error62) {
|
|
1960
1959
|
const lines = [];
|
|
1961
|
-
const issues = [...
|
|
1960
|
+
const issues = [...error62.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
1962
1961
|
for (const issue2 of issues) {
|
|
1963
1962
|
lines.push(`\u2716 ${issue2.message}`);
|
|
1964
1963
|
if (issue2.path?.length)
|
|
@@ -2014,19 +2013,19 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
2014
2013
|
};
|
|
2015
2014
|
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
2016
2015
|
function failure(Err, issues, ctx) {
|
|
2017
|
-
let
|
|
2016
|
+
let error62;
|
|
2018
2017
|
return {
|
|
2019
2018
|
success: false,
|
|
2020
2019
|
get error() {
|
|
2021
|
-
if (!
|
|
2022
|
-
|
|
2020
|
+
if (!error62) {
|
|
2021
|
+
error62 = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
2023
2022
|
issues = void 0;
|
|
2024
2023
|
ctx = void 0;
|
|
2025
2024
|
}
|
|
2026
|
-
return
|
|
2025
|
+
return error62;
|
|
2027
2026
|
},
|
|
2028
2027
|
set error(e) {
|
|
2029
|
-
|
|
2028
|
+
error62 = e;
|
|
2030
2029
|
issues = void 0;
|
|
2031
2030
|
ctx = void 0;
|
|
2032
2031
|
}
|
|
@@ -2790,7 +2789,7 @@ ${content.join("\n")}
|
|
|
2790
2789
|
var version = {
|
|
2791
2790
|
major: 4,
|
|
2792
2791
|
minor: 6,
|
|
2793
|
-
patch:
|
|
2792
|
+
patch: 2
|
|
2794
2793
|
};
|
|
2795
2794
|
|
|
2796
2795
|
// ../../node_modules/zod/v4/core/schemas.js
|
|
@@ -3594,7 +3593,7 @@ function handlePropertyResult(result, final, key, input2, optin, optout) {
|
|
|
3594
3593
|
return;
|
|
3595
3594
|
}
|
|
3596
3595
|
if (result.value === void 0) {
|
|
3597
|
-
if (isPresent) {
|
|
3596
|
+
if (isPresent || optin === "defaulted" && !isOptionalOut) {
|
|
3598
3597
|
final.value[key] = void 0;
|
|
3599
3598
|
}
|
|
3600
3599
|
} else {
|
|
@@ -3830,16 +3829,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3830
3829
|
doc.write(`
|
|
3831
3830
|
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
3832
3831
|
}
|
|
3833
|
-
|
|
3834
|
-
if (
|
|
3835
|
-
|
|
3836
|
-
newResult[${k}] = undefined;
|
|
3837
|
-
}
|
|
3832
|
+
`);
|
|
3833
|
+
if (optin === "defaulted") {
|
|
3834
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
3838
3835
|
} else {
|
|
3836
|
+
doc.write(`
|
|
3837
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
3839
3838
|
newResult[${k}] = ${id}.value;
|
|
3840
3839
|
}
|
|
3841
|
-
|
|
3842
3840
|
`);
|
|
3841
|
+
}
|
|
3843
3842
|
}
|
|
3844
3843
|
}
|
|
3845
3844
|
doc.write(`payload.value = newResult;`);
|
|
@@ -4003,16 +4002,31 @@ function getDiscriminatedOption(union2, value) {
|
|
|
4003
4002
|
const internals = union2._zod;
|
|
4004
4003
|
let map2 = internals.bag.optionsMap;
|
|
4005
4004
|
if (!map2) {
|
|
4006
|
-
map2 =
|
|
4007
|
-
const { options, discriminator } = internals.def;
|
|
4008
|
-
for (const option of options) {
|
|
4009
|
-
for (const v of option._zod.propValues?.[discriminator] ?? [])
|
|
4010
|
-
if (!map2.has(v))
|
|
4011
|
-
map2.set(v, option);
|
|
4012
|
-
}
|
|
4005
|
+
map2 = discriminatorMap(internals.def);
|
|
4013
4006
|
internals.bag.optionsMap = map2;
|
|
4014
4007
|
}
|
|
4015
|
-
|
|
4008
|
+
const option = map2.get(value);
|
|
4009
|
+
if (option === null)
|
|
4010
|
+
throw new Error(`Ambiguous discriminator value "${String(value)}"`);
|
|
4011
|
+
return option;
|
|
4012
|
+
}
|
|
4013
|
+
function discriminatorMap(def) {
|
|
4014
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
4015
|
+
for (const option of def.options) {
|
|
4016
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
4017
|
+
if (!values || values.size === 0)
|
|
4018
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
4019
|
+
for (const value of values) {
|
|
4020
|
+
if (map2.has(value)) {
|
|
4021
|
+
if (value !== void 0)
|
|
4022
|
+
throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
4023
|
+
map2.set(value, null);
|
|
4024
|
+
} else {
|
|
4025
|
+
map2.set(value, option);
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
return map2;
|
|
4016
4030
|
}
|
|
4017
4031
|
var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
4018
4032
|
def.inclusive = false;
|
|
@@ -4020,10 +4034,13 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
4020
4034
|
const _super = inst._zod.parse;
|
|
4021
4035
|
defineLazyInternal(inst, "propValues", (zod) => {
|
|
4022
4036
|
const propValues = {};
|
|
4037
|
+
let undefinedCount = 0;
|
|
4023
4038
|
for (const option of zod.def.options) {
|
|
4024
4039
|
const pv = option._zod.propValues;
|
|
4025
4040
|
if (!pv || Object.keys(pv).length === 0)
|
|
4026
4041
|
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
4042
|
+
if (pv[zod.def.discriminator]?.has(void 0))
|
|
4043
|
+
undefinedCount++;
|
|
4027
4044
|
for (const [k, v] of Object.entries(pv)) {
|
|
4028
4045
|
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
4029
4046
|
assignProp(propValues, k, /* @__PURE__ */ new Set());
|
|
@@ -4033,6 +4050,8 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
4033
4050
|
}
|
|
4034
4051
|
}
|
|
4035
4052
|
}
|
|
4053
|
+
if (!zod.def.unionFallback && undefinedCount > 1)
|
|
4054
|
+
propValues[zod.def.discriminator]?.delete(void 0);
|
|
4036
4055
|
return propValues;
|
|
4037
4056
|
});
|
|
4038
4057
|
def.options.forEach((option, i) => {
|
|
@@ -4041,22 +4060,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
4041
4060
|
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
4042
4061
|
}
|
|
4043
4062
|
});
|
|
4044
|
-
const disc = cached(() =>
|
|
4045
|
-
const opts = def.options;
|
|
4046
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
4047
|
-
for (const o of opts) {
|
|
4048
|
-
const values = o._zod.propValues?.[def.discriminator];
|
|
4049
|
-
if (!values || values.size === 0)
|
|
4050
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
4051
|
-
for (const v of values) {
|
|
4052
|
-
if (map2.has(v)) {
|
|
4053
|
-
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
4054
|
-
}
|
|
4055
|
-
map2.set(v, o);
|
|
4056
|
-
}
|
|
4057
|
-
}
|
|
4058
|
-
return map2;
|
|
4059
|
-
});
|
|
4063
|
+
const disc = cached(() => discriminatorMap(def));
|
|
4060
4064
|
inst._zod.parse = (payload, ctx) => {
|
|
4061
4065
|
const input2 = payload.value;
|
|
4062
4066
|
if (!isObject(input2)) {
|
|
@@ -4068,8 +4072,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
4068
4072
|
});
|
|
4069
4073
|
return payload;
|
|
4070
4074
|
}
|
|
4071
|
-
const
|
|
4072
|
-
|
|
4075
|
+
const value = input2?.[def.discriminator];
|
|
4076
|
+
const opt = disc.value.get(value);
|
|
4077
|
+
if (opt && (value !== void 0 || ctx.direction !== "backward")) {
|
|
4073
4078
|
return opt._zod.run(payload, ctx);
|
|
4074
4079
|
}
|
|
4075
4080
|
if (def.unionFallback || ctx.direction === "backward") {
|
|
@@ -4080,7 +4085,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
4080
4085
|
errors: [],
|
|
4081
4086
|
note: "No matching discriminator",
|
|
4082
4087
|
discriminator: def.discriminator,
|
|
4083
|
-
options: Array.from(disc.value.keys()),
|
|
4088
|
+
options: Array.from(disc.value.keys()).filter((value2) => disc.value.get(value2) !== null),
|
|
4084
4089
|
input: input2,
|
|
4085
4090
|
path: [def.discriminator],
|
|
4086
4091
|
inst
|
|
@@ -5568,6 +5573,7 @@ __export(locales_exports, {
|
|
|
5568
5573
|
sl: () => sl_default,
|
|
5569
5574
|
sv: () => sv_default,
|
|
5570
5575
|
ta: () => ta_default,
|
|
5576
|
+
tg: () => tg_default,
|
|
5571
5577
|
th: () => th_default,
|
|
5572
5578
|
tk: () => tk_default,
|
|
5573
5579
|
tr: () => tr_default,
|
|
@@ -11774,8 +11780,124 @@ function ta_default() {
|
|
|
11774
11780
|
};
|
|
11775
11781
|
}
|
|
11776
11782
|
|
|
11777
|
-
// ../../node_modules/zod/v4/locales/
|
|
11783
|
+
// ../../node_modules/zod/v4/locales/tg.js
|
|
11778
11784
|
var error51 = () => {
|
|
11785
|
+
const Sizable = {
|
|
11786
|
+
string: { unit: "\u0430\u043B\u043E\u043C\u0430\u0442", verb: "\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434" },
|
|
11787
|
+
file: { unit: "\u0431\u0430\u0439\u0442", verb: "\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434" },
|
|
11788
|
+
array: { unit: "\u0443\u043D\u0441\u0443\u0440", verb: "\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434" },
|
|
11789
|
+
set: { unit: "\u0443\u043D\u0441\u0443\u0440", verb: "\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434" },
|
|
11790
|
+
map: { unit: "\u0441\u0430\u0431\u0442", verb: "\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434" }
|
|
11791
|
+
};
|
|
11792
|
+
function getSizing(origin) {
|
|
11793
|
+
return Sizable[origin] ?? null;
|
|
11794
|
+
}
|
|
11795
|
+
const FormatDictionary = {
|
|
11796
|
+
regex: "\u0432\u0443\u0440\u0443\u0434",
|
|
11797
|
+
email: "\u0441\u0443\u0440\u043E\u0493\u0430\u0438 email",
|
|
11798
|
+
url: "URL",
|
|
11799
|
+
emoji: "\u044D\u043C\u043E\u04B7\u0438",
|
|
11800
|
+
uuid: "UUID",
|
|
11801
|
+
uuidv4: "UUIDv4",
|
|
11802
|
+
uuidv6: "UUIDv6",
|
|
11803
|
+
nanoid: "nanoid",
|
|
11804
|
+
guid: "GUID",
|
|
11805
|
+
cuid: "cuid",
|
|
11806
|
+
cuid2: "cuid2",
|
|
11807
|
+
ulid: "ULID",
|
|
11808
|
+
xid: "XID",
|
|
11809
|
+
ksuid: "KSUID",
|
|
11810
|
+
datetime: "\u0441\u0430\u043D\u0430\u0432\u0443 \u0432\u0430\u049B\u0442\u0438 ISO",
|
|
11811
|
+
date: "\u0441\u0430\u043D\u0430\u0438 ISO",
|
|
11812
|
+
time: "\u0432\u0430\u049B\u0442\u0438 ISO",
|
|
11813
|
+
duration: "\u0434\u0430\u0432\u043E\u043C\u043D\u043E\u043A\u0438\u0438 ISO",
|
|
11814
|
+
ipv4: "\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv4",
|
|
11815
|
+
ipv6: "\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv6",
|
|
11816
|
+
mac: "\u0441\u0443\u0440\u043E\u0493\u0430\u0438 MAC",
|
|
11817
|
+
cidrv4: "\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv4",
|
|
11818
|
+
cidrv6: "\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv6",
|
|
11819
|
+
base64: "\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64",
|
|
11820
|
+
base64url: "\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64url",
|
|
11821
|
+
json_string: "\u0441\u0430\u0442\u0440\u0438 JSON",
|
|
11822
|
+
e164: "\u0440\u0430\u049B\u0430\u043C\u0438 E.164",
|
|
11823
|
+
credit_card: "\u0440\u0430\u049B\u0430\u043C\u0438 \u043A\u043E\u0440\u0442\u0438 \u043A\u0440\u0435\u0434\u0438\u0442\u04E3",
|
|
11824
|
+
iban: "IBAN",
|
|
11825
|
+
jwt: "JWT",
|
|
11826
|
+
template_literal: "\u0432\u0443\u0440\u0443\u0434"
|
|
11827
|
+
};
|
|
11828
|
+
const TypeDictionary = {
|
|
11829
|
+
nan: "NaN",
|
|
11830
|
+
number: "\u0440\u0430\u049B\u0430\u043C",
|
|
11831
|
+
string: "\u0441\u0430\u0442\u0440",
|
|
11832
|
+
array: "\u043C\u0430\u0441\u0441\u0438\u0432",
|
|
11833
|
+
object: "\u043E\u0431\u044A\u0435\u043A\u0442",
|
|
11834
|
+
date: "\u0441\u0430\u043D\u0430"
|
|
11835
|
+
};
|
|
11836
|
+
return (issue2) => {
|
|
11837
|
+
switch (issue2.code) {
|
|
11838
|
+
case "invalid_type": {
|
|
11839
|
+
const expected = TypeDictionary[issue2.expected] ?? issue2.expected;
|
|
11840
|
+
const receivedType = parsedType(issue2.input);
|
|
11841
|
+
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
11842
|
+
return `\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${expected} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442, ${received} \u0433\u0438\u0440\u0438\u0444\u0442\u0430 \u0448\u0443\u0434`;
|
|
11843
|
+
}
|
|
11844
|
+
case "invalid_value":
|
|
11845
|
+
if (issue2.values.length === 1)
|
|
11846
|
+
return `\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${stringifyPrimitive(issue2.values[0])} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`;
|
|
11847
|
+
return `\u0418\u043D\u0442\u0438\u0445\u043E\u0431\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u044F\u043A\u0435 \u0430\u0437 ${joinValues(issue2.values, "|")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`;
|
|
11848
|
+
case "too_big": {
|
|
11849
|
+
const adj = issue2.inclusive ? "<=" : "<";
|
|
11850
|
+
const sizing = getSizing(issue2.origin);
|
|
11851
|
+
if (sizing)
|
|
11852
|
+
return `\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${issue2.origin ?? "\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${adj}${issue2.maximum.toString()} ${sizing.unit} ${sizing.verb}`;
|
|
11853
|
+
return `\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${issue2.origin ?? "\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${adj}${issue2.maximum.toString()} \u0431\u043E\u0448\u0430\u0434`;
|
|
11854
|
+
}
|
|
11855
|
+
case "too_small": {
|
|
11856
|
+
const adj = issue2.inclusive ? ">=" : ">";
|
|
11857
|
+
const sizing = getSizing(issue2.origin);
|
|
11858
|
+
if (sizing)
|
|
11859
|
+
return `\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${issue2.origin} \u0431\u043E\u044F\u0434 ${adj}${issue2.minimum.toString()} ${sizing.unit} ${sizing.verb}`;
|
|
11860
|
+
return `\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${issue2.origin} \u0431\u043E\u044F\u0434 ${adj}${issue2.minimum.toString()} \u0431\u043E\u0448\u0430\u0434`;
|
|
11861
|
+
}
|
|
11862
|
+
case "invalid_format": {
|
|
11863
|
+
const _issue = issue2;
|
|
11864
|
+
if (_issue.format === "starts_with")
|
|
11865
|
+
return `\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${_issue.prefix}" \u043E\u0493\u043E\u0437 \u0448\u0430\u0432\u0430\u0434`;
|
|
11866
|
+
if (_issue.format === "ends_with")
|
|
11867
|
+
return `\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${_issue.suffix}" \u0430\u043D\u04B7\u043E\u043C \u0451\u0431\u0430\u0434`;
|
|
11868
|
+
if (_issue.format === "includes")
|
|
11869
|
+
return `\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 "${_issue.includes}"-\u0440\u043E \u0434\u0430\u0440 \u0431\u0430\u0440 \u0433\u0438\u0440\u0430\u0434`;
|
|
11870
|
+
if (_issue.format === "regex")
|
|
11871
|
+
return `\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 \u043D\u0430\u043C\u0443\u043D\u0430\u0438 ${_issue.pattern} \u043C\u0443\u0432\u043E\u0444\u0438\u049B\u0430\u0442 \u043A\u0443\u043D\u0430\u0434`;
|
|
11872
|
+
return `${FormatDictionary[_issue.format] ?? issue2.format}-\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442`;
|
|
11873
|
+
}
|
|
11874
|
+
case "not_multiple_of":
|
|
11875
|
+
return `\u0420\u0430\u049B\u0430\u043C\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 ${issue2.divisor} \u0431\u0435 \u0431\u0430\u049B\u0438\u044F \u0442\u0430\u049B\u0441\u0438\u043C \u0448\u0430\u0432\u0430\u0434`;
|
|
11876
|
+
case "unrecognized_keys":
|
|
11877
|
+
return `\u041A\u0430\u043B\u0438\u0434${issue2.keys.length > 1 ? "\u04B3\u043E\u0438" : "\u0438"} \u043D\u043E\u043C\u0430\u044A\u043B\u0443\u043C: ${joinValues(issue2.keys, ", ")}`;
|
|
11878
|
+
case "invalid_key":
|
|
11879
|
+
return `\u041A\u0430\u043B\u0438\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${issue2.origin}`;
|
|
11880
|
+
case "invalid_union":
|
|
11881
|
+
if (issue2.options && Array.isArray(issue2.options) && issue2.options.length > 0) {
|
|
11882
|
+
const opts = issue2.options.map((o) => `'${o}'`).join(" | ");
|
|
11883
|
+
return `\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442\u0438 \u0434\u0438\u0441\u043A\u0440\u0438\u043C\u0438\u043D\u0430\u0442\u043E\u0440: ${opts} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`;
|
|
11884
|
+
}
|
|
11885
|
+
return "\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442";
|
|
11886
|
+
case "invalid_element":
|
|
11887
|
+
return `\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${issue2.origin}`;
|
|
11888
|
+
default:
|
|
11889
|
+
return `\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442`;
|
|
11890
|
+
}
|
|
11891
|
+
};
|
|
11892
|
+
};
|
|
11893
|
+
function tg_default() {
|
|
11894
|
+
return {
|
|
11895
|
+
localeError: error51()
|
|
11896
|
+
};
|
|
11897
|
+
}
|
|
11898
|
+
|
|
11899
|
+
// ../../node_modules/zod/v4/locales/th.js
|
|
11900
|
+
var error52 = () => {
|
|
11779
11901
|
const Sizable = {
|
|
11780
11902
|
string: { unit: "\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23", verb: "\u0E04\u0E27\u0E23\u0E21\u0E35" },
|
|
11781
11903
|
file: { unit: "\u0E44\u0E1A\u0E15\u0E4C", verb: "\u0E04\u0E27\u0E23\u0E21\u0E35" },
|
|
@@ -11885,12 +12007,12 @@ var error51 = () => {
|
|
|
11885
12007
|
};
|
|
11886
12008
|
function th_default() {
|
|
11887
12009
|
return {
|
|
11888
|
-
localeError:
|
|
12010
|
+
localeError: error52()
|
|
11889
12011
|
};
|
|
11890
12012
|
}
|
|
11891
12013
|
|
|
11892
12014
|
// ../../node_modules/zod/v4/locales/tk.js
|
|
11893
|
-
var
|
|
12015
|
+
var error53 = () => {
|
|
11894
12016
|
const Sizable = {
|
|
11895
12017
|
string: { unit: "simwol", verb: "bolmaly" },
|
|
11896
12018
|
file: { unit: "ba\xFDt", verb: "bolmaly" },
|
|
@@ -11992,12 +12114,12 @@ var error52 = () => {
|
|
|
11992
12114
|
};
|
|
11993
12115
|
function tk_default() {
|
|
11994
12116
|
return {
|
|
11995
|
-
localeError:
|
|
12117
|
+
localeError: error53()
|
|
11996
12118
|
};
|
|
11997
12119
|
}
|
|
11998
12120
|
|
|
11999
12121
|
// ../../node_modules/zod/v4/locales/tr.js
|
|
12000
|
-
var
|
|
12122
|
+
var error54 = () => {
|
|
12001
12123
|
const Sizable = {
|
|
12002
12124
|
string: { unit: "karakter", verb: "olmal\u0131" },
|
|
12003
12125
|
file: { unit: "bayt", verb: "olmal\u0131" },
|
|
@@ -12102,12 +12224,12 @@ var error53 = () => {
|
|
|
12102
12224
|
};
|
|
12103
12225
|
function tr_default() {
|
|
12104
12226
|
return {
|
|
12105
|
-
localeError:
|
|
12227
|
+
localeError: error54()
|
|
12106
12228
|
};
|
|
12107
12229
|
}
|
|
12108
12230
|
|
|
12109
12231
|
// ../../node_modules/zod/v4/locales/uk.js
|
|
12110
|
-
var
|
|
12232
|
+
var error55 = () => {
|
|
12111
12233
|
const Sizable = {
|
|
12112
12234
|
string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432", verb: "\u043C\u0430\u0442\u0438\u043C\u0435" },
|
|
12113
12235
|
file: { unit: "\u0431\u0430\u0439\u0442\u0456\u0432", verb: "\u043C\u0430\u0442\u0438\u043C\u0435" },
|
|
@@ -12215,7 +12337,7 @@ var error54 = () => {
|
|
|
12215
12337
|
};
|
|
12216
12338
|
function uk_default() {
|
|
12217
12339
|
return {
|
|
12218
|
-
localeError:
|
|
12340
|
+
localeError: error55()
|
|
12219
12341
|
};
|
|
12220
12342
|
}
|
|
12221
12343
|
|
|
@@ -12225,7 +12347,7 @@ function ua_default() {
|
|
|
12225
12347
|
}
|
|
12226
12348
|
|
|
12227
12349
|
// ../../node_modules/zod/v4/locales/ur.js
|
|
12228
|
-
var
|
|
12350
|
+
var error56 = () => {
|
|
12229
12351
|
const Sizable = {
|
|
12230
12352
|
string: { unit: "\u062D\u0631\u0648\u0641", verb: "\u06C1\u0648\u0646\u0627" },
|
|
12231
12353
|
file: { unit: "\u0628\u0627\u0626\u0679\u0633", verb: "\u06C1\u0648\u0646\u0627" },
|
|
@@ -12335,12 +12457,12 @@ var error55 = () => {
|
|
|
12335
12457
|
};
|
|
12336
12458
|
function ur_default() {
|
|
12337
12459
|
return {
|
|
12338
|
-
localeError:
|
|
12460
|
+
localeError: error56()
|
|
12339
12461
|
};
|
|
12340
12462
|
}
|
|
12341
12463
|
|
|
12342
12464
|
// ../../node_modules/zod/v4/locales/uz.js
|
|
12343
|
-
var
|
|
12465
|
+
var error57 = () => {
|
|
12344
12466
|
const Sizable = {
|
|
12345
12467
|
string: { unit: "belgi", verb: "bo\u2018lishi kerak" },
|
|
12346
12468
|
file: { unit: "bayt", verb: "bo\u2018lishi kerak" },
|
|
@@ -12448,12 +12570,12 @@ var error56 = () => {
|
|
|
12448
12570
|
};
|
|
12449
12571
|
function uz_default() {
|
|
12450
12572
|
return {
|
|
12451
|
-
localeError:
|
|
12573
|
+
localeError: error57()
|
|
12452
12574
|
};
|
|
12453
12575
|
}
|
|
12454
12576
|
|
|
12455
12577
|
// ../../node_modules/zod/v4/locales/vi.js
|
|
12456
|
-
var
|
|
12578
|
+
var error58 = () => {
|
|
12457
12579
|
const Sizable = {
|
|
12458
12580
|
string: { unit: "k\xFD t\u1EF1", verb: "c\xF3" },
|
|
12459
12581
|
file: { unit: "byte", verb: "c\xF3" },
|
|
@@ -12561,12 +12683,12 @@ var error57 = () => {
|
|
|
12561
12683
|
};
|
|
12562
12684
|
function vi_default() {
|
|
12563
12685
|
return {
|
|
12564
|
-
localeError:
|
|
12686
|
+
localeError: error58()
|
|
12565
12687
|
};
|
|
12566
12688
|
}
|
|
12567
12689
|
|
|
12568
12690
|
// ../../node_modules/zod/v4/locales/zh-CN.js
|
|
12569
|
-
var
|
|
12691
|
+
var error59 = () => {
|
|
12570
12692
|
const Sizable = {
|
|
12571
12693
|
string: { unit: "\u5B57\u7B26", verb: "\u5305\u542B" },
|
|
12572
12694
|
file: { unit: "\u5B57\u8282", verb: "\u5305\u542B" },
|
|
@@ -12675,12 +12797,12 @@ var error58 = () => {
|
|
|
12675
12797
|
};
|
|
12676
12798
|
function zh_CN_default() {
|
|
12677
12799
|
return {
|
|
12678
|
-
localeError:
|
|
12800
|
+
localeError: error59()
|
|
12679
12801
|
};
|
|
12680
12802
|
}
|
|
12681
12803
|
|
|
12682
12804
|
// ../../node_modules/zod/v4/locales/zh-TW.js
|
|
12683
|
-
var
|
|
12805
|
+
var error60 = () => {
|
|
12684
12806
|
const Sizable = {
|
|
12685
12807
|
string: { unit: "\u5B57\u5143", verb: "\u64C1\u6709" },
|
|
12686
12808
|
file: { unit: "\u4F4D\u5143\u7D44", verb: "\u64C1\u6709" },
|
|
@@ -12787,12 +12909,12 @@ var error59 = () => {
|
|
|
12787
12909
|
};
|
|
12788
12910
|
function zh_TW_default() {
|
|
12789
12911
|
return {
|
|
12790
|
-
localeError:
|
|
12912
|
+
localeError: error60()
|
|
12791
12913
|
};
|
|
12792
12914
|
}
|
|
12793
12915
|
|
|
12794
12916
|
// ../../node_modules/zod/v4/locales/yo.js
|
|
12795
|
-
var
|
|
12917
|
+
var error61 = () => {
|
|
12796
12918
|
const Sizable = {
|
|
12797
12919
|
string: { unit: "\xE0mi", verb: "n\xED" },
|
|
12798
12920
|
file: { unit: "bytes", verb: "n\xED" },
|
|
@@ -12899,7 +13021,7 @@ var error60 = () => {
|
|
|
12899
13021
|
};
|
|
12900
13022
|
function yo_default() {
|
|
12901
13023
|
return {
|
|
12902
|
-
localeError:
|
|
13024
|
+
localeError: error61()
|
|
12903
13025
|
};
|
|
12904
13026
|
}
|
|
12905
13027
|
|
|
@@ -13776,7 +13898,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
13776
13898
|
}
|
|
13777
13899
|
}
|
|
13778
13900
|
const outputVar = newVar(ctx);
|
|
13779
|
-
const hasConditionalKeys = allKeys.some((k) =>
|
|
13901
|
+
const hasConditionalKeys = allKeys.some((k) => mayOmitUndefined(propShape[k]) || dropsWhenAbsent(propShape[k]));
|
|
13780
13902
|
if (!buildsValue) {
|
|
13781
13903
|
if (unknownKeysMode === "schema") {
|
|
13782
13904
|
const knownSet = keys.length > 0 ? addConstant(ctx, new Set(keys)) : null;
|
|
@@ -13803,7 +13925,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
13803
13925
|
const out = propOutputs.get(k);
|
|
13804
13926
|
if (dropsWhenAbsent(propShape[k])) {
|
|
13805
13927
|
doc.write(`if (${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
|
|
13806
|
-
} else if (
|
|
13928
|
+
} else if (mayOmitUndefined(propShape[k])) {
|
|
13807
13929
|
doc.write(`if (${out} !== undefined || ${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
|
|
13808
13930
|
} else {
|
|
13809
13931
|
doc.write(`${outputVar}[${kx}] = ${out};`);
|
|
@@ -13936,6 +14058,9 @@ function fastPathAcceptsAbsence(schema) {
|
|
|
13936
14058
|
function dropsWhenAbsent(schema) {
|
|
13937
14059
|
return schema._zod.optin === "optional" && schema._zod.optout === "optional";
|
|
13938
14060
|
}
|
|
14061
|
+
function mayOmitUndefined(schema) {
|
|
14062
|
+
return (schema._zod.optin !== "defaulted" || schema._zod.optout === "optional") && mayOutputUndefined(schema);
|
|
14063
|
+
}
|
|
13939
14064
|
function mayOutputUndefined(schema) {
|
|
13940
14065
|
const def = schema._zod.def;
|
|
13941
14066
|
switch (def.type) {
|
|
@@ -20053,9 +20178,9 @@ function summarizeToolCallResult(toolName, payload) {
|
|
|
20053
20178
|
}
|
|
20054
20179
|
return { outcome, preview: summarizeToolCallPayloadPreview(payload) };
|
|
20055
20180
|
}
|
|
20056
|
-
function classifyToolCallOutcome(toolName, result,
|
|
20057
|
-
if (
|
|
20058
|
-
return { outcome: "error", errorCategory: classifyToolCallError(
|
|
20181
|
+
function classifyToolCallOutcome(toolName, result, error62, errorDetails = {}) {
|
|
20182
|
+
if (error62 !== void 0) {
|
|
20183
|
+
return { outcome: "error", errorCategory: classifyToolCallError(error62, errorDetails) };
|
|
20059
20184
|
}
|
|
20060
20185
|
return { outcome: summarizeToolCallResult(toolName, result).outcome };
|
|
20061
20186
|
}
|
|
@@ -21264,10 +21389,10 @@ function validateIfConditionLiteral({ condition, context, stepId }) {
|
|
|
21264
21389
|
if (!resolved)
|
|
21265
21390
|
continue;
|
|
21266
21391
|
anyResolved = true;
|
|
21267
|
-
const
|
|
21268
|
-
if (!
|
|
21392
|
+
const error62 = ifConditionLiteralError({ reference, literal: literal2, stepId, schema: resolved });
|
|
21393
|
+
if (!error62)
|
|
21269
21394
|
return null;
|
|
21270
|
-
firstError ??=
|
|
21395
|
+
firstError ??= error62;
|
|
21271
21396
|
}
|
|
21272
21397
|
return anyResolved ? firstError : null;
|
|
21273
21398
|
}
|
|
@@ -21328,17 +21453,17 @@ function validateManifestTemplateVariables(data, ctx) {
|
|
|
21328
21453
|
};
|
|
21329
21454
|
if (typeof step.if === "string") {
|
|
21330
21455
|
for (const variable of extractTemplateVariables(step.if)) {
|
|
21331
|
-
const
|
|
21456
|
+
const error62 = validateTemplateVariable({
|
|
21332
21457
|
variable,
|
|
21333
21458
|
context,
|
|
21334
21459
|
stepId: step.id,
|
|
21335
21460
|
currentStepGuard,
|
|
21336
21461
|
sourceType: "condition"
|
|
21337
21462
|
});
|
|
21338
|
-
if (
|
|
21463
|
+
if (error62) {
|
|
21339
21464
|
ctx.addIssue({
|
|
21340
21465
|
code: external_exports.ZodIssueCode.custom,
|
|
21341
|
-
message:
|
|
21466
|
+
message: error62,
|
|
21342
21467
|
path: ["steps", stepIndex, "if"]
|
|
21343
21468
|
});
|
|
21344
21469
|
}
|
|
@@ -21359,21 +21484,21 @@ function validateManifestTemplateVariables(data, ctx) {
|
|
|
21359
21484
|
if ("prompt" in step && typeof step.prompt === "string") {
|
|
21360
21485
|
const variables = extractTemplateVariables(step.prompt);
|
|
21361
21486
|
for (const variable of variables) {
|
|
21362
|
-
const
|
|
21487
|
+
const error62 = validateTemplateVariable({
|
|
21363
21488
|
variable,
|
|
21364
21489
|
context,
|
|
21365
21490
|
stepId: step.id,
|
|
21366
21491
|
currentStepGuard
|
|
21367
21492
|
});
|
|
21368
|
-
if (!
|
|
21493
|
+
if (!error62)
|
|
21369
21494
|
continue;
|
|
21370
21495
|
const parts = variable.split(".");
|
|
21371
|
-
if (parts[0] === "steps" && parts[1] && !context.steps.has(parts[1]) &&
|
|
21496
|
+
if (parts[0] === "steps" && parts[1] && !context.steps.has(parts[1]) && error62.includes("before it is available")) {
|
|
21372
21497
|
unavailableStepRefs.add(parts[1]);
|
|
21373
21498
|
} else {
|
|
21374
21499
|
ctx.addIssue({
|
|
21375
21500
|
code: external_exports.ZodIssueCode.custom,
|
|
21376
|
-
message:
|
|
21501
|
+
message: error62,
|
|
21377
21502
|
path: ["steps", stepIndex, "prompt"]
|
|
21378
21503
|
});
|
|
21379
21504
|
}
|
|
@@ -21392,18 +21517,18 @@ function validateManifestTemplateVariables(data, ctx) {
|
|
|
21392
21517
|
if (typeof value !== "string")
|
|
21393
21518
|
continue;
|
|
21394
21519
|
for (const variable of extractTemplateVariables(value)) {
|
|
21395
|
-
const
|
|
21520
|
+
const error62 = validateTemplateVariable({
|
|
21396
21521
|
variable,
|
|
21397
21522
|
context,
|
|
21398
21523
|
stepId: step.id,
|
|
21399
21524
|
currentStepGuard,
|
|
21400
21525
|
sourceType: fieldName
|
|
21401
21526
|
});
|
|
21402
|
-
if (!
|
|
21527
|
+
if (!error62)
|
|
21403
21528
|
continue;
|
|
21404
21529
|
ctx.addIssue({
|
|
21405
21530
|
code: external_exports.ZodIssueCode.custom,
|
|
21406
|
-
message:
|
|
21531
|
+
message: error62,
|
|
21407
21532
|
path: ["steps", stepIndex, fieldName]
|
|
21408
21533
|
});
|
|
21409
21534
|
}
|
|
@@ -22759,6 +22884,7 @@ var UsageBillingEntrySchema = external_exports.object({
|
|
|
22759
22884
|
var USAGE_BILLING_ENTRY_TYPES = [
|
|
22760
22885
|
"usage_settled",
|
|
22761
22886
|
"top_up",
|
|
22887
|
+
"adjustment",
|
|
22762
22888
|
"void",
|
|
22763
22889
|
"expiry",
|
|
22764
22890
|
"chargeback"
|
|
@@ -23369,10 +23495,10 @@ async function request(args) {
|
|
|
23369
23495
|
let response;
|
|
23370
23496
|
try {
|
|
23371
23497
|
response = await fetch(url2, init);
|
|
23372
|
-
} catch (
|
|
23498
|
+
} catch (error62) {
|
|
23373
23499
|
if (signal?.aborted)
|
|
23374
|
-
throw
|
|
23375
|
-
throw new AutomationsNetworkError("Request failed before a response was received",
|
|
23500
|
+
throw error62;
|
|
23501
|
+
throw new AutomationsNetworkError("Request failed before a response was received", error62);
|
|
23376
23502
|
}
|
|
23377
23503
|
const data = await readResponseBody(response);
|
|
23378
23504
|
if (!response.ok) {
|
|
@@ -24092,11 +24218,11 @@ var connectionsEndpoints = {
|
|
|
24092
24218
|
};
|
|
24093
24219
|
|
|
24094
24220
|
// ../../packages/sdk/dist/esm/clients/connections/connections-client.js
|
|
24095
|
-
function getConnectionInUseError(
|
|
24096
|
-
if (!(
|
|
24221
|
+
function getConnectionInUseError(error62) {
|
|
24222
|
+
if (!(error62 instanceof AutomationsRequestError) || error62.httpStatusCode !== 409) {
|
|
24097
24223
|
return null;
|
|
24098
24224
|
}
|
|
24099
|
-
const parsed = ConnectionInUseConflictSchema.safeParse(
|
|
24225
|
+
const parsed = ConnectionInUseConflictSchema.safeParse(error62.responseData);
|
|
24100
24226
|
return parsed.success ? parsed.data : null;
|
|
24101
24227
|
}
|
|
24102
24228
|
var connectionTokenResponseSchema = external_exports.object({
|
|
@@ -24689,6 +24815,145 @@ var AutomationsApi = class {
|
|
|
24689
24815
|
}
|
|
24690
24816
|
};
|
|
24691
24817
|
|
|
24818
|
+
// ../../packages/sdk/dist/esm/summaries/automation-summary.js
|
|
24819
|
+
function summarizeAutomation(automation) {
|
|
24820
|
+
return {
|
|
24821
|
+
...automation,
|
|
24822
|
+
connections: automation.connections.map((connection) => ({
|
|
24823
|
+
id: connection.id,
|
|
24824
|
+
name: connection.name,
|
|
24825
|
+
connectorId: connection.connectorId,
|
|
24826
|
+
capabilities: connection.capabilities,
|
|
24827
|
+
status: connection.status,
|
|
24828
|
+
createdAt: connection.createdAt
|
|
24829
|
+
}))
|
|
24830
|
+
};
|
|
24831
|
+
}
|
|
24832
|
+
function summarizeAutomationPage(page) {
|
|
24833
|
+
return { ...page, data: page.data.map(summarizeAutomation) };
|
|
24834
|
+
}
|
|
24835
|
+
|
|
24836
|
+
// ../../packages/sdk/dist/esm/summaries/run-summary.js
|
|
24837
|
+
function summarizeRun(run) {
|
|
24838
|
+
return {
|
|
24839
|
+
id: run.id,
|
|
24840
|
+
automationId: run.automationId,
|
|
24841
|
+
status: run.status,
|
|
24842
|
+
createdAt: run.createdAt,
|
|
24843
|
+
updatedAt: run.updatedAt,
|
|
24844
|
+
failureCategory: getRunOutcomeCategory(run),
|
|
24845
|
+
failureReason: getRunOutcomeReason(run),
|
|
24846
|
+
result: run.result,
|
|
24847
|
+
temporalUrl: run.temporalUrl,
|
|
24848
|
+
steps: run.steps.map((step) => ({
|
|
24849
|
+
stepId: step.stepId,
|
|
24850
|
+
type: step.type,
|
|
24851
|
+
description: step.description,
|
|
24852
|
+
status: step.status,
|
|
24853
|
+
startedAt: step.startedAt,
|
|
24854
|
+
completedAt: step.completedAt,
|
|
24855
|
+
error: step.error,
|
|
24856
|
+
toolCalls: step.toolCalls?.map((toolCall) => ({
|
|
24857
|
+
id: toolCall.id,
|
|
24858
|
+
name: toolCall.name,
|
|
24859
|
+
argumentKeys: toolCall.argumentKeys,
|
|
24860
|
+
hasResult: toolCall.hasResult,
|
|
24861
|
+
hasError: toolCall.hasError,
|
|
24862
|
+
resultPreview: toolCall.resultPreview,
|
|
24863
|
+
errorPreview: toolCall.errorPreview,
|
|
24864
|
+
timestamp: toolCall.timestamp
|
|
24865
|
+
}))
|
|
24866
|
+
}))
|
|
24867
|
+
};
|
|
24868
|
+
}
|
|
24869
|
+
|
|
24870
|
+
// ../../packages/sdk/dist/esm/connectors/connector-catalog.js
|
|
24871
|
+
var ConnectorNotFoundError = class extends Error {
|
|
24872
|
+
connectorId;
|
|
24873
|
+
constructor(connectorId) {
|
|
24874
|
+
super(`Connector ${connectorId} was not found.`);
|
|
24875
|
+
this.name = "ConnectorNotFoundError";
|
|
24876
|
+
this.connectorId = connectorId;
|
|
24877
|
+
}
|
|
24878
|
+
};
|
|
24879
|
+
async function* iterateConnectorPages(api, query, options) {
|
|
24880
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
24881
|
+
let cursor;
|
|
24882
|
+
while (true) {
|
|
24883
|
+
const page = await api.connectors.list({ query, cursor, limit: MAX_PAGINATION_LIMIT }, options);
|
|
24884
|
+
if (page.nextCursor && seenCursors.has(page.nextCursor)) {
|
|
24885
|
+
throw new Error("The API returned a repeated pagination cursor.");
|
|
24886
|
+
}
|
|
24887
|
+
yield page;
|
|
24888
|
+
if (!page.nextCursor)
|
|
24889
|
+
return;
|
|
24890
|
+
seenCursors.add(page.nextCursor);
|
|
24891
|
+
cursor = page.nextCursor;
|
|
24892
|
+
}
|
|
24893
|
+
}
|
|
24894
|
+
async function findConnector(api, connectorId, options) {
|
|
24895
|
+
for await (const page of iterateConnectorPages(api, void 0, options)) {
|
|
24896
|
+
const connector = page.data.find((item) => item.id === connectorId);
|
|
24897
|
+
if (connector)
|
|
24898
|
+
return connector;
|
|
24899
|
+
}
|
|
24900
|
+
throw new ConnectorNotFoundError(connectorId);
|
|
24901
|
+
}
|
|
24902
|
+
async function listConnectors(api, options, requestOptions) {
|
|
24903
|
+
const [connectors, connectionResponse] = await Promise.all([
|
|
24904
|
+
collectConnectorPages(api, options.query, requestOptions),
|
|
24905
|
+
options.connections ? api.connections.list({}, requestOptions) : void 0
|
|
24906
|
+
]);
|
|
24907
|
+
const connectionsByConnector = groupConnectionsByConnector(connectionResponse?.connections ?? []);
|
|
24908
|
+
const data = connectors.filter((connector) => connectorSupportsCapability(connector, options.capability)).map((connector) => options.connections ? enrichConnector(connector, connectionsByConnector.get(connector.id) ?? []) : connector).filter((connector) => matchesConnectionFilters(connector, options));
|
|
24909
|
+
return { connectionsIncluded: options.connections, data };
|
|
24910
|
+
}
|
|
24911
|
+
function getConnectorCapabilities(connector) {
|
|
24912
|
+
return [
|
|
24913
|
+
...connector.capabilities.mcp ? ["mcp"] : [],
|
|
24914
|
+
...connector.capabilities.triggers ? ["trigger"] : []
|
|
24915
|
+
];
|
|
24916
|
+
}
|
|
24917
|
+
function connectorSupportsCapability(connector, capability) {
|
|
24918
|
+
return !capability || getConnectorCapabilities(connector).includes(capability);
|
|
24919
|
+
}
|
|
24920
|
+
function enrichConnector(connector, connections) {
|
|
24921
|
+
return { ...connector, connections: connections.map(summarizeConnectorConnection) };
|
|
24922
|
+
}
|
|
24923
|
+
function groupConnectionsByConnector(connections) {
|
|
24924
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
24925
|
+
for (const connection of connections) {
|
|
24926
|
+
const group = grouped.get(connection.connectorId) ?? [];
|
|
24927
|
+
group.push(connection);
|
|
24928
|
+
grouped.set(connection.connectorId, group);
|
|
24929
|
+
}
|
|
24930
|
+
return grouped;
|
|
24931
|
+
}
|
|
24932
|
+
function matchesConnectionFilters(connector, options) {
|
|
24933
|
+
if (!connector.connections)
|
|
24934
|
+
return true;
|
|
24935
|
+
if (options.withoutConnections)
|
|
24936
|
+
return connector.connections.length === 0;
|
|
24937
|
+
if (!options.connectionStatus)
|
|
24938
|
+
return true;
|
|
24939
|
+
return connector.connections.some((connection) => connection.status === options.connectionStatus && (!options.capability || connection.capabilities.some((item) => item.capability === options.capability)));
|
|
24940
|
+
}
|
|
24941
|
+
async function collectConnectorPages(api, query, options) {
|
|
24942
|
+
const connectors = [];
|
|
24943
|
+
for await (const page of iterateConnectorPages(api, query, options)) {
|
|
24944
|
+
connectors.push(...page.data);
|
|
24945
|
+
}
|
|
24946
|
+
return connectors;
|
|
24947
|
+
}
|
|
24948
|
+
function summarizeConnectorConnection(connection) {
|
|
24949
|
+
return {
|
|
24950
|
+
id: connection.id,
|
|
24951
|
+
status: connection.status,
|
|
24952
|
+
capabilities: connection.capabilities,
|
|
24953
|
+
createdAt: connection.createdAt
|
|
24954
|
+
};
|
|
24955
|
+
}
|
|
24956
|
+
|
|
24692
24957
|
// src/lib/auth-environment.ts
|
|
24693
24958
|
import { InvalidArgumentError } from "commander";
|
|
24694
24959
|
var ENVIRONMENTS = {
|
|
@@ -25038,9 +25303,9 @@ async function fetchTodoistUser(token, todoistApiUrl) {
|
|
|
25038
25303
|
response = await fetch(url2, {
|
|
25039
25304
|
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" }
|
|
25040
25305
|
});
|
|
25041
|
-
} catch (
|
|
25306
|
+
} catch (error62) {
|
|
25042
25307
|
throw new Error(
|
|
25043
|
-
`Could not reach Todoist to identify the account: ${getErrorMessage(
|
|
25308
|
+
`Could not reach Todoist to identify the account: ${getErrorMessage(error62)}`
|
|
25044
25309
|
);
|
|
25045
25310
|
}
|
|
25046
25311
|
if (!response.ok) {
|
|
@@ -25051,9 +25316,9 @@ async function fetchTodoistUser(token, todoistApiUrl) {
|
|
|
25051
25316
|
let user;
|
|
25052
25317
|
try {
|
|
25053
25318
|
user = await response.json();
|
|
25054
|
-
} catch (
|
|
25319
|
+
} catch (error62) {
|
|
25055
25320
|
throw new Error(
|
|
25056
|
-
`Todoist returned an unreadable identity response: ${getErrorMessage(
|
|
25321
|
+
`Todoist returned an unreadable identity response: ${getErrorMessage(error62)}`
|
|
25057
25322
|
);
|
|
25058
25323
|
}
|
|
25059
25324
|
return { id: requireUserId(user.id), email: typeof user.email === "string" ? user.email : "" };
|
|
@@ -25066,16 +25331,16 @@ function requireUserId(id) {
|
|
|
25066
25331
|
|
|
25067
25332
|
// src/lib/errors.ts
|
|
25068
25333
|
import { getErrorMessage as getErrorMessage2 } from "@doist/cli-core";
|
|
25069
|
-
function getErrorCode(
|
|
25070
|
-
return typeof
|
|
25334
|
+
function getErrorCode(error62) {
|
|
25335
|
+
return typeof error62 === "object" && error62 !== null && "code" in error62 ? String(error62.code) : void 0;
|
|
25071
25336
|
}
|
|
25072
|
-
function formatError2(
|
|
25073
|
-
const hints = errorHints(
|
|
25074
|
-
return [getErrorMessage2(
|
|
25337
|
+
function formatError2(error62) {
|
|
25338
|
+
const hints = errorHints(error62);
|
|
25339
|
+
return [getErrorMessage2(error62), ...hints.map((hint) => ` - ${hint}`)].join("\n");
|
|
25075
25340
|
}
|
|
25076
|
-
function errorHints(
|
|
25077
|
-
if (typeof
|
|
25078
|
-
const hints =
|
|
25341
|
+
function errorHints(error62) {
|
|
25342
|
+
if (typeof error62 !== "object" || error62 === null || !("hints" in error62)) return [];
|
|
25343
|
+
const hints = error62.hints;
|
|
25079
25344
|
return Array.isArray(hints) ? hints.filter((hint) => typeof hint === "string") : [];
|
|
25080
25345
|
}
|
|
25081
25346
|
|
|
@@ -25106,8 +25371,8 @@ async function resolveCredential(options = {}) {
|
|
|
25106
25371
|
let snapshot;
|
|
25107
25372
|
try {
|
|
25108
25373
|
snapshot = await store2.activeBundle();
|
|
25109
|
-
} catch (
|
|
25110
|
-
return resolveAfterStoreFailure(
|
|
25374
|
+
} catch (error62) {
|
|
25375
|
+
return resolveAfterStoreFailure(error62);
|
|
25111
25376
|
}
|
|
25112
25377
|
if (!snapshot) return fromEnvironment() ?? raiseNotAuthenticated();
|
|
25113
25378
|
const accessToken = await freshAccessToken(store2, snapshot, options.minimumTokenLifetimeMs);
|
|
@@ -25129,12 +25394,12 @@ async function freshAccessToken(store2, snapshot, minimumTokenLifetimeMs) {
|
|
|
25129
25394
|
handshake: { env: getEnvironment().name }
|
|
25130
25395
|
});
|
|
25131
25396
|
return result.bundle.accessToken;
|
|
25132
|
-
} catch (
|
|
25133
|
-
return accessTokenAfterFailedRefresh(
|
|
25397
|
+
} catch (error62) {
|
|
25398
|
+
return accessTokenAfterFailedRefresh(error62, snapshot);
|
|
25134
25399
|
}
|
|
25135
25400
|
}
|
|
25136
|
-
function accessTokenAfterFailedRefresh(
|
|
25137
|
-
switch (getErrorCode(
|
|
25401
|
+
function accessTokenAfterFailedRefresh(error62, snapshot) {
|
|
25402
|
+
switch (getErrorCode(error62)) {
|
|
25138
25403
|
case "AUTH_REFRESH_UNAVAILABLE":
|
|
25139
25404
|
return snapshot.bundle.accessToken;
|
|
25140
25405
|
case "AUTH_REFRESH_EXPIRED":
|
|
@@ -25145,7 +25410,7 @@ function accessTokenAfterFailedRefresh(error61, snapshot) {
|
|
|
25145
25410
|
if (hasTokenLifeLeft(snapshot)) return snapshot.bundle.accessToken;
|
|
25146
25411
|
throw new CredentialError(
|
|
25147
25412
|
"REFRESH_FAILED",
|
|
25148
|
-
`Could not refresh your access token: ${getErrorMessage3(
|
|
25413
|
+
`Could not refresh your access token: ${getErrorMessage3(error62)}`,
|
|
25149
25414
|
["Check your network connection and try again."]
|
|
25150
25415
|
);
|
|
25151
25416
|
}
|
|
@@ -25161,8 +25426,8 @@ function fromEnvironment() {
|
|
|
25161
25426
|
function raiseNotAuthenticated() {
|
|
25162
25427
|
throw new NotAuthenticatedError();
|
|
25163
25428
|
}
|
|
25164
|
-
function resolveAfterStoreFailure(
|
|
25165
|
-
const code = getErrorCode(
|
|
25429
|
+
function resolveAfterStoreFailure(error62) {
|
|
25430
|
+
const code = getErrorCode(error62);
|
|
25166
25431
|
if (code === "NO_ACCOUNT_SELECTED") {
|
|
25167
25432
|
throw new CredentialError(
|
|
25168
25433
|
"ACCOUNT_AMBIGUOUS",
|
|
@@ -25173,25 +25438,25 @@ function resolveAfterStoreFailure(error61) {
|
|
|
25173
25438
|
if (code !== "AUTH_STORE_READ_FAILED") {
|
|
25174
25439
|
throw new CredentialError(
|
|
25175
25440
|
"CREDENTIAL_UNREADABLE",
|
|
25176
|
-
`Could not read the stored credential: ${getErrorMessage3(
|
|
25441
|
+
`Could not read the stored credential: ${getErrorMessage3(error62)}`,
|
|
25177
25442
|
["Run `tda auth logout` and then `tda auth login` to replace it."]
|
|
25178
25443
|
);
|
|
25179
25444
|
}
|
|
25180
25445
|
const fallback = fromEnvironment();
|
|
25181
25446
|
if (fallback) {
|
|
25182
25447
|
process.stderr.write(
|
|
25183
|
-
`Warning: could not read the stored credential (${getErrorMessage3(
|
|
25448
|
+
`Warning: could not read the stored credential (${getErrorMessage3(error62)}). Using ${TOKEN_ENV_VAR}.
|
|
25184
25449
|
`
|
|
25185
25450
|
);
|
|
25186
25451
|
return fallback;
|
|
25187
25452
|
}
|
|
25188
|
-
throw new CredentialError("CREDENTIAL_UNREADABLE", getErrorMessage3(
|
|
25453
|
+
throw new CredentialError("CREDENTIAL_UNREADABLE", getErrorMessage3(error62), [
|
|
25189
25454
|
`Set ${TOKEN_ENV_VAR} to bypass the credential store.`,
|
|
25190
25455
|
"Or re-run `tda auth login --credential-store plaintext`."
|
|
25191
25456
|
]);
|
|
25192
25457
|
}
|
|
25193
|
-
function explainAuthFailure(
|
|
25194
|
-
const status = httpStatus(
|
|
25458
|
+
function explainAuthFailure(error62, source) {
|
|
25459
|
+
const status = httpStatus(error62);
|
|
25195
25460
|
if (status === 401) {
|
|
25196
25461
|
return source === "env" ? new CredentialError("NOT_AUTHENTICATED", `Your ${TOKEN_ENV_VAR} was rejected.`, [
|
|
25197
25462
|
"Check the token is a valid Todoist API token.",
|
|
@@ -25200,14 +25465,14 @@ function explainAuthFailure(error61, source) {
|
|
|
25200
25465
|
"Run `tda auth login` to sign in again."
|
|
25201
25466
|
]);
|
|
25202
25467
|
}
|
|
25203
|
-
if (status === 403 && isInsufficientScopeChallenge(authChallenge(
|
|
25468
|
+
if (status === 403 && isInsufficientScopeChallenge(authChallenge(error62))) {
|
|
25204
25469
|
return new CredentialError(
|
|
25205
25470
|
"INSUFFICIENT_SCOPE",
|
|
25206
25471
|
"Your login does not grant what this command needs.",
|
|
25207
|
-
insufficientScopeFixes(requiredScope(
|
|
25472
|
+
insufficientScopeFixes(requiredScope(error62))
|
|
25208
25473
|
);
|
|
25209
25474
|
}
|
|
25210
|
-
return
|
|
25475
|
+
return error62;
|
|
25211
25476
|
}
|
|
25212
25477
|
function insufficientScopeFixes(scope) {
|
|
25213
25478
|
if (!scope) {
|
|
@@ -25222,23 +25487,23 @@ function insufficientScopeFixes(scope) {
|
|
|
25222
25487
|
flag ? `Run \`tda auth login --additional-scopes ${flag}\` to grant it.` : "Run `tda auth login` to authorize again, without --read-only."
|
|
25223
25488
|
];
|
|
25224
25489
|
}
|
|
25225
|
-
function requiredScope(
|
|
25226
|
-
return readStringProperty(
|
|
25490
|
+
function requiredScope(error62) {
|
|
25491
|
+
return readStringProperty(error62, "requiredScope");
|
|
25227
25492
|
}
|
|
25228
|
-
function authChallenge(
|
|
25229
|
-
return readStringProperty(
|
|
25493
|
+
function authChallenge(error62) {
|
|
25494
|
+
return readStringProperty(error62, "authChallenge");
|
|
25230
25495
|
}
|
|
25231
|
-
function httpStatus(
|
|
25232
|
-
const status = readProperty(
|
|
25496
|
+
function httpStatus(error62) {
|
|
25497
|
+
const status = readProperty(error62, "httpStatusCode");
|
|
25233
25498
|
return typeof status === "number" ? status : void 0;
|
|
25234
25499
|
}
|
|
25235
|
-
function readStringProperty(
|
|
25236
|
-
const value = readProperty(
|
|
25500
|
+
function readStringProperty(error62, key) {
|
|
25501
|
+
const value = readProperty(error62, key);
|
|
25237
25502
|
return typeof value === "string" ? value : void 0;
|
|
25238
25503
|
}
|
|
25239
|
-
function readProperty(
|
|
25240
|
-
if (typeof
|
|
25241
|
-
return
|
|
25504
|
+
function readProperty(error62, key) {
|
|
25505
|
+
if (typeof error62 !== "object" || error62 === null || !(key in error62)) return void 0;
|
|
25506
|
+
return error62[key];
|
|
25242
25507
|
}
|
|
25243
25508
|
|
|
25244
25509
|
// src/lib/api-configuration.ts
|
|
@@ -25891,8 +26156,8 @@ async function revokeToken(token) {
|
|
|
25891
26156
|
signal: AbortSignal.timeout(REVOKE_TIMEOUT_MS)
|
|
25892
26157
|
});
|
|
25893
26158
|
return response.ok ? void 0 : `HTTP ${response.status}`;
|
|
25894
|
-
} catch (
|
|
25895
|
-
return getErrorMessage4(
|
|
26159
|
+
} catch (error62) {
|
|
26160
|
+
return getErrorMessage4(error62);
|
|
25896
26161
|
}
|
|
25897
26162
|
}
|
|
25898
26163
|
|
|
@@ -26057,8 +26322,8 @@ async function writeNdjsonItem(item, stream = process.stdout) {
|
|
|
26057
26322
|
}
|
|
26058
26323
|
|
|
26059
26324
|
// src/lib/command-error.ts
|
|
26060
|
-
function renderFailure(
|
|
26061
|
-
const explained = context.source ? explainAuthFailure(
|
|
26325
|
+
function renderFailure(error62, context = {}) {
|
|
26326
|
+
const explained = context.source ? explainAuthFailure(error62, context.source) : error62;
|
|
26062
26327
|
const code = getErrorCode(explained);
|
|
26063
26328
|
return {
|
|
26064
26329
|
message: getErrorMessage5(explained),
|
|
@@ -26108,7 +26373,7 @@ async function runApiCommand(command, operation, presentation, execution = {}) {
|
|
|
26108
26373
|
);
|
|
26109
26374
|
stopEarlySpinner();
|
|
26110
26375
|
writeResult(mode, result, presentation);
|
|
26111
|
-
} catch (
|
|
26376
|
+
} catch (error62) {
|
|
26112
26377
|
if (abortController.signal.aborted) {
|
|
26113
26378
|
writeFailure(mode, "interrupted", {
|
|
26114
26379
|
message: "Interrupted.",
|
|
@@ -26117,7 +26382,7 @@ async function runApiCommand(command, operation, presentation, execution = {}) {
|
|
|
26117
26382
|
process.exitCode = 130;
|
|
26118
26383
|
return;
|
|
26119
26384
|
}
|
|
26120
|
-
writeFailure(mode, "error", renderFailure(
|
|
26385
|
+
writeFailure(mode, "error", renderFailure(error62, { mode, source }));
|
|
26121
26386
|
process.exitCode = 1;
|
|
26122
26387
|
} finally {
|
|
26123
26388
|
process.removeListener("SIGINT", onInterrupt);
|
|
@@ -26176,22 +26441,6 @@ function formatAutomation(automation) {
|
|
|
26176
26441
|
formatValue(automation.manifest)
|
|
26177
26442
|
].join("\n");
|
|
26178
26443
|
}
|
|
26179
|
-
function summarizeAutomation(automation) {
|
|
26180
|
-
return {
|
|
26181
|
-
...automation,
|
|
26182
|
-
connections: automation.connections.map((connection) => ({
|
|
26183
|
-
id: connection.id,
|
|
26184
|
-
name: connection.name,
|
|
26185
|
-
connectorId: connection.connectorId,
|
|
26186
|
-
capabilities: connection.capabilities,
|
|
26187
|
-
status: connection.status,
|
|
26188
|
-
createdAt: connection.createdAt
|
|
26189
|
-
}))
|
|
26190
|
-
};
|
|
26191
|
-
}
|
|
26192
|
-
function summarizeAutomationPage(page) {
|
|
26193
|
-
return { ...page, data: page.data.map(summarizeAutomation) };
|
|
26194
|
-
}
|
|
26195
26444
|
function formatDraftList(page) {
|
|
26196
26445
|
if (page.data.length === 0) return "No drafts found.";
|
|
26197
26446
|
return withNextCursor(
|
|
@@ -26293,38 +26542,6 @@ function formatRun(run) {
|
|
|
26293
26542
|
}
|
|
26294
26543
|
return lines.join("\n");
|
|
26295
26544
|
}
|
|
26296
|
-
function summarizeRun(run) {
|
|
26297
|
-
return {
|
|
26298
|
-
id: run.id,
|
|
26299
|
-
automationId: run.automationId,
|
|
26300
|
-
status: run.status,
|
|
26301
|
-
createdAt: run.createdAt,
|
|
26302
|
-
updatedAt: run.updatedAt,
|
|
26303
|
-
failureCategory: getRunOutcomeCategory(run),
|
|
26304
|
-
failureReason: getRunOutcomeReason(run),
|
|
26305
|
-
result: run.result,
|
|
26306
|
-
temporalUrl: run.temporalUrl,
|
|
26307
|
-
steps: run.steps.map((step) => ({
|
|
26308
|
-
stepId: step.stepId,
|
|
26309
|
-
type: step.type,
|
|
26310
|
-
description: step.description,
|
|
26311
|
-
status: step.status,
|
|
26312
|
-
startedAt: step.startedAt,
|
|
26313
|
-
completedAt: step.completedAt,
|
|
26314
|
-
error: step.error,
|
|
26315
|
-
toolCalls: step.toolCalls?.map((toolCall) => ({
|
|
26316
|
-
id: toolCall.id,
|
|
26317
|
-
name: toolCall.name,
|
|
26318
|
-
argumentKeys: toolCall.argumentKeys,
|
|
26319
|
-
hasResult: toolCall.hasResult,
|
|
26320
|
-
hasError: toolCall.hasError,
|
|
26321
|
-
resultPreview: toolCall.resultPreview,
|
|
26322
|
-
errorPreview: toolCall.errorPreview,
|
|
26323
|
-
timestamp: toolCall.timestamp
|
|
26324
|
-
}))
|
|
26325
|
-
}))
|
|
26326
|
-
};
|
|
26327
|
-
}
|
|
26328
26545
|
function getResourceName(manifest) {
|
|
26329
26546
|
if (!isRecord2(manifest)) return "(unnamed)";
|
|
26330
26547
|
return typeof manifest.name === "string" && manifest.name.trim() ? manifest.name : "(unnamed)";
|
|
@@ -26558,13 +26775,13 @@ async function runStreamingCommand(command, handlers) {
|
|
|
26558
26775
|
const context = { options, mode, output: output2, signal: abortController.signal };
|
|
26559
26776
|
const result = await handlers.operation(context);
|
|
26560
26777
|
await handlers.onSuccess(result, context);
|
|
26561
|
-
} catch (
|
|
26778
|
+
} catch (error62) {
|
|
26562
26779
|
const state = { mode, output: output2, signal: abortController.signal };
|
|
26563
26780
|
if (abortController.signal.aborted) {
|
|
26564
26781
|
await handlers.onInterrupted(state);
|
|
26565
26782
|
process.exitCode = 130;
|
|
26566
26783
|
} else {
|
|
26567
|
-
await handlers.onError(
|
|
26784
|
+
await handlers.onError(error62, state);
|
|
26568
26785
|
process.exitCode = 1;
|
|
26569
26786
|
}
|
|
26570
26787
|
} finally {
|
|
@@ -26573,10 +26790,79 @@ async function runStreamingCommand(command, handlers) {
|
|
|
26573
26790
|
}
|
|
26574
26791
|
}
|
|
26575
26792
|
|
|
26576
|
-
//
|
|
26577
|
-
|
|
26578
|
-
|
|
26579
|
-
|
|
26793
|
+
// ../../packages/sdk/dist/esm/chat-turn/connection-requirements.js
|
|
26794
|
+
var CONNECTION_LOOKUP_CONCURRENCY = 4;
|
|
26795
|
+
function deduplicateConnectionRequirements(requirements) {
|
|
26796
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26797
|
+
return requirements.filter((requirement) => {
|
|
26798
|
+
const key = JSON.stringify([requirement.connectorId, requirement.connectionType]);
|
|
26799
|
+
if (seen.has(key))
|
|
26800
|
+
return false;
|
|
26801
|
+
seen.add(key);
|
|
26802
|
+
return true;
|
|
26803
|
+
});
|
|
26804
|
+
}
|
|
26805
|
+
async function loadConnectionRequirements(connections, requirements, options) {
|
|
26806
|
+
return mapWithConcurrency(deduplicateConnectionRequirements(requirements), CONNECTION_LOOKUP_CONCURRENCY, async (requirement) => {
|
|
26807
|
+
const response = await connections.list({
|
|
26808
|
+
connectorId: requirement.connectorId,
|
|
26809
|
+
capability: requirement.connectionType,
|
|
26810
|
+
status: "authorized"
|
|
26811
|
+
}, options);
|
|
26812
|
+
return {
|
|
26813
|
+
...requirement,
|
|
26814
|
+
availableConnections: response.connections.map((connection) => ({
|
|
26815
|
+
id: connection.id,
|
|
26816
|
+
label: connection.accountDisplayLabel ?? connection.name ?? connection.id
|
|
26817
|
+
}))
|
|
26818
|
+
};
|
|
26819
|
+
});
|
|
26820
|
+
}
|
|
26821
|
+
async function mapWithConcurrency(items, concurrency, map2) {
|
|
26822
|
+
const results = new Array(items.length);
|
|
26823
|
+
let next = 0;
|
|
26824
|
+
const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
26825
|
+
while (next < items.length) {
|
|
26826
|
+
const index = next;
|
|
26827
|
+
next += 1;
|
|
26828
|
+
results[index] = await map2(items[index]);
|
|
26829
|
+
}
|
|
26830
|
+
});
|
|
26831
|
+
await Promise.all(workers);
|
|
26832
|
+
return results;
|
|
26833
|
+
}
|
|
26834
|
+
|
|
26835
|
+
// ../../packages/sdk/dist/esm/chat-turn/connection-setup.js
|
|
26836
|
+
async function startConnectionSetup(connections, request2, options) {
|
|
26837
|
+
const created = await connections.create({
|
|
26838
|
+
connectorId: request2.connectorId,
|
|
26839
|
+
capability: request2.capability,
|
|
26840
|
+
...request2.automationIds?.length ? { body: { automationIds: [...request2.automationIds] } } : {}
|
|
26841
|
+
}, options);
|
|
26842
|
+
return { connectionId: created.connectionId, setup: created.setup, resumed: false };
|
|
26843
|
+
}
|
|
26844
|
+
function summarizeConnectionSetup(setup) {
|
|
26845
|
+
if (setup?.kind === "oauth") {
|
|
26846
|
+
return { setupKind: "oauth", authorizationUrl: setup.authorizationUrl };
|
|
26847
|
+
}
|
|
26848
|
+
if (setup?.kind === "managed") {
|
|
26849
|
+
return {
|
|
26850
|
+
setupKind: "managed",
|
|
26851
|
+
instructions: setup.instructions,
|
|
26852
|
+
code: setup.code,
|
|
26853
|
+
deepLinkUrl: setup.deepLinkUrl,
|
|
26854
|
+
expiresAt: setup.expiresAt
|
|
26855
|
+
};
|
|
26856
|
+
}
|
|
26857
|
+
return { setupKind: "none" };
|
|
26858
|
+
}
|
|
26859
|
+
function getConnectionSetupUrl(setup) {
|
|
26860
|
+
if (setup?.kind === "oauth")
|
|
26861
|
+
return setup.authorizationUrl;
|
|
26862
|
+
if (setup?.kind === "managed")
|
|
26863
|
+
return setup.deepLinkUrl;
|
|
26864
|
+
return null;
|
|
26865
|
+
}
|
|
26580
26866
|
|
|
26581
26867
|
// ../../packages/core/dist/esm/chat-tools/client-tool-result.js
|
|
26582
26868
|
var clientToolContinuationPartSchema = external_exports.discriminatedUnion("type", [
|
|
@@ -26611,11 +26897,10 @@ var toolUpdateMemoryResultSchema = external_exports.object({
|
|
|
26611
26897
|
output: UpdateMemoryOutputSchema
|
|
26612
26898
|
});
|
|
26613
26899
|
|
|
26614
|
-
//
|
|
26615
|
-
import { randomUUID } from "node:crypto";
|
|
26900
|
+
// ../../packages/sdk/dist/esm/chat-turn/messages.js
|
|
26616
26901
|
function createUserMessage(text) {
|
|
26617
26902
|
return {
|
|
26618
|
-
id: randomUUID(),
|
|
26903
|
+
id: globalThis.crypto.randomUUID(),
|
|
26619
26904
|
role: "user",
|
|
26620
26905
|
parts: [{ type: "text", text }]
|
|
26621
26906
|
};
|
|
@@ -26634,9 +26919,7 @@ function toUiMessage(message) {
|
|
|
26634
26919
|
};
|
|
26635
26920
|
}
|
|
26636
26921
|
function getVisibleText(message) {
|
|
26637
|
-
return message.parts.filter(
|
|
26638
|
-
(part) => part.type === "text"
|
|
26639
|
-
).map((part) => part.text).join("");
|
|
26922
|
+
return message.parts.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
26640
26923
|
}
|
|
26641
26924
|
function getPendingClientAction(message) {
|
|
26642
26925
|
for (let index = message.parts.length - 1; index >= 0; index -= 1) {
|
|
@@ -26661,6 +26944,12 @@ function getPendingClientAction(message) {
|
|
|
26661
26944
|
}
|
|
26662
26945
|
return null;
|
|
26663
26946
|
}
|
|
26947
|
+
function getPendingActionFromMessages(messages) {
|
|
26948
|
+
const latestMessage = messages.at(-1);
|
|
26949
|
+
if (!latestMessage || latestMessage.role !== "assistant")
|
|
26950
|
+
return null;
|
|
26951
|
+
return getPendingClientAction(toUiMessage(latestMessage));
|
|
26952
|
+
}
|
|
26664
26953
|
function getPublishedAutomationId(message) {
|
|
26665
26954
|
for (let index = message.parts.length - 1; index >= 0; index -= 1) {
|
|
26666
26955
|
const part = message.parts[index];
|
|
@@ -26685,7 +26974,181 @@ function createSelectConnectionsContinuation(action, output2) {
|
|
|
26685
26974
|
};
|
|
26686
26975
|
}
|
|
26687
26976
|
|
|
26688
|
-
//
|
|
26977
|
+
// ../../packages/sdk/dist/esm/chat-turn/types.js
|
|
26978
|
+
var ChatTurnInputError = class extends Error {
|
|
26979
|
+
code;
|
|
26980
|
+
constructor(code, message) {
|
|
26981
|
+
super(message);
|
|
26982
|
+
this.name = "ChatTurnInputError";
|
|
26983
|
+
this.code = code;
|
|
26984
|
+
}
|
|
26985
|
+
};
|
|
26986
|
+
|
|
26987
|
+
// ../../packages/sdk/dist/esm/chat-turn/run-conversation-turn.js
|
|
26988
|
+
async function runConversationTurn(options) {
|
|
26989
|
+
const { api, transport, conversationId, signal } = options;
|
|
26990
|
+
const workspaceId = options.workspaceId ?? null;
|
|
26991
|
+
const requestOptions = { signal };
|
|
26992
|
+
const pending = await readPendingAction(options);
|
|
26993
|
+
let nextMessage;
|
|
26994
|
+
if (pending?.kind === "enable_push") {
|
|
26995
|
+
if ("selections" in options.input && options.input.selections.length > 0) {
|
|
26996
|
+
throw new ChatTurnInputError("not_awaiting_selection", "The conversation is not waiting for connection selection.");
|
|
26997
|
+
}
|
|
26998
|
+
return actionRequired(conversationId, getVisibleText(pending.message), {
|
|
26999
|
+
kind: "enable_push",
|
|
27000
|
+
toolCallId: pending.toolCallId,
|
|
27001
|
+
draftId: pending.draftId
|
|
27002
|
+
});
|
|
27003
|
+
}
|
|
27004
|
+
if ("message" in options.input) {
|
|
27005
|
+
if (pending?.kind === "select_connections") {
|
|
27006
|
+
throw new ChatTurnInputError("awaiting_selection", "The conversation is waiting for connection selection.");
|
|
27007
|
+
}
|
|
27008
|
+
nextMessage = createUserMessage(options.input.message);
|
|
27009
|
+
} else {
|
|
27010
|
+
const selections = options.input.selections;
|
|
27011
|
+
if (pending?.kind !== "select_connections") {
|
|
27012
|
+
throw new ChatTurnInputError(selections.length > 0 ? "not_awaiting_selection" : "input_required", selections.length > 0 ? "The conversation is not waiting for connection selection." : "A message is required to continue.");
|
|
27013
|
+
}
|
|
27014
|
+
const resolution = await resolveSelectConnections(options, pending, selections);
|
|
27015
|
+
if (resolution.kind === "required") {
|
|
27016
|
+
return actionRequired(conversationId, getVisibleText(pending.message), resolution.pendingAction);
|
|
27017
|
+
}
|
|
27018
|
+
nextMessage = resolution.continuation;
|
|
27019
|
+
}
|
|
27020
|
+
while (true) {
|
|
27021
|
+
const response = await transport.streamTurn({
|
|
27022
|
+
conversationId,
|
|
27023
|
+
workspaceId,
|
|
27024
|
+
message: nextMessage,
|
|
27025
|
+
signal,
|
|
27026
|
+
onText: options.onText,
|
|
27027
|
+
onToolActivity: options.onToolActivity
|
|
27028
|
+
});
|
|
27029
|
+
const assistantText = getVisibleText(response);
|
|
27030
|
+
const automationId = getPublishedAutomationId(response);
|
|
27031
|
+
if (automationId) {
|
|
27032
|
+
options.onPublished?.(automationId);
|
|
27033
|
+
const archive = await archiveConversation(api, conversationId, requestOptions);
|
|
27034
|
+
return {
|
|
27035
|
+
conversationId,
|
|
27036
|
+
outcome: "published",
|
|
27037
|
+
assistantText,
|
|
27038
|
+
automationId,
|
|
27039
|
+
...archive
|
|
27040
|
+
};
|
|
27041
|
+
}
|
|
27042
|
+
const responseAction = getPendingClientAction(response);
|
|
27043
|
+
if (responseAction?.kind === "select_connections") {
|
|
27044
|
+
const resolution = await resolveSelectConnections(options, responseAction, []);
|
|
27045
|
+
if (resolution.kind === "resolved") {
|
|
27046
|
+
nextMessage = resolution.continuation;
|
|
27047
|
+
continue;
|
|
27048
|
+
}
|
|
27049
|
+
return actionRequired(conversationId, assistantText, resolution.pendingAction);
|
|
27050
|
+
}
|
|
27051
|
+
if (responseAction?.kind === "enable_push") {
|
|
27052
|
+
return actionRequired(conversationId, assistantText, {
|
|
27053
|
+
kind: "enable_push",
|
|
27054
|
+
toolCallId: responseAction.toolCallId,
|
|
27055
|
+
draftId: responseAction.draftId
|
|
27056
|
+
});
|
|
27057
|
+
}
|
|
27058
|
+
return { conversationId, outcome: "awaiting_input", assistantText };
|
|
27059
|
+
}
|
|
27060
|
+
}
|
|
27061
|
+
async function readPendingAction(options) {
|
|
27062
|
+
if (options.pendingAction !== void 0)
|
|
27063
|
+
return options.pendingAction;
|
|
27064
|
+
const messages = await options.api.chat.getMessages(options.conversationId, {
|
|
27065
|
+
signal: options.signal
|
|
27066
|
+
});
|
|
27067
|
+
return getPendingActionFromMessages(messages);
|
|
27068
|
+
}
|
|
27069
|
+
function actionRequired(conversationId, assistantText, pendingAction) {
|
|
27070
|
+
return { conversationId, outcome: "action_required", assistantText, pendingAction };
|
|
27071
|
+
}
|
|
27072
|
+
async function archiveConversation(api, conversationId, requestOptions) {
|
|
27073
|
+
try {
|
|
27074
|
+
const conversation = await api.chat.updateConversation(conversationId, { isArchived: true }, requestOptions);
|
|
27075
|
+
if (!conversation.isArchived) {
|
|
27076
|
+
throw new Error("The Automations API returned an active conversation.");
|
|
27077
|
+
}
|
|
27078
|
+
return { conversationArchived: true };
|
|
27079
|
+
} catch (error62) {
|
|
27080
|
+
return {
|
|
27081
|
+
conversationArchived: false,
|
|
27082
|
+
conversationArchiveError: error62 instanceof Error ? error62.message : String(error62)
|
|
27083
|
+
};
|
|
27084
|
+
}
|
|
27085
|
+
}
|
|
27086
|
+
async function resolveSelectConnections(options, action, selections) {
|
|
27087
|
+
const { api, signal } = options;
|
|
27088
|
+
const requestOptions = { signal };
|
|
27089
|
+
const requirements = await loadConnectionRequirements(api.connections, action.connections, requestOptions);
|
|
27090
|
+
assertSelectionsUnambiguous(requirements, selections);
|
|
27091
|
+
const resolved = [];
|
|
27092
|
+
for (const requirement of requirements) {
|
|
27093
|
+
const explicit = selections.find((selection) => selection.connectorId === requirement.connectorId && (!selection.connectionType || selection.connectionType === requirement.connectionType));
|
|
27094
|
+
let connectionId = explicit?.connectionId;
|
|
27095
|
+
let setup;
|
|
27096
|
+
if (connectionId) {
|
|
27097
|
+
const exists = requirement.availableConnections.some((connection) => connection.id === connectionId);
|
|
27098
|
+
if (!exists) {
|
|
27099
|
+
throw new ChatTurnInputError("unknown_connection", `Connection ${connectionId} is not an authorized ${requirement.serviceName} connection.`);
|
|
27100
|
+
}
|
|
27101
|
+
} else if (requirement.availableConnections.length === 1) {
|
|
27102
|
+
connectionId = requirement.availableConnections[0]?.id;
|
|
27103
|
+
} else if (requirement.availableConnections.length > 1) {
|
|
27104
|
+
connectionId = await options.chooseConnection?.(requirement);
|
|
27105
|
+
} else if (options.authorizeConnection) {
|
|
27106
|
+
connectionId = await options.authorizeConnection(requirement);
|
|
27107
|
+
} else {
|
|
27108
|
+
setup = await startConnectionSetup(api.connections, { connectorId: requirement.connectorId, capability: requirement.connectionType }, requestOptions);
|
|
27109
|
+
}
|
|
27110
|
+
if (!connectionId) {
|
|
27111
|
+
return {
|
|
27112
|
+
kind: "required",
|
|
27113
|
+
pendingAction: {
|
|
27114
|
+
kind: "select_connections",
|
|
27115
|
+
toolCallId: action.toolCallId,
|
|
27116
|
+
draftId: action.draftId,
|
|
27117
|
+
requirements: requirements.map((item) => item === requirement && setup ? { ...item, setup } : item)
|
|
27118
|
+
}
|
|
27119
|
+
};
|
|
27120
|
+
}
|
|
27121
|
+
resolved.push({ requirement, connectionId });
|
|
27122
|
+
}
|
|
27123
|
+
const output2 = [];
|
|
27124
|
+
for (const item of resolved) {
|
|
27125
|
+
const body = {
|
|
27126
|
+
connectorId: item.requirement.connectorId,
|
|
27127
|
+
connectionType: item.requirement.connectionType,
|
|
27128
|
+
connectionId: item.connectionId
|
|
27129
|
+
};
|
|
27130
|
+
const workspaceId = options.workspaceId ?? null;
|
|
27131
|
+
if (workspaceId === null) {
|
|
27132
|
+
await api.automationDraftConnections.upsert(action.draftId, body, requestOptions);
|
|
27133
|
+
} else {
|
|
27134
|
+
await api.workspaceAutomationDraftConnections.upsert(workspaceId, action.draftId, body, requestOptions);
|
|
27135
|
+
}
|
|
27136
|
+
output2.push({ type: "success", ...body });
|
|
27137
|
+
}
|
|
27138
|
+
return { kind: "resolved", continuation: createSelectConnectionsContinuation(action, output2) };
|
|
27139
|
+
}
|
|
27140
|
+
function assertSelectionsUnambiguous(requirements, selections) {
|
|
27141
|
+
for (const selection of selections) {
|
|
27142
|
+
if (selection.connectionType)
|
|
27143
|
+
continue;
|
|
27144
|
+
const matchingTypes = new Set(requirements.filter((requirement) => requirement.connectorId === selection.connectorId).map((requirement) => requirement.connectionType));
|
|
27145
|
+
if (matchingTypes.size > 1) {
|
|
27146
|
+
throw new ChatTurnInputError("ambiguous_selection", `Connection selection for ${selection.connectorId} is ambiguous. Specify ${selection.connectorId}:mcp or ${selection.connectorId}:trigger.`);
|
|
27147
|
+
}
|
|
27148
|
+
}
|
|
27149
|
+
}
|
|
27150
|
+
|
|
27151
|
+
// ../../packages/sdk/dist/esm/chat-turn/transport.js
|
|
26689
27152
|
import { DefaultChatTransport, readUIMessageStream } from "ai";
|
|
26690
27153
|
var ChatTurnTransport = class {
|
|
26691
27154
|
transport;
|
|
@@ -26712,14 +27175,7 @@ var ChatTurnTransport = class {
|
|
|
26712
27175
|
});
|
|
26713
27176
|
}
|
|
26714
27177
|
/** Streams one server turn, reporting incremental text and deduplicated tool state changes. */
|
|
26715
|
-
async streamTurn({
|
|
26716
|
-
conversationId,
|
|
26717
|
-
workspaceId = null,
|
|
26718
|
-
message,
|
|
26719
|
-
signal,
|
|
26720
|
-
onText,
|
|
26721
|
-
onToolActivity
|
|
26722
|
-
}) {
|
|
27178
|
+
async streamTurn({ conversationId, workspaceId = null, message, signal, onText, onToolActivity }) {
|
|
26723
27179
|
const stream = await this.transport.sendMessages({
|
|
26724
27180
|
trigger: "submit-message",
|
|
26725
27181
|
chatId: conversationId,
|
|
@@ -26739,14 +27195,17 @@ var ChatTurnTransport = class {
|
|
|
26739
27195
|
const visibleText = getVisibleText(currentMessage);
|
|
26740
27196
|
if (visibleText.startsWith(emittedText)) {
|
|
26741
27197
|
const delta = visibleText.slice(emittedText.length);
|
|
26742
|
-
if (delta)
|
|
27198
|
+
if (delta)
|
|
27199
|
+
onText?.(delta);
|
|
26743
27200
|
emittedText = visibleText;
|
|
26744
27201
|
}
|
|
26745
27202
|
for (const part of currentMessage.parts) {
|
|
26746
27203
|
const activity = toToolActivity(part);
|
|
26747
|
-
if (!activity)
|
|
27204
|
+
if (!activity)
|
|
27205
|
+
continue;
|
|
26748
27206
|
const key = `${activity.toolCallId}:${activity.state}`;
|
|
26749
|
-
if (emittedToolStates.has(key))
|
|
27207
|
+
if (emittedToolStates.has(key))
|
|
27208
|
+
continue;
|
|
26750
27209
|
emittedToolStates.add(key);
|
|
26751
27210
|
onToolActivity?.(activity);
|
|
26752
27211
|
}
|
|
@@ -26768,6 +27227,9 @@ function toToolActivity(part) {
|
|
|
26768
27227
|
};
|
|
26769
27228
|
}
|
|
26770
27229
|
|
|
27230
|
+
// src/commands/chat/chat-service.ts
|
|
27231
|
+
import { createInterface } from "node:readline/promises";
|
|
27232
|
+
|
|
26771
27233
|
// src/commands/chat/connection-authorizer.ts
|
|
26772
27234
|
import open2 from "open";
|
|
26773
27235
|
import { setTimeout as wait } from "node:timers/promises";
|
|
@@ -27084,11 +27546,12 @@ var ApiConnectionAuthorizer = class {
|
|
|
27084
27546
|
this.timeoutMs = timeoutMs ?? CONNECTION_AUTHORIZATION_TIMEOUT_MS;
|
|
27085
27547
|
}
|
|
27086
27548
|
async authorize(request2, signal) {
|
|
27087
|
-
const created = await
|
|
27549
|
+
const created = await startConnectionSetup(
|
|
27550
|
+
this.connections,
|
|
27088
27551
|
{
|
|
27089
27552
|
connectorId: request2.connectorId,
|
|
27090
27553
|
capability: request2.connectionType,
|
|
27091
|
-
|
|
27554
|
+
automationIds: request2.automationIds
|
|
27092
27555
|
},
|
|
27093
27556
|
{ signal }
|
|
27094
27557
|
);
|
|
@@ -27115,19 +27578,12 @@ var ApiConnectionAuthorizer = class {
|
|
|
27115
27578
|
connectionType: request2.connectionType,
|
|
27116
27579
|
state: "waiting_for_user",
|
|
27117
27580
|
terminal: false,
|
|
27118
|
-
|
|
27119
|
-
...resumed ? { resumed: true } : {}
|
|
27120
|
-
...setup?.kind === "oauth" ? { authorizationUrl: setup.authorizationUrl } : {},
|
|
27121
|
-
...setup?.kind === "managed" ? {
|
|
27122
|
-
instructions: setup.instructions,
|
|
27123
|
-
code: setup.code,
|
|
27124
|
-
deepLinkUrl: setup.deepLinkUrl,
|
|
27125
|
-
expiresAt: setup.expiresAt
|
|
27126
|
-
} : {}
|
|
27581
|
+
...summarizeConnectionSetup(setup),
|
|
27582
|
+
...resumed ? { resumed: true } : {}
|
|
27127
27583
|
});
|
|
27128
27584
|
}
|
|
27129
27585
|
async openSetup(request2, connectionId, setup, signal) {
|
|
27130
|
-
const url2 = setup
|
|
27586
|
+
const url2 = getConnectionSetupUrl(setup);
|
|
27131
27587
|
if (!url2 || !this.openBrowser || !isSafeSetupUrl(url2)) return;
|
|
27132
27588
|
try {
|
|
27133
27589
|
signal?.throwIfAborted();
|
|
@@ -27142,8 +27598,8 @@ var ApiConnectionAuthorizer = class {
|
|
|
27142
27598
|
state: "waiting_for_user",
|
|
27143
27599
|
terminal: false
|
|
27144
27600
|
});
|
|
27145
|
-
} catch (
|
|
27146
|
-
if (signal?.aborted) throw
|
|
27601
|
+
} catch (error62) {
|
|
27602
|
+
if (signal?.aborted) throw error62;
|
|
27147
27603
|
this.output.emit({
|
|
27148
27604
|
type: "warning",
|
|
27149
27605
|
code: "TDA_BROWSER_OPEN_FAILED",
|
|
@@ -27208,22 +27664,11 @@ function isSafeSetupUrl(value) {
|
|
|
27208
27664
|
}
|
|
27209
27665
|
}
|
|
27210
27666
|
|
|
27211
|
-
// src/commands/chat/connection-requirements.ts
|
|
27212
|
-
function deduplicateConnectionRequirements(requirements) {
|
|
27213
|
-
const seen = /* @__PURE__ */ new Set();
|
|
27214
|
-
return requirements.filter((requirement) => {
|
|
27215
|
-
const key = JSON.stringify([requirement.connectorId, requirement.connectionType]);
|
|
27216
|
-
if (seen.has(key)) return false;
|
|
27217
|
-
seen.add(key);
|
|
27218
|
-
return true;
|
|
27219
|
-
});
|
|
27220
|
-
}
|
|
27221
|
-
|
|
27222
27667
|
// src/commands/chat/conversation-turn-lock.ts
|
|
27223
27668
|
import { link, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
27224
27669
|
import { tmpdir } from "node:os";
|
|
27225
27670
|
import { join } from "node:path";
|
|
27226
|
-
import { randomUUID
|
|
27671
|
+
import { randomUUID } from "node:crypto";
|
|
27227
27672
|
var ConversationTurnLock = class {
|
|
27228
27673
|
directory;
|
|
27229
27674
|
pid;
|
|
@@ -27237,7 +27682,7 @@ var ConversationTurnLock = class {
|
|
|
27237
27682
|
async acquire(conversationId) {
|
|
27238
27683
|
await mkdir(this.directory, { recursive: true, mode: 448 });
|
|
27239
27684
|
const path = join(this.directory, `${encodeURIComponent(conversationId)}.lock`);
|
|
27240
|
-
const ownerId =
|
|
27685
|
+
const ownerId = randomUUID();
|
|
27241
27686
|
const pendingPath = `${path}.${ownerId}.pending`;
|
|
27242
27687
|
await writeFile(
|
|
27243
27688
|
pendingPath,
|
|
@@ -27255,8 +27700,8 @@ var ConversationTurnLock = class {
|
|
|
27255
27700
|
const current2 = await readLock(path);
|
|
27256
27701
|
if (current2?.ownerId === ownerId) await rm(path, { force: true });
|
|
27257
27702
|
};
|
|
27258
|
-
} catch (
|
|
27259
|
-
if (!isFileExistsError(
|
|
27703
|
+
} catch (error62) {
|
|
27704
|
+
if (!isFileExistsError(error62)) throw error62;
|
|
27260
27705
|
}
|
|
27261
27706
|
const current = await readLock(path);
|
|
27262
27707
|
if (current && this.isProcessRunning(current.pid)) {
|
|
@@ -27277,8 +27722,8 @@ async function readLock(path) {
|
|
|
27277
27722
|
if (typeof value === "object" && value !== null && typeof value.ownerId === "string" && typeof value.pid === "number") {
|
|
27278
27723
|
return value;
|
|
27279
27724
|
}
|
|
27280
|
-
} catch (
|
|
27281
|
-
if (!isFileMissingError(
|
|
27725
|
+
} catch (error62) {
|
|
27726
|
+
if (!isFileMissingError(error62) && !(error62 instanceof SyntaxError)) throw error62;
|
|
27282
27727
|
}
|
|
27283
27728
|
return null;
|
|
27284
27729
|
}
|
|
@@ -27291,23 +27736,22 @@ function isProcessRunning(pid) {
|
|
|
27291
27736
|
try {
|
|
27292
27737
|
process.kill(pid, 0);
|
|
27293
27738
|
return true;
|
|
27294
|
-
} catch (
|
|
27295
|
-
return !isNoSuchProcessError(
|
|
27739
|
+
} catch (error62) {
|
|
27740
|
+
return !isNoSuchProcessError(error62);
|
|
27296
27741
|
}
|
|
27297
27742
|
}
|
|
27298
|
-
function isFileExistsError(
|
|
27299
|
-
return getErrorCode(
|
|
27743
|
+
function isFileExistsError(error62) {
|
|
27744
|
+
return getErrorCode(error62) === "EEXIST";
|
|
27300
27745
|
}
|
|
27301
|
-
function isFileMissingError(
|
|
27302
|
-
return getErrorCode(
|
|
27746
|
+
function isFileMissingError(error62) {
|
|
27747
|
+
return getErrorCode(error62) === "ENOENT";
|
|
27303
27748
|
}
|
|
27304
|
-
function isNoSuchProcessError(
|
|
27305
|
-
return getErrorCode(
|
|
27749
|
+
function isNoSuchProcessError(error62) {
|
|
27750
|
+
return getErrorCode(error62) === "ESRCH";
|
|
27306
27751
|
}
|
|
27307
27752
|
|
|
27308
27753
|
// src/commands/chat/chat-service.ts
|
|
27309
27754
|
var TURN_HEARTBEAT_INTERVAL_MS = 15e3;
|
|
27310
|
-
var CONNECTION_LOOKUP_CONCURRENCY = 4;
|
|
27311
27755
|
var TURN_RUNNING_MESSAGE = "Keep monitoring this process; do not invoke continue until turn_completed with terminal=true is emitted and the process exits.";
|
|
27312
27756
|
var ChatService = class {
|
|
27313
27757
|
api;
|
|
@@ -27351,12 +27795,12 @@ var ChatService = class {
|
|
|
27351
27795
|
this.output.emit({ type: "session_started", conversationId: conversation.id });
|
|
27352
27796
|
return this.withActiveTurn(
|
|
27353
27797
|
conversation.id,
|
|
27354
|
-
() => this.
|
|
27355
|
-
conversationId: conversation.id,
|
|
27356
|
-
|
|
27357
|
-
|
|
27358
|
-
|
|
27359
|
-
|
|
27798
|
+
() => this.runUntilTerminal(
|
|
27799
|
+
{ conversationId: conversation.id, workspaceId: conversation.workspaceId },
|
|
27800
|
+
{ message },
|
|
27801
|
+
signal,
|
|
27802
|
+
null
|
|
27803
|
+
)
|
|
27360
27804
|
);
|
|
27361
27805
|
}
|
|
27362
27806
|
/** Resumes a persisted conversation with a message or pending connection selections. */
|
|
@@ -27367,59 +27811,26 @@ var ChatService = class {
|
|
|
27367
27811
|
signal
|
|
27368
27812
|
}) {
|
|
27369
27813
|
const conversation = await this.api.chat.getConversation(conversationId, { signal });
|
|
27370
|
-
const { workspaceId }
|
|
27814
|
+
const scope = { conversationId, workspaceId: conversation.workspaceId };
|
|
27371
27815
|
return this.withActiveTurn(
|
|
27372
27816
|
conversationId,
|
|
27373
27817
|
async () => {
|
|
27374
|
-
let incomingMessage;
|
|
27375
27818
|
const pendingAction = await this.getPersistedPendingAction(conversationId, signal);
|
|
27376
|
-
|
|
27377
|
-
|
|
27378
|
-
|
|
27379
|
-
|
|
27380
|
-
|
|
27381
|
-
}
|
|
27382
|
-
const resolution = await this.resolveSelectConnections(
|
|
27383
|
-
{ conversationId, workspaceId },
|
|
27384
|
-
pendingAction,
|
|
27385
|
-
selections,
|
|
27386
|
-
this.interactive,
|
|
27387
|
-
signal
|
|
27388
|
-
);
|
|
27389
|
-
if (resolution.kind === "required") {
|
|
27390
|
-
return this.completeRequiredConnectionAction(
|
|
27391
|
-
conversationId,
|
|
27392
|
-
getVisibleText(pendingAction.message),
|
|
27393
|
-
resolution.action
|
|
27394
|
-
);
|
|
27395
|
-
}
|
|
27396
|
-
incomingMessage = resolution.continuation;
|
|
27397
|
-
} else if (pendingAction?.kind === "enable_push") {
|
|
27398
|
-
if (selections.length > 0) {
|
|
27399
|
-
throw new Error("The conversation is not waiting for connection selection.");
|
|
27400
|
-
}
|
|
27401
|
-
return this.completeRequiredPushAction(
|
|
27402
|
-
conversationId,
|
|
27403
|
-
getVisibleText(pendingAction.message),
|
|
27404
|
-
pendingAction
|
|
27405
|
-
);
|
|
27406
|
-
} else if (selections.length > 0) {
|
|
27407
|
-
throw new Error("The conversation is not waiting for connection selection.");
|
|
27819
|
+
let input2;
|
|
27820
|
+
if (message) {
|
|
27821
|
+
input2 = { message };
|
|
27822
|
+
} else if (selections.length > 0 || pendingAction) {
|
|
27823
|
+
input2 = { selections };
|
|
27408
27824
|
} else {
|
|
27409
|
-
const nextMessage =
|
|
27825
|
+
const nextMessage = this.interactive ? await this.promptForMessage(signal) : "";
|
|
27410
27826
|
if (!nextMessage) {
|
|
27411
27827
|
throw new Error(
|
|
27412
27828
|
"A message or --connection selection is required to continue."
|
|
27413
27829
|
);
|
|
27414
27830
|
}
|
|
27415
|
-
|
|
27831
|
+
input2 = { message: nextMessage };
|
|
27416
27832
|
}
|
|
27417
|
-
return this.
|
|
27418
|
-
conversationId,
|
|
27419
|
-
workspaceId,
|
|
27420
|
-
incomingMessage,
|
|
27421
|
-
signal
|
|
27422
|
-
});
|
|
27833
|
+
return this.runUntilTerminal(scope, input2, signal, pendingAction);
|
|
27423
27834
|
},
|
|
27424
27835
|
() => this.output.emit({ type: "session_resumed", conversationId })
|
|
27425
27836
|
);
|
|
@@ -27451,13 +27862,12 @@ var ChatService = class {
|
|
|
27451
27862
|
close() {
|
|
27452
27863
|
this.readline?.close();
|
|
27453
27864
|
}
|
|
27454
|
-
|
|
27455
|
-
|
|
27456
|
-
|
|
27457
|
-
|
|
27458
|
-
|
|
27459
|
-
|
|
27460
|
-
let nextIncomingMessage = incomingMessage;
|
|
27865
|
+
/**
|
|
27866
|
+
* Runs server turns until one ends somewhere the CLI has to stop: a pending client action,
|
|
27867
|
+
* a publication, or, outside an interactive terminal, the agent waiting for input.
|
|
27868
|
+
*/
|
|
27869
|
+
async runUntilTerminal(scope, input2, signal, pendingAction) {
|
|
27870
|
+
const { conversationId } = scope;
|
|
27461
27871
|
const startedAt = Date.now();
|
|
27462
27872
|
let lastActivityAt = startedAt;
|
|
27463
27873
|
const markActivity = () => {
|
|
@@ -27477,67 +27887,29 @@ var ChatService = class {
|
|
|
27477
27887
|
}, this.heartbeatIntervalMs);
|
|
27478
27888
|
heartbeat?.unref();
|
|
27479
27889
|
try {
|
|
27890
|
+
let nextInput = input2;
|
|
27891
|
+
let knownPendingAction = pendingAction;
|
|
27480
27892
|
while (true) {
|
|
27481
|
-
const
|
|
27482
|
-
|
|
27483
|
-
workspaceId,
|
|
27484
|
-
message: nextIncomingMessage,
|
|
27485
|
-
signal,
|
|
27486
|
-
onText: (text) => {
|
|
27487
|
-
markActivity();
|
|
27488
|
-
this.output.emit({ type: "assistant_text", conversationId, text });
|
|
27489
|
-
},
|
|
27490
|
-
onToolActivity: (activity) => {
|
|
27491
|
-
markActivity();
|
|
27492
|
-
this.output.emit({ type: "tool_activity", conversationId, ...activity });
|
|
27493
|
-
}
|
|
27893
|
+
const result = await this.runTurn(scope, nextInput, signal, knownPendingAction, {
|
|
27894
|
+
markActivity
|
|
27494
27895
|
});
|
|
27495
|
-
|
|
27496
|
-
|
|
27497
|
-
if (automationId) {
|
|
27498
|
-
this.output.emit({ type: "published", conversationId, automationId });
|
|
27499
|
-
const conversationArchived = await this.archivePublishedConversation(
|
|
27500
|
-
conversationId,
|
|
27501
|
-
signal
|
|
27502
|
-
);
|
|
27896
|
+
if (result.outcome === "published") {
|
|
27897
|
+
this.emitArchiveResult(result);
|
|
27503
27898
|
return this.completeTurn({
|
|
27504
27899
|
conversationId,
|
|
27505
|
-
assistantText,
|
|
27900
|
+
assistantText: result.assistantText,
|
|
27506
27901
|
status: "published",
|
|
27507
|
-
automationId,
|
|
27508
|
-
conversationArchived
|
|
27902
|
+
automationId: result.automationId,
|
|
27903
|
+
conversationArchived: result.conversationArchived
|
|
27509
27904
|
});
|
|
27510
27905
|
}
|
|
27511
|
-
|
|
27512
|
-
|
|
27513
|
-
const resolution = await this.resolveSelectConnections(
|
|
27514
|
-
{ conversationId, workspaceId },
|
|
27515
|
-
pendingAction,
|
|
27516
|
-
[],
|
|
27517
|
-
this.interactive,
|
|
27518
|
-
signal
|
|
27519
|
-
);
|
|
27520
|
-
if (resolution.kind === "resolved") {
|
|
27521
|
-
nextIncomingMessage = resolution.continuation;
|
|
27522
|
-
continue;
|
|
27523
|
-
}
|
|
27524
|
-
return this.completeRequiredConnectionAction(
|
|
27525
|
-
conversationId,
|
|
27526
|
-
assistantText,
|
|
27527
|
-
resolution.action
|
|
27528
|
-
);
|
|
27529
|
-
}
|
|
27530
|
-
if (pendingAction?.kind === "enable_push") {
|
|
27531
|
-
return this.completeRequiredPushAction(
|
|
27532
|
-
conversationId,
|
|
27533
|
-
assistantText,
|
|
27534
|
-
pendingAction
|
|
27535
|
-
);
|
|
27906
|
+
if (result.outcome === "action_required" && result.pendingAction) {
|
|
27907
|
+
return this.completeRequiredAction(result, result.pendingAction);
|
|
27536
27908
|
}
|
|
27537
27909
|
if (!this.interactive) {
|
|
27538
27910
|
return this.completeTurn({
|
|
27539
27911
|
conversationId,
|
|
27540
|
-
assistantText,
|
|
27912
|
+
assistantText: result.assistantText,
|
|
27541
27913
|
status: "awaiting_input"
|
|
27542
27914
|
});
|
|
27543
27915
|
}
|
|
@@ -27545,17 +27917,76 @@ var ChatService = class {
|
|
|
27545
27917
|
if (!userMessage || userMessage === "/exit") {
|
|
27546
27918
|
return this.completeTurn({
|
|
27547
27919
|
conversationId,
|
|
27548
|
-
assistantText,
|
|
27920
|
+
assistantText: result.assistantText,
|
|
27549
27921
|
status: "awaiting_input"
|
|
27550
27922
|
});
|
|
27551
27923
|
}
|
|
27552
27924
|
markActivity();
|
|
27553
|
-
|
|
27925
|
+
nextInput = { message: userMessage };
|
|
27926
|
+
knownPendingAction = null;
|
|
27554
27927
|
}
|
|
27555
27928
|
} finally {
|
|
27556
27929
|
if (heartbeat) clearInterval(heartbeat);
|
|
27557
27930
|
}
|
|
27558
27931
|
}
|
|
27932
|
+
async runTurn({ conversationId, workspaceId }, input2, signal, pendingAction, { markActivity }) {
|
|
27933
|
+
try {
|
|
27934
|
+
return await runConversationTurn({
|
|
27935
|
+
api: this.api,
|
|
27936
|
+
transport: this.transport,
|
|
27937
|
+
conversationId,
|
|
27938
|
+
workspaceId,
|
|
27939
|
+
input: input2,
|
|
27940
|
+
pendingAction,
|
|
27941
|
+
signal,
|
|
27942
|
+
onText: (text) => {
|
|
27943
|
+
markActivity();
|
|
27944
|
+
this.output.emit({ type: "assistant_text", conversationId, text });
|
|
27945
|
+
},
|
|
27946
|
+
onToolActivity: (activity) => {
|
|
27947
|
+
markActivity();
|
|
27948
|
+
this.output.emit({ type: "tool_activity", conversationId, ...activity });
|
|
27949
|
+
},
|
|
27950
|
+
onPublished: (automationId) => {
|
|
27951
|
+
this.output.emit({ type: "published", conversationId, automationId });
|
|
27952
|
+
},
|
|
27953
|
+
chooseConnection: this.interactive ? (requirement) => this.promptForConnection(requirement, signal) : void 0,
|
|
27954
|
+
authorizeConnection: async (requirement) => {
|
|
27955
|
+
if (this.interactive && !await this.confirmConnectionAuthorization(requirement, signal)) {
|
|
27956
|
+
return void 0;
|
|
27957
|
+
}
|
|
27958
|
+
return this.connectionAuthorizer.authorize(
|
|
27959
|
+
{ ...requirement, conversationId },
|
|
27960
|
+
signal
|
|
27961
|
+
);
|
|
27962
|
+
}
|
|
27963
|
+
});
|
|
27964
|
+
} catch (error62) {
|
|
27965
|
+
if (error62 instanceof ChatTurnInputError) {
|
|
27966
|
+
throw new Error(describeInputError(error62));
|
|
27967
|
+
}
|
|
27968
|
+
throw error62;
|
|
27969
|
+
}
|
|
27970
|
+
}
|
|
27971
|
+
emitArchiveResult(result) {
|
|
27972
|
+
if (result.conversationArchived) {
|
|
27973
|
+
this.output.emit({
|
|
27974
|
+
type: "conversation_archived",
|
|
27975
|
+
conversationId: result.conversationId,
|
|
27976
|
+
state: "completed",
|
|
27977
|
+
terminal: false
|
|
27978
|
+
});
|
|
27979
|
+
return;
|
|
27980
|
+
}
|
|
27981
|
+
this.output.emit({
|
|
27982
|
+
type: "warning",
|
|
27983
|
+
code: "TDA_CHAT_ARCHIVE_FAILED",
|
|
27984
|
+
conversationId: result.conversationId,
|
|
27985
|
+
message: `The automation was published, but its chat could not be archived: ${result.conversationArchiveError}`,
|
|
27986
|
+
state: "warning",
|
|
27987
|
+
terminal: false
|
|
27988
|
+
});
|
|
27989
|
+
}
|
|
27559
27990
|
completeTurn(summary) {
|
|
27560
27991
|
const resumeCommand = getResumeCommand(summary);
|
|
27561
27992
|
this.output.emit({
|
|
@@ -27570,66 +28001,23 @@ var ChatService = class {
|
|
|
27570
28001
|
});
|
|
27571
28002
|
return summary;
|
|
27572
28003
|
}
|
|
27573
|
-
|
|
28004
|
+
completeRequiredAction(result, pendingAction) {
|
|
28005
|
+
const { conversationId } = result;
|
|
28006
|
+
const action = toRequiredActionPayload(pendingAction);
|
|
27574
28007
|
this.output.emit({
|
|
27575
28008
|
type: "action_required",
|
|
27576
28009
|
conversationId,
|
|
27577
|
-
action:
|
|
27578
|
-
message: "Select or authorize the required service connections.",
|
|
28010
|
+
action: pendingAction.kind,
|
|
28011
|
+
message: pendingAction.kind === "select_connections" ? "Select or authorize the required service connections." : "Enable Todoist push notifications in a supported Todoist client.",
|
|
27579
28012
|
...action
|
|
27580
28013
|
});
|
|
27581
28014
|
return this.completeTurn({
|
|
27582
28015
|
conversationId,
|
|
27583
|
-
assistantText,
|
|
28016
|
+
assistantText: result.assistantText,
|
|
27584
28017
|
status: "action_required",
|
|
27585
28018
|
action
|
|
27586
28019
|
});
|
|
27587
28020
|
}
|
|
27588
|
-
completeRequiredPushAction(conversationId, assistantText, action) {
|
|
27589
|
-
const actionPayload = toActionPayload(action);
|
|
27590
|
-
this.output.emit({
|
|
27591
|
-
type: "action_required",
|
|
27592
|
-
conversationId,
|
|
27593
|
-
action: action.kind,
|
|
27594
|
-
message: "Enable Todoist push notifications in a supported Todoist client.",
|
|
27595
|
-
...actionPayload
|
|
27596
|
-
});
|
|
27597
|
-
return this.completeTurn({
|
|
27598
|
-
conversationId,
|
|
27599
|
-
assistantText,
|
|
27600
|
-
status: "action_required",
|
|
27601
|
-
action: actionPayload
|
|
27602
|
-
});
|
|
27603
|
-
}
|
|
27604
|
-
async archivePublishedConversation(conversationId, signal) {
|
|
27605
|
-
try {
|
|
27606
|
-
const conversation = await this.api.chat.updateConversation(
|
|
27607
|
-
conversationId,
|
|
27608
|
-
{ isArchived: true },
|
|
27609
|
-
{ signal }
|
|
27610
|
-
);
|
|
27611
|
-
if (!conversation.isArchived) {
|
|
27612
|
-
throw new Error("The Automations API returned an active conversation.");
|
|
27613
|
-
}
|
|
27614
|
-
this.output.emit({
|
|
27615
|
-
type: "conversation_archived",
|
|
27616
|
-
conversationId,
|
|
27617
|
-
state: "completed",
|
|
27618
|
-
terminal: false
|
|
27619
|
-
});
|
|
27620
|
-
return true;
|
|
27621
|
-
} catch (error61) {
|
|
27622
|
-
this.output.emit({
|
|
27623
|
-
type: "warning",
|
|
27624
|
-
code: "TDA_CHAT_ARCHIVE_FAILED",
|
|
27625
|
-
conversationId,
|
|
27626
|
-
message: `The automation was published, but its chat could not be archived: ${getErrorMessage6(error61)}`,
|
|
27627
|
-
state: "warning",
|
|
27628
|
-
terminal: false
|
|
27629
|
-
});
|
|
27630
|
-
return false;
|
|
27631
|
-
}
|
|
27632
|
-
}
|
|
27633
28021
|
async withActiveTurn(conversationId, operation, onAcquired) {
|
|
27634
28022
|
const release = await this.turnLock.acquire(conversationId);
|
|
27635
28023
|
onAcquired?.();
|
|
@@ -27650,108 +28038,6 @@ var ChatService = class {
|
|
|
27650
28038
|
const messages = await this.api.chat.getMessages(conversationId, { signal });
|
|
27651
28039
|
return getPendingActionFromMessages(messages);
|
|
27652
28040
|
}
|
|
27653
|
-
async resolveSelectConnections({ conversationId, workspaceId }, action, selections, allowPrompt, signal) {
|
|
27654
|
-
const uniqueConnections = deduplicateConnectionRequirements(action.connections);
|
|
27655
|
-
const limitConnectionLookup = pLimit(CONNECTION_LOOKUP_CONCURRENCY);
|
|
27656
|
-
const requirements = await Promise.all(
|
|
27657
|
-
uniqueConnections.map(
|
|
27658
|
-
(connection) => limitConnectionLookup(async () => {
|
|
27659
|
-
const response = await this.api.connections.list(
|
|
27660
|
-
{
|
|
27661
|
-
connectorId: connection.connectorId,
|
|
27662
|
-
capability: connection.connectionType,
|
|
27663
|
-
status: "authorized"
|
|
27664
|
-
},
|
|
27665
|
-
{ signal }
|
|
27666
|
-
);
|
|
27667
|
-
return {
|
|
27668
|
-
...connection,
|
|
27669
|
-
availableConnections: response.connections.map((availableConnection) => ({
|
|
27670
|
-
id: availableConnection.id,
|
|
27671
|
-
label: availableConnection.accountDisplayLabel ?? availableConnection.name ?? availableConnection.id
|
|
27672
|
-
}))
|
|
27673
|
-
};
|
|
27674
|
-
})
|
|
27675
|
-
)
|
|
27676
|
-
);
|
|
27677
|
-
for (const selection of selections) {
|
|
27678
|
-
if (selection.connectionType) continue;
|
|
27679
|
-
const matchingTypes = new Set(
|
|
27680
|
-
requirements.filter((requirement) => requirement.connectorId === selection.connectorId).map((requirement) => requirement.connectionType)
|
|
27681
|
-
);
|
|
27682
|
-
if (matchingTypes.size > 1) {
|
|
27683
|
-
throw new Error(
|
|
27684
|
-
`Connection selection for ${selection.connectorId} is ambiguous. Specify ${selection.connectorId}:mcp or ${selection.connectorId}:trigger.`
|
|
27685
|
-
);
|
|
27686
|
-
}
|
|
27687
|
-
}
|
|
27688
|
-
const resolved = [];
|
|
27689
|
-
for (const requirement of requirements) {
|
|
27690
|
-
const explicit = selections.find(
|
|
27691
|
-
(selection) => selection.connectorId === requirement.connectorId && (!selection.connectionType || selection.connectionType === requirement.connectionType)
|
|
27692
|
-
);
|
|
27693
|
-
let connectionId = explicit?.connectionId;
|
|
27694
|
-
if (connectionId) {
|
|
27695
|
-
const exists = requirement.availableConnections.some(
|
|
27696
|
-
(connection) => connection.id === connectionId
|
|
27697
|
-
);
|
|
27698
|
-
if (!exists) {
|
|
27699
|
-
throw new Error(
|
|
27700
|
-
`Connection ${connectionId} is not an authorized ${requirement.serviceName} connection.`
|
|
27701
|
-
);
|
|
27702
|
-
}
|
|
27703
|
-
} else if (requirement.availableConnections.length === 1) {
|
|
27704
|
-
connectionId = requirement.availableConnections[0]?.id;
|
|
27705
|
-
} else if (allowPrompt && requirement.availableConnections.length > 1) {
|
|
27706
|
-
connectionId = await this.promptForConnection(requirement, signal);
|
|
27707
|
-
} else if (requirement.availableConnections.length === 0 && (!this.interactive || await this.confirmConnectionAuthorization(requirement, signal))) {
|
|
27708
|
-
connectionId = await this.connectionAuthorizer.authorize(
|
|
27709
|
-
{ ...requirement, conversationId },
|
|
27710
|
-
signal
|
|
27711
|
-
);
|
|
27712
|
-
}
|
|
27713
|
-
if (!connectionId) {
|
|
27714
|
-
return {
|
|
27715
|
-
kind: "required",
|
|
27716
|
-
action: {
|
|
27717
|
-
toolCallId: action.toolCallId,
|
|
27718
|
-
draftId: action.draftId,
|
|
27719
|
-
requirements,
|
|
27720
|
-
resume: requirements.some((item) => item.availableConnections.length === 0) ? "tda chat continue <conversation-id>" : "tda chat continue <conversation-id> --connection <connector-id>=<connection-id>"
|
|
27721
|
-
}
|
|
27722
|
-
};
|
|
27723
|
-
}
|
|
27724
|
-
resolved.push({ requirement, connectionId });
|
|
27725
|
-
}
|
|
27726
|
-
const output2 = [];
|
|
27727
|
-
for (const item of resolved) {
|
|
27728
|
-
const body = {
|
|
27729
|
-
connectorId: item.requirement.connectorId,
|
|
27730
|
-
connectionType: item.requirement.connectionType,
|
|
27731
|
-
connectionId: item.connectionId
|
|
27732
|
-
};
|
|
27733
|
-
if (workspaceId === null) {
|
|
27734
|
-
await this.api.automationDraftConnections.upsert(action.draftId, body, { signal });
|
|
27735
|
-
} else {
|
|
27736
|
-
await this.api.workspaceAutomationDraftConnections.upsert(
|
|
27737
|
-
workspaceId,
|
|
27738
|
-
action.draftId,
|
|
27739
|
-
body,
|
|
27740
|
-
{ signal }
|
|
27741
|
-
);
|
|
27742
|
-
}
|
|
27743
|
-
output2.push({
|
|
27744
|
-
type: "success",
|
|
27745
|
-
connectionId: item.connectionId,
|
|
27746
|
-
connectorId: item.requirement.connectorId,
|
|
27747
|
-
connectionType: item.requirement.connectionType
|
|
27748
|
-
});
|
|
27749
|
-
}
|
|
27750
|
-
return {
|
|
27751
|
-
kind: "resolved",
|
|
27752
|
-
continuation: createSelectConnectionsContinuation(action, output2)
|
|
27753
|
-
};
|
|
27754
|
-
}
|
|
27755
28041
|
async promptForConnection(requirement, signal) {
|
|
27756
28042
|
const readline = this.getReadline();
|
|
27757
28043
|
process.stdout.write(
|
|
@@ -27786,10 +28072,28 @@ No authorized ${sanitizeTerminalText(requirement.serviceName)} connection exists
|
|
|
27786
28072
|
return this.readline;
|
|
27787
28073
|
}
|
|
27788
28074
|
};
|
|
27789
|
-
function
|
|
27790
|
-
|
|
27791
|
-
|
|
27792
|
-
|
|
28075
|
+
function describeInputError(error62) {
|
|
28076
|
+
switch (error62.code) {
|
|
28077
|
+
case "awaiting_selection":
|
|
28078
|
+
return "Use either a message or --connection selections, not both.";
|
|
28079
|
+
case "not_awaiting_selection":
|
|
28080
|
+
return "The conversation is not waiting for connection selection.";
|
|
28081
|
+
case "input_required":
|
|
28082
|
+
return "A message or --connection selection is required to continue.";
|
|
28083
|
+
default:
|
|
28084
|
+
return error62.message;
|
|
28085
|
+
}
|
|
28086
|
+
}
|
|
28087
|
+
function toRequiredActionPayload(action) {
|
|
28088
|
+
if (action.kind === "enable_push") {
|
|
28089
|
+
return { toolCallId: action.toolCallId, draftId: action.draftId };
|
|
28090
|
+
}
|
|
28091
|
+
return {
|
|
28092
|
+
toolCallId: action.toolCallId,
|
|
28093
|
+
draftId: action.draftId,
|
|
28094
|
+
requirements: action.requirements,
|
|
28095
|
+
resume: action.requirements.some((item) => item.availableConnections.length === 0) ? "tda chat continue <conversation-id>" : "tda chat continue <conversation-id> --connection <connector-id>=<connection-id>"
|
|
28096
|
+
};
|
|
27793
28097
|
}
|
|
27794
28098
|
function toActionPayload(action) {
|
|
27795
28099
|
if (action.kind === "select_connections") {
|
|
@@ -27917,8 +28221,8 @@ async function runCommand(command, operation) {
|
|
|
27917
28221
|
assistantText: ""
|
|
27918
28222
|
});
|
|
27919
28223
|
},
|
|
27920
|
-
onError: (
|
|
27921
|
-
const failure2 = renderFailure(
|
|
28224
|
+
onError: (error62, { mode, output: output2 }) => {
|
|
28225
|
+
const failure2 = renderFailure(error62, { mode, source });
|
|
27922
28226
|
const message = mode === "human" ? failure2.humanMessage : failure2.message;
|
|
27923
28227
|
output2.emit({
|
|
27924
28228
|
type: "error",
|
|
@@ -28049,31 +28353,19 @@ function formatConnectionChange(result) {
|
|
|
28049
28353
|
return `Connection ${result.connectionId} authorized.`;
|
|
28050
28354
|
}
|
|
28051
28355
|
}
|
|
28052
|
-
function getConnectorCapabilities(connector) {
|
|
28053
|
-
return [
|
|
28054
|
-
...connector.capabilities.mcp ? ["mcp"] : [],
|
|
28055
|
-
...connector.capabilities.triggers ? ["trigger"] : []
|
|
28056
|
-
];
|
|
28057
|
-
}
|
|
28058
28356
|
|
|
28059
28357
|
// src/commands/connector/connector-service.ts
|
|
28060
|
-
async function
|
|
28358
|
+
async function listConnectors2(api, options, signal) {
|
|
28061
28359
|
validateListOptions(options);
|
|
28062
|
-
|
|
28063
|
-
listAllConnectors(api, options.query, signal),
|
|
28064
|
-
options.connections ? api.connections.list({}, { signal }) : void 0
|
|
28065
|
-
]);
|
|
28066
|
-
const connectionsByConnector = groupConnections(connectionResponse?.connections ?? []);
|
|
28067
|
-
const data = connectors.filter((connector) => connectorSupportsCapability(connector, options.capability)).map(
|
|
28068
|
-
(connector) => options.connections ? enrichConnector(connector, connectionsByConnector.get(connector.id) ?? []) : connector
|
|
28069
|
-
).filter((connector) => matchesConnectionFilters(connector, options));
|
|
28070
|
-
return { connectionsIncluded: options.connections, data };
|
|
28360
|
+
return listConnectors(api, options, { signal });
|
|
28071
28361
|
}
|
|
28072
28362
|
async function* streamConnectorNdjsonItems(api, options, signal) {
|
|
28073
28363
|
validateListOptions(options);
|
|
28074
28364
|
const connectionResponse = options.connections ? await api.connections.list({}, { signal }) : void 0;
|
|
28075
|
-
const connectionsByConnector =
|
|
28076
|
-
|
|
28365
|
+
const connectionsByConnector = groupConnectionsByConnector(
|
|
28366
|
+
connectionResponse?.connections ?? []
|
|
28367
|
+
);
|
|
28368
|
+
for await (const page of iterateConnectorPages(api, options.query, { signal })) {
|
|
28077
28369
|
for (const connector of page.data) {
|
|
28078
28370
|
if (!connectorSupportsCapability(connector, options.capability)) continue;
|
|
28079
28371
|
const enriched = options.connections ? enrichConnector(connector, connectionsByConnector.get(connector.id) ?? []) : connector;
|
|
@@ -28082,49 +28374,8 @@ async function* streamConnectorNdjsonItems(api, options, signal) {
|
|
|
28082
28374
|
}
|
|
28083
28375
|
yield { _meta: true, connectionsIncluded: options.connections };
|
|
28084
28376
|
}
|
|
28085
|
-
|
|
28086
|
-
|
|
28087
|
-
const connector = page.data.find((item) => item.id === connectorId);
|
|
28088
|
-
if (connector) return connector;
|
|
28089
|
-
}
|
|
28090
|
-
throw new Error(`Connector ${connectorId} was not found.`);
|
|
28091
|
-
}
|
|
28092
|
-
function enrichConnector(connector, connections) {
|
|
28093
|
-
return { ...connector, connections: connections.map(summarizeConnection) };
|
|
28094
|
-
}
|
|
28095
|
-
function connectorSupportsCapability(connector, capability) {
|
|
28096
|
-
if (!capability) return true;
|
|
28097
|
-
return capability === "mcp" ? connector.capabilities.mcp !== void 0 : connector.capabilities.triggers !== void 0;
|
|
28098
|
-
}
|
|
28099
|
-
async function listAllConnectors(api, query, signal) {
|
|
28100
|
-
const { data } = await collectCursorPages(
|
|
28101
|
-
{ all: true },
|
|
28102
|
-
(args) => api.connectors.list({ query, ...args }, { signal })
|
|
28103
|
-
);
|
|
28104
|
-
return data;
|
|
28105
|
-
}
|
|
28106
|
-
function iterateConnectorPages(api, query, signal) {
|
|
28107
|
-
return iterateCursorPages(
|
|
28108
|
-
{ all: true },
|
|
28109
|
-
(args) => api.connectors.list({ query, ...args }, { signal })
|
|
28110
|
-
);
|
|
28111
|
-
}
|
|
28112
|
-
function groupConnections(connections) {
|
|
28113
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
28114
|
-
for (const connection of connections) {
|
|
28115
|
-
const group = grouped.get(connection.connectorId) ?? [];
|
|
28116
|
-
group.push(connection);
|
|
28117
|
-
grouped.set(connection.connectorId, group);
|
|
28118
|
-
}
|
|
28119
|
-
return grouped;
|
|
28120
|
-
}
|
|
28121
|
-
function summarizeConnection(connection) {
|
|
28122
|
-
return {
|
|
28123
|
-
id: connection.id,
|
|
28124
|
-
status: connection.status,
|
|
28125
|
-
capabilities: connection.capabilities,
|
|
28126
|
-
createdAt: connection.createdAt
|
|
28127
|
-
};
|
|
28377
|
+
function findConnector2(api, connectorId, signal) {
|
|
28378
|
+
return findConnector(api, connectorId, { signal });
|
|
28128
28379
|
}
|
|
28129
28380
|
function validateListOptions(options) {
|
|
28130
28381
|
if (!options.connections && (options.connectionStatus || options.withoutConnections)) {
|
|
@@ -28134,14 +28385,6 @@ function validateListOptions(options) {
|
|
|
28134
28385
|
throw new Error("--connection-status cannot be combined with --without-connections.");
|
|
28135
28386
|
}
|
|
28136
28387
|
}
|
|
28137
|
-
function matchesConnectionFilters(connector, options) {
|
|
28138
|
-
if (!connector.connections) return true;
|
|
28139
|
-
if (options.withoutConnections) return connector.connections.length === 0;
|
|
28140
|
-
if (!options.connectionStatus) return true;
|
|
28141
|
-
return connector.connections.some(
|
|
28142
|
-
(connection) => connection.status === options.connectionStatus && (!options.capability || connection.capabilities.some((item) => item.capability === options.capability))
|
|
28143
|
-
);
|
|
28144
|
-
}
|
|
28145
28388
|
|
|
28146
28389
|
// src/commands/connector/authorization-command.ts
|
|
28147
28390
|
async function runAuthorizationCommand(command, operation) {
|
|
@@ -28179,8 +28422,8 @@ async function runAuthorizationCommand(command, operation) {
|
|
|
28179
28422
|
});
|
|
28180
28423
|
output2.finish({ status: "interrupted", message: "Interrupted." });
|
|
28181
28424
|
},
|
|
28182
|
-
onError: (
|
|
28183
|
-
const failure2 = renderFailure(
|
|
28425
|
+
onError: (error62, { mode, output: output2 }) => {
|
|
28426
|
+
const failure2 = renderFailure(error62, { mode, source });
|
|
28184
28427
|
const message = mode === "human" ? failure2.humanMessage : failure2.message;
|
|
28185
28428
|
output2.emit({
|
|
28186
28429
|
type: "error",
|
|
@@ -28223,10 +28466,10 @@ async function disconnectConnection(api, connectionId, { confirmed, force }, sig
|
|
|
28223
28466
|
}
|
|
28224
28467
|
try {
|
|
28225
28468
|
await api.connections.delete(connectionId, { signal, force });
|
|
28226
|
-
} catch (
|
|
28227
|
-
const conflict = getConnectionInUseError(
|
|
28469
|
+
} catch (error62) {
|
|
28470
|
+
const conflict = getConnectionInUseError(error62);
|
|
28228
28471
|
if (!conflict) {
|
|
28229
|
-
throw
|
|
28472
|
+
throw error62;
|
|
28230
28473
|
}
|
|
28231
28474
|
const details = conflict.automations.map((automation) => `${automation.id} (${automation.name})`).join(", ");
|
|
28232
28475
|
throw new Error(
|
|
@@ -28263,7 +28506,7 @@ function registerConnectorMutationCommands(connector) {
|
|
|
28263
28506
|
new Option3("--capability <capability>", "Capability to authorize").choices(["mcp", "trigger"]).makeOptionMandatory()
|
|
28264
28507
|
).action(async (connectorId, options, command) => {
|
|
28265
28508
|
await runAuthorizationCommand(command, async ({ api, authorizer, signal }) => {
|
|
28266
|
-
const selected2 = await
|
|
28509
|
+
const selected2 = await findConnector2(api, connectorId, signal);
|
|
28267
28510
|
assertConnectorSupportsCapability(selected2, options.capability);
|
|
28268
28511
|
if (!selected2.requiresConnection) {
|
|
28269
28512
|
throw new Error(`${selected2.name} does not require a connection.`);
|
|
@@ -28363,7 +28606,7 @@ function registerConnectorReadCommands(connector) {
|
|
|
28363
28606
|
).option("--without-connections", "Only include connectors with no connection records").option("--no-connections", "Do not fetch or include user connections").action(async (options, command) => {
|
|
28364
28607
|
await runApiCommand(
|
|
28365
28608
|
command,
|
|
28366
|
-
({ api, signal }) =>
|
|
28609
|
+
({ api, signal }) => listConnectors2(api, options, signal),
|
|
28367
28610
|
{
|
|
28368
28611
|
human: formatConnectorList
|
|
28369
28612
|
},
|
|
@@ -28378,7 +28621,7 @@ function registerConnectorReadCommands(connector) {
|
|
|
28378
28621
|
command,
|
|
28379
28622
|
async ({ api, signal }) => {
|
|
28380
28623
|
const [selected2, connections] = await Promise.all([
|
|
28381
|
-
|
|
28624
|
+
findConnector2(api, connectorId, signal),
|
|
28382
28625
|
api.connections.list({ connectorId }, { signal })
|
|
28383
28626
|
]);
|
|
28384
28627
|
return enrichConnector(selected2, connections.connections);
|
|
@@ -28551,8 +28794,8 @@ async function runLocalCommand(command, operation, presentation, execution = {})
|
|
|
28551
28794
|
const result = await withSpinner({ text: execution.spinner ?? "Loading..." }, operation);
|
|
28552
28795
|
stopEarlySpinner();
|
|
28553
28796
|
writeResult(mode, result, presentation);
|
|
28554
|
-
} catch (
|
|
28555
|
-
writeFailure(mode, "error", renderFailure(
|
|
28797
|
+
} catch (error62) {
|
|
28798
|
+
writeFailure(mode, "error", renderFailure(error62, { mode }));
|
|
28556
28799
|
process.exitCode = 1;
|
|
28557
28800
|
}
|
|
28558
28801
|
}
|
|
@@ -28669,7 +28912,7 @@ async function updateAllSkills(options, command) {
|
|
|
28669
28912
|
throw new CliError3(
|
|
28670
28913
|
"UPDATE_FAILED",
|
|
28671
28914
|
`Could not update ${result.errors.length} skill file(s).`,
|
|
28672
|
-
{ hints: result.errors.map((
|
|
28915
|
+
{ hints: result.errors.map((error62) => `${error62.agent}: ${error62.message}`) }
|
|
28673
28916
|
);
|
|
28674
28917
|
}
|
|
28675
28918
|
return { action: "updated_all", ...result };
|
|
@@ -28866,9 +29109,9 @@ if (isEntrypoint()) {
|
|
|
28866
29109
|
try {
|
|
28867
29110
|
startEarlySpinner();
|
|
28868
29111
|
await createProgram().parseAsync(process.argv);
|
|
28869
|
-
} catch (
|
|
29112
|
+
} catch (error62) {
|
|
28870
29113
|
stopEarlySpinner();
|
|
28871
|
-
process.stderr.write(`error: ${formatError2(
|
|
29114
|
+
process.stderr.write(`error: ${formatError2(error62)}
|
|
28872
29115
|
`);
|
|
28873
29116
|
process.exitCode = 1;
|
|
28874
29117
|
} finally {
|