@runtypelabs/cli 2.30.1 → 2.31.1
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 +1029 -462
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -72,12 +72,35 @@ var init_credential_store = __esm({
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Replace the entire backing store in one file write. Conf's runtime has a
|
|
77
|
+
* `store` setter (used for exactly this whole-store replacement), but its
|
|
78
|
+
* published typings declare the property read-only, so the assignment needs
|
|
79
|
+
* a cast. Single-write replacement is load-bearing for claim completion:
|
|
80
|
+
* the server has already revoked the previous key, so a multi-write
|
|
81
|
+
* sequence could lose the only copy of the fresh credential.
|
|
82
|
+
*/
|
|
83
|
+
replaceStore(data) {
|
|
84
|
+
;
|
|
85
|
+
this.config.store = data;
|
|
86
|
+
}
|
|
75
87
|
getMachineKey() {
|
|
76
88
|
const hostname4 = os.hostname();
|
|
77
89
|
const username = os.userInfo().username;
|
|
78
90
|
return crypto3.createHash("sha256").update(`runtype-cli-${hostname4}-${username}`).digest("hex").substring(0, 32);
|
|
79
91
|
}
|
|
80
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Store credentials, optionally together with agent-auth claim state in the
|
|
94
|
+
* same write. Passing `claimState` here (rather than a follow-up
|
|
95
|
+
* `saveClaimState` call) keeps the temporary credential and its claim token
|
|
96
|
+
* atomic — a crash between two writes would otherwise orphan a pre-claim
|
|
97
|
+
* key that `auth status` then misreports as a full account.
|
|
98
|
+
*
|
|
99
|
+
* Storing credentials WITHOUT `claimState` invalidates any in-flight claim
|
|
100
|
+
* ceremony: every login path (api-key, browser, claim completion) must not
|
|
101
|
+
* leave stale claim state behind.
|
|
102
|
+
*/
|
|
103
|
+
async saveCredentials(credentials, claimState) {
|
|
81
104
|
const configData = {
|
|
82
105
|
apiKey: this.encrypt(credentials.apiKey),
|
|
83
106
|
userId: credentials.userId,
|
|
@@ -90,7 +113,21 @@ var init_credential_store = __esm({
|
|
|
90
113
|
if (credentials.apiUrl !== void 0) {
|
|
91
114
|
configData.apiUrl = credentials.apiUrl;
|
|
92
115
|
}
|
|
93
|
-
|
|
116
|
+
if (claimState) {
|
|
117
|
+
Object.assign(configData, this.claimStateToConfig(claimState));
|
|
118
|
+
}
|
|
119
|
+
this.replaceStore(configData);
|
|
120
|
+
}
|
|
121
|
+
claimStateToConfig(state) {
|
|
122
|
+
const data = {
|
|
123
|
+
claimToken: this.encrypt(state.claimToken),
|
|
124
|
+
registrationId: state.registrationId
|
|
125
|
+
};
|
|
126
|
+
if (state.claimEmail !== void 0) data.claimEmail = state.claimEmail;
|
|
127
|
+
if (state.credentialExpires !== void 0) data.credentialExpires = state.credentialExpires;
|
|
128
|
+
if (state.claimTokenExpires !== void 0) data.claimTokenExpires = state.claimTokenExpires;
|
|
129
|
+
if (state.apiUrl !== void 0) data.claimApiUrl = state.apiUrl;
|
|
130
|
+
return data;
|
|
94
131
|
}
|
|
95
132
|
async getApiKey() {
|
|
96
133
|
const encrypted = this.config.get("apiKey");
|
|
@@ -109,6 +146,39 @@ var init_credential_store = __esm({
|
|
|
109
146
|
async clearCredentials() {
|
|
110
147
|
this.config.clear();
|
|
111
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Persist agent-auth claim ceremony state alongside the pre-claim credential
|
|
151
|
+
* so `runtype auth claim` / `runtype auth verify` can run as separate
|
|
152
|
+
* invocations (the agent asks the user for their email and OTP in between).
|
|
153
|
+
* The claim token is encrypted like the API key — it can mint the
|
|
154
|
+
* post-claim credential, so it is a secret.
|
|
155
|
+
*/
|
|
156
|
+
async saveClaimState(state) {
|
|
157
|
+
this.config.set(this.claimStateToConfig(state));
|
|
158
|
+
}
|
|
159
|
+
async getClaimState() {
|
|
160
|
+
const claimToken = this.config.get("claimToken");
|
|
161
|
+
const registrationId = this.config.get("registrationId");
|
|
162
|
+
if (!claimToken || !registrationId) return null;
|
|
163
|
+
return {
|
|
164
|
+
claimToken: this.decrypt(claimToken),
|
|
165
|
+
registrationId,
|
|
166
|
+
claimEmail: this.config.get("claimEmail"),
|
|
167
|
+
credentialExpires: this.config.get("credentialExpires"),
|
|
168
|
+
claimTokenExpires: this.config.get("claimTokenExpires"),
|
|
169
|
+
apiUrl: this.config.get("claimApiUrl")
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
async clearClaimState() {
|
|
173
|
+
const store = { ...this.config.store };
|
|
174
|
+
delete store.claimToken;
|
|
175
|
+
delete store.registrationId;
|
|
176
|
+
delete store.claimEmail;
|
|
177
|
+
delete store.credentialExpires;
|
|
178
|
+
delete store.claimTokenExpires;
|
|
179
|
+
delete store.claimApiUrl;
|
|
180
|
+
this.replaceStore(store);
|
|
181
|
+
}
|
|
112
182
|
async hasCredentials() {
|
|
113
183
|
return !!this.config.get("apiKey");
|
|
114
184
|
}
|
|
@@ -159,7 +229,7 @@ function loadEnv(path20 = resolve(process.cwd(), ".env")) {
|
|
|
159
229
|
|
|
160
230
|
// src/commands/auth.ts
|
|
161
231
|
import { Command } from "commander";
|
|
162
|
-
import
|
|
232
|
+
import chalk2 from "chalk";
|
|
163
233
|
import React from "react";
|
|
164
234
|
import { render } from "ink";
|
|
165
235
|
import { useState as useState2, useEffect as useEffect3 } from "react";
|
|
@@ -1168,9 +1238,9 @@ function $constructor(name, initializer3, params) {
|
|
|
1168
1238
|
const proto = _2.prototype;
|
|
1169
1239
|
const keys = Object.keys(proto);
|
|
1170
1240
|
for (let i = 0; i < keys.length; i++) {
|
|
1171
|
-
const
|
|
1172
|
-
if (!(
|
|
1173
|
-
inst[
|
|
1241
|
+
const k = keys[i];
|
|
1242
|
+
if (!(k in inst)) {
|
|
1243
|
+
inst[k] = proto[k].bind(inst);
|
|
1174
1244
|
}
|
|
1175
1245
|
}
|
|
1176
1246
|
}
|
|
@@ -1300,8 +1370,8 @@ function assertNever(_x) {
|
|
|
1300
1370
|
function assert(_2) {
|
|
1301
1371
|
}
|
|
1302
1372
|
function getEnumValues(entries) {
|
|
1303
|
-
const numericValues = Object.values(entries).filter((
|
|
1304
|
-
const values = Object.entries(entries).filter(([
|
|
1373
|
+
const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
|
|
1374
|
+
const values = Object.entries(entries).filter(([k, _2]) => numericValues.indexOf(+k) === -1).map(([_2, v2]) => v2);
|
|
1305
1375
|
return values;
|
|
1306
1376
|
}
|
|
1307
1377
|
function joinValues(array2, separator = "|") {
|
|
@@ -1355,9 +1425,9 @@ function defineLazy(object2, key, getter) {
|
|
|
1355
1425
|
}
|
|
1356
1426
|
return value;
|
|
1357
1427
|
},
|
|
1358
|
-
set(
|
|
1428
|
+
set(v2) {
|
|
1359
1429
|
Object.defineProperty(object2, key, {
|
|
1360
|
-
value:
|
|
1430
|
+
value: v2
|
|
1361
1431
|
// configurable: true,
|
|
1362
1432
|
});
|
|
1363
1433
|
},
|
|
@@ -1429,8 +1499,8 @@ var allowsEval = /* @__PURE__ */ cached(() => {
|
|
|
1429
1499
|
return false;
|
|
1430
1500
|
}
|
|
1431
1501
|
try {
|
|
1432
|
-
const
|
|
1433
|
-
new
|
|
1502
|
+
const F = Function;
|
|
1503
|
+
new F("");
|
|
1434
1504
|
return true;
|
|
1435
1505
|
} catch (_2) {
|
|
1436
1506
|
return false;
|
|
@@ -1591,8 +1661,8 @@ function stringifyPrimitive(value) {
|
|
|
1591
1661
|
return `${value}`;
|
|
1592
1662
|
}
|
|
1593
1663
|
function optionalKeys(shape) {
|
|
1594
|
-
return Object.keys(shape).filter((
|
|
1595
|
-
return shape[
|
|
1664
|
+
return Object.keys(shape).filter((k) => {
|
|
1665
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
1596
1666
|
});
|
|
1597
1667
|
}
|
|
1598
1668
|
var NUMBER_FORMAT_RANGES = {
|
|
@@ -1869,8 +1939,8 @@ function issue(...args) {
|
|
|
1869
1939
|
return { ...iss };
|
|
1870
1940
|
}
|
|
1871
1941
|
function cleanEnum(obj) {
|
|
1872
|
-
return Object.entries(obj).filter(([
|
|
1873
|
-
return Number.isNaN(Number.parseInt(
|
|
1942
|
+
return Object.entries(obj).filter(([k, _2]) => {
|
|
1943
|
+
return Number.isNaN(Number.parseInt(k, 10));
|
|
1874
1944
|
}).map((el) => el[1]);
|
|
1875
1945
|
}
|
|
1876
1946
|
function base64ToUint8Array(base643) {
|
|
@@ -2877,11 +2947,11 @@ var Doc = class {
|
|
|
2877
2947
|
}
|
|
2878
2948
|
}
|
|
2879
2949
|
compile() {
|
|
2880
|
-
const
|
|
2950
|
+
const F = Function;
|
|
2881
2951
|
const args = this?.args;
|
|
2882
2952
|
const content = this?.content ?? [``];
|
|
2883
2953
|
const lines = [...content.map((x2) => ` ${x2}`)];
|
|
2884
|
-
return new
|
|
2954
|
+
return new F(...args, lines.join("\n"));
|
|
2885
2955
|
}
|
|
2886
2956
|
};
|
|
2887
2957
|
|
|
@@ -3044,10 +3114,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
|
3044
3114
|
v7: 7,
|
|
3045
3115
|
v8: 8
|
|
3046
3116
|
};
|
|
3047
|
-
const
|
|
3048
|
-
if (
|
|
3117
|
+
const v2 = versionMap[def.version];
|
|
3118
|
+
if (v2 === void 0)
|
|
3049
3119
|
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
3050
|
-
def.pattern ?? (def.pattern = uuid(
|
|
3120
|
+
def.pattern ?? (def.pattern = uuid(v2));
|
|
3051
3121
|
} else
|
|
3052
3122
|
def.pattern ?? (def.pattern = uuid());
|
|
3053
3123
|
$ZodStringFormat.init(inst, def);
|
|
@@ -3578,9 +3648,9 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
|
|
|
3578
3648
|
}
|
|
3579
3649
|
function normalizeDef(def) {
|
|
3580
3650
|
const keys = Object.keys(def.shape);
|
|
3581
|
-
for (const
|
|
3582
|
-
if (!def.shape?.[
|
|
3583
|
-
throw new Error(`Invalid element at key "${
|
|
3651
|
+
for (const k of keys) {
|
|
3652
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
3653
|
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
3584
3654
|
}
|
|
3585
3655
|
}
|
|
3586
3656
|
const okeys = optionalKeys(def.shape);
|
|
@@ -3652,8 +3722,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3652
3722
|
const field = shape[key]._zod;
|
|
3653
3723
|
if (field.values) {
|
|
3654
3724
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3655
|
-
for (const
|
|
3656
|
-
propValues[key].add(
|
|
3725
|
+
for (const v2 of field.values)
|
|
3726
|
+
propValues[key].add(v2);
|
|
3657
3727
|
}
|
|
3658
3728
|
}
|
|
3659
3729
|
return propValues;
|
|
@@ -3701,8 +3771,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3701
3771
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
3702
3772
|
const normalized = _normalized.value;
|
|
3703
3773
|
const parseStr = (key) => {
|
|
3704
|
-
const
|
|
3705
|
-
return `shape[${
|
|
3774
|
+
const k = esc(key);
|
|
3775
|
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
3706
3776
|
};
|
|
3707
3777
|
doc.write(`const input = payload.value;`);
|
|
3708
3778
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
@@ -3713,7 +3783,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3713
3783
|
doc.write(`const newResult = {};`);
|
|
3714
3784
|
for (const key of normalized.keys) {
|
|
3715
3785
|
const id = ids[key];
|
|
3716
|
-
const
|
|
3786
|
+
const k = esc(key);
|
|
3717
3787
|
const schema = shape[key];
|
|
3718
3788
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
3719
3789
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
@@ -3721,30 +3791,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3721
3791
|
if (isOptionalIn && isOptionalOut) {
|
|
3722
3792
|
doc.write(`
|
|
3723
3793
|
if (${id}.issues.length) {
|
|
3724
|
-
if (${
|
|
3794
|
+
if (${k} in input) {
|
|
3725
3795
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
3726
3796
|
...iss,
|
|
3727
|
-
path: iss.path ? [${
|
|
3797
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3728
3798
|
})));
|
|
3729
3799
|
}
|
|
3730
3800
|
}
|
|
3731
3801
|
|
|
3732
3802
|
if (${id}.value === undefined) {
|
|
3733
|
-
if (${
|
|
3734
|
-
newResult[${
|
|
3803
|
+
if (${k} in input) {
|
|
3804
|
+
newResult[${k}] = undefined;
|
|
3735
3805
|
}
|
|
3736
3806
|
} else {
|
|
3737
|
-
newResult[${
|
|
3807
|
+
newResult[${k}] = ${id}.value;
|
|
3738
3808
|
}
|
|
3739
3809
|
|
|
3740
3810
|
`);
|
|
3741
3811
|
} else if (!isOptionalIn) {
|
|
3742
3812
|
doc.write(`
|
|
3743
|
-
const ${id}_present = ${
|
|
3813
|
+
const ${id}_present = ${k} in input;
|
|
3744
3814
|
if (${id}.issues.length) {
|
|
3745
3815
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
3746
3816
|
...iss,
|
|
3747
|
-
path: iss.path ? [${
|
|
3817
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3748
3818
|
})));
|
|
3749
3819
|
}
|
|
3750
3820
|
if (!${id}_present && !${id}.issues.length) {
|
|
@@ -3752,15 +3822,15 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3752
3822
|
code: "invalid_type",
|
|
3753
3823
|
expected: "nonoptional",
|
|
3754
3824
|
input: undefined,
|
|
3755
|
-
path: [${
|
|
3825
|
+
path: [${k}]
|
|
3756
3826
|
});
|
|
3757
3827
|
}
|
|
3758
3828
|
|
|
3759
3829
|
if (${id}_present) {
|
|
3760
3830
|
if (${id}.value === undefined) {
|
|
3761
|
-
newResult[${
|
|
3831
|
+
newResult[${k}] = undefined;
|
|
3762
3832
|
} else {
|
|
3763
|
-
newResult[${
|
|
3833
|
+
newResult[${k}] = ${id}.value;
|
|
3764
3834
|
}
|
|
3765
3835
|
}
|
|
3766
3836
|
|
|
@@ -3770,16 +3840,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3770
3840
|
if (${id}.issues.length) {
|
|
3771
3841
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
3772
3842
|
...iss,
|
|
3773
|
-
path: iss.path ? [${
|
|
3843
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3774
3844
|
})));
|
|
3775
3845
|
}
|
|
3776
3846
|
|
|
3777
3847
|
if (${id}.value === undefined) {
|
|
3778
|
-
if (${
|
|
3779
|
-
newResult[${
|
|
3848
|
+
if (${k} in input) {
|
|
3849
|
+
newResult[${k}] = undefined;
|
|
3780
3850
|
}
|
|
3781
3851
|
} else {
|
|
3782
|
-
newResult[${
|
|
3852
|
+
newResult[${k}] = ${id}.value;
|
|
3783
3853
|
}
|
|
3784
3854
|
|
|
3785
3855
|
`);
|
|
@@ -3948,11 +4018,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3948
4018
|
const pv = option._zod.propValues;
|
|
3949
4019
|
if (!pv || Object.keys(pv).length === 0)
|
|
3950
4020
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
3951
|
-
for (const [
|
|
3952
|
-
if (!propValues[
|
|
3953
|
-
propValues[
|
|
3954
|
-
for (const val of
|
|
3955
|
-
propValues[
|
|
4021
|
+
for (const [k, v2] of Object.entries(pv)) {
|
|
4022
|
+
if (!propValues[k])
|
|
4023
|
+
propValues[k] = /* @__PURE__ */ new Set();
|
|
4024
|
+
for (const val of v2) {
|
|
4025
|
+
propValues[k].add(val);
|
|
3956
4026
|
}
|
|
3957
4027
|
}
|
|
3958
4028
|
}
|
|
@@ -3965,11 +4035,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3965
4035
|
const values = o._zod.propValues?.[def.discriminator];
|
|
3966
4036
|
if (!values || values.size === 0)
|
|
3967
4037
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
3968
|
-
for (const
|
|
3969
|
-
if (map2.has(
|
|
3970
|
-
throw new Error(`Duplicate discriminator value "${String(
|
|
4038
|
+
for (const v2 of values) {
|
|
4039
|
+
if (map2.has(v2)) {
|
|
4040
|
+
throw new Error(`Duplicate discriminator value "${String(v2)}"`);
|
|
3971
4041
|
}
|
|
3972
|
-
map2.set(
|
|
4042
|
+
map2.set(v2, o);
|
|
3973
4043
|
}
|
|
3974
4044
|
}
|
|
3975
4045
|
return map2;
|
|
@@ -4070,10 +4140,10 @@ function handleIntersectionResults(result, left, right) {
|
|
|
4070
4140
|
for (const iss of left.issues) {
|
|
4071
4141
|
if (iss.code === "unrecognized_keys") {
|
|
4072
4142
|
unrecIssue ?? (unrecIssue = iss);
|
|
4073
|
-
for (const
|
|
4074
|
-
if (!unrecKeys.has(
|
|
4075
|
-
unrecKeys.set(
|
|
4076
|
-
unrecKeys.get(
|
|
4143
|
+
for (const k of iss.keys) {
|
|
4144
|
+
if (!unrecKeys.has(k))
|
|
4145
|
+
unrecKeys.set(k, {});
|
|
4146
|
+
unrecKeys.get(k).l = true;
|
|
4077
4147
|
}
|
|
4078
4148
|
} else {
|
|
4079
4149
|
result.issues.push(iss);
|
|
@@ -4081,16 +4151,16 @@ function handleIntersectionResults(result, left, right) {
|
|
|
4081
4151
|
}
|
|
4082
4152
|
for (const iss of right.issues) {
|
|
4083
4153
|
if (iss.code === "unrecognized_keys") {
|
|
4084
|
-
for (const
|
|
4085
|
-
if (!unrecKeys.has(
|
|
4086
|
-
unrecKeys.set(
|
|
4087
|
-
unrecKeys.get(
|
|
4154
|
+
for (const k of iss.keys) {
|
|
4155
|
+
if (!unrecKeys.has(k))
|
|
4156
|
+
unrecKeys.set(k, {});
|
|
4157
|
+
unrecKeys.get(k).r = true;
|
|
4088
4158
|
}
|
|
4089
4159
|
} else {
|
|
4090
4160
|
result.issues.push(iss);
|
|
4091
4161
|
}
|
|
4092
4162
|
}
|
|
4093
|
-
const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([
|
|
4163
|
+
const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([k]) => k);
|
|
4094
4164
|
if (bothKeys.length && unrecIssue) {
|
|
4095
4165
|
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
4096
4166
|
}
|
|
@@ -4434,7 +4504,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
4434
4504
|
const values = getEnumValues(def.entries);
|
|
4435
4505
|
const valuesSet = new Set(values);
|
|
4436
4506
|
inst._zod.values = valuesSet;
|
|
4437
|
-
inst._zod.pattern = new RegExp(`^(${values.filter((
|
|
4507
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
4438
4508
|
inst._zod.parse = (payload, _ctx) => {
|
|
4439
4509
|
const input = payload.value;
|
|
4440
4510
|
if (valuesSet.has(input)) {
|
|
@@ -4608,8 +4678,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
4608
4678
|
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
4609
4679
|
$ZodType.init(inst, def);
|
|
4610
4680
|
defineLazy(inst._zod, "values", () => {
|
|
4611
|
-
const
|
|
4612
|
-
return
|
|
4681
|
+
const v2 = def.innerType._zod.values;
|
|
4682
|
+
return v2 ? new Set([...v2].filter((x2) => x2 !== void 0)) : void 0;
|
|
4613
4683
|
});
|
|
4614
4684
|
inst._zod.parse = (payload, ctx) => {
|
|
4615
4685
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -4900,9 +4970,9 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
4900
4970
|
return payload;
|
|
4901
4971
|
};
|
|
4902
4972
|
inst.input = (...args) => {
|
|
4903
|
-
const
|
|
4973
|
+
const F = inst.constructor;
|
|
4904
4974
|
if (Array.isArray(args[0])) {
|
|
4905
|
-
return new
|
|
4975
|
+
return new F({
|
|
4906
4976
|
type: "function",
|
|
4907
4977
|
input: new $ZodTuple({
|
|
4908
4978
|
type: "tuple",
|
|
@@ -4912,15 +4982,15 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
4912
4982
|
output: inst._def.output
|
|
4913
4983
|
});
|
|
4914
4984
|
}
|
|
4915
|
-
return new
|
|
4985
|
+
return new F({
|
|
4916
4986
|
type: "function",
|
|
4917
4987
|
input: args[0],
|
|
4918
4988
|
output: inst._def.output
|
|
4919
4989
|
});
|
|
4920
4990
|
};
|
|
4921
4991
|
inst.output = (output) => {
|
|
4922
|
-
const
|
|
4923
|
-
return new
|
|
4992
|
+
const F = inst.constructor;
|
|
4993
|
+
return new F({
|
|
4924
4994
|
type: "function",
|
|
4925
4995
|
input: inst._def.input,
|
|
4926
4996
|
output
|
|
@@ -4937,10 +5007,10 @@ var $ZodPromise = /* @__PURE__ */ $constructor("$ZodPromise", (inst, def) => {
|
|
|
4937
5007
|
var $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
|
|
4938
5008
|
$ZodType.init(inst, def);
|
|
4939
5009
|
defineLazy(inst._zod, "innerType", () => {
|
|
4940
|
-
const
|
|
4941
|
-
if (!
|
|
4942
|
-
|
|
4943
|
-
return
|
|
5010
|
+
const d2 = def;
|
|
5011
|
+
if (!d2._cachedInner)
|
|
5012
|
+
d2._cachedInner = def.getter();
|
|
5013
|
+
return d2._cachedInner;
|
|
4944
5014
|
});
|
|
4945
5015
|
defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
|
4946
5016
|
defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
@@ -7006,7 +7076,7 @@ var error17 = () => {
|
|
|
7006
7076
|
if (issue2.values.length === 1) {
|
|
7007
7077
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${stringifyPrimitive(issue2.values[0])}`;
|
|
7008
7078
|
}
|
|
7009
|
-
const stringified = issue2.values.map((
|
|
7079
|
+
const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
|
|
7010
7080
|
if (issue2.values.length === 2) {
|
|
7011
7081
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${stringified[0]} \u05D0\u05D5 ${stringified[1]}`;
|
|
7012
7082
|
}
|
|
@@ -11761,7 +11831,7 @@ function _set(Class2, valueType, params) {
|
|
|
11761
11831
|
}
|
|
11762
11832
|
// @__NO_SIDE_EFFECTS__
|
|
11763
11833
|
function _enum(Class2, values, params) {
|
|
11764
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
11834
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
11765
11835
|
return new Class2({
|
|
11766
11836
|
type: "enum",
|
|
11767
11837
|
entries,
|
|
@@ -11966,8 +12036,8 @@ function _stringbool(Classes, _params) {
|
|
|
11966
12036
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
11967
12037
|
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
11968
12038
|
if (params.case !== "sensitive") {
|
|
11969
|
-
truthyArray = truthyArray.map((
|
|
11970
|
-
falsyArray = falsyArray.map((
|
|
12039
|
+
truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
12040
|
+
falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
11971
12041
|
}
|
|
11972
12042
|
const truthySet = new Set(truthyArray);
|
|
11973
12043
|
const falsySet = new Set(falsyArray);
|
|
@@ -12509,9 +12579,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
12509
12579
|
var enumProcessor = (schema, _ctx, json2, _params) => {
|
|
12510
12580
|
const def = schema._zod.def;
|
|
12511
12581
|
const values = getEnumValues(def.entries);
|
|
12512
|
-
if (values.every((
|
|
12582
|
+
if (values.every((v2) => typeof v2 === "number"))
|
|
12513
12583
|
json2.type = "number";
|
|
12514
|
-
if (values.every((
|
|
12584
|
+
if (values.every((v2) => typeof v2 === "string"))
|
|
12515
12585
|
json2.type = "string";
|
|
12516
12586
|
json2.enum = values;
|
|
12517
12587
|
};
|
|
@@ -12544,13 +12614,13 @@ var literalProcessor = (schema, ctx, json2, _params) => {
|
|
|
12544
12614
|
json2.const = val;
|
|
12545
12615
|
}
|
|
12546
12616
|
} else {
|
|
12547
|
-
if (vals.every((
|
|
12617
|
+
if (vals.every((v2) => typeof v2 === "number"))
|
|
12548
12618
|
json2.type = "number";
|
|
12549
|
-
if (vals.every((
|
|
12619
|
+
if (vals.every((v2) => typeof v2 === "string"))
|
|
12550
12620
|
json2.type = "string";
|
|
12551
|
-
if (vals.every((
|
|
12621
|
+
if (vals.every((v2) => typeof v2 === "boolean"))
|
|
12552
12622
|
json2.type = "boolean";
|
|
12553
|
-
if (vals.every((
|
|
12623
|
+
if (vals.every((v2) => v2 === null))
|
|
12554
12624
|
json2.type = "null";
|
|
12555
12625
|
json2.enum = vals;
|
|
12556
12626
|
}
|
|
@@ -12648,11 +12718,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12648
12718
|
}
|
|
12649
12719
|
const allKeys = new Set(Object.keys(shape));
|
|
12650
12720
|
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
12651
|
-
const
|
|
12721
|
+
const v2 = def.shape[key]._zod;
|
|
12652
12722
|
if (ctx.io === "input") {
|
|
12653
|
-
return
|
|
12723
|
+
return v2.optin === void 0;
|
|
12654
12724
|
} else {
|
|
12655
|
-
return
|
|
12725
|
+
return v2.optout === void 0;
|
|
12656
12726
|
}
|
|
12657
12727
|
}));
|
|
12658
12728
|
if (requiredKeys.size > 0) {
|
|
@@ -12772,7 +12842,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
12772
12842
|
}
|
|
12773
12843
|
const keyValues = keyType._zod.values;
|
|
12774
12844
|
if (keyValues) {
|
|
12775
|
-
const validKeyValues = [...keyValues].filter((
|
|
12845
|
+
const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
|
|
12776
12846
|
if (validKeyValues.length > 0) {
|
|
12777
12847
|
json2.required = validKeyValues;
|
|
12778
12848
|
}
|
|
@@ -13337,12 +13407,12 @@ function _installLazyMethods(inst, group, methods) {
|
|
|
13337
13407
|
});
|
|
13338
13408
|
return bound;
|
|
13339
13409
|
},
|
|
13340
|
-
set(
|
|
13410
|
+
set(v2) {
|
|
13341
13411
|
Object.defineProperty(this, key, {
|
|
13342
13412
|
configurable: true,
|
|
13343
13413
|
writable: true,
|
|
13344
13414
|
enumerable: true,
|
|
13345
|
-
value:
|
|
13415
|
+
value: v2
|
|
13346
13416
|
});
|
|
13347
13417
|
}
|
|
13348
13418
|
});
|
|
@@ -13432,11 +13502,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
13432
13502
|
transform(tx) {
|
|
13433
13503
|
return pipe(this, transform(tx));
|
|
13434
13504
|
},
|
|
13435
|
-
default(
|
|
13436
|
-
return _default2(this,
|
|
13505
|
+
default(d2) {
|
|
13506
|
+
return _default2(this, d2);
|
|
13437
13507
|
},
|
|
13438
|
-
prefault(
|
|
13439
|
-
return prefault(this,
|
|
13508
|
+
prefault(d2) {
|
|
13509
|
+
return prefault(this, d2);
|
|
13440
13510
|
},
|
|
13441
13511
|
catch(params) {
|
|
13442
13512
|
return _catch2(this, params);
|
|
@@ -14138,11 +14208,11 @@ function record(keyType, valueType, params) {
|
|
|
14138
14208
|
});
|
|
14139
14209
|
}
|
|
14140
14210
|
function partialRecord(keyType, valueType, params) {
|
|
14141
|
-
const
|
|
14142
|
-
|
|
14211
|
+
const k = clone(keyType);
|
|
14212
|
+
k._zod.values = void 0;
|
|
14143
14213
|
return new ZodRecord({
|
|
14144
14214
|
type: "record",
|
|
14145
|
-
keyType:
|
|
14215
|
+
keyType: k,
|
|
14146
14216
|
valueType,
|
|
14147
14217
|
...util_exports.normalizeParams(params)
|
|
14148
14218
|
});
|
|
@@ -14230,7 +14300,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
14230
14300
|
};
|
|
14231
14301
|
});
|
|
14232
14302
|
function _enum2(values, params) {
|
|
14233
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
14303
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
14234
14304
|
return new ZodEnum({
|
|
14235
14305
|
type: "enum",
|
|
14236
14306
|
entries,
|
|
@@ -14784,10 +14854,10 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14784
14854
|
if (enumValues.length === 1) {
|
|
14785
14855
|
return z.literal(enumValues[0]);
|
|
14786
14856
|
}
|
|
14787
|
-
if (enumValues.every((
|
|
14857
|
+
if (enumValues.every((v2) => typeof v2 === "string")) {
|
|
14788
14858
|
return z.enum(enumValues);
|
|
14789
14859
|
}
|
|
14790
|
-
const literalSchemas = enumValues.map((
|
|
14860
|
+
const literalSchemas = enumValues.map((v2) => z.literal(v2));
|
|
14791
14861
|
if (literalSchemas.length < 2) {
|
|
14792
14862
|
return literalSchemas[0];
|
|
14793
14863
|
}
|
|
@@ -15632,7 +15702,7 @@ var _SimpleTemplateEngine = class _SimpleTemplateEngine2 {
|
|
|
15632
15702
|
const result = this.substitute(template, context);
|
|
15633
15703
|
if (result.usedDefaults.length > 0) {
|
|
15634
15704
|
warnings.push(
|
|
15635
|
-
`Used ${result.usedDefaults.length} default values: ${result.usedDefaults.map((
|
|
15705
|
+
`Used ${result.usedDefaults.length} default values: ${result.usedDefaults.map((d2) => d2.variable).join(", ")}`
|
|
15636
15706
|
);
|
|
15637
15707
|
}
|
|
15638
15708
|
if (result.missingVariables.length > 0) {
|
|
@@ -17075,15 +17145,13 @@ var AGENT_CONTENT_CONFIG_KEYS = {
|
|
|
17075
17145
|
tenancyStrategy: true
|
|
17076
17146
|
};
|
|
17077
17147
|
var AGENT_CONTENT_CONFIG_KEY_LIST = Object.keys(AGENT_CONTENT_CONFIG_KEYS).sort();
|
|
17078
|
-
var configurationStatusSchema = external_exports.enum([
|
|
17079
|
-
|
|
17080
|
-
"needs_configuration",
|
|
17081
|
-
"invalid"
|
|
17082
|
-
]);
|
|
17148
|
+
var configurationStatusSchema = external_exports.enum(["configured", "needs_configuration", "invalid"]);
|
|
17149
|
+
var secretDocsUrlSchema = external_exports.url({ protocol: /^https$/ }).max(2048);
|
|
17083
17150
|
var secretRequirementSourceSchema = external_exports.object({
|
|
17084
17151
|
type: external_exports.enum(["manual", "secret", "product"]),
|
|
17085
17152
|
key: external_exports.string().optional(),
|
|
17086
|
-
productId: external_exports.string().optional()
|
|
17153
|
+
productId: external_exports.string().optional(),
|
|
17154
|
+
description: external_exports.string().optional()
|
|
17087
17155
|
});
|
|
17088
17156
|
var secretIntakeItemSchema = external_exports.object({
|
|
17089
17157
|
itemId: external_exports.string(),
|
|
@@ -17131,6 +17199,10 @@ var secretIntakeSubmitItemSchema = external_exports.object({
|
|
|
17131
17199
|
displayName: external_exports.string().optional(),
|
|
17132
17200
|
description: external_exports.string().optional(),
|
|
17133
17201
|
value: external_exports.string().optional(),
|
|
17202
|
+
// Write-path acquisition link for API/MCP submitters. The dashboard intake
|
|
17203
|
+
// form does not expose an input for it in v1; it flows into the same
|
|
17204
|
+
// create/update service paths. https-only via secretDocsUrlSchema.
|
|
17205
|
+
docsUrl: secretDocsUrlSchema.optional(),
|
|
17134
17206
|
// Required when `value` is set AND the item targets an existing secret
|
|
17135
17207
|
// (has `secretId` or a `key` that already exists). Echoed from the
|
|
17136
17208
|
// manifest item's `version` field. Omit for new-secret creations.
|
|
@@ -38886,6 +38958,13 @@ var userProfileFeaturesSchema = external_exports.object({
|
|
|
38886
38958
|
// until a rule enables it). Execution and tool listings are gated
|
|
38887
38959
|
// server-side by the same flag.
|
|
38888
38960
|
enableMassiveWebRender: external_exports.boolean(),
|
|
38961
|
+
// Gates the agent voice configuration UI in the dashboard (the Voice tab in
|
|
38962
|
+
// the agent editor). Driven by the `enable-voice` boolean flag (fail-closed
|
|
38963
|
+
// in production until a rule enables it; non-prod defaults on, preserving
|
|
38964
|
+
// the staging-first rollout the flag replaced). The voice API routes stay
|
|
38965
|
+
// ungated: they already require per-agent `config.voice.enabled` opt-in,
|
|
38966
|
+
// which production users can only set once this flag exposes the UI.
|
|
38967
|
+
enableVoice: external_exports.boolean(),
|
|
38889
38968
|
// Gates the workspace-model arms of the dashboard signup / switcher UI
|
|
38890
38969
|
// (docs/features/planning/2026-07-07-workspace-model-migration.md). Driven by
|
|
38891
38970
|
// the `enable-workspace-model` boolean flag (fail-closed in production until a
|
|
@@ -40001,7 +40080,7 @@ var PLATFORM_KEY_PROVIDER_MAP = {
|
|
|
40001
40080
|
"mock": false
|
|
40002
40081
|
};
|
|
40003
40082
|
var PLATFORM_KEY_PROVIDERS = new Set(
|
|
40004
|
-
Object.entries(PLATFORM_KEY_PROVIDER_MAP).filter(([,
|
|
40083
|
+
Object.entries(PLATFORM_KEY_PROVIDER_MAP).filter(([, v2]) => v2).map(([k]) => k)
|
|
40005
40084
|
);
|
|
40006
40085
|
var MANUAL_PROVIDER_MAP_OVERRIDES = {
|
|
40007
40086
|
// Bedrock uses different model ID format
|
|
@@ -41325,18 +41404,18 @@ function extractSecretReferencesFromAnyValue(value, maxDepth = 10) {
|
|
|
41325
41404
|
const keys = /* @__PURE__ */ new Set();
|
|
41326
41405
|
walk(value, 0);
|
|
41327
41406
|
return Array.from(keys);
|
|
41328
|
-
function walk(
|
|
41407
|
+
function walk(v2, depth) {
|
|
41329
41408
|
if (depth > maxDepth) return;
|
|
41330
|
-
if (typeof
|
|
41331
|
-
for (const key of extractSecretReferences(
|
|
41409
|
+
if (typeof v2 === "string") {
|
|
41410
|
+
for (const key of extractSecretReferences(v2)) keys.add(key);
|
|
41332
41411
|
return;
|
|
41333
41412
|
}
|
|
41334
|
-
if (Array.isArray(
|
|
41335
|
-
for (const item of
|
|
41413
|
+
if (Array.isArray(v2)) {
|
|
41414
|
+
for (const item of v2) walk(item, depth + 1);
|
|
41336
41415
|
return;
|
|
41337
41416
|
}
|
|
41338
|
-
if (
|
|
41339
|
-
for (const inner of Object.values(
|
|
41417
|
+
if (v2 && typeof v2 === "object") {
|
|
41418
|
+
for (const inner of Object.values(v2)) {
|
|
41340
41419
|
walk(inner, depth + 1);
|
|
41341
41420
|
}
|
|
41342
41421
|
}
|
|
@@ -41682,7 +41761,7 @@ var capabilitySchema = external_exports.object({
|
|
|
41682
41761
|
}).refine(
|
|
41683
41762
|
(cap) => {
|
|
41684
41763
|
const set2 = [cap.flow, cap.agent, cap.existingFlowId, cap.existingAgentId].filter(
|
|
41685
|
-
(
|
|
41764
|
+
(v2) => v2 !== void 0 && v2 !== null
|
|
41686
41765
|
);
|
|
41687
41766
|
return set2.length === 1;
|
|
41688
41767
|
},
|
|
@@ -41699,11 +41778,12 @@ var secretSchema = external_exports.object({
|
|
|
41699
41778
|
var setupInstructionsSchema = external_exports.object({
|
|
41700
41779
|
summary: external_exports.string().min(1),
|
|
41701
41780
|
steps: external_exports.array(external_exports.string()),
|
|
41702
|
-
// Constrained to an absolute URL because this lands in the
|
|
41703
|
-
// `<a href={…}>` in the secret intake and quick-start preview UIs —
|
|
41704
|
-
// `javascript:` / `data:` schemes in an unrestricted string would
|
|
41705
|
-
// live XSS vector when a malicious template is imported.
|
|
41706
|
-
|
|
41781
|
+
// Constrained to an https-only absolute URL because this lands in the
|
|
41782
|
+
// rendered `<a href={…}>` in the secret intake and quick-start preview UIs —
|
|
41783
|
+
// `javascript:` / `data:` / `http:` schemes in an unrestricted string would
|
|
41784
|
+
// be a live XSS / downgrade vector when a malicious template is imported.
|
|
41785
|
+
// Canonical schema lives in secrets-types.ts (`secretDocsUrlSchema`).
|
|
41786
|
+
docsUrl: secretDocsUrlSchema.optional()
|
|
41707
41787
|
});
|
|
41708
41788
|
var toolAuthSchema = external_exports.object({
|
|
41709
41789
|
type: external_exports.enum(["oauth", "api_key", "none", "user_provided"]),
|
|
@@ -42040,6 +42120,90 @@ var productReadinessSchema = external_exports.object({
|
|
|
42040
42120
|
/** Single best dashboard link if any browser step remains (secret-parity). */
|
|
42041
42121
|
handoff: browserFulfillmentSchema.optional()
|
|
42042
42122
|
});
|
|
42123
|
+
var briefFieldStatusSchema = external_exports.enum(["confirmed", "assumed"]);
|
|
42124
|
+
var briefProblemSchema = external_exports.object({
|
|
42125
|
+
status: briefFieldStatusSchema,
|
|
42126
|
+
/** The specific situation, in the user's own words. Always present when the field is. */
|
|
42127
|
+
statement: external_exports.string().min(1),
|
|
42128
|
+
/** Who runs into this situation. */
|
|
42129
|
+
whoFeelsIt: external_exports.string().min(1).optional(),
|
|
42130
|
+
/** What the problem costs them (time, money, missed work, frustration). */
|
|
42131
|
+
cost: external_exports.string().min(1).optional()
|
|
42132
|
+
});
|
|
42133
|
+
var briefAudienceGroupSchema = external_exports.object({
|
|
42134
|
+
group: external_exports.string().min(1),
|
|
42135
|
+
whatTheyDo: external_exports.string().min(1)
|
|
42136
|
+
});
|
|
42137
|
+
var briefAudienceSchema = external_exports.object({
|
|
42138
|
+
status: briefFieldStatusSchema,
|
|
42139
|
+
groups: external_exports.array(briefAudienceGroupSchema)
|
|
42140
|
+
});
|
|
42141
|
+
var briefCapabilitySchema = external_exports.object({
|
|
42142
|
+
name: external_exports.string().min(1),
|
|
42143
|
+
/** What it does, in plain terms. */
|
|
42144
|
+
behavior: external_exports.string().min(1),
|
|
42145
|
+
/** True = needed on day one; false = explicitly deferred to "later". */
|
|
42146
|
+
dayOne: external_exports.boolean()
|
|
42147
|
+
});
|
|
42148
|
+
var briefCapabilitiesSchema = external_exports.object({
|
|
42149
|
+
status: briefFieldStatusSchema,
|
|
42150
|
+
items: external_exports.array(briefCapabilitySchema)
|
|
42151
|
+
});
|
|
42152
|
+
var briefSurfaceTypeSchema = surfaceSchema.shape.type;
|
|
42153
|
+
var briefSurfaceSchema = external_exports.object({
|
|
42154
|
+
type: briefSurfaceTypeSchema,
|
|
42155
|
+
/** Optional plain-language label (e.g. "our website chat"). */
|
|
42156
|
+
name: external_exports.string().min(1).optional(),
|
|
42157
|
+
/** Optional note on why people reach the product here. */
|
|
42158
|
+
purpose: external_exports.string().min(1).optional()
|
|
42159
|
+
});
|
|
42160
|
+
var briefSurfacesSchema = external_exports.object({
|
|
42161
|
+
status: briefFieldStatusSchema,
|
|
42162
|
+
items: external_exports.array(briefSurfaceSchema)
|
|
42163
|
+
});
|
|
42164
|
+
var briefDataNeedsSchema = external_exports.object({
|
|
42165
|
+
status: briefFieldStatusSchema,
|
|
42166
|
+
/** Things it should remember run-to-run. */
|
|
42167
|
+
remembers: external_exports.array(external_exports.string().min(1)).optional(),
|
|
42168
|
+
/** Things it must already know before it can help. */
|
|
42169
|
+
mustAlreadyKnow: external_exports.array(external_exports.string().min(1)).optional()
|
|
42170
|
+
});
|
|
42171
|
+
var briefIntegrationSchema = external_exports.object({
|
|
42172
|
+
name: external_exports.string().min(1),
|
|
42173
|
+
purpose: external_exports.string().min(1).optional()
|
|
42174
|
+
});
|
|
42175
|
+
var briefIntegrationsSchema = external_exports.object({
|
|
42176
|
+
status: briefFieldStatusSchema,
|
|
42177
|
+
items: external_exports.array(briefIntegrationSchema)
|
|
42178
|
+
});
|
|
42179
|
+
var briefSuccessCriteriaSchema = external_exports.object({
|
|
42180
|
+
status: briefFieldStatusSchema,
|
|
42181
|
+
measure: external_exports.string().min(1)
|
|
42182
|
+
});
|
|
42183
|
+
var productBriefSchema = external_exports.object({
|
|
42184
|
+
problem: briefProblemSchema.optional(),
|
|
42185
|
+
audience: briefAudienceSchema.optional(),
|
|
42186
|
+
capabilities: briefCapabilitiesSchema.optional(),
|
|
42187
|
+
surfaces: briefSurfacesSchema.optional(),
|
|
42188
|
+
dataNeeds: briefDataNeedsSchema.optional(),
|
|
42189
|
+
integrations: briefIntegrationsSchema.optional(),
|
|
42190
|
+
successCriteria: briefSuccessCriteriaSchema.optional()
|
|
42191
|
+
});
|
|
42192
|
+
var fieldSoliditySchema = external_exports.enum(["empty", "sketched", "solid"]);
|
|
42193
|
+
var briefReadinessFieldsSchema = external_exports.object({
|
|
42194
|
+
problem: fieldSoliditySchema,
|
|
42195
|
+
audience: fieldSoliditySchema,
|
|
42196
|
+
capabilities: fieldSoliditySchema,
|
|
42197
|
+
surfaces: fieldSoliditySchema,
|
|
42198
|
+
dataNeeds: fieldSoliditySchema,
|
|
42199
|
+
integrations: fieldSoliditySchema,
|
|
42200
|
+
successCriteria: fieldSoliditySchema
|
|
42201
|
+
});
|
|
42202
|
+
var briefReadinessSchema = external_exports.object({
|
|
42203
|
+
ready: external_exports.boolean(),
|
|
42204
|
+
fields: briefReadinessFieldsSchema,
|
|
42205
|
+
missing: external_exports.array(external_exports.string())
|
|
42206
|
+
});
|
|
42043
42207
|
var FLAT_ADVANCED_CONFIG_KEYS = {
|
|
42044
42208
|
loopConfig: true,
|
|
42045
42209
|
reasoning: true,
|
|
@@ -42253,7 +42417,7 @@ function validateCapability(cap, index, context) {
|
|
|
42253
42417
|
const result = emptyResult();
|
|
42254
42418
|
const base = `capabilities[${index}]`;
|
|
42255
42419
|
const backings = [cap.flow, cap.agent, cap.existingFlowId, cap.existingAgentId].filter(
|
|
42256
|
-
(
|
|
42420
|
+
(v2) => v2 !== void 0 && v2 !== null
|
|
42257
42421
|
);
|
|
42258
42422
|
if (backings.length === 0) {
|
|
42259
42423
|
result.errors.push(
|
|
@@ -45920,7 +46084,18 @@ var ApiKeyManager = class {
|
|
|
45920
46084
|
try {
|
|
45921
46085
|
data = await client.get("/auth/me");
|
|
45922
46086
|
} catch {
|
|
45923
|
-
|
|
46087
|
+
try {
|
|
46088
|
+
const profile = await client.get(
|
|
46089
|
+
"/users/profile"
|
|
46090
|
+
);
|
|
46091
|
+
if (typeof profile.id === "string") {
|
|
46092
|
+
data = { userId: profile.id, orgId: profile.orgId ?? null, email: profile.email };
|
|
46093
|
+
}
|
|
46094
|
+
} catch {
|
|
46095
|
+
}
|
|
46096
|
+
if (!data) {
|
|
46097
|
+
throw new Error("Failed to get user information");
|
|
46098
|
+
}
|
|
45924
46099
|
}
|
|
45925
46100
|
if (!isAuthMeResponse(data)) {
|
|
45926
46101
|
throw new Error("Invalid user response format");
|
|
@@ -46167,23 +46342,418 @@ function MutationResult({
|
|
|
46167
46342
|
return null;
|
|
46168
46343
|
}
|
|
46169
46344
|
|
|
46170
|
-
// src/commands/auth.ts
|
|
46171
|
-
|
|
46172
|
-
|
|
46345
|
+
// src/commands/auth-agent.ts
|
|
46346
|
+
init_credential_store();
|
|
46347
|
+
|
|
46348
|
+
// src/auth/agent-auth-client.ts
|
|
46349
|
+
var AgentAuthError = class extends Error {
|
|
46350
|
+
constructor(code, status, message, hint) {
|
|
46351
|
+
super(message);
|
|
46352
|
+
this.code = code;
|
|
46353
|
+
this.status = status;
|
|
46354
|
+
this.hint = hint;
|
|
46355
|
+
this.name = "AgentAuthError";
|
|
46356
|
+
}
|
|
46357
|
+
code;
|
|
46358
|
+
status;
|
|
46359
|
+
hint;
|
|
46360
|
+
};
|
|
46361
|
+
var ERROR_HINTS = {
|
|
46362
|
+
email_already_registered: "This email already has a Runtype account, so it cannot claim a new agent account. Ask the user to sign in at the dashboard, create an API key (Settings > API keys), and give it to you. Then run: runtype auth login --api-key <key> --no-tty",
|
|
46363
|
+
invalid_claim_token: "The claim token is invalid or expired. Run: runtype auth register --force",
|
|
46364
|
+
claim_expired: "The claim window expired. Run: runtype auth register --force",
|
|
46365
|
+
credential_expired: "The temporary credential expired. Run: runtype auth register --force",
|
|
46366
|
+
claimed_or_in_flight: "A claim is already in progress. Ask the user for the 6-digit code from their email, then run: runtype auth verify <code>. If the code expired, re-run: runtype auth claim <email>",
|
|
46367
|
+
otp_invalid: "That code is not correct. Ask the user to re-check the 6-digit code from the most recent Runtype email and run: runtype auth verify <code>",
|
|
46368
|
+
otp_expired: "The code expired. Re-send it with: runtype auth claim <email>",
|
|
46369
|
+
previously_claimed: "This registration was already claimed. Run: runtype auth status to inspect stored credentials.",
|
|
46370
|
+
email_send_failed: "The verification email could not be sent. Retry: runtype auth claim <email>",
|
|
46371
|
+
rate_limited: "Too many attempts. Wait a minute, then retry the same command.",
|
|
46372
|
+
service_disabled: "Agent registration is temporarily disabled. Try again later."
|
|
46373
|
+
};
|
|
46374
|
+
async function postJson(url2, body) {
|
|
46375
|
+
let response;
|
|
46173
46376
|
try {
|
|
46174
|
-
|
|
46175
|
-
|
|
46377
|
+
response = await fetch(url2, {
|
|
46378
|
+
method: "POST",
|
|
46379
|
+
headers: {
|
|
46380
|
+
"content-type": "application/json",
|
|
46381
|
+
"user-agent": "runtype-cli"
|
|
46382
|
+
},
|
|
46383
|
+
body: JSON.stringify(body)
|
|
46384
|
+
});
|
|
46385
|
+
} catch (error51) {
|
|
46386
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
46387
|
+
throw new AgentAuthError(
|
|
46388
|
+
"network_error",
|
|
46389
|
+
0,
|
|
46390
|
+
`Could not reach ${url2}: ${message}`,
|
|
46391
|
+
"Check network access and the --api-url value, then retry the same command."
|
|
46392
|
+
);
|
|
46393
|
+
}
|
|
46394
|
+
let data = {};
|
|
46395
|
+
try {
|
|
46396
|
+
data = await response.json();
|
|
46176
46397
|
} catch {
|
|
46177
|
-
return null;
|
|
46178
46398
|
}
|
|
46399
|
+
if (!response.ok) {
|
|
46400
|
+
const code = typeof data.error === "string" ? data.error : `http_${response.status}`;
|
|
46401
|
+
const message = typeof data.message === "string" ? data.message : `Request failed (${response.status})`;
|
|
46402
|
+
throw new AgentAuthError(code, response.status, message, ERROR_HINTS[code]);
|
|
46403
|
+
}
|
|
46404
|
+
return { status: response.status, data };
|
|
46179
46405
|
}
|
|
46180
|
-
|
|
46181
|
-
|
|
46406
|
+
function requireString(data, key) {
|
|
46407
|
+
const value = data[key];
|
|
46408
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
46409
|
+
throw new AgentAuthError(
|
|
46410
|
+
"invalid_response",
|
|
46411
|
+
0,
|
|
46412
|
+
`Registration response is missing "${key}". The API may be an incompatible version.`
|
|
46413
|
+
);
|
|
46414
|
+
}
|
|
46415
|
+
return value;
|
|
46416
|
+
}
|
|
46417
|
+
function stringArray(value) {
|
|
46418
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
46419
|
+
}
|
|
46420
|
+
async function registerAnonymousAgent(apiUrl) {
|
|
46421
|
+
const base = apiUrl || getApiUrl();
|
|
46422
|
+
const { data } = await postJson(`${base}/agent/auth`, {
|
|
46423
|
+
// @snake-case-ok-start: auth.md protocol field names
|
|
46424
|
+
type: "anonymous",
|
|
46425
|
+
requested_credential_type: "api_key"
|
|
46426
|
+
// @snake-case-ok-end
|
|
46427
|
+
});
|
|
46428
|
+
return {
|
|
46429
|
+
// @snake-case-ok-start: auth.md protocol field names
|
|
46430
|
+
registrationId: requireString(data, "registration_id"),
|
|
46431
|
+
credential: requireString(data, "credential"),
|
|
46432
|
+
credentialExpires: requireString(data, "credential_expires"),
|
|
46433
|
+
scopes: stringArray(data.scopes),
|
|
46434
|
+
claimToken: requireString(data, "claim_token"),
|
|
46435
|
+
claimTokenExpires: requireString(data, "claim_token_expires"),
|
|
46436
|
+
postClaimScopes: stringArray(data.post_claim_scopes)
|
|
46437
|
+
// @snake-case-ok-end
|
|
46438
|
+
};
|
|
46439
|
+
}
|
|
46440
|
+
async function initiateClaim(claimToken, email3, apiUrl) {
|
|
46441
|
+
const base = apiUrl || getApiUrl();
|
|
46442
|
+
const { data } = await postJson(`${base}/agent/auth/claim`, {
|
|
46443
|
+
// @snake-case-ok-start: auth.md protocol field names
|
|
46444
|
+
claim_token: claimToken,
|
|
46445
|
+
email: email3
|
|
46446
|
+
// @snake-case-ok-end
|
|
46447
|
+
});
|
|
46448
|
+
return {
|
|
46449
|
+
// @snake-case-ok-start: auth.md protocol field names
|
|
46450
|
+
registrationId: requireString(data, "registration_id"),
|
|
46451
|
+
status: typeof data.status === "string" ? data.status : "initiated",
|
|
46452
|
+
otpExpiresAt: requireString(data, "expires_at")
|
|
46453
|
+
// @snake-case-ok-end
|
|
46454
|
+
};
|
|
46455
|
+
}
|
|
46456
|
+
async function completeClaim(claimToken, otp, apiUrl) {
|
|
46457
|
+
const base = apiUrl || getApiUrl();
|
|
46458
|
+
const { data } = await postJson(`${base}/agent/auth/claim/complete`, {
|
|
46459
|
+
// @snake-case-ok-start: auth.md protocol field names
|
|
46460
|
+
claim_token: claimToken,
|
|
46461
|
+
otp
|
|
46462
|
+
// @snake-case-ok-end
|
|
46463
|
+
});
|
|
46464
|
+
return {
|
|
46465
|
+
// @snake-case-ok-start: auth.md protocol field names
|
|
46466
|
+
registrationId: requireString(data, "registration_id"),
|
|
46467
|
+
credential: requireString(data, "credential"),
|
|
46468
|
+
scopes: stringArray(data.scopes)
|
|
46469
|
+
// @snake-case-ok-end
|
|
46470
|
+
};
|
|
46471
|
+
}
|
|
46472
|
+
|
|
46473
|
+
// src/lib/output.ts
|
|
46474
|
+
import chalk from "chalk";
|
|
46475
|
+
function printJson(data) {
|
|
46476
|
+
console.log(JSON.stringify(data, null, 2));
|
|
46477
|
+
}
|
|
46478
|
+
function printList(items, options) {
|
|
46479
|
+
console.log(chalk.cyan(`${options.title}:`));
|
|
46480
|
+
if (items.length === 0) {
|
|
46481
|
+
console.log(chalk.gray(` ${options.emptyMessage || "None found"}`));
|
|
46482
|
+
return;
|
|
46483
|
+
}
|
|
46484
|
+
for (const item of items) {
|
|
46485
|
+
const parts = [];
|
|
46486
|
+
for (const col of options.columns) {
|
|
46487
|
+
const value = item[col.key];
|
|
46488
|
+
if (value === void 0 || value === null) continue;
|
|
46489
|
+
const str = String(value);
|
|
46490
|
+
const colorFn = col.color ? chalk[col.color] : (s) => s;
|
|
46491
|
+
if (col.label) {
|
|
46492
|
+
parts.push(`${col.label}: ${colorFn(str)}`);
|
|
46493
|
+
} else {
|
|
46494
|
+
parts.push(colorFn(str));
|
|
46495
|
+
}
|
|
46496
|
+
}
|
|
46497
|
+
console.log(` ${parts.join(" - ")}`);
|
|
46498
|
+
}
|
|
46499
|
+
if (options.total !== void 0) {
|
|
46500
|
+
console.log(chalk.dim(`
|
|
46501
|
+
Total: ${options.total}`));
|
|
46502
|
+
}
|
|
46503
|
+
}
|
|
46504
|
+
function printDetail(title, fields) {
|
|
46505
|
+
console.log(chalk.cyan(`${title}:`));
|
|
46506
|
+
for (const field of fields) {
|
|
46507
|
+
if (field.value === void 0 || field.value === null) continue;
|
|
46508
|
+
const str = typeof field.value === "object" ? JSON.stringify(field.value) : String(field.value);
|
|
46509
|
+
console.log(` ${chalk.gray(field.label + ":")} ${str}`);
|
|
46510
|
+
}
|
|
46511
|
+
}
|
|
46512
|
+
function getTotalCount(pagination) {
|
|
46513
|
+
return pagination?.totalCount ?? pagination?.total ?? void 0;
|
|
46514
|
+
}
|
|
46515
|
+
function buildListParams(options, extra) {
|
|
46516
|
+
const params = {};
|
|
46517
|
+
if (options.limit) params.limit = options.limit;
|
|
46518
|
+
if (options.cursor) params.cursor = options.cursor;
|
|
46519
|
+
if (extra) {
|
|
46520
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
46521
|
+
if (value !== void 0) params[key] = value;
|
|
46522
|
+
}
|
|
46523
|
+
}
|
|
46524
|
+
return params;
|
|
46525
|
+
}
|
|
46526
|
+
function printNextCursorHint(commandPath, pagination) {
|
|
46527
|
+
const hasMore = pagination?.hasMore ?? pagination?.hasNextPage ?? false;
|
|
46528
|
+
const nextCursor = pagination?.nextCursor !== void 0 ? pagination.nextCursor : pagination?.cursor ?? null;
|
|
46529
|
+
if (!hasMore || !nextCursor) return;
|
|
46530
|
+
console.log(
|
|
46531
|
+
chalk.yellow("\n More results available \u2014 fetch the next page with:") + chalk.dim(`
|
|
46532
|
+
${commandPath} --cursor ${nextCursor}`)
|
|
46533
|
+
);
|
|
46534
|
+
}
|
|
46535
|
+
|
|
46536
|
+
// src/commands/auth-agent.ts
|
|
46537
|
+
var VERIFY_NEXT = "Ask the user for the 6-digit code from their email, then run: runtype auth verify <code>";
|
|
46538
|
+
function claimNext(email3) {
|
|
46539
|
+
return email3 ? `Send the verification email with: runtype auth claim ${email3}` : "Ask the user for their email address, then run: runtype auth claim <email>";
|
|
46540
|
+
}
|
|
46541
|
+
function fail(payload) {
|
|
46542
|
+
console.error(JSON.stringify(payload, null, 2));
|
|
46543
|
+
process.exit(1);
|
|
46544
|
+
}
|
|
46545
|
+
function failFromError(error51, fallbackNext) {
|
|
46546
|
+
if (error51 instanceof AgentAuthError) {
|
|
46547
|
+
fail({
|
|
46548
|
+
status: "error",
|
|
46549
|
+
code: error51.code,
|
|
46550
|
+
error: error51.message,
|
|
46551
|
+
...error51.hint || fallbackNext ? { next: error51.hint || fallbackNext } : {}
|
|
46552
|
+
});
|
|
46553
|
+
}
|
|
46554
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
46555
|
+
fail({ status: "error", error: message, ...fallbackNext ? { next: fallbackNext } : {} });
|
|
46556
|
+
}
|
|
46557
|
+
async function fetchIdentity(apiKey, apiUrl) {
|
|
46558
|
+
const client = createCliClient(apiKey, apiUrl);
|
|
46559
|
+
const profile = await client.get(
|
|
46560
|
+
"/users/profile"
|
|
46561
|
+
);
|
|
46562
|
+
return {
|
|
46563
|
+
userId: typeof profile.id === "string" ? profile.id : "unknown",
|
|
46564
|
+
orgId: typeof profile.orgId === "string" ? profile.orgId : void 0,
|
|
46565
|
+
email: typeof profile.email === "string" ? profile.email : void 0
|
|
46566
|
+
};
|
|
46567
|
+
}
|
|
46568
|
+
async function registerAction(options) {
|
|
46569
|
+
const store = new CredentialStore();
|
|
46570
|
+
const apiUrl = options.apiUrl || getApiUrl();
|
|
46571
|
+
const existingClaim = await store.getClaimState();
|
|
46572
|
+
const hasCredentials = await store.hasCredentials();
|
|
46573
|
+
if (existingClaim && !options.force) {
|
|
46574
|
+
const resumeDeadline = existingClaim.claimTokenExpires ?? existingClaim.credentialExpires;
|
|
46575
|
+
const expired = resumeDeadline && new Date(resumeDeadline) < /* @__PURE__ */ new Date();
|
|
46576
|
+
if (!expired) {
|
|
46577
|
+
const payload = {
|
|
46578
|
+
status: "registration_pending",
|
|
46579
|
+
registrationId: existingClaim.registrationId,
|
|
46580
|
+
credentialExpires: existingClaim.credentialExpires,
|
|
46581
|
+
next: existingClaim.claimEmail ? VERIFY_NEXT : claimNext(options.email)
|
|
46582
|
+
};
|
|
46583
|
+
if (existingClaim.claimEmail) payload.claimEmail = existingClaim.claimEmail;
|
|
46584
|
+
printJson(payload);
|
|
46585
|
+
return;
|
|
46586
|
+
}
|
|
46587
|
+
}
|
|
46588
|
+
if (hasCredentials && !existingClaim && !options.force) {
|
|
46589
|
+
fail({
|
|
46590
|
+
status: "error",
|
|
46591
|
+
code: "already_authenticated",
|
|
46592
|
+
error: "Credentials are already stored for a claimed account.",
|
|
46593
|
+
next: "Run: runtype auth whoami --no-tty to confirm, or runtype auth logout first if the user wants a different account."
|
|
46594
|
+
});
|
|
46595
|
+
}
|
|
46596
|
+
let registration;
|
|
46597
|
+
try {
|
|
46598
|
+
registration = await registerAnonymousAgent(apiUrl);
|
|
46599
|
+
} catch (error51) {
|
|
46600
|
+
failFromError(error51, "Retry: runtype auth register");
|
|
46601
|
+
}
|
|
46602
|
+
let identity = { userId: "unknown" };
|
|
46603
|
+
try {
|
|
46604
|
+
identity = await fetchIdentity(registration.credential, apiUrl);
|
|
46605
|
+
} catch {
|
|
46606
|
+
}
|
|
46607
|
+
const claimState = {
|
|
46608
|
+
claimToken: registration.claimToken,
|
|
46609
|
+
registrationId: registration.registrationId,
|
|
46610
|
+
credentialExpires: registration.credentialExpires,
|
|
46611
|
+
claimTokenExpires: registration.claimTokenExpires,
|
|
46612
|
+
apiUrl
|
|
46613
|
+
};
|
|
46614
|
+
await store.saveCredentials(
|
|
46615
|
+
{
|
|
46616
|
+
apiKey: registration.credential,
|
|
46617
|
+
userId: identity.userId,
|
|
46618
|
+
orgId: identity.orgId,
|
|
46619
|
+
apiUrl
|
|
46620
|
+
},
|
|
46621
|
+
claimState
|
|
46622
|
+
);
|
|
46623
|
+
const base = {
|
|
46624
|
+
status: "registered",
|
|
46625
|
+
accountState: "temporary",
|
|
46626
|
+
registrationId: registration.registrationId,
|
|
46627
|
+
userId: identity.userId,
|
|
46628
|
+
credentialExpires: registration.credentialExpires,
|
|
46629
|
+
note: "A temporary account is active: CLI commands work now with limited models and quota. Verifying an email upgrades it to a full account and replaces the stored credential automatically."
|
|
46630
|
+
};
|
|
46631
|
+
if (options.email) {
|
|
46632
|
+
try {
|
|
46633
|
+
const claim = await initiateClaim(registration.claimToken, options.email, apiUrl);
|
|
46634
|
+
await store.saveClaimState({ ...claimState, claimEmail: options.email });
|
|
46635
|
+
printJson({
|
|
46636
|
+
...base,
|
|
46637
|
+
status: "otp_sent",
|
|
46638
|
+
claimEmail: options.email,
|
|
46639
|
+
otpExpiresAt: claim.otpExpiresAt,
|
|
46640
|
+
next: VERIFY_NEXT
|
|
46641
|
+
});
|
|
46642
|
+
return;
|
|
46643
|
+
} catch (error51) {
|
|
46644
|
+
if (error51 instanceof AgentAuthError) {
|
|
46645
|
+
fail({
|
|
46646
|
+
...base,
|
|
46647
|
+
status: "registered_claim_failed",
|
|
46648
|
+
code: error51.code,
|
|
46649
|
+
error: error51.message,
|
|
46650
|
+
next: error51.hint || claimNext(options.email)
|
|
46651
|
+
});
|
|
46652
|
+
}
|
|
46653
|
+
throw error51;
|
|
46654
|
+
}
|
|
46655
|
+
}
|
|
46656
|
+
printJson({ ...base, next: claimNext() });
|
|
46657
|
+
}
|
|
46658
|
+
async function claimAction(email3, options) {
|
|
46659
|
+
const store = new CredentialStore();
|
|
46660
|
+
const claimState = await store.getClaimState();
|
|
46661
|
+
const apiUrl = options.apiUrl || claimState?.apiUrl || (await store.getCredentials())?.apiUrl || getApiUrl();
|
|
46662
|
+
if (!claimState) {
|
|
46663
|
+
const hasCredentials = await store.hasCredentials();
|
|
46664
|
+
fail({
|
|
46665
|
+
status: "error",
|
|
46666
|
+
code: "no_pending_registration",
|
|
46667
|
+
error: hasCredentials ? "Stored credentials are already claimed; there is nothing to claim." : "No registration found.",
|
|
46668
|
+
next: hasCredentials ? "Run: runtype auth whoami --no-tty" : `Run: runtype auth register --email ${email3}`
|
|
46669
|
+
});
|
|
46670
|
+
}
|
|
46671
|
+
try {
|
|
46672
|
+
const claim = await initiateClaim(claimState.claimToken, email3, apiUrl);
|
|
46673
|
+
await store.saveClaimState({ ...claimState, claimEmail: email3 });
|
|
46674
|
+
printJson({
|
|
46675
|
+
status: "otp_sent",
|
|
46676
|
+
registrationId: claim.registrationId,
|
|
46677
|
+
claimEmail: email3,
|
|
46678
|
+
otpExpiresAt: claim.otpExpiresAt,
|
|
46679
|
+
next: VERIFY_NEXT
|
|
46680
|
+
});
|
|
46681
|
+
} catch (error51) {
|
|
46682
|
+
failFromError(error51, `Retry: runtype auth claim ${email3}`);
|
|
46683
|
+
}
|
|
46684
|
+
}
|
|
46685
|
+
async function verifyAction(code, options) {
|
|
46686
|
+
const store = new CredentialStore();
|
|
46687
|
+
const claimState = await store.getClaimState();
|
|
46688
|
+
const apiUrl = options.apiUrl || claimState?.apiUrl || (await store.getCredentials())?.apiUrl || getApiUrl();
|
|
46689
|
+
if (!claimState) {
|
|
46690
|
+
fail({
|
|
46691
|
+
status: "error",
|
|
46692
|
+
code: "no_pending_registration",
|
|
46693
|
+
error: "No claim in progress.",
|
|
46694
|
+
next: "Run: runtype auth register --email <email> first."
|
|
46695
|
+
});
|
|
46696
|
+
}
|
|
46697
|
+
if (!claimState.claimEmail) {
|
|
46698
|
+
fail({
|
|
46699
|
+
status: "error",
|
|
46700
|
+
code: "claim_not_initiated",
|
|
46701
|
+
error: "No verification email has been sent yet, so there is no code to verify.",
|
|
46702
|
+
next: claimNext()
|
|
46703
|
+
});
|
|
46704
|
+
}
|
|
46705
|
+
let completed;
|
|
46706
|
+
try {
|
|
46707
|
+
completed = await completeClaim(claimState.claimToken, code.trim(), apiUrl);
|
|
46708
|
+
} catch (error51) {
|
|
46709
|
+
failFromError(error51);
|
|
46710
|
+
}
|
|
46711
|
+
let identity = { userId: "unknown" };
|
|
46712
|
+
try {
|
|
46713
|
+
identity = await fetchIdentity(completed.credential, apiUrl);
|
|
46714
|
+
} catch {
|
|
46715
|
+
}
|
|
46716
|
+
await store.saveCredentials({
|
|
46717
|
+
apiKey: completed.credential,
|
|
46718
|
+
userId: identity.userId,
|
|
46719
|
+
orgId: identity.orgId,
|
|
46720
|
+
apiUrl
|
|
46721
|
+
});
|
|
46722
|
+
await store.clearClaimState();
|
|
46723
|
+
printJson({
|
|
46724
|
+
status: "authenticated",
|
|
46725
|
+
accountState: "full",
|
|
46726
|
+
registrationId: completed.registrationId,
|
|
46727
|
+
userId: identity.userId,
|
|
46728
|
+
email: identity.email ?? claimState.claimEmail,
|
|
46729
|
+
note: "The account is fully activated and the stored credential was rotated. All limits from the temporary account are removed.",
|
|
46730
|
+
next: "Continue with setup: runtype install-mcp (then confirm with: runtype auth whoami --no-tty)"
|
|
46731
|
+
});
|
|
46732
|
+
}
|
|
46733
|
+
function registerAgentAuthCommands(authCommand2) {
|
|
46734
|
+
authCommand2.command("register").description("Create a Runtype account without a browser (agent signup, step 1 of 2)").option("--email <email>", "Also send the verification email in the same step").option("--force", "Register a new account even if one is stored or pending").option("--api-url <url>", "Custom API URL").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(registerAction);
|
|
46735
|
+
authCommand2.command("claim <email>").description("Email the user a 6-digit code to attach the account to them").option("--api-url <url>", "Custom API URL").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(claimAction);
|
|
46736
|
+
authCommand2.command("verify <code>").description("Complete signup with the 6-digit code from the verification email (step 2 of 2)").option("--api-url <url>", "Custom API URL").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(verifyAction);
|
|
46737
|
+
}
|
|
46738
|
+
|
|
46739
|
+
// src/commands/auth.ts
|
|
46740
|
+
var authCommand = new Command("auth").description("Manage authentication");
|
|
46741
|
+
var NON_TTY_LOGIN_GUIDANCE = {
|
|
46742
|
+
status: "error",
|
|
46743
|
+
code: "tty_required",
|
|
46744
|
+
error: "Browser login needs an interactive terminal, which this environment does not have.",
|
|
46745
|
+
next: [
|
|
46746
|
+
"New account (no browser needed): ask the user for their email, then run: runtype auth register --email <email> \u2014 a 6-digit code is emailed to them; finish with: runtype auth verify <code>",
|
|
46747
|
+
"Existing account: ask the user for an API key from the dashboard (Settings > API keys), then run: runtype auth login --api-key <key>"
|
|
46748
|
+
]
|
|
46749
|
+
};
|
|
46750
|
+
function refuseForcedTtyLogin(options) {
|
|
46751
|
+
if (options.tty === true && process.stdout.isTTY !== true) {
|
|
46182
46752
|
console.error(
|
|
46183
46753
|
JSON.stringify(
|
|
46184
46754
|
{
|
|
46185
|
-
|
|
46186
|
-
error: "Browser login
|
|
46755
|
+
...NON_TTY_LOGIN_GUIDANCE,
|
|
46756
|
+
error: "Browser login needs a real interactive terminal. Forcing --tty from a non-terminal only changes output formatting; the browser OAuth callback still cannot complete here, so the command would hang."
|
|
46187
46757
|
},
|
|
46188
46758
|
null,
|
|
46189
46759
|
2
|
|
@@ -46191,6 +46761,22 @@ authCommand.command("signup").description('Create a new Runtype account (alias f
|
|
|
46191
46761
|
);
|
|
46192
46762
|
process.exit(1);
|
|
46193
46763
|
}
|
|
46764
|
+
return false;
|
|
46765
|
+
}
|
|
46766
|
+
async function getBillingInfo(apiKey, apiUrl) {
|
|
46767
|
+
try {
|
|
46768
|
+
const client = createCliClient(apiKey, apiUrl);
|
|
46769
|
+
return await client.get("/billing/status");
|
|
46770
|
+
} catch {
|
|
46771
|
+
return null;
|
|
46772
|
+
}
|
|
46773
|
+
}
|
|
46774
|
+
authCommand.command("signup").description('Create a new Runtype account (alias for "auth login")').option("--api-url <url>", "Custom API URL").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
|
|
46775
|
+
refuseForcedTtyLogin(options);
|
|
46776
|
+
if (!isTTY(options)) {
|
|
46777
|
+
console.error(JSON.stringify(NON_TTY_LOGIN_GUIDANCE, null, 2));
|
|
46778
|
+
process.exit(1);
|
|
46779
|
+
}
|
|
46194
46780
|
const App = () => {
|
|
46195
46781
|
const [loading, setLoading] = useState2(true);
|
|
46196
46782
|
const [loadingLabel, setLoadingLabel] = useState2("Opening browser for authentication...");
|
|
@@ -46263,7 +46849,11 @@ async function loginAction(options) {
|
|
|
46263
46849
|
});
|
|
46264
46850
|
console.log(
|
|
46265
46851
|
JSON.stringify(
|
|
46266
|
-
{
|
|
46852
|
+
{
|
|
46853
|
+
status: "authenticated",
|
|
46854
|
+
userId: userData.userId,
|
|
46855
|
+
next: "Continue with setup: runtype install-mcp (then confirm with: runtype auth whoami)"
|
|
46856
|
+
},
|
|
46267
46857
|
null,
|
|
46268
46858
|
2
|
|
46269
46859
|
)
|
|
@@ -46321,14 +46911,9 @@ async function loginAction(options) {
|
|
|
46321
46911
|
await waitUntilExit2();
|
|
46322
46912
|
return;
|
|
46323
46913
|
}
|
|
46914
|
+
refuseForcedTtyLogin(options);
|
|
46324
46915
|
if (!isTTY(options)) {
|
|
46325
|
-
console.error(
|
|
46326
|
-
JSON.stringify(
|
|
46327
|
-
{ status: "error", error: "Browser login requires TTY mode. Use --api-key instead." },
|
|
46328
|
-
null,
|
|
46329
|
-
2
|
|
46330
|
-
)
|
|
46331
|
-
);
|
|
46916
|
+
console.error(JSON.stringify(NON_TTY_LOGIN_GUIDANCE, null, 2));
|
|
46332
46917
|
process.exit(1);
|
|
46333
46918
|
}
|
|
46334
46919
|
const App = () => {
|
|
@@ -46393,17 +46978,34 @@ authCommand.command("status").description("Show authentication status").option("
|
|
|
46393
46978
|
try {
|
|
46394
46979
|
const hasCredentials = await store.hasCredentials();
|
|
46395
46980
|
if (!hasCredentials) {
|
|
46396
|
-
console.log(
|
|
46981
|
+
console.log(
|
|
46982
|
+
JSON.stringify(
|
|
46983
|
+
{
|
|
46984
|
+
status: "unauthenticated",
|
|
46985
|
+
next: "New account: runtype auth register --email <email>. Existing account: runtype auth login --api-key <key>."
|
|
46986
|
+
},
|
|
46987
|
+
null,
|
|
46988
|
+
2
|
|
46989
|
+
)
|
|
46990
|
+
);
|
|
46397
46991
|
return;
|
|
46398
46992
|
}
|
|
46399
46993
|
const credentials = await store.getCredentials();
|
|
46994
|
+
const claimState = await store.getClaimState();
|
|
46400
46995
|
console.log(
|
|
46401
46996
|
JSON.stringify(
|
|
46402
46997
|
{
|
|
46403
46998
|
status: "authenticated",
|
|
46999
|
+
accountState: claimState ? "temporary" : "full",
|
|
46404
47000
|
userId: credentials?.userId,
|
|
46405
47001
|
apiUrl: credentials?.apiUrl || "default",
|
|
46406
|
-
orgId: credentials?.orgId || null
|
|
47002
|
+
orgId: credentials?.orgId || null,
|
|
47003
|
+
...claimState ? {
|
|
47004
|
+
registrationId: claimState.registrationId,
|
|
47005
|
+
credentialExpires: claimState.credentialExpires,
|
|
47006
|
+
claimEmail: claimState.claimEmail ?? null,
|
|
47007
|
+
next: claimState.claimEmail ? "Finish signup: ask the user for the 6-digit code from their email, then run: runtype auth verify <code>" : "Finish signup: ask the user for their email, then run: runtype auth claim <email>"
|
|
47008
|
+
} : {}
|
|
46407
47009
|
},
|
|
46408
47010
|
null,
|
|
46409
47011
|
2
|
|
@@ -46486,6 +47088,7 @@ authCommand.command("export-key").description("Print the stored API key to stdou
|
|
|
46486
47088
|
}
|
|
46487
47089
|
process.stdout.write(apiKey);
|
|
46488
47090
|
});
|
|
47091
|
+
registerAgentAuthCommands(authCommand);
|
|
46489
47092
|
authCommand.command("logout").description("Remove stored credentials").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
|
|
46490
47093
|
const store = new CredentialStore();
|
|
46491
47094
|
if (!isTTY(options)) {
|
|
@@ -46548,7 +47151,7 @@ authCommand.command("whoami").description("Display current user information").op
|
|
|
46548
47151
|
if (!isTTY(options) || options.json) {
|
|
46549
47152
|
console.log(JSON.stringify({ status: "unauthenticated" }, null, 2));
|
|
46550
47153
|
} else {
|
|
46551
|
-
console.log(
|
|
47154
|
+
console.log(chalk2.yellow("Not logged in"));
|
|
46552
47155
|
console.log("Run: runtype auth login");
|
|
46553
47156
|
}
|
|
46554
47157
|
return;
|
|
@@ -46640,17 +47243,17 @@ import { useState as useState3, useEffect as useEffect4 } from "react";
|
|
|
46640
47243
|
|
|
46641
47244
|
// src/lib/file-utils.ts
|
|
46642
47245
|
import { readFileSync as readFileSync3 } from "fs";
|
|
46643
|
-
import
|
|
47246
|
+
import chalk3 from "chalk";
|
|
46644
47247
|
function parseJsonObject(raw, label) {
|
|
46645
47248
|
let parsed;
|
|
46646
47249
|
try {
|
|
46647
47250
|
parsed = JSON.parse(raw);
|
|
46648
47251
|
} catch {
|
|
46649
|
-
console.error(
|
|
47252
|
+
console.error(chalk3.red(`Invalid JSON in ${label}`));
|
|
46650
47253
|
process.exit(1);
|
|
46651
47254
|
}
|
|
46652
47255
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
46653
|
-
console.error(
|
|
47256
|
+
console.error(chalk3.red(`${label} must be a JSON object`));
|
|
46654
47257
|
process.exit(1);
|
|
46655
47258
|
}
|
|
46656
47259
|
return parsed;
|
|
@@ -46661,7 +47264,7 @@ function readJsonFile(path20, opts = {}) {
|
|
|
46661
47264
|
try {
|
|
46662
47265
|
raw = readFileSync3(path20, "utf-8");
|
|
46663
47266
|
} catch {
|
|
46664
|
-
console.error(
|
|
47267
|
+
console.error(chalk3.red(`Failed to read ${label}: ${path20}`));
|
|
46665
47268
|
process.exit(1);
|
|
46666
47269
|
}
|
|
46667
47270
|
const obj = parseJsonObject(raw, label);
|
|
@@ -46675,11 +47278,11 @@ function readJsonFile(path20, opts = {}) {
|
|
|
46675
47278
|
}
|
|
46676
47279
|
function resolveJsonPayload(inline, fromFile, label) {
|
|
46677
47280
|
if (inline !== void 0 && fromFile !== void 0) {
|
|
46678
|
-
console.error(
|
|
47281
|
+
console.error(chalk3.red(`Error: provide only one of inline JSON or --from-file for ${label}`));
|
|
46679
47282
|
process.exit(1);
|
|
46680
47283
|
}
|
|
46681
47284
|
if (inline === void 0 && fromFile === void 0) {
|
|
46682
|
-
console.error(
|
|
47285
|
+
console.error(chalk3.red(`Error: ${label} is required \u2014 pass inline JSON or --from-file <path>`));
|
|
46683
47286
|
process.exit(1);
|
|
46684
47287
|
}
|
|
46685
47288
|
if (fromFile !== void 0) {
|
|
@@ -46696,7 +47299,7 @@ import {
|
|
|
46696
47299
|
// src/lib/ensure-auth.ts
|
|
46697
47300
|
init_credential_store();
|
|
46698
47301
|
import readline from "readline";
|
|
46699
|
-
import
|
|
47302
|
+
import chalk4 from "chalk";
|
|
46700
47303
|
async function promptConfirm(message, options) {
|
|
46701
47304
|
const defaultYes = options?.default !== false;
|
|
46702
47305
|
const hint = defaultYes ? "Y/n" : "y/N";
|
|
@@ -46706,7 +47309,7 @@ async function promptConfirm(message, options) {
|
|
|
46706
47309
|
terminal: true
|
|
46707
47310
|
});
|
|
46708
47311
|
return new Promise((resolve13) => {
|
|
46709
|
-
rl.question(
|
|
47312
|
+
rl.question(chalk4.cyan(`${message} (${hint}): `), (answer) => {
|
|
46710
47313
|
rl.close();
|
|
46711
47314
|
const trimmed2 = answer.trim().toLowerCase();
|
|
46712
47315
|
if (trimmed2 === "") {
|
|
@@ -46735,9 +47338,9 @@ async function ensureAuth(options) {
|
|
|
46735
47338
|
return apiKey;
|
|
46736
47339
|
}
|
|
46737
47340
|
if (options?.interactive === false) {
|
|
46738
|
-
console.error(
|
|
47341
|
+
console.error(chalk4.yellow("\nAuthentication required."));
|
|
46739
47342
|
console.error(
|
|
46740
|
-
|
|
47343
|
+
chalk4.gray(
|
|
46741
47344
|
'Run "runtype auth login" first or set RUNTYPE_API_KEY before reading command input from stdin.'
|
|
46742
47345
|
)
|
|
46743
47346
|
);
|
|
@@ -46746,10 +47349,10 @@ async function ensureAuth(options) {
|
|
|
46746
47349
|
}
|
|
46747
47350
|
return null;
|
|
46748
47351
|
}
|
|
46749
|
-
console.log(
|
|
47352
|
+
console.log(chalk4.yellow("\nAuthentication required."));
|
|
46750
47353
|
const shouldLogin = await promptConfirm("Would you like to log in now?", { default: true });
|
|
46751
47354
|
if (!shouldLogin) {
|
|
46752
|
-
console.log(
|
|
47355
|
+
console.log(chalk4.gray(`Run "runtype auth login" when you're ready.`));
|
|
46753
47356
|
if (options?.exitOnFailure !== false) {
|
|
46754
47357
|
process.exit(1);
|
|
46755
47358
|
}
|
|
@@ -46758,100 +47361,37 @@ async function ensureAuth(options) {
|
|
|
46758
47361
|
return handleBrowserLogin(store, options?.apiUrl);
|
|
46759
47362
|
}
|
|
46760
47363
|
async function handleBrowserLogin(store, apiUrl) {
|
|
46761
|
-
console.log(
|
|
47364
|
+
console.log(chalk4.gray("Opening browser for authentication..."));
|
|
46762
47365
|
try {
|
|
46763
47366
|
const oauth = new OAuthManager({
|
|
46764
47367
|
clerkPublishableKey: getClerkPublishableKey(),
|
|
46765
47368
|
dashboardUrl: getDashboardUrl()
|
|
46766
47369
|
});
|
|
46767
|
-
console.log(
|
|
47370
|
+
console.log(chalk4.gray("Waiting for browser authentication..."));
|
|
46768
47371
|
const sessionToken = await oauth.authenticate("sign-in");
|
|
46769
|
-
console.log(
|
|
47372
|
+
console.log(chalk4.gray("Getting API key..."));
|
|
46770
47373
|
const apiKeyManager = new ApiKeyManager();
|
|
46771
47374
|
const { key, userId, orgId } = await apiKeyManager.exchangeSessionForApiKey(
|
|
46772
47375
|
sessionToken,
|
|
46773
47376
|
apiUrl || getApiUrl()
|
|
46774
47377
|
);
|
|
46775
|
-
console.log(
|
|
47378
|
+
console.log(chalk4.gray("Storing credentials..."));
|
|
46776
47379
|
await store.saveCredentials({
|
|
46777
47380
|
apiKey: key,
|
|
46778
47381
|
userId,
|
|
46779
47382
|
orgId,
|
|
46780
47383
|
apiUrl: apiUrl || getApiUrl()
|
|
46781
47384
|
});
|
|
46782
|
-
console.log(
|
|
47385
|
+
console.log(chalk4.green("Logged in successfully!"));
|
|
46783
47386
|
return key;
|
|
46784
47387
|
} catch (error51) {
|
|
46785
47388
|
const message = error51 instanceof Error ? error51.message : "Unknown error";
|
|
46786
|
-
console.log(
|
|
46787
|
-
console.error(
|
|
47389
|
+
console.log(chalk4.red("Login failed"));
|
|
47390
|
+
console.error(chalk4.red(message));
|
|
46788
47391
|
return null;
|
|
46789
47392
|
}
|
|
46790
47393
|
}
|
|
46791
47394
|
|
|
46792
|
-
// src/lib/output.ts
|
|
46793
|
-
import chalk4 from "chalk";
|
|
46794
|
-
function printJson(data) {
|
|
46795
|
-
console.log(JSON.stringify(data, null, 2));
|
|
46796
|
-
}
|
|
46797
|
-
function printList(items, options) {
|
|
46798
|
-
console.log(chalk4.cyan(`${options.title}:`));
|
|
46799
|
-
if (items.length === 0) {
|
|
46800
|
-
console.log(chalk4.gray(` ${options.emptyMessage || "None found"}`));
|
|
46801
|
-
return;
|
|
46802
|
-
}
|
|
46803
|
-
for (const item of items) {
|
|
46804
|
-
const parts = [];
|
|
46805
|
-
for (const col of options.columns) {
|
|
46806
|
-
const value = item[col.key];
|
|
46807
|
-
if (value === void 0 || value === null) continue;
|
|
46808
|
-
const str = String(value);
|
|
46809
|
-
const colorFn = col.color ? chalk4[col.color] : (s) => s;
|
|
46810
|
-
if (col.label) {
|
|
46811
|
-
parts.push(`${col.label}: ${colorFn(str)}`);
|
|
46812
|
-
} else {
|
|
46813
|
-
parts.push(colorFn(str));
|
|
46814
|
-
}
|
|
46815
|
-
}
|
|
46816
|
-
console.log(` ${parts.join(" - ")}`);
|
|
46817
|
-
}
|
|
46818
|
-
if (options.total !== void 0) {
|
|
46819
|
-
console.log(chalk4.dim(`
|
|
46820
|
-
Total: ${options.total}`));
|
|
46821
|
-
}
|
|
46822
|
-
}
|
|
46823
|
-
function printDetail(title, fields) {
|
|
46824
|
-
console.log(chalk4.cyan(`${title}:`));
|
|
46825
|
-
for (const field of fields) {
|
|
46826
|
-
if (field.value === void 0 || field.value === null) continue;
|
|
46827
|
-
const str = typeof field.value === "object" ? JSON.stringify(field.value) : String(field.value);
|
|
46828
|
-
console.log(` ${chalk4.gray(field.label + ":")} ${str}`);
|
|
46829
|
-
}
|
|
46830
|
-
}
|
|
46831
|
-
function getTotalCount(pagination) {
|
|
46832
|
-
return pagination?.totalCount ?? pagination?.total ?? void 0;
|
|
46833
|
-
}
|
|
46834
|
-
function buildListParams(options, extra) {
|
|
46835
|
-
const params = {};
|
|
46836
|
-
if (options.limit) params.limit = options.limit;
|
|
46837
|
-
if (options.cursor) params.cursor = options.cursor;
|
|
46838
|
-
if (extra) {
|
|
46839
|
-
for (const [key, value] of Object.entries(extra)) {
|
|
46840
|
-
if (value !== void 0) params[key] = value;
|
|
46841
|
-
}
|
|
46842
|
-
}
|
|
46843
|
-
return params;
|
|
46844
|
-
}
|
|
46845
|
-
function printNextCursorHint(commandPath, pagination) {
|
|
46846
|
-
const hasMore = pagination?.hasMore ?? pagination?.hasNextPage ?? false;
|
|
46847
|
-
const nextCursor = pagination?.nextCursor !== void 0 ? pagination.nextCursor : pagination?.cursor ?? null;
|
|
46848
|
-
if (!hasMore || !nextCursor) return;
|
|
46849
|
-
console.log(
|
|
46850
|
-
chalk4.yellow("\n More results available \u2014 fetch the next page with:") + chalk4.dim(`
|
|
46851
|
-
${commandPath} --cursor ${nextCursor}`)
|
|
46852
|
-
);
|
|
46853
|
-
}
|
|
46854
|
-
|
|
46855
47395
|
// src/commands/flows.ts
|
|
46856
47396
|
function flowsListParams(options) {
|
|
46857
47397
|
return {
|
|
@@ -49356,8 +49896,8 @@ configCommand.command("get [key]").description("Get configuration value").action
|
|
|
49356
49896
|
const allConfig = config2.store;
|
|
49357
49897
|
if (Object.keys(allConfig).length > 0) {
|
|
49358
49898
|
console.log(chalk10.cyan("Current Configuration:"));
|
|
49359
|
-
for (const [
|
|
49360
|
-
console.log(` ${chalk10.green(
|
|
49899
|
+
for (const [k, v2] of Object.entries(allConfig)) {
|
|
49900
|
+
console.log(` ${chalk10.green(k)}: ${v2}`);
|
|
49361
49901
|
}
|
|
49362
49902
|
} else {
|
|
49363
49903
|
console.log(chalk10.gray("No configuration set"));
|
|
@@ -50757,7 +51297,7 @@ Keys (${keys.length}):`));
|
|
|
50757
51297
|
const itemSummary = items.length === 0 ? "No items" : items.map(
|
|
50758
51298
|
(i) => `${i.exposedName || i.capabilityName || i.capabilityId}${i.isEntryPoint ? " (entry point)" : ""}`
|
|
50759
51299
|
).join("\n");
|
|
50760
|
-
const keySummary = keys.length === 0 ? "No keys" : keys.map((
|
|
51300
|
+
const keySummary = keys.length === 0 ? "No keys" : keys.map((k) => `${k.name ?? "(unnamed)"} ${k.keyPrefix ?? ""}`.trim()).join("\n");
|
|
50761
51301
|
setResultNode(
|
|
50762
51302
|
React10.createElement(EntityCard, {
|
|
50763
51303
|
fields: [
|
|
@@ -50936,7 +51476,7 @@ logsCommand.command("stats").description("Aggregate log stats: totals, counts by
|
|
|
50936
51476
|
const formatCounts = (counts) => {
|
|
50937
51477
|
const entries = Object.entries(counts);
|
|
50938
51478
|
if (entries.length === 0) return "(none)";
|
|
50939
|
-
return entries.map(([
|
|
51479
|
+
return entries.map(([k, v2]) => `${k}=${v2}`).join(", ");
|
|
50940
51480
|
};
|
|
50941
51481
|
if (!isTTY(options) || options.json) {
|
|
50942
51482
|
try {
|
|
@@ -52256,8 +52796,8 @@ var dispatchCommand = new Command15("dispatch").description("Execute a flow or a
|
|
|
52256
52796
|
}
|
|
52257
52797
|
if (options.variable && options.variable.length > 0) {
|
|
52258
52798
|
const variables = {};
|
|
52259
|
-
for (const
|
|
52260
|
-
const [key, ...rest] =
|
|
52799
|
+
for (const v2 of options.variable) {
|
|
52800
|
+
const [key, ...rest] = v2.split("=");
|
|
52261
52801
|
variables[key] = rest.join("=");
|
|
52262
52802
|
}
|
|
52263
52803
|
payload.variables = variables;
|
|
@@ -52869,7 +53409,7 @@ function buildToolPreview(params) {
|
|
|
52869
53409
|
function pushRawEvent(eventsRef, type, data, writer, listData) {
|
|
52870
53410
|
const event = { timestamp: Date.now(), type, data, ...listData ? { listData } : {} };
|
|
52871
53411
|
if (writer?.current) {
|
|
52872
|
-
const
|
|
53412
|
+
const w2 = writer.current;
|
|
52873
53413
|
const jsonlEvent = {
|
|
52874
53414
|
timestamp: event.timestamp,
|
|
52875
53415
|
type: event.type,
|
|
@@ -52877,7 +53417,7 @@ function pushRawEvent(eventsRef, type, data, writer, listData) {
|
|
|
52877
53417
|
};
|
|
52878
53418
|
queueMicrotask(() => {
|
|
52879
53419
|
try {
|
|
52880
|
-
|
|
53420
|
+
w2(jsonlEvent);
|
|
52881
53421
|
} catch {
|
|
52882
53422
|
}
|
|
52883
53423
|
});
|
|
@@ -56106,7 +56646,7 @@ function BlinkingTextInput({
|
|
|
56106
56646
|
return;
|
|
56107
56647
|
}
|
|
56108
56648
|
blinkRef.current = setInterval(() => {
|
|
56109
|
-
setBlinkVisible((
|
|
56649
|
+
setBlinkVisible((v2) => !v2);
|
|
56110
56650
|
}, CURSOR_BLINK_MS);
|
|
56111
56651
|
return () => {
|
|
56112
56652
|
if (blinkRef.current) {
|
|
@@ -56646,8 +57186,8 @@ function TextArea({
|
|
|
56646
57186
|
const separator = theme21.separator ?? " \xB7 ";
|
|
56647
57187
|
const [lines, setLines] = useState24(() => splitLines(defaultValue));
|
|
56648
57188
|
const [cursor, setCursor] = useState24(() => {
|
|
56649
|
-
const
|
|
56650
|
-
return { line:
|
|
57189
|
+
const l = splitLines(defaultValue);
|
|
57190
|
+
return { line: l.length - 1, col: l[l.length - 1].length };
|
|
56651
57191
|
});
|
|
56652
57192
|
const [scrollOffset, setScrollOffset] = useState24(0);
|
|
56653
57193
|
const [blinkVisible, setBlinkVisible] = useState24(true);
|
|
@@ -56658,7 +57198,7 @@ function TextArea({
|
|
|
56658
57198
|
cursorRef.current = cursor;
|
|
56659
57199
|
useEffect21(() => {
|
|
56660
57200
|
blinkRef.current = setInterval(() => {
|
|
56661
|
-
setBlinkVisible((
|
|
57201
|
+
setBlinkVisible((v2) => !v2);
|
|
56662
57202
|
}, CURSOR_BLINK_MS);
|
|
56663
57203
|
return () => {
|
|
56664
57204
|
if (blinkRef.current) {
|
|
@@ -57616,11 +58156,11 @@ function compactRawStreamEventForCopy(event) {
|
|
|
57616
58156
|
data = JSON.parse(JSON.stringify(event.listData, stringCompactionReplacer));
|
|
57617
58157
|
} else {
|
|
57618
58158
|
data = {};
|
|
57619
|
-
for (const [
|
|
57620
|
-
if (STREAM_EVENT_HEAVY_KEYS.has(
|
|
57621
|
-
data[
|
|
58159
|
+
for (const [k, v2] of Object.entries(event.data)) {
|
|
58160
|
+
if (STREAM_EVENT_HEAVY_KEYS.has(k)) {
|
|
58161
|
+
data[k] = compactHeavyField(v2);
|
|
57622
58162
|
} else {
|
|
57623
|
-
data[
|
|
58163
|
+
data[k] = compactJsonLike(v2);
|
|
57624
58164
|
}
|
|
57625
58165
|
}
|
|
57626
58166
|
}
|
|
@@ -65461,10 +66001,10 @@ modelsCommand.command("available").description("List all available models groupe
|
|
|
65461
66001
|
const group = item;
|
|
65462
66002
|
return React18.createElement(EntityCard, {
|
|
65463
66003
|
title: `${group.provider} / ${group.baseModel}`,
|
|
65464
|
-
fields: group.variants.map((
|
|
65465
|
-
label:
|
|
65466
|
-
value:
|
|
65467
|
-
color:
|
|
66004
|
+
fields: group.variants.map((v2) => ({
|
|
66005
|
+
label: v2.modelId,
|
|
66006
|
+
value: v2.configured ? "configured" : "available",
|
|
66007
|
+
color: v2.configured ? "green" : void 0
|
|
65468
66008
|
}))
|
|
65469
66009
|
});
|
|
65470
66010
|
},
|
|
@@ -66785,10 +67325,10 @@ apiKeysCommand.command("list").description("List your API keys").option("--json"
|
|
|
66785
67325
|
total,
|
|
66786
67326
|
emptyMessage: "No API keys found",
|
|
66787
67327
|
renderCard: (item) => {
|
|
66788
|
-
const
|
|
66789
|
-
const prefix =
|
|
66790
|
-
const lastUsed =
|
|
66791
|
-
return React21.createElement(Text35, null, ` ${
|
|
67328
|
+
const k = item;
|
|
67329
|
+
const prefix = k.prefix ? ` (${k.prefix}...)` : "";
|
|
67330
|
+
const lastUsed = k.lastUsedAt ? ` last used: ${k.lastUsedAt}` : "";
|
|
67331
|
+
return React21.createElement(Text35, null, ` ${k.id} ${k.name}${prefix}${lastUsed}`);
|
|
66792
67332
|
}
|
|
66793
67333
|
});
|
|
66794
67334
|
};
|
|
@@ -67348,8 +67888,8 @@ clientTokensCommand.command("create").description("Create a new client token").r
|
|
|
67348
67888
|
console.log(` Token: ${chalk30.yellow(data.token)}`);
|
|
67349
67889
|
if (data.warnings?.length > 0) {
|
|
67350
67890
|
console.log("");
|
|
67351
|
-
for (const
|
|
67352
|
-
console.log(chalk30.yellow(` \u26A0 ${
|
|
67891
|
+
for (const w2 of data.warnings) {
|
|
67892
|
+
console.log(chalk30.yellow(` \u26A0 ${w2.message}`));
|
|
67353
67893
|
}
|
|
67354
67894
|
}
|
|
67355
67895
|
}
|
|
@@ -67377,8 +67917,8 @@ clientTokensCommand.command("create").description("Create a new client token").r
|
|
|
67377
67917
|
{ label: "Token", value: data.token, color: "yellow" }
|
|
67378
67918
|
];
|
|
67379
67919
|
if (data.warnings?.length > 0) {
|
|
67380
|
-
for (const
|
|
67381
|
-
fields.push({ label: "Warning", value:
|
|
67920
|
+
for (const w2 of data.warnings) {
|
|
67921
|
+
fields.push({ label: "Warning", value: w2.message, color: "yellow" });
|
|
67382
67922
|
}
|
|
67383
67923
|
}
|
|
67384
67924
|
setResultNode(React22.createElement(EntityCard, { fields }));
|
|
@@ -67569,16 +68109,16 @@ import { execFileSync } from "child_process";
|
|
|
67569
68109
|
// src/lib/persona-init.ts
|
|
67570
68110
|
init_credential_store();
|
|
67571
68111
|
|
|
67572
|
-
// ../../node_modules/.pnpm/@runtypelabs+persona@4.
|
|
67573
|
-
var
|
|
67574
|
-
var c =
|
|
68112
|
+
// ../../node_modules/.pnpm/@runtypelabs+persona@4.8.0/node_modules/@runtypelabs/persona/dist/codegen.js
|
|
68113
|
+
var w = "4.8.0";
|
|
68114
|
+
var c = w;
|
|
67575
68115
|
function u(e) {
|
|
67576
|
-
if (e !== void 0) return typeof e == "string" ? e : Array.isArray(e) ? `[${e.map((
|
|
68116
|
+
if (e !== void 0) return typeof e == "string" ? e : Array.isArray(e) ? `[${e.map((i) => i.toString()).join(", ")}]` : e.toString();
|
|
67577
68117
|
}
|
|
67578
|
-
function
|
|
68118
|
+
function P(e) {
|
|
67579
68119
|
if (e) return { getHeaders: u(e.getHeaders), onFeedback: u(e.onFeedback), onCopy: u(e.onCopy), requestMiddleware: u(e.requestMiddleware), actionHandlers: u(e.actionHandlers), actionParsers: u(e.actionParsers), postprocessMessage: u(e.postprocessMessage), contextProviders: u(e.contextProviders), streamParser: u(e.streamParser) };
|
|
67580
68120
|
}
|
|
67581
|
-
var
|
|
68121
|
+
var S = `({ text, message }: any) => {
|
|
67582
68122
|
const jsonSource = (message as any).rawContent || text || message.content;
|
|
67583
68123
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
67584
68124
|
let cleanJson = jsonSource
|
|
@@ -67592,7 +68132,7 @@ var x = `({ text, message }: any) => {
|
|
|
67592
68132
|
} catch (e) { return null; }
|
|
67593
68133
|
return null;
|
|
67594
68134
|
}`;
|
|
67595
|
-
var
|
|
68135
|
+
var x = `function(ctx) {
|
|
67596
68136
|
var jsonSource = ctx.message.rawContent || ctx.text || ctx.message.content;
|
|
67597
68137
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
67598
68138
|
var cleanJson = jsonSource
|
|
@@ -67606,7 +68146,7 @@ var A = `function(ctx) {
|
|
|
67606
68146
|
} catch (e) { return null; }
|
|
67607
68147
|
return null;
|
|
67608
68148
|
}`;
|
|
67609
|
-
var
|
|
68149
|
+
var A = `(action: any, context: any) => {
|
|
67610
68150
|
if (action.type !== 'nav_then_click') return;
|
|
67611
68151
|
const payload = action.payload || action.raw || {};
|
|
67612
68152
|
const url = payload?.page;
|
|
@@ -67624,7 +68164,7 @@ var j = `(action: any, context: any) => {
|
|
|
67624
68164
|
window.location.href = targetUrl;
|
|
67625
68165
|
return { handled: true, displayText: text };
|
|
67626
68166
|
}`;
|
|
67627
|
-
var
|
|
68167
|
+
var j = `function(action, context) {
|
|
67628
68168
|
if (action.type !== 'nav_then_click') return;
|
|
67629
68169
|
var payload = action.payload || action.raw || {};
|
|
67630
68170
|
var url = payload.page;
|
|
@@ -67642,136 +68182,134 @@ var O = `function(action, context) {
|
|
|
67642
68182
|
window.location.href = targetUrl;
|
|
67643
68183
|
return { handled: true, displayText: text };
|
|
67644
68184
|
}`;
|
|
67645
|
-
var
|
|
68185
|
+
var v = `(parsed: any) => {
|
|
67646
68186
|
if (!parsed || typeof parsed !== 'object') return null;
|
|
67647
68187
|
if (parsed.action === 'nav_then_click') return 'Navigating...';
|
|
67648
68188
|
if (parsed.action === 'message') return parsed.text || '';
|
|
67649
68189
|
if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
|
|
67650
68190
|
return parsed.text || null;
|
|
67651
68191
|
}`;
|
|
67652
|
-
var
|
|
68192
|
+
var I = `function(parsed) {
|
|
67653
68193
|
if (!parsed || typeof parsed !== 'object') return null;
|
|
67654
68194
|
if (parsed.action === 'nav_then_click') return 'Navigating...';
|
|
67655
68195
|
if (parsed.action === 'message') return parsed.text || '';
|
|
67656
68196
|
if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
|
|
67657
68197
|
return parsed.text || null;
|
|
67658
68198
|
}`;
|
|
67659
|
-
function
|
|
68199
|
+
function _(e) {
|
|
67660
68200
|
if (!e) return null;
|
|
67661
|
-
let
|
|
67662
|
-
return
|
|
68201
|
+
let i = e.toString();
|
|
68202
|
+
return i.includes("createJsonStreamParser") || i.includes("partial-json") ? "json" : i.includes("createRegexJsonParser") || i.includes("regex") ? "regex-json" : i.includes("createXmlParser") || i.includes("<text>") ? "xml" : null;
|
|
67663
68203
|
}
|
|
67664
|
-
function
|
|
67665
|
-
|
|
67666
|
-
return (n = (r = e.parserType) != null ? r : M(e.streamParser)) != null ? n : "plain";
|
|
68204
|
+
function g(e) {
|
|
68205
|
+
return e.parserType ?? _(e.streamParser) ?? "plain";
|
|
67667
68206
|
}
|
|
67668
|
-
function m(e,
|
|
68207
|
+
function m(e, i) {
|
|
67669
68208
|
let n = [];
|
|
67670
|
-
return e.toolCall && (n.push(`${
|
|
67671
|
-
typeof o == "string" && n.push(`${
|
|
67672
|
-
}), n.push(`${
|
|
68209
|
+
return e.toolCall && (n.push(`${i}toolCall: {`), Object.entries(e.toolCall).forEach(([s, o]) => {
|
|
68210
|
+
typeof o == "string" && n.push(`${i} ${s}: "${o}",`);
|
|
68211
|
+
}), n.push(`${i}},`)), n;
|
|
67673
68212
|
}
|
|
67674
|
-
function f(e,
|
|
67675
|
-
let s = [], o = e.messageActions && Object.entries(e.messageActions).some(([
|
|
67676
|
-
return (o || t) && (s.push(`${
|
|
67677
|
-
|
|
67678
|
-
}), n
|
|
68213
|
+
function f(e, i, n) {
|
|
68214
|
+
let s = [], o = e.messageActions && Object.entries(e.messageActions).some(([r, a]) => r !== "onFeedback" && r !== "onCopy" && a !== void 0), t = n?.onFeedback || n?.onCopy;
|
|
68215
|
+
return (o || t) && (s.push(`${i}messageActions: {`), e.messageActions && Object.entries(e.messageActions).forEach(([r, a]) => {
|
|
68216
|
+
r === "onFeedback" || r === "onCopy" || (typeof a == "string" ? s.push(`${i} ${r}: "${a}",`) : typeof a == "boolean" && s.push(`${i} ${r}: ${a},`));
|
|
68217
|
+
}), n?.onFeedback && s.push(`${i} onFeedback: ${n.onFeedback},`), n?.onCopy && s.push(`${i} onCopy: ${n.onCopy},`), s.push(`${i}},`)), s;
|
|
67679
68218
|
}
|
|
67680
|
-
function y(e,
|
|
68219
|
+
function y(e, i) {
|
|
67681
68220
|
let n = [];
|
|
67682
68221
|
if (e.markdown) {
|
|
67683
68222
|
let s = e.markdown.options && Object.keys(e.markdown.options).length > 0, o = e.markdown.disableDefaultStyles !== void 0;
|
|
67684
|
-
(s || o) && (n.push(`${
|
|
67685
|
-
typeof
|
|
67686
|
-
}), n.push(`${
|
|
68223
|
+
(s || o) && (n.push(`${i}markdown: {`), s && (n.push(`${i} options: {`), Object.entries(e.markdown.options).forEach(([t, r]) => {
|
|
68224
|
+
typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`);
|
|
68225
|
+
}), n.push(`${i} },`)), o && n.push(`${i} disableDefaultStyles: ${e.markdown.disableDefaultStyles},`), n.push(`${i}},`));
|
|
67687
68226
|
}
|
|
67688
68227
|
return n;
|
|
67689
68228
|
}
|
|
67690
|
-
function C(e,
|
|
68229
|
+
function C(e, i) {
|
|
67691
68230
|
let n = [];
|
|
67692
68231
|
if (e.layout) {
|
|
67693
68232
|
let s = e.layout.header && Object.keys(e.layout.header).some((t) => t !== "render"), o = e.layout.messages && Object.keys(e.layout.messages).some((t) => t !== "renderUserMessage" && t !== "renderAssistantMessage");
|
|
67694
|
-
(s || o) && (n.push(`${
|
|
67695
|
-
t !== "render" && (typeof
|
|
67696
|
-
}), n.push(`${
|
|
67697
|
-
t === "renderUserMessage" || t === "renderAssistantMessage" || (t === "avatar" && typeof
|
|
67698
|
-
typeof p == "string" ? n.push(`${
|
|
67699
|
-
}), n.push(`${
|
|
67700
|
-
p !== "format" && (typeof
|
|
67701
|
-
}), n.push(`${
|
|
67702
|
-
}), n.push(`${
|
|
68233
|
+
(s || o) && (n.push(`${i}layout: {`), s && (n.push(`${i} header: {`), Object.entries(e.layout.header).forEach(([t, r]) => {
|
|
68234
|
+
t !== "render" && (typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`));
|
|
68235
|
+
}), n.push(`${i} },`)), o && (n.push(`${i} messages: {`), Object.entries(e.layout.messages).forEach(([t, r]) => {
|
|
68236
|
+
t === "renderUserMessage" || t === "renderAssistantMessage" || (t === "avatar" && typeof r == "object" && r !== null ? (n.push(`${i} avatar: {`), Object.entries(r).forEach(([a, p]) => {
|
|
68237
|
+
typeof p == "string" ? n.push(`${i} ${a}: "${p}",`) : typeof p == "boolean" && n.push(`${i} ${a}: ${p},`);
|
|
68238
|
+
}), n.push(`${i} },`)) : t === "timestamp" && typeof r == "object" && r !== null ? Object.entries(r).some(([p]) => p !== "format") && (n.push(`${i} timestamp: {`), Object.entries(r).forEach(([p, l]) => {
|
|
68239
|
+
p !== "format" && (typeof l == "string" ? n.push(`${i} ${p}: "${l}",`) : typeof l == "boolean" && n.push(`${i} ${p}: ${l},`));
|
|
68240
|
+
}), n.push(`${i} },`)) : typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`));
|
|
68241
|
+
}), n.push(`${i} },`)), n.push(`${i}},`));
|
|
67703
68242
|
}
|
|
67704
68243
|
return n;
|
|
67705
68244
|
}
|
|
67706
|
-
function $(e,
|
|
68245
|
+
function $(e, i) {
|
|
67707
68246
|
let n = [];
|
|
67708
|
-
return e && (e.getHeaders && n.push(`${
|
|
68247
|
+
return e && (e.getHeaders && n.push(`${i}getHeaders: ${e.getHeaders},`), e.requestMiddleware && n.push(`${i}requestMiddleware: ${e.requestMiddleware},`), e.actionParsers && n.push(`${i}actionParsers: ${e.actionParsers},`), e.actionHandlers && n.push(`${i}actionHandlers: ${e.actionHandlers},`), e.contextProviders && n.push(`${i}contextProviders: ${e.contextProviders},`), e.streamParser && n.push(`${i}streamParser: ${e.streamParser},`)), n;
|
|
67709
68248
|
}
|
|
67710
|
-
function
|
|
67711
|
-
Object.entries(
|
|
68249
|
+
function O(e, i, n) {
|
|
68250
|
+
Object.entries(i).forEach(([s, o]) => {
|
|
67712
68251
|
if (!(o === void 0 || typeof o == "function")) {
|
|
67713
68252
|
if (Array.isArray(o)) {
|
|
67714
68253
|
e.push(`${n}${s}: ${JSON.stringify(o)},`);
|
|
67715
68254
|
return;
|
|
67716
68255
|
}
|
|
67717
68256
|
if (o && typeof o == "object") {
|
|
67718
|
-
e.push(`${n}${s}: {`),
|
|
68257
|
+
e.push(`${n}${s}: {`), O(e, o, `${n} `), e.push(`${n}},`);
|
|
67719
68258
|
return;
|
|
67720
68259
|
}
|
|
67721
68260
|
e.push(`${n}${s}: ${JSON.stringify(o)},`);
|
|
67722
68261
|
}
|
|
67723
68262
|
});
|
|
67724
68263
|
}
|
|
67725
|
-
function
|
|
67726
|
-
n && (e.push(`${s}${
|
|
68264
|
+
function d(e, i, n, s) {
|
|
68265
|
+
n && (e.push(`${s}${i}: {`), O(e, n, `${s} `), e.push(`${s}},`));
|
|
67727
68266
|
}
|
|
67728
|
-
function
|
|
67729
|
-
|
|
67730
|
-
return ((r = e == null ? void 0 : e.target) != null ? r : "body").replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
68267
|
+
function h(e) {
|
|
68268
|
+
return (e?.target ?? "body").replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
67731
68269
|
}
|
|
67732
|
-
function
|
|
68270
|
+
function T(e, i = "esm", n) {
|
|
67733
68271
|
let s = { ...e };
|
|
67734
68272
|
delete s.postprocessMessage, delete s.initialMessages;
|
|
67735
|
-
let o = n ? { ...n, hooks:
|
|
67736
|
-
return
|
|
67737
|
-
}
|
|
67738
|
-
function
|
|
67739
|
-
let n =
|
|
67740
|
-
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 &&
|
|
67741
|
-
t.push(` ${
|
|
67742
|
-
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([
|
|
67743
|
-
typeof a == "string" ? t.push(` ${
|
|
67744
|
-
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([
|
|
67745
|
-
typeof a == "string" ? t.push(` ${
|
|
67746
|
-
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([
|
|
67747
|
-
typeof a == "string" ? t.push(` ${
|
|
67748
|
-
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([
|
|
67749
|
-
t.push(` ${
|
|
67750
|
-
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((
|
|
67751
|
-
t.push(` "${
|
|
67752
|
-
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n
|
|
68273
|
+
let o = n ? { ...n, hooks: P(n.hooks) } : void 0;
|
|
68274
|
+
return i === "esm" ? M(s, o) : i === "script-installer" ? H(s, o) : i === "script-advanced" ? D(s, o) : i === "react-component" ? R(s, o) : i === "react-advanced" ? W(s, o) : N(s, o);
|
|
68275
|
+
}
|
|
68276
|
+
function M(e, i) {
|
|
68277
|
+
let n = i?.hooks, s = g(e), o = s !== "plain", t = ["import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "", "initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
|
|
68278
|
+
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
|
|
68279
|
+
t.push(` ${r}: "${a}",`);
|
|
68280
|
+
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
|
|
68281
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
|
|
68282
|
+
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
|
|
68283
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
|
|
68284
|
+
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
|
|
68285
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
|
|
68286
|
+
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
|
|
68287
|
+
t.push(` ${r}: ${a},`);
|
|
68288
|
+
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
|
|
68289
|
+
t.push(` "${r}",`);
|
|
68290
|
+
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n?.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text)"), t.push(" }"), t.push("});"), t.join(`
|
|
67753
68291
|
`);
|
|
67754
68292
|
}
|
|
67755
|
-
function
|
|
67756
|
-
let n =
|
|
67757
|
-
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 &&
|
|
67758
|
-
t.push(` ${
|
|
67759
|
-
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([
|
|
67760
|
-
typeof a == "string" ? t.push(` ${
|
|
67761
|
-
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([
|
|
67762
|
-
typeof a == "string" ? t.push(` ${
|
|
67763
|
-
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([
|
|
67764
|
-
typeof a == "string" ? t.push(` ${
|
|
67765
|
-
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([
|
|
67766
|
-
t.push(` ${
|
|
67767
|
-
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((
|
|
67768
|
-
t.push(` "${
|
|
67769
|
-
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n
|
|
68293
|
+
function R(e, i) {
|
|
68294
|
+
let n = i?.hooks, s = g(e), o = s !== "plain", t = ["// ChatWidget.tsx", "'use client'; // Required for Next.js - remove for Vite/CRA", "", "import { useEffect } from 'react';", "import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "import type { AgentWidgetInitHandle } from '@runtypelabs/persona';", "", "export function ChatWidget() {", " useEffect(() => {", " let handle: AgentWidgetInitHandle | null = null;", "", " handle = initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
|
|
68295
|
+
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
|
|
68296
|
+
t.push(` ${r}: "${a}",`);
|
|
68297
|
+
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
|
|
68298
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
|
|
68299
|
+
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
|
|
68300
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
|
|
68301
|
+
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
|
|
68302
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
|
|
68303
|
+
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
|
|
68304
|
+
t.push(` ${r}: ${a},`);
|
|
68305
|
+
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
|
|
68306
|
+
t.push(` "${r}",`);
|
|
68307
|
+
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n?.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text)"), t.push(" }"), t.push(" });"), t.push(""), t.push(" // Cleanup on unmount"), t.push(" return () => {"), t.push(" if (handle) {"), t.push(" handle.destroy();"), t.push(" }"), t.push(" };"), t.push(" }, []);"), t.push(""), t.push(" return null; // Widget injects itself into the DOM"), t.push("}"), t.push(""), t.push("// Usage in your app:"), t.push("// import { ChatWidget } from './components/ChatWidget';"), t.push("//"), t.push("// export default function App() {"), t.push("// return ("), t.push("// <div>"), t.push("// {/* Your app content */}"), t.push("// <ChatWidget />"), t.push("// </div>"), t.push("// );"), t.push("// }"), t.join(`
|
|
67770
68308
|
`);
|
|
67771
68309
|
}
|
|
67772
|
-
function
|
|
67773
|
-
let n =
|
|
67774
|
-
return e.apiUrl && s.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && s.push(` clientToken: "${e.clientToken}",`), e.agentId && s.push(` agentId: "${e.agentId}",`), e.target && s.push(` target: "${e.target}",`), e.flowId && s.push(` flowId: "${e.flowId}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 &&
|
|
68310
|
+
function W(e, i) {
|
|
68311
|
+
let n = i?.hooks, s = ["// ChatWidgetAdvanced.tsx", "'use client'; // Required for Next.js - remove for Vite/CRA", "", "import { useEffect } from 'react';", "import '@runtypelabs/persona/widget.css';", "import {", " initAgentWidget,", " createFlexibleJsonStreamParser,", " defaultJsonActionParser,", " defaultActionHandlers,", " markdownPostprocessor", "} from '@runtypelabs/persona';", "import type { AgentWidgetInitHandle } from '@runtypelabs/persona';", "", "const STORAGE_KEY = 'chat-widget-state';", "const PROCESSED_ACTIONS_KEY = 'chat-widget-processed-actions';", "", "// Types for DOM elements", "interface PageElement {", " type: string;", " tagName: string;", " selector: string;", " innerText: string;", " href?: string;", "}", "", "interface DOMContext {", " page_elements: PageElement[];", " page_element_count: number;", " element_types: Record<string, number>;", " page_url: string;", " page_title: string;", " timestamp: string;", "}", "", "// DOM context provider - extracts page elements for AI context", "const collectDOMContext = (): DOMContext => {", " const selectors = {", ` products: '[data-product-id], .product-card, .product-item, [role="article"]',`, ` buttons: 'button, [role="button"], .btn',`, " links: 'a[href]',", " inputs: 'input, textarea, select'", " };", "", " const elements: PageElement[] = [];", " Object.entries(selectors).forEach(([type, selector]) => {", " document.querySelectorAll(selector).forEach((element) => {", " if (!(element instanceof HTMLElement)) return;", " ", " // Exclude elements within the widget", " const widgetHost = element.closest('.persona-host');", " if (widgetHost) return;", " ", " const text = element.innerText?.trim();", " if (!text) return;", "", " const selectorString =", " element.id ? `#${element.id}` :", " element.getAttribute('data-testid') ? `[data-testid=\"${element.getAttribute('data-testid')}\"]` :", " element.getAttribute('data-product-id') ? `[data-product-id=\"${element.getAttribute('data-product-id')}\"]` :", " element.tagName.toLowerCase();", "", " const elementData: PageElement = {", " type,", " tagName: element.tagName.toLowerCase(),", " selector: selectorString,", " innerText: text.substring(0, 200)", " };", "", " if (type === 'links' && element instanceof HTMLAnchorElement && element.href) {", " elementData.href = element.href;", " }", "", " elements.push(elementData);", " });", " });", "", " const counts = elements.reduce((acc, el) => {", " acc[el.type] = (acc[el.type] || 0) + 1;", " return acc;", " }, {} as Record<string, number>);", "", " return {", " page_elements: elements.slice(0, 50),", " page_element_count: elements.length,", " element_types: counts,", " page_url: window.location.href,", " page_title: document.title,", " timestamp: new Date().toISOString()", " };", "};", "", "export function ChatWidgetAdvanced() {", " useEffect(() => {", " let handle: AgentWidgetInitHandle | null = null;", "", " // Load saved state", " const loadSavedMessages = () => {", " const savedState = localStorage.getItem(STORAGE_KEY);", " if (savedState) {", " try {", " const { messages } = JSON.parse(savedState);", " return messages || [];", " } catch (e) {", " console.error('Failed to load saved state:', e);", " }", " }", " return [];", " };", "", " handle = initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
|
|
68312
|
+
return e.apiUrl && s.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && s.push(` clientToken: "${e.clientToken}",`), e.agentId && s.push(` agentId: "${e.agentId}",`), e.target && s.push(` target: "${e.target}",`), e.flowId && s.push(` flowId: "${e.flowId}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(s, "theme", e.theme, " "), e.launcher && d(s, "launcher", e.launcher, " "), e.copy && (s.push(" copy: {"), Object.entries(e.copy).forEach(([o, t]) => {
|
|
67775
68313
|
s.push(` ${o}: "${t}",`);
|
|
67776
68314
|
}), s.push(" },")), e.sendButton && (s.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([o, t]) => {
|
|
67777
68315
|
typeof t == "string" ? s.push(` ${o}: "${t}",`) : typeof t == "boolean" && s.push(` ${o}: ${t},`);
|
|
@@ -67783,78 +68321,77 @@ function k(e, r) {
|
|
|
67783
68321
|
s.push(` ${o}: ${t},`);
|
|
67784
68322
|
}), s.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (s.push(" suggestionChips: ["), e.suggestionChips.forEach((o) => {
|
|
67785
68323
|
s.push(` "${o}",`);
|
|
67786
|
-
}), s.push(" ],")), e.suggestionChipsConfig && (s.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && s.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && s.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && s.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && s.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), s.push(" },")), s.push(...m(e, " ")), s.push(...f(e, " ", n)), s.push(...y(e, " ")), s.push(...C(e, " ")), n
|
|
68324
|
+
}), s.push(" ],")), e.suggestionChipsConfig && (s.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && s.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && s.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && s.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && s.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), s.push(" },")), s.push(...m(e, " ")), s.push(...f(e, " ", n)), s.push(...y(e, " ")), s.push(...C(e, " ")), n?.getHeaders && s.push(` getHeaders: ${n.getHeaders},`), n?.contextProviders && s.push(` contextProviders: ${n.contextProviders},`), e.debug && s.push(` debug: ${e.debug},`), s.push(" initialMessages: loadSavedMessages(),"), n?.streamParser ? s.push(` streamParser: ${n.streamParser},`) : (s.push(" // Flexible JSON stream parser for handling structured actions"), s.push(` streamParser: () => createFlexibleJsonStreamParser(${v}),`)), n?.actionParsers ? (s.push(" // Action parsers (custom merged with defaults)"), s.push(` actionParsers: [...(${n.actionParsers}), defaultJsonActionParser,`), s.push(" // Built-in parser for markdown-wrapped JSON"), s.push(` ${S}`), s.push(" ],")) : (s.push(" // Action parsers to detect JSON actions in responses"), s.push(" actionParsers: ["), s.push(" defaultJsonActionParser,"), s.push(" // Parser for markdown-wrapped JSON"), s.push(` ${S}`), s.push(" ],")), n?.actionHandlers ? (s.push(" // Action handlers (custom merged with defaults)"), s.push(` actionHandlers: [...(${n.actionHandlers}),`), s.push(" defaultActionHandlers.message,"), s.push(" defaultActionHandlers.messageAndClick,"), s.push(" // Built-in handler for nav_then_click action"), s.push(` ${A}`), s.push(" ],")) : (s.push(" // Action handlers for navigation and other actions"), s.push(" actionHandlers: ["), s.push(" defaultActionHandlers.message,"), s.push(" defaultActionHandlers.messageAndClick,"), s.push(" // Handler for nav_then_click action"), s.push(` ${A}`), s.push(" ],")), n?.postprocessMessage ? s.push(` postprocessMessage: ${n.postprocessMessage},`) : s.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text),"), n?.requestMiddleware ? (s.push(" // Request middleware (custom merged with DOM context)"), s.push(" requestMiddleware: ({ payload, config }) => {"), s.push(` const customResult = (${n.requestMiddleware})({ payload, config });`), s.push(" const merged = customResult || payload;"), s.push(" return {"), s.push(" ...merged,"), s.push(" metadata: { ...merged.metadata, ...collectDOMContext() }"), s.push(" };"), s.push(" }")) : (s.push(" requestMiddleware: ({ payload }) => {"), s.push(" return {"), s.push(" ...payload,"), s.push(" metadata: collectDOMContext()"), s.push(" };"), s.push(" }")), s.push(" }"), s.push(" });"), s.push(""), s.push(" // Save state on message events"), s.push(" const handleMessage = () => {"), s.push(" const session = handle?.getSession?.();"), s.push(" if (session) {"), s.push(" localStorage.setItem(STORAGE_KEY, JSON.stringify({"), s.push(" messages: session.messages,"), s.push(" timestamp: new Date().toISOString()"), s.push(" }));"), s.push(" }"), s.push(" };"), s.push(""), s.push(" // Clear state on clear chat"), s.push(" const handleClearChat = () => {"), s.push(" localStorage.removeItem(STORAGE_KEY);"), s.push(" localStorage.removeItem(PROCESSED_ACTIONS_KEY);"), s.push(" };"), s.push(""), s.push(" window.addEventListener('persona:message', handleMessage);"), s.push(" window.addEventListener('persona:clear-chat', handleClearChat);"), s.push(""), s.push(" // Cleanup on unmount"), s.push(" return () => {"), s.push(" window.removeEventListener('persona:message', handleMessage);"), s.push(" window.removeEventListener('persona:clear-chat', handleClearChat);"), s.push(" if (handle) {"), s.push(" handle.destroy();"), s.push(" }"), s.push(" };"), s.push(" }, []);"), s.push(""), s.push(" return null; // Widget injects itself into the DOM"), s.push("}"), s.push(""), s.push("// Usage: Collects DOM context for AI-powered navigation"), s.push("// Features:"), s.push("// - Extracts page elements (products, buttons, links)"), s.push("// - Persists chat history across page loads"), s.push("// - Handles navigation actions (nav_then_click)"), s.push("// - Processes structured JSON actions from AI"), s.push("//"), s.push("// Example usage in Next.js:"), s.push("// import { ChatWidgetAdvanced } from './components/ChatWidgetAdvanced';"), s.push("//"), s.push("// export default function RootLayout({ children }) {"), s.push("// return ("), s.push('// <html lang="en">'), s.push("// <body>"), s.push("// {children}"), s.push("// <ChatWidgetAdvanced />"), s.push("// </body>"), s.push("// </html>"), s.push("// );"), s.push("// }"), s.join(`
|
|
67787
68325
|
`);
|
|
67788
68326
|
}
|
|
67789
|
-
function
|
|
67790
|
-
|
|
67791
|
-
|
|
67792
|
-
|
|
67793
|
-
|
|
67794
|
-
|
|
67795
|
-
|
|
67796
|
-
}), Object.keys(t).length > 0 && (s.toolCall = t);
|
|
68327
|
+
function E(e) {
|
|
68328
|
+
let i = g(e), n = i !== "plain", s = {};
|
|
68329
|
+
if (e.apiUrl && (s.apiUrl = e.apiUrl), e.clientToken && (s.clientToken = e.clientToken), e.agentId && (s.agentId = e.agentId), e.target && (s.target = e.target), e.flowId && (s.flowId = e.flowId), n && (s.parserType = i), e.theme && (s.theme = e.theme), e.launcher && (s.launcher = e.launcher), e.copy && (s.copy = e.copy), e.sendButton && (s.sendButton = e.sendButton), e.voiceRecognition && (s.voiceRecognition = e.voiceRecognition), e.statusIndicator && (s.statusIndicator = e.statusIndicator), e.features && (s.features = e.features), e.suggestionChips?.length > 0 && (s.suggestionChips = e.suggestionChips), e.suggestionChipsConfig && (s.suggestionChipsConfig = e.suggestionChipsConfig), e.debug && (s.debug = e.debug), e.toolCall) {
|
|
68330
|
+
let o = {};
|
|
68331
|
+
Object.entries(e.toolCall).forEach(([t, r]) => {
|
|
68332
|
+
typeof r == "string" && (o[t] = r);
|
|
68333
|
+
}), Object.keys(o).length > 0 && (s.toolCall = o);
|
|
67797
68334
|
}
|
|
67798
68335
|
if (e.messageActions) {
|
|
67799
|
-
let
|
|
67800
|
-
Object.entries(e.messageActions).forEach(([
|
|
67801
|
-
|
|
67802
|
-
}), Object.keys(
|
|
68336
|
+
let o = {};
|
|
68337
|
+
Object.entries(e.messageActions).forEach(([t, r]) => {
|
|
68338
|
+
t !== "onFeedback" && t !== "onCopy" && r !== void 0 && (typeof r == "string" || typeof r == "boolean") && (o[t] = r);
|
|
68339
|
+
}), Object.keys(o).length > 0 && (s.messageActions = o);
|
|
67803
68340
|
}
|
|
67804
68341
|
if (e.markdown) {
|
|
67805
|
-
let
|
|
67806
|
-
e.markdown.options && (
|
|
68342
|
+
let o = {};
|
|
68343
|
+
e.markdown.options && (o.options = e.markdown.options), e.markdown.disableDefaultStyles !== void 0 && (o.disableDefaultStyles = e.markdown.disableDefaultStyles), Object.keys(o).length > 0 && (s.markdown = o);
|
|
67807
68344
|
}
|
|
67808
68345
|
if (e.layout) {
|
|
67809
|
-
let
|
|
68346
|
+
let o = {};
|
|
67810
68347
|
if (e.layout.header) {
|
|
67811
|
-
let
|
|
67812
|
-
Object.entries(e.layout.header).forEach(([
|
|
67813
|
-
|
|
67814
|
-
}), Object.keys(
|
|
68348
|
+
let t = {};
|
|
68349
|
+
Object.entries(e.layout.header).forEach(([r, a]) => {
|
|
68350
|
+
r !== "render" && (typeof a == "string" || typeof a == "boolean") && (t[r] = a);
|
|
68351
|
+
}), Object.keys(t).length > 0 && (o.header = t);
|
|
67815
68352
|
}
|
|
67816
68353
|
if (e.layout.messages) {
|
|
67817
|
-
let
|
|
67818
|
-
Object.entries(e.layout.messages).forEach(([
|
|
67819
|
-
if (
|
|
67820
|
-
else if (
|
|
67821
|
-
let
|
|
67822
|
-
Object.entries(
|
|
67823
|
-
|
|
67824
|
-
}), Object.keys(
|
|
67825
|
-
} else (typeof
|
|
67826
|
-
}), Object.keys(
|
|
67827
|
-
}
|
|
67828
|
-
Object.keys(
|
|
68354
|
+
let t = {};
|
|
68355
|
+
Object.entries(e.layout.messages).forEach(([r, a]) => {
|
|
68356
|
+
if (r !== "renderUserMessage" && r !== "renderAssistantMessage") if (r === "avatar" && typeof a == "object" && a !== null) t.avatar = a;
|
|
68357
|
+
else if (r === "timestamp" && typeof a == "object" && a !== null) {
|
|
68358
|
+
let p = {};
|
|
68359
|
+
Object.entries(a).forEach(([l, b]) => {
|
|
68360
|
+
l !== "format" && (typeof b == "string" || typeof b == "boolean") && (p[l] = b);
|
|
68361
|
+
}), Object.keys(p).length > 0 && (t.timestamp = p);
|
|
68362
|
+
} else (typeof a == "string" || typeof a == "boolean") && (t[r] = a);
|
|
68363
|
+
}), Object.keys(t).length > 0 && (o.messages = t);
|
|
68364
|
+
}
|
|
68365
|
+
Object.keys(o).length > 0 && (s.layout = o);
|
|
67829
68366
|
}
|
|
67830
68367
|
return s;
|
|
67831
68368
|
}
|
|
67832
|
-
function
|
|
67833
|
-
let n =
|
|
68369
|
+
function H(e, i) {
|
|
68370
|
+
let n = E(e), o = !!(i?.windowKey || i?.target) ? { config: n, ...i?.windowKey ? { windowKey: i.windowKey } : {}, ...i?.target ? { target: i.target } : {} } : n, t = JSON.stringify(o, null, 0).replace(/'/g, "'");
|
|
67834
68371
|
return `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/install.global.js" data-config='${t}'></script>`;
|
|
67835
68372
|
}
|
|
67836
|
-
function
|
|
67837
|
-
let n =
|
|
67838
|
-
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 &&
|
|
67839
|
-
t.push(` ${
|
|
67840
|
-
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([
|
|
67841
|
-
typeof a == "string" ? t.push(` ${
|
|
67842
|
-
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([
|
|
67843
|
-
typeof a == "string" ? t.push(` ${
|
|
67844
|
-
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([
|
|
67845
|
-
typeof a == "string" ? t.push(` ${
|
|
67846
|
-
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([
|
|
67847
|
-
t.push(` ${
|
|
67848
|
-
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((
|
|
67849
|
-
t.push(` "${
|
|
67850
|
-
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n
|
|
68373
|
+
function N(e, i) {
|
|
68374
|
+
let n = i?.hooks, s = g(e), o = s !== "plain", t = ["<!-- Load CSS -->", `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/widget.css" />`, "", "<!-- Load JavaScript -->", `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/index.global.js"></script>`, "", "<!-- Initialize widget -->", "<script>", " var handle = window.AgentWidget.initAgentWidget({", ` target: '${h(i)}',`, ...i?.windowKey ? [` windowKey: '${i.windowKey}',`] : [], " config: {"];
|
|
68375
|
+
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
|
|
68376
|
+
t.push(` ${r}: "${a}",`);
|
|
68377
|
+
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
|
|
68378
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
|
|
68379
|
+
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
|
|
68380
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
|
|
68381
|
+
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
|
|
68382
|
+
typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
|
|
68383
|
+
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
|
|
68384
|
+
t.push(` ${r}: ${a},`);
|
|
68385
|
+
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
|
|
68386
|
+
t.push(` "${r}",`);
|
|
68387
|
+
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n?.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => window.AgentWidget.markdownPostprocessor(text)"), t.push(" }"), t.push(" });"), t.push("</script>"), t.join(`
|
|
67851
68388
|
`);
|
|
67852
68389
|
}
|
|
67853
|
-
function
|
|
67854
|
-
let n =
|
|
67855
|
-
`).map((
|
|
68390
|
+
function D(e, i) {
|
|
68391
|
+
let n = i?.hooks, s = E(e), t = ["<script>", "(function() {", " 'use strict';", "", " // Configuration", ` var CONFIG = ${JSON.stringify(s, null, 2).split(`
|
|
68392
|
+
`).map((r, a) => a === 0 ? r : " " + r).join(`
|
|
67856
68393
|
`)};`, "", " // Constants", ` var CDN_BASE = 'https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist';`, " var STORAGE_KEY = 'chat-widget-state';", " var PROCESSED_ACTIONS_KEY = 'chat-widget-processed-actions';", "", " // DOM context provider - extracts page elements for AI context", " var domContextProvider = function() {", " var selectors = {", ` products: '[data-product-id], .product-card, .product-item, [role="article"]',`, ` buttons: 'button, [role="button"], .btn',`, " links: 'a[href]',", " inputs: 'input, textarea, select'", " };", "", " var elements = [];", " Object.entries(selectors).forEach(function(entry) {", " var type = entry[0], selector = entry[1];", " document.querySelectorAll(selector).forEach(function(element) {", " if (!(element instanceof HTMLElement)) return;", " var widgetHost = element.closest('.persona-host');", " if (widgetHost) return;", " var text = element.innerText ? element.innerText.trim() : '';", " if (!text) return;", "", " var selectorString = element.id ? '#' + element.id :", ` element.getAttribute('data-testid') ? '[data-testid="' + element.getAttribute('data-testid') + '"]' :`, ` element.getAttribute('data-product-id') ? '[data-product-id="' + element.getAttribute('data-product-id') + '"]' :`, " element.tagName.toLowerCase();", "", " var elementData = {", " type: type,", " tagName: element.tagName.toLowerCase(),", " selector: selectorString,", " innerText: text.substring(0, 200)", " };", "", " if (type === 'links' && element instanceof HTMLAnchorElement && element.href) {", " elementData.href = element.href;", " }", " elements.push(elementData);", " });", " });", "", " var counts = elements.reduce(function(acc, el) {", " acc[el.type] = (acc[el.type] || 0) + 1;", " return acc;", " }, {});", "", " return {", " page_elements: elements.slice(0, 50),", " page_element_count: elements.length,", " element_types: counts,", " page_url: window.location.href,", " page_title: document.title,", " timestamp: new Date().toISOString()", " };", " };", "", " // Load CSS dynamically", " var loadCSS = function() {", " if (document.querySelector('link[data-persona]')) return;", " var link = document.createElement('link');", " link.rel = 'stylesheet';", " link.href = CDN_BASE + '/widget.css';", " link.setAttribute('data-persona', 'true');", " document.head.appendChild(link);", " };", "", " // Load JS dynamically", " var loadJS = function(callback) {", " if (window.AgentWidget) { callback(); return; }", " var script = document.createElement('script');", " script.src = CDN_BASE + '/index.global.js';", " script.onload = callback;", " script.onerror = function() { console.error('Failed to load AgentWidget'); };", " document.head.appendChild(script);", " };", "", " // Create widget config with advanced features", " var createWidgetConfig = function(agentWidget) {", " var widgetConfig = Object.assign({}, CONFIG);", ""];
|
|
67857
|
-
return n
|
|
68394
|
+
return n?.getHeaders && (t.push(` widgetConfig.getHeaders = ${n.getHeaders};`), t.push("")), n?.contextProviders && (t.push(` widgetConfig.contextProviders = ${n.contextProviders};`), t.push("")), n?.streamParser ? t.push(` widgetConfig.streamParser = ${n.streamParser};`) : (t.push(" // Flexible JSON stream parser for handling structured actions"), t.push(" widgetConfig.streamParser = function() {"), t.push(` return agentWidget.createFlexibleJsonStreamParser(${I});`), t.push(" };")), t.push(""), n?.actionParsers ? (t.push(" // Action parsers (custom merged with defaults)"), t.push(` var customParsers = ${n.actionParsers};`), t.push(" widgetConfig.actionParsers = customParsers.concat(["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${x}`), t.push(" ]);")) : (t.push(" // Action parsers to detect JSON actions in responses"), t.push(" widgetConfig.actionParsers = ["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${x}`), t.push(" ];")), t.push(""), n?.actionHandlers ? (t.push(" // Action handlers (custom merged with defaults)"), t.push(` var customHandlers = ${n.actionHandlers};`), t.push(" widgetConfig.actionHandlers = customHandlers.concat(["), t.push(" agentWidget.defaultActionHandlers.message,"), t.push(" agentWidget.defaultActionHandlers.messageAndClick,"), t.push(` ${j}`), t.push(" ]);")) : (t.push(" // Action handlers for navigation and other actions"), t.push(" widgetConfig.actionHandlers = ["), t.push(" agentWidget.defaultActionHandlers.message,"), t.push(" agentWidget.defaultActionHandlers.messageAndClick,"), t.push(` ${j}`), t.push(" ];")), t.push(""), n?.requestMiddleware ? (t.push(" // Request middleware (custom merged with DOM context)"), t.push(" widgetConfig.requestMiddleware = function(ctx) {"), t.push(` var customResult = (${n.requestMiddleware})(ctx);`), t.push(" var merged = customResult || ctx.payload;"), t.push(" return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });"), t.push(" };")) : (t.push(" // Send DOM context with each request"), t.push(" widgetConfig.requestMiddleware = function(ctx) {"), t.push(" return Object.assign({}, ctx.payload, { metadata: domContextProvider() });"), t.push(" };")), t.push(""), n?.postprocessMessage ? t.push(` widgetConfig.postprocessMessage = ${n.postprocessMessage};`) : (t.push(" // Markdown postprocessor"), t.push(" widgetConfig.postprocessMessage = function(ctx) {"), t.push(" return agentWidget.markdownPostprocessor(ctx.text);"), t.push(" };")), t.push(""), (n?.onFeedback || n?.onCopy) && (t.push(" // Message action callbacks"), t.push(" widgetConfig.messageActions = widgetConfig.messageActions || {};"), n?.onFeedback && t.push(` widgetConfig.messageActions.onFeedback = ${n.onFeedback};`), n?.onCopy && t.push(` widgetConfig.messageActions.onCopy = ${n.onCopy};`), t.push("")), t.push(" return widgetConfig;", " };", "", " // Initialize widget", " var init = function() {", " var agentWidget = window.AgentWidget;", " if (!agentWidget) {", " console.error('AgentWidget not loaded');", " return;", " }", "", " var widgetConfig = createWidgetConfig(agentWidget);", "", " // Load saved state", " var savedState = localStorage.getItem(STORAGE_KEY);", " if (savedState) {", " try {", " var parsed = JSON.parse(savedState);", " widgetConfig.initialMessages = parsed.messages || [];", " } catch (e) {", " console.error('Failed to load saved state:', e);", " }", " }", "", " // Initialize widget", " var handle = agentWidget.initAgentWidget({", ` target: '${h(i)}',`, " useShadowDom: false,", ...i?.windowKey ? [` windowKey: '${i.windowKey}',`] : [], " config: widgetConfig", " });", "", " // Save state on message events", " window.addEventListener('persona:message', function() {", " var session = handle.getSession ? handle.getSession() : null;", " if (session) {", " localStorage.setItem(STORAGE_KEY, JSON.stringify({", " messages: session.messages,", " timestamp: new Date().toISOString()", " }));", " }", " });", "", " // Clear state on clear chat", " window.addEventListener('persona:clear-chat', function() {", " localStorage.removeItem(STORAGE_KEY);", " localStorage.removeItem(PROCESSED_ACTIONS_KEY);", " });", " };", "", " // Wait for framework hydration to complete (Next.js, Nuxt, etc.)", " // This prevents the framework from removing dynamically added CSS during reconciliation", " var waitForHydration = function(callback) {", " var executed = false;", " ", " var execute = function() {", " if (executed) return;", " executed = true;", " callback();", " };", "", " var afterDom = function() {", " // Strategy 1: Use requestIdleCallback if available (best for detecting idle after hydration)", " if (typeof requestIdleCallback !== 'undefined') {", " requestIdleCallback(function() {", " // Double requestAnimationFrame ensures at least one full paint cycle completed", " requestAnimationFrame(function() {", " requestAnimationFrame(execute);", " });", " }, { timeout: 3000 }); // Max wait 3 seconds, then proceed anyway", " } else {", " // Strategy 2: Fallback for Safari (no requestIdleCallback)", " // 300ms is typically enough for hydration on most pages", " setTimeout(execute, 300);", " }", " };", "", " if (document.readyState === 'loading') {", " document.addEventListener('DOMContentLoaded', afterDom);", " } else {", " // DOM already ready, but still wait for potential hydration", " afterDom();", " }", " };", "", " // Boot sequence: wait for hydration, then load CSS and JS, then initialize", " // This prevents Next.js/Nuxt/etc. from removing dynamically added CSS during reconciliation", " waitForHydration(function() {", " loadCSS();", " loadJS(function() {", " init();", " });", " });", "})();", "</script>"), t.join(`
|
|
67858
68395
|
`);
|
|
67859
68396
|
}
|
|
67860
68397
|
|
|
@@ -67894,14 +68431,14 @@ function buildWidgetConfig(input) {
|
|
|
67894
68431
|
function generatePersonaInitSnippet(input, personaFormat) {
|
|
67895
68432
|
const widgetConfig = buildWidgetConfig(input);
|
|
67896
68433
|
const target = input.targetSelector?.trim();
|
|
67897
|
-
return
|
|
68434
|
+
return T(
|
|
67898
68435
|
widgetConfig,
|
|
67899
68436
|
personaFormat,
|
|
67900
68437
|
target ? { target } : void 0
|
|
67901
68438
|
);
|
|
67902
68439
|
}
|
|
67903
68440
|
function getPersonaInstallerScriptUrl() {
|
|
67904
|
-
const snippet =
|
|
68441
|
+
const snippet = T(
|
|
67905
68442
|
{
|
|
67906
68443
|
apiUrl: "https://api.runtype.com",
|
|
67907
68444
|
clientToken: "ct_test_demo_00000000000000000000000000000000",
|
|
@@ -68863,8 +69400,8 @@ Dashboard: ${initial.dashboardUrl}`));
|
|
|
68863
69400
|
}
|
|
68864
69401
|
}
|
|
68865
69402
|
if (initial.warnings?.length) {
|
|
68866
|
-
for (const
|
|
68867
|
-
console.log(chalk31.yellow(`\u26A0 ${
|
|
69403
|
+
for (const w2 of initial.warnings) {
|
|
69404
|
+
console.log(chalk31.yellow(`\u26A0 ${w2.message}`));
|
|
68868
69405
|
}
|
|
68869
69406
|
}
|
|
68870
69407
|
if (demo) {
|
|
@@ -69322,8 +69859,8 @@ Dashboard: ${output.dashboardUrl}`));
|
|
|
69322
69859
|
);
|
|
69323
69860
|
}
|
|
69324
69861
|
if (success2.warnings?.length) {
|
|
69325
|
-
for (const
|
|
69326
|
-
console.log(chalk31.yellow(`\u26A0 ${
|
|
69862
|
+
for (const w2 of success2.warnings) {
|
|
69863
|
+
console.log(chalk31.yellow(`\u26A0 ${w2.message}`));
|
|
69327
69864
|
}
|
|
69328
69865
|
}
|
|
69329
69866
|
if (!demoOutput) {
|
|
@@ -69751,11 +70288,11 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
|
|
|
69751
70288
|
return;
|
|
69752
70289
|
}
|
|
69753
70290
|
console.log(chalk34.cyan(`Versions for flow ${flowId}:`));
|
|
69754
|
-
for (const
|
|
69755
|
-
const publishedTag =
|
|
69756
|
-
const versionNum =
|
|
69757
|
-
const date5 =
|
|
69758
|
-
console.log(` ${chalk34.green(
|
|
70291
|
+
for (const v2 of versions) {
|
|
70292
|
+
const publishedTag = v2.published ? chalk34.green(" [published]") : "";
|
|
70293
|
+
const versionNum = v2.version !== void 0 ? `v${v2.version}` : v2.id;
|
|
70294
|
+
const date5 = v2.createdAt ? chalk34.gray(` ${v2.createdAt}`) : "";
|
|
70295
|
+
console.log(` ${chalk34.green(v2.id)} ${versionNum}${publishedTag}${date5}`);
|
|
69759
70296
|
}
|
|
69760
70297
|
}
|
|
69761
70298
|
} catch (error51) {
|
|
@@ -69790,10 +70327,10 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
|
|
|
69790
70327
|
loading,
|
|
69791
70328
|
emptyMessage: "No versions found",
|
|
69792
70329
|
renderCard: (item) => {
|
|
69793
|
-
const
|
|
69794
|
-
const publishedTag =
|
|
69795
|
-
const versionNum =
|
|
69796
|
-
return React25.createElement(Text38, null, ` ${
|
|
70330
|
+
const v2 = item;
|
|
70331
|
+
const publishedTag = v2.published ? " [published]" : "";
|
|
70332
|
+
const versionNum = v2.version !== void 0 ? `v${v2.version}` : v2.id;
|
|
70333
|
+
return React25.createElement(Text38, null, ` ${v2.id} ${versionNum}${publishedTag}${v2.createdAt ? ` ${v2.createdAt}` : ""}`);
|
|
69797
70334
|
}
|
|
69798
70335
|
});
|
|
69799
70336
|
};
|
|
@@ -70008,12 +70545,12 @@ agentVersionsCommand.command("list <agentId>").description("List all versions fo
|
|
|
70008
70545
|
return;
|
|
70009
70546
|
}
|
|
70010
70547
|
console.log(chalk35.cyan(`Versions for agent ${agentId}:`));
|
|
70011
|
-
for (const
|
|
70012
|
-
const isPublished =
|
|
70548
|
+
for (const v2 of versions) {
|
|
70549
|
+
const isPublished = v2.id === data.publishedVersionId;
|
|
70013
70550
|
const liveTag = isPublished ? chalk35.green(" [live]") : "";
|
|
70014
|
-
const versionLabel =
|
|
70015
|
-
const date5 =
|
|
70016
|
-
console.log(` ${chalk35.green(
|
|
70551
|
+
const versionLabel = v2.label || (v2.versionNumber !== void 0 ? `v${v2.versionNumber}` : v2.id);
|
|
70552
|
+
const date5 = v2.createdAt ? chalk35.gray(` ${v2.createdAt}`) : "";
|
|
70553
|
+
console.log(` ${chalk35.green(v2.id)} ${versionLabel}${liveTag}${date5}`);
|
|
70017
70554
|
}
|
|
70018
70555
|
}
|
|
70019
70556
|
} catch (error51) {
|
|
@@ -70050,13 +70587,13 @@ agentVersionsCommand.command("list <agentId>").description("List all versions fo
|
|
|
70050
70587
|
loading,
|
|
70051
70588
|
emptyMessage: "No versions found",
|
|
70052
70589
|
renderCard: (item) => {
|
|
70053
|
-
const
|
|
70054
|
-
const liveTag =
|
|
70055
|
-
const versionLabel =
|
|
70590
|
+
const v2 = item;
|
|
70591
|
+
const liveTag = v2.id === publishedId ? " [live]" : "";
|
|
70592
|
+
const versionLabel = v2.label || (v2.versionNumber !== void 0 ? `v${v2.versionNumber}` : v2.id);
|
|
70056
70593
|
return React26.createElement(
|
|
70057
70594
|
Text39,
|
|
70058
70595
|
null,
|
|
70059
|
-
` ${
|
|
70596
|
+
` ${v2.id} ${versionLabel}${liveTag}${v2.createdAt ? ` ${v2.createdAt}` : ""}`
|
|
70060
70597
|
);
|
|
70061
70598
|
}
|
|
70062
70599
|
});
|
|
@@ -70269,11 +70806,11 @@ function abbreviateId(id) {
|
|
|
70269
70806
|
return `${prefix}_${suffix.slice(0, 4)}...`;
|
|
70270
70807
|
}
|
|
70271
70808
|
function formatTime(ts) {
|
|
70272
|
-
const
|
|
70273
|
-
const hh = String(
|
|
70274
|
-
const mm = String(
|
|
70275
|
-
const ss = String(
|
|
70276
|
-
const ms = String(
|
|
70809
|
+
const d2 = new Date(ts);
|
|
70810
|
+
const hh = String(d2.getHours()).padStart(2, "0");
|
|
70811
|
+
const mm = String(d2.getMinutes()).padStart(2, "0");
|
|
70812
|
+
const ss = String(d2.getSeconds()).padStart(2, "0");
|
|
70813
|
+
const ms = String(d2.getMilliseconds()).padStart(3, "0");
|
|
70277
70814
|
return `${hh}:${mm}:${ss}.${ms}`;
|
|
70278
70815
|
}
|
|
70279
70816
|
var LEVEL_COLORS = {
|
|
@@ -70293,7 +70830,7 @@ function categoryBadge(category, useColor) {
|
|
|
70293
70830
|
return chalk36.magenta(`[${category}]`);
|
|
70294
70831
|
}
|
|
70295
70832
|
function formatTailData(data) {
|
|
70296
|
-
return Object.entries(data).map(([
|
|
70833
|
+
return Object.entries(data).map(([k, v2]) => `${k}=${typeof v2 === "string" ? v2 : JSON.stringify(v2)}`).join(" ");
|
|
70297
70834
|
}
|
|
70298
70835
|
function formatContextIds(event, useColor) {
|
|
70299
70836
|
const ids = [];
|
|
@@ -70381,9 +70918,9 @@ async function createSession(apiUrl, apiKey, filters) {
|
|
|
70381
70918
|
level: "levels",
|
|
70382
70919
|
category: "categories"
|
|
70383
70920
|
};
|
|
70384
|
-
for (const [
|
|
70385
|
-
if (
|
|
70386
|
-
filter[arrayFields[
|
|
70921
|
+
for (const [k, v2] of Object.entries(filters)) {
|
|
70922
|
+
if (v2 !== void 0 && arrayFields[k]) {
|
|
70923
|
+
filter[arrayFields[k]] = [v2];
|
|
70387
70924
|
}
|
|
70388
70925
|
}
|
|
70389
70926
|
const body = Object.keys(filter).length > 0 ? { filter } : {};
|
|
@@ -70438,7 +70975,7 @@ async function runTail(options) {
|
|
|
70438
70975
|
category: options.category
|
|
70439
70976
|
};
|
|
70440
70977
|
const useColor = options.color;
|
|
70441
|
-
const activeFilters = Object.entries(filters).filter(([,
|
|
70978
|
+
const activeFilters = Object.entries(filters).filter(([, v2]) => v2 !== void 0).map(([k, v2]) => `${k}=${v2}`);
|
|
70442
70979
|
process.stderr.write(
|
|
70443
70980
|
(useColor ? chalk36.gray(
|
|
70444
70981
|
`Connecting to ${apiUrl}...${activeFilters.length ? ` filters: ${activeFilters.join(", ")}` : ""}`
|
|
@@ -71634,11 +72171,11 @@ function collectSecretNames(agentDef) {
|
|
|
71634
72171
|
function slugify2(s) {
|
|
71635
72172
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63);
|
|
71636
72173
|
}
|
|
71637
|
-
var deployCommand = new Command31("deploy").description("Export an agent or flow and scaffold a deployment (cloud-run, cloudflare, or vercel)").option("--agent <id>", "Agent ID to export (may be repeated)", (
|
|
71638
|
-
acc.push(
|
|
72174
|
+
var deployCommand = new Command31("deploy").description("Export an agent or flow and scaffold a deployment (cloud-run, cloudflare, or vercel)").option("--agent <id>", "Agent ID to export (may be repeated)", (v2, acc) => {
|
|
72175
|
+
acc.push(v2);
|
|
71639
72176
|
return acc;
|
|
71640
|
-
}, []).option("--flow <id>", "Flow ID to export (may be repeated)", (
|
|
71641
|
-
acc.push(
|
|
72177
|
+
}, []).option("--flow <id>", "Flow ID to export (may be repeated)", (v2, acc) => {
|
|
72178
|
+
acc.push(v2);
|
|
71642
72179
|
return acc;
|
|
71643
72180
|
}, []).option("--output <dir>", "Output directory for the scaffold (default: ./runtype-deploy)", "./runtype-deploy").option("--name <name>", "Project name used in package.json (default: derived from output dir)").option("--target <target>", "Deployment target: cloud-run, cloudflare, or vercel (default: cloud-run)", "cloud-run").action(
|
|
71644
72181
|
async (options) => {
|
|
@@ -72823,32 +73360,54 @@ import chalk42 from "chalk";
|
|
|
72823
73360
|
// ../shared/dist/agent-onboarding-content.mjs
|
|
72824
73361
|
var AGENT_ONBOARDING_MARKDOWN = `# Runtype for Coding Agents
|
|
72825
73362
|
|
|
72826
|
-
You are reading the setup script served by \`https://runtype.ai\`. Your durable goal is to leave this coding harness connected to Runtype's hosted MCP server
|
|
73363
|
+
You are reading the setup script served by \`https://runtype.ai\`. Your durable goal is to leave this coding harness connected to Runtype's hosted MCP server. Use the Runtype CLI as a bridge during this first session; do not treat it as the final integration.
|
|
73364
|
+
|
|
73365
|
+
Signup never requires a browser. The only things you may ask the user for are their email address and the 6-digit code Runtype emails them. Do not tell the user to open a dashboard, sign-in page, or OAuth window during signup.
|
|
72827
73366
|
|
|
72828
73367
|
## Golden path \u2014 do exactly this
|
|
72829
73368
|
|
|
72830
73369
|
If the live Runtype MCP tools are already available in this session, skip setup and go to "After MCP is active" below. Otherwise follow every step in order:
|
|
72831
73370
|
|
|
72832
|
-
### 1. Install and
|
|
73371
|
+
### 1. Install the CLI and check auth
|
|
72833
73372
|
|
|
72834
73373
|
\`\`\`bash
|
|
72835
73374
|
npm install -g @runtypelabs/cli
|
|
72836
|
-
runtype auth
|
|
73375
|
+
runtype auth status
|
|
72837
73376
|
\`\`\`
|
|
72838
73377
|
|
|
72839
|
-
|
|
73378
|
+
If status reports \`authenticated\` with \`accountState: "full"\`, skip to step 3. If it reports a pending signup, its \`next\` field tells you the exact command to resume with.
|
|
72840
73379
|
|
|
72841
|
-
### 2.
|
|
73380
|
+
### 2. Sign the user up from the terminal
|
|
73381
|
+
|
|
73382
|
+
Ask the user one question: "What email address should I use for your Runtype account?" Then run:
|
|
72842
73383
|
|
|
72843
73384
|
\`\`\`bash
|
|
72844
|
-
runtype
|
|
73385
|
+
runtype auth register --email <their-email>
|
|
72845
73386
|
\`\`\`
|
|
72846
73387
|
|
|
72847
|
-
This
|
|
73388
|
+
This creates the account and emails the user a 6-digit code. Ask the user: "Runtype emailed a 6-digit code to <their-email> \u2014 what is it?" Then run:
|
|
73389
|
+
|
|
73390
|
+
\`\`\`bash
|
|
73391
|
+
runtype auth verify <code>
|
|
73392
|
+
\`\`\`
|
|
72848
73393
|
|
|
72849
|
-
|
|
73394
|
+
That completes signup. Every command in this flow prints JSON with a \`next\` field \u2014 follow it. Notes:
|
|
72850
73395
|
|
|
72851
|
-
|
|
73396
|
+
- These commands work without a TTY and never open a browser.
|
|
73397
|
+
- \`register\` is safe to re-run; it resumes a pending signup instead of creating a duplicate account.
|
|
73398
|
+
- After \`register\` (before \`verify\`) you already hold a temporary credential: CLI commands work with restricted models and quota, and \`verify\` upgrades the same stored login in place. Do not build anything substantial until \`verify\` succeeds.
|
|
73399
|
+
- If the email already has a Runtype account, the command reports \`email_already_registered\`. In that case ask the user for an API key from their dashboard (Settings > API keys) and run \`runtype auth login --api-key <key>\` instead. This is the only path where the user touches the dashboard, and only because they already have an account.
|
|
73400
|
+
- A wrong code returns \`otp_invalid\` \u2014 ask the user to re-check and run \`runtype auth verify\` again. An expired code returns \`otp_expired\` \u2014 re-send with \`runtype auth claim <email>\`. Codes expire after 10 minutes and lock after 5 wrong attempts, so confirm the code with the user rather than guessing; after a lockout or expiry, re-send with \`runtype auth claim <email>\`.
|
|
73401
|
+
|
|
73402
|
+
### 3. Install skills and the MCP connection
|
|
73403
|
+
|
|
73404
|
+
\`\`\`bash
|
|
73405
|
+
runtype install-mcp
|
|
73406
|
+
\`\`\`
|
|
73407
|
+
|
|
73408
|
+
This command detects the current coding harness, installs the Runtype agent skills for it, and writes the user-level hosted MCP configuration. If it asks which harness to configure, select the harness running this session. If it reports an OAuth action for the harness's own MCP connection, relay that instruction to the user for later \u2014 it happens on the harness's schedule, not during signup. That harness-side OAuth may open a browser when the user runs it; that is fine and expected \u2014 the no-browser rule above applies to Runtype signup, not to the harness's own connection ceremony.
|
|
73409
|
+
|
|
73410
|
+
### 4. Keep working in this session with the CLI
|
|
72852
73411
|
|
|
72853
73412
|
Do not stop just because the new MCP connection is not visible yet. Use CLI commands for useful first-session work:
|
|
72854
73413
|
|
|
@@ -72860,19 +73419,19 @@ runtype products list
|
|
|
72860
73419
|
runtype --help
|
|
72861
73420
|
\`\`\`
|
|
72862
73421
|
|
|
72863
|
-
The CLI also supports dispatch, records, validation, product setup, and other account operations. Read command help before mutating resources, and report concrete IDs and URLs to the user.
|
|
73422
|
+
The CLI also supports dispatch, records, validation, product setup, and other account operations. Read command help before mutating resources, and report concrete IDs and URLs to the user. If you need Runtype MCP tools before the restart, the CLI bridges them: \`runtype mcp tools\` lists them and \`runtype mcp call <tool>\` invokes one \u2014 same hosted tools, no restart needed.
|
|
72864
73423
|
|
|
72865
|
-
###
|
|
73424
|
+
### 5. Tell the user to restart or reload the harness
|
|
72866
73425
|
|
|
72867
|
-
Before finishing this session, read the final status and next steps from \`runtype install-mcp\`.
|
|
73426
|
+
Before finishing this session, read the final status and next steps from \`runtype install-mcp\`. Retry any failed skill installation. Do not call setup complete while the command reports \`action-required\`, \`partial\`, or an error.
|
|
72868
73427
|
|
|
72869
|
-
Only after
|
|
73428
|
+
Only after signup is verified and skills are installed, tell the user exactly what changed and ask them to restart or reload the coding harness. Use direct language such as:
|
|
72870
73429
|
|
|
72871
|
-
> Runtype
|
|
73430
|
+
> Your Runtype account is verified and the skills plus MCP connection are installed. Please restart or reload this coding agent (or start a new session) so it can activate the new MCP tools. I used the CLI to keep this first session productive; after restart I will use MCP by default.
|
|
72872
73431
|
|
|
72873
73432
|
If an action remains, report that exact action instead of using the success wording above. Do not claim the running agent can use MCP until its Runtype tools actually appear.
|
|
72874
73433
|
|
|
72875
|
-
###
|
|
73434
|
+
### 6. Switch to MCP after restart
|
|
72876
73435
|
|
|
72877
73436
|
In the next session, use Runtype MCP first. Do not fall back to the CLI just because it worked previously. Start by calling:
|
|
72878
73437
|
|
|
@@ -72898,13 +73457,21 @@ runtype install-mcp --agent opencode
|
|
|
72898
73457
|
runtype install-mcp --agent vscode
|
|
72899
73458
|
\`\`\`
|
|
72900
73459
|
|
|
72901
|
-
Use only the line for the current harness. Follow the command's
|
|
73460
|
+
Use only the line for the current harness. Follow the command's restart instructions. Use \`--force\` only when the command reports that an existing MCP server named \`runtype\` points to a different URL and the user agrees to replace it.
|
|
73461
|
+
|
|
73462
|
+
## Auth reference
|
|
73463
|
+
|
|
73464
|
+
The signup commands wrap the agent auth protocol documented at \`https://runtype.com/auth.md\` (anonymous registration plus an email claim ceremony). You normally never need the raw protocol \u2014 the CLI is the supported client:
|
|
72902
73465
|
|
|
72903
|
-
|
|
73466
|
+
- \`runtype auth register --email <email>\` \u2014 create the account and send the code (one step)
|
|
73467
|
+
- \`runtype auth claim <email>\` \u2014 re-send or change the email for a pending signup
|
|
73468
|
+
- \`runtype auth verify <code>\` \u2014 finish signup with the 6-digit code
|
|
73469
|
+
- \`runtype auth login --api-key <key>\` \u2014 existing accounts only
|
|
73470
|
+
- \`runtype auth status\` / \`runtype auth whoami\` \u2014 inspect the current login
|
|
72904
73471
|
|
|
72905
|
-
|
|
73472
|
+
A user-supplied \`RUNTYPE_API_KEY\` environment variable also authenticates every CLI command without a stored login. Never print a credential into the transcript or write one into a committed file.
|
|
72906
73473
|
|
|
72907
|
-
|
|
73474
|
+
Browser login (\`runtype auth login\` with no flags) exists for humans running the CLI in their own interactive terminal. Do not use it from a coding harness.
|
|
72908
73475
|
|
|
72909
73476
|
## After MCP is active
|
|
72910
73477
|
|
|
@@ -72923,7 +73490,7 @@ API: [api.runtype.com](https://api.runtype.com)
|
|
|
72923
73490
|
|
|
72924
73491
|
// src/commands/onboard.ts
|
|
72925
73492
|
init_credential_store();
|
|
72926
|
-
var AUTH_LOGIN_INSTRUCTION = "Sign in to Runtype:
|
|
73493
|
+
var AUTH_LOGIN_INSTRUCTION = "Sign in to Runtype first. New account: `runtype auth register --email <email>` then `runtype auth verify <code>`. Existing account: `runtype auth login --api-key <key>` (or set RUNTYPE_API_KEY). Then re-run `runtype onboard`.";
|
|
72927
73494
|
var AFTER_RESTART_STEPS = [
|
|
72928
73495
|
"Use the Runtype MCP server first for all Runtype work.",
|
|
72929
73496
|
"Start with the get_build_instructions tool before creating or changing resources.",
|
|
@@ -73208,7 +73775,7 @@ function collectBundleFiles(dir) {
|
|
|
73208
73775
|
walk(dir);
|
|
73209
73776
|
return zippable;
|
|
73210
73777
|
}
|
|
73211
|
-
function
|
|
73778
|
+
function fail2(message, jsonMode, code) {
|
|
73212
73779
|
if (jsonMode) {
|
|
73213
73780
|
printJson({ status: "error", error: message, code });
|
|
73214
73781
|
} else {
|
|
@@ -73247,7 +73814,7 @@ appsCommand.command("list").description("List your apps").option("--json", "Stru
|
|
|
73247
73814
|
console.log(` ${app.url} ${status} ${app.visibility}${serving}`);
|
|
73248
73815
|
}
|
|
73249
73816
|
} catch (error51) {
|
|
73250
|
-
|
|
73817
|
+
fail2(
|
|
73251
73818
|
`Failed to list apps: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
73252
73819
|
jsonMode,
|
|
73253
73820
|
"LIST_FAILED"
|
|
@@ -73276,7 +73843,7 @@ appsCommand.command("create").description("Create an app (the hostname is {slug}
|
|
|
73276
73843
|
console.log(` ${app.url}`);
|
|
73277
73844
|
console.log(chalk43.dim(" Deploy a bundle with `runtype apps deploy <dir> --app " + app.id + "`"));
|
|
73278
73845
|
} catch (error51) {
|
|
73279
|
-
|
|
73846
|
+
fail2(
|
|
73280
73847
|
`Failed to create app: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
73281
73848
|
jsonMode,
|
|
73282
73849
|
"CREATE_FAILED"
|
|
@@ -73291,27 +73858,27 @@ appsCommand.command("deploy <dir>").description("Zip a bundle directory, upload
|
|
|
73291
73858
|
const apiKey = await ensureAuth();
|
|
73292
73859
|
if (!apiKey) return;
|
|
73293
73860
|
if (!existsSync17(dir) || !statSync7(dir).isDirectory()) {
|
|
73294
|
-
|
|
73861
|
+
fail2(`Not a directory: ${dir}`, jsonMode, "INVALID_DIR");
|
|
73295
73862
|
}
|
|
73296
73863
|
let bundleFiles = {};
|
|
73297
73864
|
try {
|
|
73298
73865
|
bundleFiles = collectBundleFiles(dir);
|
|
73299
73866
|
} catch (error51) {
|
|
73300
|
-
|
|
73867
|
+
fail2(
|
|
73301
73868
|
`Failed to read ${dir}: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
73302
73869
|
jsonMode,
|
|
73303
73870
|
"INVALID_DIR"
|
|
73304
73871
|
);
|
|
73305
73872
|
}
|
|
73306
73873
|
if (!bundleFiles["index.html"]) {
|
|
73307
|
-
|
|
73874
|
+
fail2(
|
|
73308
73875
|
`${dir} is missing index.html at its root (symlinked files are not bundled).`,
|
|
73309
73876
|
jsonMode,
|
|
73310
73877
|
"MISSING_INDEX"
|
|
73311
73878
|
);
|
|
73312
73879
|
}
|
|
73313
73880
|
if (!bundleFiles[MANIFEST_FILENAME]) {
|
|
73314
|
-
|
|
73881
|
+
fail2(
|
|
73315
73882
|
`${dir} is missing ${MANIFEST_FILENAME} at its root (symlinked files are not bundled). Every app bundle needs a manifest; see the build-runtype-app skill or the Runtype docs.`,
|
|
73316
73883
|
jsonMode,
|
|
73317
73884
|
"MISSING_MANIFEST"
|
|
@@ -73359,7 +73926,7 @@ appsCommand.command("deploy <dir>").description("Zip a bundle directory, upload
|
|
|
73359
73926
|
console.log(chalk43.dim(` Uploaded but not activated. Activate with \`runtype apps activate ${options.app} ${version2.id}\``));
|
|
73360
73927
|
}
|
|
73361
73928
|
} catch (error51) {
|
|
73362
|
-
|
|
73929
|
+
fail2(
|
|
73363
73930
|
`Deploy failed: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
73364
73931
|
jsonMode,
|
|
73365
73932
|
"DEPLOY_FAILED"
|
|
@@ -73390,7 +73957,7 @@ appsCommand.command("versions <appId>").description("List an app's versions, new
|
|
|
73390
73957
|
);
|
|
73391
73958
|
}
|
|
73392
73959
|
} catch (error51) {
|
|
73393
|
-
|
|
73960
|
+
fail2(
|
|
73394
73961
|
`Failed to list versions: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
73395
73962
|
jsonMode,
|
|
73396
73963
|
"VERSIONS_FAILED"
|
|
@@ -73412,7 +73979,7 @@ appsCommand.command("activate <appId> <versionId>").description("Activate an upl
|
|
|
73412
73979
|
console.log(chalk43.green(`Activated version ${version2.versionNumber}`));
|
|
73413
73980
|
console.log(` Live at ${chalk43.bold(app.url)}`);
|
|
73414
73981
|
} catch (error51) {
|
|
73415
|
-
|
|
73982
|
+
fail2(
|
|
73416
73983
|
`Activation failed: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
73417
73984
|
jsonMode,
|
|
73418
73985
|
"ACTIVATE_FAILED"
|
|
@@ -73433,7 +74000,7 @@ appsCommand.command("delete <appId>").description("Permanently delete an app, it
|
|
|
73433
74000
|
}
|
|
73434
74001
|
console.log(chalk43.green(`Deleted ${appId}`));
|
|
73435
74002
|
} catch (error51) {
|
|
73436
|
-
|
|
74003
|
+
fail2(
|
|
73437
74004
|
`Delete failed: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
73438
74005
|
jsonMode,
|
|
73439
74006
|
"DELETE_FAILED"
|