@runtypelabs/cli 2.22.12 → 2.22.13
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 +1232 -174
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -142,9 +142,9 @@ import chalk42 from "chalk";
|
|
|
142
142
|
// src/lib/load-env.ts
|
|
143
143
|
import { readFileSync } from "fs";
|
|
144
144
|
import { resolve } from "path";
|
|
145
|
-
function loadEnv(
|
|
145
|
+
function loadEnv(path19 = resolve(process.cwd(), ".env")) {
|
|
146
146
|
try {
|
|
147
|
-
const content = readFileSync(
|
|
147
|
+
const content = readFileSync(path19, "utf8").replace(/\r\n?/g, "\n");
|
|
148
148
|
for (const line of content.split("\n")) {
|
|
149
149
|
if (!line.trim() || line.trimStart().startsWith("#")) continue;
|
|
150
150
|
const match = line.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/);
|
|
@@ -1386,10 +1386,10 @@ function mergeDefs(...defs) {
|
|
|
1386
1386
|
function cloneDef(schema) {
|
|
1387
1387
|
return mergeDefs(schema._zod.def);
|
|
1388
1388
|
}
|
|
1389
|
-
function getElementAtPath(obj,
|
|
1390
|
-
if (!
|
|
1389
|
+
function getElementAtPath(obj, path19) {
|
|
1390
|
+
if (!path19)
|
|
1391
1391
|
return obj;
|
|
1392
|
-
return
|
|
1392
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
1393
1393
|
}
|
|
1394
1394
|
function promiseAllObject(promisesObj) {
|
|
1395
1395
|
const keys = Object.keys(promisesObj);
|
|
@@ -1798,11 +1798,11 @@ function explicitlyAborted(x2, startIndex = 0) {
|
|
|
1798
1798
|
}
|
|
1799
1799
|
return false;
|
|
1800
1800
|
}
|
|
1801
|
-
function prefixIssues(
|
|
1801
|
+
function prefixIssues(path19, issues) {
|
|
1802
1802
|
return issues.map((iss) => {
|
|
1803
1803
|
var _a3;
|
|
1804
1804
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1805
|
-
iss.path.unshift(
|
|
1805
|
+
iss.path.unshift(path19);
|
|
1806
1806
|
return iss;
|
|
1807
1807
|
});
|
|
1808
1808
|
}
|
|
@@ -1949,16 +1949,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1949
1949
|
}
|
|
1950
1950
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1951
1951
|
const fieldErrors = { _errors: [] };
|
|
1952
|
-
const processError = (error52,
|
|
1952
|
+
const processError = (error52, path19 = []) => {
|
|
1953
1953
|
for (const issue2 of error52.issues) {
|
|
1954
1954
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1955
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1955
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
1956
1956
|
} else if (issue2.code === "invalid_key") {
|
|
1957
|
-
processError({ issues: issue2.issues }, [...
|
|
1957
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
1958
1958
|
} else if (issue2.code === "invalid_element") {
|
|
1959
|
-
processError({ issues: issue2.issues }, [...
|
|
1959
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
1960
1960
|
} else {
|
|
1961
|
-
const fullpath = [...
|
|
1961
|
+
const fullpath = [...path19, ...issue2.path];
|
|
1962
1962
|
if (fullpath.length === 0) {
|
|
1963
1963
|
fieldErrors._errors.push(mapper(issue2));
|
|
1964
1964
|
} else {
|
|
@@ -1985,17 +1985,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1985
1985
|
}
|
|
1986
1986
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1987
1987
|
const result = { errors: [] };
|
|
1988
|
-
const processError = (error52,
|
|
1988
|
+
const processError = (error52, path19 = []) => {
|
|
1989
1989
|
var _a3, _b;
|
|
1990
1990
|
for (const issue2 of error52.issues) {
|
|
1991
1991
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1992
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1992
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
1993
1993
|
} else if (issue2.code === "invalid_key") {
|
|
1994
|
-
processError({ issues: issue2.issues }, [...
|
|
1994
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
1995
1995
|
} else if (issue2.code === "invalid_element") {
|
|
1996
|
-
processError({ issues: issue2.issues }, [...
|
|
1996
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
1997
1997
|
} else {
|
|
1998
|
-
const fullpath = [...
|
|
1998
|
+
const fullpath = [...path19, ...issue2.path];
|
|
1999
1999
|
if (fullpath.length === 0) {
|
|
2000
2000
|
result.errors.push(mapper(issue2));
|
|
2001
2001
|
continue;
|
|
@@ -2027,8 +2027,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2027
2027
|
}
|
|
2028
2028
|
function toDotPath(_path) {
|
|
2029
2029
|
const segs = [];
|
|
2030
|
-
const
|
|
2031
|
-
for (const seg of
|
|
2030
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
2031
|
+
for (const seg of path19) {
|
|
2032
2032
|
if (typeof seg === "number")
|
|
2033
2033
|
segs.push(`[${seg}]`);
|
|
2034
2034
|
else if (typeof seg === "symbol")
|
|
@@ -14714,13 +14714,13 @@ function resolveRef(ref, ctx) {
|
|
|
14714
14714
|
if (!ref.startsWith("#")) {
|
|
14715
14715
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14716
14716
|
}
|
|
14717
|
-
const
|
|
14718
|
-
if (
|
|
14717
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
14718
|
+
if (path19.length === 0) {
|
|
14719
14719
|
return ctx.rootSchema;
|
|
14720
14720
|
}
|
|
14721
14721
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14722
|
-
if (
|
|
14723
|
-
const key =
|
|
14722
|
+
if (path19[0] === defsKey) {
|
|
14723
|
+
const key = path19[1];
|
|
14724
14724
|
if (!key || !ctx.defs[key]) {
|
|
14725
14725
|
throw new Error(`Reference not found: ${ref}`);
|
|
14726
14726
|
}
|
|
@@ -15182,8 +15182,8 @@ var edgeContextPayloadSchema = external_exports.object({
|
|
|
15182
15182
|
});
|
|
15183
15183
|
|
|
15184
15184
|
// ../shared/dist/chunk-3FPSMWBQ.mjs
|
|
15185
|
-
function getNestedValue(obj,
|
|
15186
|
-
let normalizedPath =
|
|
15185
|
+
function getNestedValue(obj, path19) {
|
|
15186
|
+
let normalizedPath = path19;
|
|
15187
15187
|
normalizedPath = normalizedPath.replace(/^\$\.?/, "");
|
|
15188
15188
|
normalizedPath = normalizedPath.replace(/\[(\d+)\]/g, ".$1");
|
|
15189
15189
|
normalizedPath = normalizedPath.replace(/\[['"]([^'"\]]+)['"]\]/g, ".$1");
|
|
@@ -19966,8 +19966,8 @@ function validateCodeToolNameCollisions(toolNames, stepRef, code, preSeededCount
|
|
|
19966
19966
|
}
|
|
19967
19967
|
return null;
|
|
19968
19968
|
}
|
|
19969
|
-
function formatPath(
|
|
19970
|
-
return
|
|
19969
|
+
function formatPath(path19) {
|
|
19970
|
+
return path19.reduce((acc, part) => {
|
|
19971
19971
|
if (typeof part === "number") {
|
|
19972
19972
|
return `${acc}[${part}]`;
|
|
19973
19973
|
}
|
|
@@ -20088,17 +20088,17 @@ function collectTransformDataCodeToolNameCheck(toolsConfig, stepIndex, stepRef,
|
|
|
20088
20088
|
if (typeof toolId !== "string") {
|
|
20089
20089
|
continue;
|
|
20090
20090
|
}
|
|
20091
|
-
const
|
|
20091
|
+
const path19 = `flowSteps[${stepIndex}].config.tools.toolIds[${toolIdIndex}]`;
|
|
20092
20092
|
const named = parseNamedToolRef(toolId);
|
|
20093
20093
|
if (named) {
|
|
20094
|
-
selectedToolNames.push({ name: named.name, path:
|
|
20094
|
+
selectedToolNames.push({ name: named.name, path: path19 });
|
|
20095
20095
|
continue;
|
|
20096
20096
|
}
|
|
20097
20097
|
const { customToolIds } = separateToolIds([toolId]);
|
|
20098
20098
|
if (customToolIds.length === 0) {
|
|
20099
20099
|
continue;
|
|
20100
20100
|
}
|
|
20101
|
-
selectedToolIds.push({ toolId, path:
|
|
20101
|
+
selectedToolIds.push({ toolId, path: path19 });
|
|
20102
20102
|
}
|
|
20103
20103
|
if (selectedToolIds.length > 0 || selectedToolNames.length > 0) {
|
|
20104
20104
|
pendingChecks.hasAccountScopedReferences = true;
|
|
@@ -20131,10 +20131,10 @@ function collectCodeModeToolNameCheck(toolsConfig, stepIndex, stepRef, pendingCh
|
|
|
20131
20131
|
if (typeof entry !== "string" || entry.length === 0 || entry.endsWith(":*")) {
|
|
20132
20132
|
continue;
|
|
20133
20133
|
}
|
|
20134
|
-
const
|
|
20134
|
+
const path19 = `flowSteps[${stepIndex}].config.tools.codeModeConfig.toolPool[${toolPoolIndex}]`;
|
|
20135
20135
|
const named = parseNamedToolRef(entry);
|
|
20136
20136
|
if (named) {
|
|
20137
|
-
selectedToolNames.push({ name: named.name, path:
|
|
20137
|
+
selectedToolNames.push({ name: named.name, path: path19 });
|
|
20138
20138
|
continue;
|
|
20139
20139
|
}
|
|
20140
20140
|
if (runtimeToolNames.has(entry)) {
|
|
@@ -20145,7 +20145,7 @@ function collectCodeModeToolNameCheck(toolsConfig, stepIndex, stepRef, pendingCh
|
|
|
20145
20145
|
if (customToolIds.length === 0) {
|
|
20146
20146
|
continue;
|
|
20147
20147
|
}
|
|
20148
|
-
selectedToolIds.push({ toolId: entry, path:
|
|
20148
|
+
selectedToolIds.push({ toolId: entry, path: path19 });
|
|
20149
20149
|
}
|
|
20150
20150
|
if (selectedToolIds.length > 0 || selectedToolNames.length > 0) {
|
|
20151
20151
|
pendingChecks.hasAccountScopedReferences = true;
|
|
@@ -20196,19 +20196,19 @@ var TEMPLATE_STRING_FIELDS = /* @__PURE__ */ new Set([
|
|
|
20196
20196
|
"requestTemplate"
|
|
20197
20197
|
]);
|
|
20198
20198
|
var NON_FLOW_VARIABLE_SUBTREE_KEYS = /* @__PURE__ */ new Set(["tools"]);
|
|
20199
|
-
function extractTemplateStrings(config3,
|
|
20199
|
+
function extractTemplateStrings(config3, path19 = []) {
|
|
20200
20200
|
const results = [];
|
|
20201
20201
|
if (typeof config3 === "string") {
|
|
20202
|
-
const fieldName =
|
|
20203
|
-
const parentFieldName =
|
|
20202
|
+
const fieldName = path19[path19.length - 1];
|
|
20203
|
+
const parentFieldName = path19.length >= 2 ? path19[path19.length - 2] : void 0;
|
|
20204
20204
|
if (fieldName && TEMPLATE_STRING_FIELDS.has(fieldName) || parentFieldName && TEMPLATE_STRING_FIELDS.has(parentFieldName)) {
|
|
20205
|
-
results.push({ value: config3, fieldPath:
|
|
20205
|
+
results.push({ value: config3, fieldPath: path19.join(".") });
|
|
20206
20206
|
}
|
|
20207
20207
|
return results;
|
|
20208
20208
|
}
|
|
20209
20209
|
if (Array.isArray(config3)) {
|
|
20210
20210
|
for (const [index, item] of config3.entries()) {
|
|
20211
|
-
results.push(...extractTemplateStrings(item, [...
|
|
20211
|
+
results.push(...extractTemplateStrings(item, [...path19, String(index)]));
|
|
20212
20212
|
}
|
|
20213
20213
|
return results;
|
|
20214
20214
|
}
|
|
@@ -20216,9 +20216,9 @@ function extractTemplateStrings(config3, path18 = []) {
|
|
|
20216
20216
|
for (const [key, val] of Object.entries(config3)) {
|
|
20217
20217
|
if (NON_FLOW_VARIABLE_SUBTREE_KEYS.has(key)) continue;
|
|
20218
20218
|
if (typeof val === "string" && TEMPLATE_STRING_FIELDS.has(key)) {
|
|
20219
|
-
results.push({ value: val, fieldPath: [...
|
|
20219
|
+
results.push({ value: val, fieldPath: [...path19, key].join(".") });
|
|
20220
20220
|
} else if (typeof val === "object" && val !== null) {
|
|
20221
|
-
results.push(...extractTemplateStrings(val, [...
|
|
20221
|
+
results.push(...extractTemplateStrings(val, [...path19, key]));
|
|
20222
20222
|
}
|
|
20223
20223
|
}
|
|
20224
20224
|
}
|
|
@@ -20249,8 +20249,8 @@ function extractVariableReferences(config3) {
|
|
|
20249
20249
|
while ((match = pattern.exec(value)) !== null) {
|
|
20250
20250
|
const expr = match[1];
|
|
20251
20251
|
if (!expr) continue;
|
|
20252
|
-
for (const
|
|
20253
|
-
references.push({ variable:
|
|
20252
|
+
for (const path19 of extractTemplateExpressionPaths(expr)) {
|
|
20253
|
+
references.push({ variable: path19, fieldPath });
|
|
20254
20254
|
}
|
|
20255
20255
|
}
|
|
20256
20256
|
}
|
|
@@ -20403,7 +20403,7 @@ function validateUpsertRecordSourceShape(flowSteps, buckets) {
|
|
|
20403
20403
|
}
|
|
20404
20404
|
}
|
|
20405
20405
|
}
|
|
20406
|
-
function checkConditionExpression(expr,
|
|
20406
|
+
function checkConditionExpression(expr, path19, stepRef, buckets) {
|
|
20407
20407
|
if (typeof expr !== "string" || !expr.includes("{{")) return;
|
|
20408
20408
|
const match = UNQUOTED_TEMPLATE_BEFORE_OP.exec(expr) || UNQUOTED_TEMPLATE_AFTER_OP.exec(expr);
|
|
20409
20409
|
if (!match) return;
|
|
@@ -20413,7 +20413,7 @@ function checkConditionExpression(expr, path18, stepRef, buckets) {
|
|
|
20413
20413
|
{
|
|
20414
20414
|
code: "CONDITION_UNQUOTED_TEMPLATE_COMPARISON",
|
|
20415
20415
|
message: `Expression compares an unquoted {{...}} placeholder against a string literal (\`${snippet}\`). \`condition\` / \`when\` predicates are JavaScript evaluated after template substitution, so a non-numeric value substitutes in as a bare identifier (e.g. \`healthy === 'watch'\`) and throws "ReferenceError: <value> is not defined" at runtime. Quote the placeholder \u2014 e.g. '{{var}}' === '...' \u2014 or compare numerically.`,
|
|
20416
|
-
path:
|
|
20416
|
+
path: path19,
|
|
20417
20417
|
step: stepRef,
|
|
20418
20418
|
details: { snippet }
|
|
20419
20419
|
},
|
|
@@ -20491,24 +20491,24 @@ function collectAccountScopedReferences(step, stepIndex, pendingChecks) {
|
|
|
20491
20491
|
if (step.type === "execute-agent") {
|
|
20492
20492
|
const agentId = step.config.agentId;
|
|
20493
20493
|
if (typeof agentId === "string" && !agentId.includes("{{")) {
|
|
20494
|
-
const
|
|
20495
|
-
registerAgentReference(agentId,
|
|
20494
|
+
const path19 = `flowSteps[${stepIndex}].config.agentId`;
|
|
20495
|
+
registerAgentReference(agentId, path19, stepRef, pendingChecks);
|
|
20496
20496
|
}
|
|
20497
20497
|
return;
|
|
20498
20498
|
}
|
|
20499
20499
|
if (step.type === "tool-call") {
|
|
20500
20500
|
const toolId = step.config.toolId;
|
|
20501
20501
|
if (typeof toolId === "string") {
|
|
20502
|
-
const
|
|
20502
|
+
const path19 = `flowSteps[${stepIndex}].config.toolId`;
|
|
20503
20503
|
const named = parseNamedToolRef(toolId);
|
|
20504
20504
|
if (named) {
|
|
20505
20505
|
pendingChecks.hasAccountScopedReferences = true;
|
|
20506
|
-
registerReference(pendingChecks.toolReferencesByName, named.name, { path:
|
|
20506
|
+
registerReference(pendingChecks.toolReferencesByName, named.name, { path: path19, step: stepRef });
|
|
20507
20507
|
} else {
|
|
20508
20508
|
const { customToolIds } = separateToolIds([toolId]);
|
|
20509
20509
|
if (customToolIds.length > 0) {
|
|
20510
20510
|
pendingChecks.hasAccountScopedReferences = true;
|
|
20511
|
-
registerReference(pendingChecks.toolReferencesById, toolId, { path:
|
|
20511
|
+
registerReference(pendingChecks.toolReferencesById, toolId, { path: path19, step: stepRef });
|
|
20512
20512
|
}
|
|
20513
20513
|
}
|
|
20514
20514
|
}
|
|
@@ -20527,17 +20527,17 @@ function collectAccountScopedReferences(step, stepIndex, pendingChecks) {
|
|
|
20527
20527
|
if (typeof toolId !== "string") {
|
|
20528
20528
|
continue;
|
|
20529
20529
|
}
|
|
20530
|
-
const
|
|
20530
|
+
const path19 = `flowSteps[${stepIndex}].config.tools.toolIds[${toolIdIndex}]`;
|
|
20531
20531
|
const named = parseNamedToolRef(toolId);
|
|
20532
20532
|
if (named) {
|
|
20533
20533
|
pendingChecks.hasAccountScopedReferences = true;
|
|
20534
|
-
registerReference(pendingChecks.toolReferencesByName, named.name, { path:
|
|
20534
|
+
registerReference(pendingChecks.toolReferencesByName, named.name, { path: path19, step: stepRef });
|
|
20535
20535
|
continue;
|
|
20536
20536
|
}
|
|
20537
20537
|
const { customToolIds } = separateToolIds([toolId]);
|
|
20538
20538
|
if (customToolIds.length > 0) {
|
|
20539
20539
|
pendingChecks.hasAccountScopedReferences = true;
|
|
20540
|
-
registerReference(pendingChecks.toolReferencesById, toolId, { path:
|
|
20540
|
+
registerReference(pendingChecks.toolReferencesById, toolId, { path: path19, step: stepRef });
|
|
20541
20541
|
}
|
|
20542
20542
|
}
|
|
20543
20543
|
}
|
|
@@ -20575,22 +20575,22 @@ function collectAccountScopedReferences(step, stepIndex, pendingChecks) {
|
|
|
20575
20575
|
}
|
|
20576
20576
|
}
|
|
20577
20577
|
}
|
|
20578
|
-
function registerAgentReference(agentId,
|
|
20578
|
+
function registerAgentReference(agentId, path19, stepRef, pendingChecks) {
|
|
20579
20579
|
const named = parseNamedAgentRef(agentId);
|
|
20580
20580
|
pendingChecks.hasAccountScopedReferences = true;
|
|
20581
20581
|
if (named) {
|
|
20582
|
-
registerReference(pendingChecks.agentReferencesByName, named.name, { path:
|
|
20582
|
+
registerReference(pendingChecks.agentReferencesByName, named.name, { path: path19, step: stepRef });
|
|
20583
20583
|
} else {
|
|
20584
|
-
registerReference(pendingChecks.agentReferencesById, agentId, { path:
|
|
20584
|
+
registerReference(pendingChecks.agentReferencesById, agentId, { path: path19, step: stepRef });
|
|
20585
20585
|
}
|
|
20586
20586
|
}
|
|
20587
|
-
function registerFlowReference(flowId,
|
|
20587
|
+
function registerFlowReference(flowId, path19, stepRef, pendingChecks) {
|
|
20588
20588
|
const named = parseNamedFlowRef(flowId);
|
|
20589
20589
|
pendingChecks.hasAccountScopedReferences = true;
|
|
20590
20590
|
if (named) {
|
|
20591
|
-
registerReference(pendingChecks.flowReferencesByName, named.name, { path:
|
|
20591
|
+
registerReference(pendingChecks.flowReferencesByName, named.name, { path: path19, step: stepRef });
|
|
20592
20592
|
} else {
|
|
20593
|
-
registerReference(pendingChecks.flowReferencesById, flowId, { path:
|
|
20593
|
+
registerReference(pendingChecks.flowReferencesById, flowId, { path: path19, step: stepRef });
|
|
20594
20594
|
}
|
|
20595
20595
|
}
|
|
20596
20596
|
function validateSubagentConfig(value, stepTools, stepIndex, stepRef) {
|
|
@@ -35752,7 +35752,7 @@ var CORE_BUILTIN_TOOLS_REGISTRY = [
|
|
|
35752
35752
|
{
|
|
35753
35753
|
id: "bash",
|
|
35754
35754
|
name: "Bash",
|
|
35755
|
-
description:
|
|
35755
|
+
description: 'Run a shell command on your Linux computer (Node 22, Python 3.12, git, pnpm, uv, ripgrep preinstalled). Commands run in /workspace; files you write there are available to later commands, but system-level changes outside /workspace may not persist. Combined stdout/stderr is returned. Prefer searching over dumping: use `rg`/`grep` to find the lines you need and `head`/`tail`/`sed -n` to read slices, rather than printing whole files or verbose logs. Output is capped (head + tail) and the full output is spilled to a file in the sandbox that you can grep \u2014 so re-running a noisy command to "see the rest" wastes time; grep the spilled file instead. Pass slow_ok=true for commands that take a while (installs, builds, test suites).',
|
|
35756
35756
|
category: BuiltInToolCategory.SANDBOX,
|
|
35757
35757
|
toolGroup: BuiltInToolGroup.SANDBOX_AGENT,
|
|
35758
35758
|
providers: [BuiltInToolProvider.MULTI],
|
|
@@ -35779,7 +35779,7 @@ var CORE_BUILTIN_TOOLS_REGISTRY = [
|
|
|
35779
35779
|
{
|
|
35780
35780
|
id: "read_file",
|
|
35781
35781
|
name: "Read File",
|
|
35782
|
-
description: "Read a file from your computer. Returns the
|
|
35782
|
+
description: "Read a file from your computer (relative paths resolve against /workspace). Returns the contents as a string. Large files and very long lines are truncated; to find something in a big file, grep/rg it from bash (e.g. `rg -n <pattern> <path>`) or read a slice with `sed -n` instead of reading the whole file.",
|
|
35783
35783
|
category: BuiltInToolCategory.SANDBOX,
|
|
35784
35784
|
toolGroup: BuiltInToolGroup.SANDBOX_AGENT,
|
|
35785
35785
|
providers: [BuiltInToolProvider.MULTI],
|
|
@@ -40866,8 +40866,8 @@ var FLAT_ADVANCED_CONFIG_KEYS = {
|
|
|
40866
40866
|
var FLAT_ADVANCED_CONFIG_KEY_LIST = Object.keys(
|
|
40867
40867
|
FLAT_ADVANCED_CONFIG_KEYS
|
|
40868
40868
|
);
|
|
40869
|
-
function createIssue(severity, code, message,
|
|
40870
|
-
return { code, message, path:
|
|
40869
|
+
function createIssue(severity, code, message, path19, suggestedFix) {
|
|
40870
|
+
return { code, message, path: path19, severity, ...suggestedFix ? { suggestedFix } : {} };
|
|
40871
40871
|
}
|
|
40872
40872
|
function emptyResult() {
|
|
40873
40873
|
return { valid: true, errors: [], warnings: [], recommendations: [] };
|
|
@@ -41593,16 +41593,16 @@ var FLOW_PREFIX = Object.values(RUNTIME_PREFIXES).find((spec) => spec.namespace
|
|
|
41593
41593
|
var SECRET_PREFIX = Object.values(RUNTIME_PREFIXES).find(
|
|
41594
41594
|
(spec) => spec.namespace === "secret"
|
|
41595
41595
|
).prefix;
|
|
41596
|
-
function collectStringLeafPaths(value,
|
|
41596
|
+
function collectStringLeafPaths(value, path19 = []) {
|
|
41597
41597
|
if (typeof value === "string") {
|
|
41598
|
-
return [{ path:
|
|
41598
|
+
return [{ path: path19, value }];
|
|
41599
41599
|
}
|
|
41600
41600
|
if (Array.isArray(value)) {
|
|
41601
|
-
return value.flatMap((item, index) => collectStringLeafPaths(item, [...
|
|
41601
|
+
return value.flatMap((item, index) => collectStringLeafPaths(item, [...path19, String(index)]));
|
|
41602
41602
|
}
|
|
41603
41603
|
if (value && typeof value === "object") {
|
|
41604
41604
|
return Object.entries(value).flatMap(
|
|
41605
|
-
([key, nestedValue]) => collectStringLeafPaths(nestedValue, [...
|
|
41605
|
+
([key, nestedValue]) => collectStringLeafPaths(nestedValue, [...path19, key])
|
|
41606
41606
|
);
|
|
41607
41607
|
}
|
|
41608
41608
|
return [];
|
|
@@ -43460,7 +43460,7 @@ function buildDashboardUrl(opts) {
|
|
|
43460
43460
|
while (base.endsWith("/")) {
|
|
43461
43461
|
base = base.slice(0, -1);
|
|
43462
43462
|
}
|
|
43463
|
-
const
|
|
43463
|
+
const path19 = opts.path.startsWith("/") ? opts.path : `/${opts.path}`;
|
|
43464
43464
|
const params = new URLSearchParams();
|
|
43465
43465
|
if (isValidAccountId(opts.account)) {
|
|
43466
43466
|
params.set(ACCOUNT_QUERY_PARAM, opts.account);
|
|
@@ -43473,7 +43473,7 @@ function buildDashboardUrl(opts) {
|
|
|
43473
43473
|
}
|
|
43474
43474
|
}
|
|
43475
43475
|
const qs = params.toString();
|
|
43476
|
-
return qs ? `${base}${
|
|
43476
|
+
return qs ? `${base}${path19}?${qs}` : `${base}${path19}`;
|
|
43477
43477
|
}
|
|
43478
43478
|
function parseAccountId(value) {
|
|
43479
43479
|
if (!value) return null;
|
|
@@ -44776,13 +44776,13 @@ function parseJsonObject(raw, label) {
|
|
|
44776
44776
|
}
|
|
44777
44777
|
return parsed;
|
|
44778
44778
|
}
|
|
44779
|
-
function readJsonFile(
|
|
44779
|
+
function readJsonFile(path19, opts = {}) {
|
|
44780
44780
|
const label = opts.label ?? "file";
|
|
44781
44781
|
let raw;
|
|
44782
44782
|
try {
|
|
44783
|
-
raw = readFileSync3(
|
|
44783
|
+
raw = readFileSync3(path19, "utf-8");
|
|
44784
44784
|
} catch {
|
|
44785
|
-
console.error(chalk2.red(`Failed to read ${label}: ${
|
|
44785
|
+
console.error(chalk2.red(`Failed to read ${label}: ${path19}`));
|
|
44786
44786
|
process.exit(1);
|
|
44787
44787
|
}
|
|
44788
44788
|
const obj = parseJsonObject(raw, label);
|
|
@@ -48664,11 +48664,21 @@ import open2 from "open";
|
|
|
48664
48664
|
|
|
48665
48665
|
// src/lib/account-context.ts
|
|
48666
48666
|
init_credential_store();
|
|
48667
|
-
async function getCurrentAccountId() {
|
|
48667
|
+
async function getCurrentAccountId(options) {
|
|
48668
|
+
if (options?.apiKey) {
|
|
48669
|
+
try {
|
|
48670
|
+
const apiKeyManager = new ApiKeyManager();
|
|
48671
|
+
const user = await apiKeyManager.getCurrentUser(options.apiKey, options.apiUrl);
|
|
48672
|
+
const account = selectAccountId({ userId: user.userId, organizationId: user.orgId });
|
|
48673
|
+
if (account) return account;
|
|
48674
|
+
} catch {
|
|
48675
|
+
}
|
|
48676
|
+
}
|
|
48668
48677
|
try {
|
|
48669
48678
|
const store = new CredentialStore();
|
|
48670
48679
|
const creds = await store.getCredentials();
|
|
48671
48680
|
if (!creds) return void 0;
|
|
48681
|
+
if (options?.apiKey && creds.apiKey !== options.apiKey) return void 0;
|
|
48672
48682
|
return selectAccountId({ userId: creds.userId, organizationId: creds.orgId });
|
|
48673
48683
|
} catch {
|
|
48674
48684
|
return void 0;
|
|
@@ -64429,8 +64439,8 @@ apiKeysCommand.command("analytics").description("Show API key usage analytics").
|
|
|
64429
64439
|
const client = createCliClient(apiKey);
|
|
64430
64440
|
if (!isTTY(options) || options.json) {
|
|
64431
64441
|
try {
|
|
64432
|
-
const
|
|
64433
|
-
const data = await client.get(
|
|
64442
|
+
const path19 = options.key ? `/api-keys/${options.key}/analytics` : "/api-keys/analytics";
|
|
64443
|
+
const data = await client.get(path19);
|
|
64434
64444
|
printJson(data);
|
|
64435
64445
|
} catch (error51) {
|
|
64436
64446
|
const message = error51 instanceof Error ? error51.message : "Unknown error";
|
|
@@ -64447,8 +64457,8 @@ apiKeysCommand.command("analytics").description("Show API key usage analytics").
|
|
|
64447
64457
|
useEffect31(() => {
|
|
64448
64458
|
const run2 = async () => {
|
|
64449
64459
|
try {
|
|
64450
|
-
const
|
|
64451
|
-
const data = await client.get(
|
|
64460
|
+
const path19 = options.key ? `/api-keys/${options.key}/analytics` : "/api-keys/analytics";
|
|
64461
|
+
const data = await client.get(path19);
|
|
64452
64462
|
printJson(data);
|
|
64453
64463
|
setSuccess(true);
|
|
64454
64464
|
setLoading(false);
|
|
@@ -64901,7 +64911,7 @@ clientTokensCommand.command("regenerate <id>").description("Regenerate a client
|
|
|
64901
64911
|
import { Command as Command23 } from "commander";
|
|
64902
64912
|
import chalk30 from "chalk";
|
|
64903
64913
|
import readline3 from "readline";
|
|
64904
|
-
import
|
|
64914
|
+
import openBrowser from "open";
|
|
64905
64915
|
import { execFileSync } from "child_process";
|
|
64906
64916
|
|
|
64907
64917
|
// src/lib/persona-init.ts
|
|
@@ -65238,8 +65248,52 @@ function generatePersonaInitSnippet(input, personaFormat) {
|
|
|
65238
65248
|
target ? { target } : void 0
|
|
65239
65249
|
);
|
|
65240
65250
|
}
|
|
65251
|
+
function getPersonaInstallerScriptUrl() {
|
|
65252
|
+
const snippet = R(
|
|
65253
|
+
{
|
|
65254
|
+
apiUrl: "https://api.runtype.com",
|
|
65255
|
+
clientToken: "ct_test_demo_00000000000000000000000000000000",
|
|
65256
|
+
parserType: "json"
|
|
65257
|
+
},
|
|
65258
|
+
"script-installer"
|
|
65259
|
+
);
|
|
65260
|
+
const match = snippet.match(/<script\s+src="([^"]+)"/);
|
|
65261
|
+
return match?.[1] ?? "https://cdn.jsdelivr.net/npm/@runtypelabs/persona/dist/install.global.js";
|
|
65262
|
+
}
|
|
65241
65263
|
|
|
65242
65264
|
// src/lib/persona-init.ts
|
|
65265
|
+
var PERSONA_INIT_AGENT_MODEL = "nemotron-3-ultra-550b-a55b";
|
|
65266
|
+
var PERSONA_INIT_DEMO_SYSTEM_PROMPT = `
|
|
65267
|
+
# Persona Playground Agent
|
|
65268
|
+
|
|
65269
|
+
## Role
|
|
65270
|
+
|
|
65271
|
+
You are the assistant inside a local Persona Playground generated by the Runtype CLI.
|
|
65272
|
+
|
|
65273
|
+
## Goal
|
|
65274
|
+
|
|
65275
|
+
Give the user one quick, visible "aha" moment: inspect the local page, request approval for a browser-side update, make the page change, and leave them with native next-step pills.
|
|
65276
|
+
|
|
65277
|
+
## Available page tools
|
|
65278
|
+
|
|
65279
|
+
- \`get_playground_state\` \u2014 read the current accent, headline, note, status, checklist, URL, and allowed origins.
|
|
65280
|
+
- \`update_playground\` \u2014 update the accent, headline, note, status, or checklist on the local HTML page.
|
|
65281
|
+
|
|
65282
|
+
## Demo behavior
|
|
65283
|
+
|
|
65284
|
+
1. Use \`get_playground_state\` before describing the current page or proposing a specific page change.
|
|
65285
|
+
2. Use \`update_playground\` when the user asks you to change the page.
|
|
65286
|
+
3. Explain, only when relevant, that mutating page updates require the user to approve Persona's tool-call bubble.
|
|
65287
|
+
4. After every successful \`update_playground\` call, follow \`responseGuidance\` exactly: do not send a visible response yet; first call \`suggest_replies\` with \`responseGuidance.suggestedReplies\`.
|
|
65288
|
+
5. When \`suggest_replies\` returns, send \`responseGuidance.assistantMessage\` exactly once as your only visible confirmation, then stop.
|
|
65289
|
+
6. Do not ask "what would you like to do next?" in prose; the Persona widget renders \`suggest_replies\` as tappable next-step pills.
|
|
65290
|
+
|
|
65291
|
+
## Response style
|
|
65292
|
+
|
|
65293
|
+
- Be concise, direct, and practical.
|
|
65294
|
+
- Prefer showing the page changing over explaining how it works.
|
|
65295
|
+
- If the user asks how to customize the demo, point them to \`index.html\`, the generated README, and the Runtype dashboard link.
|
|
65296
|
+
`.trim();
|
|
65243
65297
|
async function getPersonaInitApiKeyNonInteractive(apiUrl) {
|
|
65244
65298
|
const envApiKey = getRuntimeApiKey();
|
|
65245
65299
|
if (envApiKey) {
|
|
@@ -65257,14 +65311,75 @@ async function getPersonaInitApiKeyNonInteractive(apiUrl) {
|
|
|
65257
65311
|
}
|
|
65258
65312
|
async function runPersonaInit(options) {
|
|
65259
65313
|
const client = createCliClient(options.apiKey, options.apiUrl);
|
|
65314
|
+
const demoEnabled = !!options.demo;
|
|
65260
65315
|
const agent = await client.post("/agents", {
|
|
65261
65316
|
name: options.agentName,
|
|
65262
65317
|
description: options.agentDescription || "A Persona test agent",
|
|
65263
65318
|
config: {
|
|
65264
|
-
model:
|
|
65265
|
-
systemPrompt: "You are a helpful assistant."
|
|
65319
|
+
model: PERSONA_INIT_AGENT_MODEL,
|
|
65320
|
+
systemPrompt: demoEnabled ? PERSONA_INIT_DEMO_SYSTEM_PROMPT : "You are a helpful assistant."
|
|
65266
65321
|
}
|
|
65267
65322
|
});
|
|
65323
|
+
let demoResources;
|
|
65324
|
+
if (options.demo) {
|
|
65325
|
+
const product = await client.post("/products", {
|
|
65326
|
+
name: `${options.agentName} Persona Playground`,
|
|
65327
|
+
description: "Local Persona WebMCP playground generated by the Runtype CLI.",
|
|
65328
|
+
icon: "\u2728",
|
|
65329
|
+
spec: {
|
|
65330
|
+
productGoal: "Demonstrate a Persona widget operating a host page through WebMCP tools.",
|
|
65331
|
+
targetAudience: "Developers testing Persona locally.",
|
|
65332
|
+
productStage: "prototype"
|
|
65333
|
+
}
|
|
65334
|
+
});
|
|
65335
|
+
const capability = await client.post(
|
|
65336
|
+
`/products/${product.id}/capabilities`,
|
|
65337
|
+
{
|
|
65338
|
+
agentId: agent.id,
|
|
65339
|
+
capabilityName: "Persona Playground Assistant",
|
|
65340
|
+
capabilityDescription: "Agent that can read and update the local Persona Playground page through WebMCP tools.",
|
|
65341
|
+
enabled: true
|
|
65342
|
+
}
|
|
65343
|
+
);
|
|
65344
|
+
const allowlist = options.demo.origins.map((origin) => ({
|
|
65345
|
+
origin,
|
|
65346
|
+
tools: options.demo?.toolNames ?? []
|
|
65347
|
+
}));
|
|
65348
|
+
const surface = await client.post(
|
|
65349
|
+
`/products/${product.id}/surfaces`,
|
|
65350
|
+
{
|
|
65351
|
+
name: "Local Persona Playground",
|
|
65352
|
+
type: "chat",
|
|
65353
|
+
status: "active",
|
|
65354
|
+
environment: "development",
|
|
65355
|
+
behavior: {
|
|
65356
|
+
type: "chat",
|
|
65357
|
+
welcomeMessage: "Try asking me to inspect or update this local page. I can use WebMCP tools registered by the HTML file.",
|
|
65358
|
+
webmcp: {
|
|
65359
|
+
enabled: true,
|
|
65360
|
+
allowlist,
|
|
65361
|
+
requireConfirmFor: ["update_playground"]
|
|
65362
|
+
}
|
|
65363
|
+
}
|
|
65364
|
+
}
|
|
65365
|
+
);
|
|
65366
|
+
const surfaceItem = await client.post(
|
|
65367
|
+
`/products/${product.id}/surfaces/${surface.id}/items`,
|
|
65368
|
+
{
|
|
65369
|
+
capabilityId: capability.id,
|
|
65370
|
+
exposedName: "Persona Playground Assistant",
|
|
65371
|
+
exposedDescription: "Operate the generated local HTML playground.",
|
|
65372
|
+
enabled: true,
|
|
65373
|
+
isEntryPoint: true
|
|
65374
|
+
}
|
|
65375
|
+
);
|
|
65376
|
+
demoResources = {
|
|
65377
|
+
productId: product.id,
|
|
65378
|
+
capabilityId: capability.id,
|
|
65379
|
+
surfaceId: surface.id,
|
|
65380
|
+
surfaceItemId: surfaceItem.id
|
|
65381
|
+
};
|
|
65382
|
+
}
|
|
65268
65383
|
const tokenBody = {
|
|
65269
65384
|
name: options.tokenName,
|
|
65270
65385
|
flowIds: [],
|
|
@@ -65274,7 +65389,8 @@ async function runPersonaInit(options) {
|
|
|
65274
65389
|
rateLimitPerMinute: 10,
|
|
65275
65390
|
rateLimitPerHour: 100,
|
|
65276
65391
|
maxMessagesPerSession: 100,
|
|
65277
|
-
sessionIdleTimeoutMinutes: 30
|
|
65392
|
+
sessionIdleTimeoutMinutes: 30,
|
|
65393
|
+
...demoResources ? { productSurfaceId: demoResources.surfaceId } : {}
|
|
65278
65394
|
};
|
|
65279
65395
|
const tokenRes = await client.post("/client-tokens", tokenBody);
|
|
65280
65396
|
const personaFormat = mapCliFormatToPersona(options.format);
|
|
@@ -65287,7 +65403,7 @@ async function runPersonaInit(options) {
|
|
|
65287
65403
|
personaFormat
|
|
65288
65404
|
);
|
|
65289
65405
|
const dashboardBase = getDashboardUrl();
|
|
65290
|
-
const account = await getCurrentAccountId();
|
|
65406
|
+
const account = await getCurrentAccountId({ apiKey: options.apiKey, apiUrl: options.apiUrl });
|
|
65291
65407
|
const dashboardUrl = buildDashboardUrl({
|
|
65292
65408
|
baseUrl: dashboardBase,
|
|
65293
65409
|
path: `/agents/${agent.id}`,
|
|
@@ -65304,20 +65420,718 @@ async function runPersonaInit(options) {
|
|
|
65304
65420
|
},
|
|
65305
65421
|
snippet: { format: options.format, code },
|
|
65306
65422
|
dashboardUrl,
|
|
65307
|
-
warnings: tokenRes.warnings
|
|
65423
|
+
warnings: tokenRes.warnings,
|
|
65424
|
+
...demoResources ? { demo: demoResources } : {}
|
|
65308
65425
|
};
|
|
65309
65426
|
}
|
|
65310
65427
|
|
|
65428
|
+
// src/lib/persona-demo.ts
|
|
65429
|
+
import { createServer } from "http";
|
|
65430
|
+
import { createServer as createNetServer } from "net";
|
|
65431
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync17, writeFileSync as writeFileSync6 } from "fs";
|
|
65432
|
+
import path16 from "path";
|
|
65433
|
+
var PERSONA_DEMO_DEFAULT_DIR = "persona-demo";
|
|
65434
|
+
var PERSONA_DEMO_DEFAULT_PORT = 43110;
|
|
65435
|
+
var PERSONA_DEMO_TOOL_NAMES = ["get_playground_state", "update_playground"];
|
|
65436
|
+
function unique(values) {
|
|
65437
|
+
return [...new Set(values.filter(Boolean))];
|
|
65438
|
+
}
|
|
65439
|
+
function buildPersonaDemoOrigins(port) {
|
|
65440
|
+
return [`http://localhost:${port}`, `http://127.0.0.1:${port}`];
|
|
65441
|
+
}
|
|
65442
|
+
function mergePersonaDemoAllowedOrigins(requestedOrigins, demoOrigins) {
|
|
65443
|
+
const explicitOrigins = (requestedOrigins ?? []).filter((origin) => origin !== "*");
|
|
65444
|
+
return unique([...demoOrigins, ...explicitOrigins]);
|
|
65445
|
+
}
|
|
65446
|
+
function resolvePersonaDemoDirectory(input) {
|
|
65447
|
+
return path16.resolve(process.cwd(), input?.trim() || PERSONA_DEMO_DEFAULT_DIR);
|
|
65448
|
+
}
|
|
65449
|
+
function personaDemoIndexPath(directory) {
|
|
65450
|
+
return path16.join(directory, "index.html");
|
|
65451
|
+
}
|
|
65452
|
+
function personaDemoReadmePath(directory) {
|
|
65453
|
+
return path16.join(directory, "README.md");
|
|
65454
|
+
}
|
|
65455
|
+
function ensurePersonaDemoCanWrite(directory, force) {
|
|
65456
|
+
const existingFiles = [personaDemoIndexPath(directory), personaDemoReadmePath(directory)].filter(
|
|
65457
|
+
(filePath) => existsSync13(filePath)
|
|
65458
|
+
);
|
|
65459
|
+
if (existingFiles.length > 0 && !force) {
|
|
65460
|
+
throw new Error(
|
|
65461
|
+
`Demo file already exists at ${existingFiles.join(", ")}. Pass --force to overwrite demo files or choose --demo-dir.`
|
|
65462
|
+
);
|
|
65463
|
+
}
|
|
65464
|
+
}
|
|
65465
|
+
function writePersonaDemoPage(options) {
|
|
65466
|
+
ensurePersonaDemoCanWrite(options.directory, options.force);
|
|
65467
|
+
mkdirSync8(options.directory, { recursive: true });
|
|
65468
|
+
const filePath = personaDemoIndexPath(options.directory);
|
|
65469
|
+
const readmePath = personaDemoReadmePath(options.directory);
|
|
65470
|
+
writeFileSync6(filePath, `${options.html.trim()}
|
|
65471
|
+
`, "utf8");
|
|
65472
|
+
writeFileSync6(readmePath, `${options.readme.trim()}
|
|
65473
|
+
`, "utf8");
|
|
65474
|
+
return { directory: options.directory, filePath, readmePath };
|
|
65475
|
+
}
|
|
65476
|
+
async function findAvailablePersonaDemoPort(preferredPort = PERSONA_DEMO_DEFAULT_PORT) {
|
|
65477
|
+
for (let offset = 0; offset < 50; offset += 1) {
|
|
65478
|
+
const port = preferredPort + offset;
|
|
65479
|
+
if (await canListenOnPort(port)) {
|
|
65480
|
+
return port;
|
|
65481
|
+
}
|
|
65482
|
+
}
|
|
65483
|
+
throw new Error(`Could not find an available local port starting at ${preferredPort}`);
|
|
65484
|
+
}
|
|
65485
|
+
function canListenOnPort(port) {
|
|
65486
|
+
return new Promise((resolve11) => {
|
|
65487
|
+
const server = createNetServer();
|
|
65488
|
+
server.once("error", () => {
|
|
65489
|
+
resolve11(false);
|
|
65490
|
+
});
|
|
65491
|
+
server.once("listening", () => {
|
|
65492
|
+
server.close(() => resolve11(true));
|
|
65493
|
+
});
|
|
65494
|
+
server.listen(port, "127.0.0.1");
|
|
65495
|
+
});
|
|
65496
|
+
}
|
|
65497
|
+
async function startPersonaDemoServer(options) {
|
|
65498
|
+
const filePath = personaDemoIndexPath(options.directory);
|
|
65499
|
+
const server = createServer((req, res) => {
|
|
65500
|
+
const url2 = req.url?.split("?")[0] ?? "/";
|
|
65501
|
+
if (url2 !== "/" && url2 !== "/index.html") {
|
|
65502
|
+
res.writeHead(404, { "content-type": "text/plain; charset=utf-8" });
|
|
65503
|
+
res.end("Not found");
|
|
65504
|
+
return;
|
|
65505
|
+
}
|
|
65506
|
+
res.writeHead(200, {
|
|
65507
|
+
"content-type": "text/html; charset=utf-8",
|
|
65508
|
+
"cache-control": "no-store"
|
|
65509
|
+
});
|
|
65510
|
+
res.end(readIndexHtml(filePath));
|
|
65511
|
+
});
|
|
65512
|
+
await listen(server, options.port);
|
|
65513
|
+
return {
|
|
65514
|
+
url: `http://127.0.0.1:${options.port}/`,
|
|
65515
|
+
port: options.port,
|
|
65516
|
+
close: () => new Promise((resolve11, reject) => {
|
|
65517
|
+
server.close((error51) => {
|
|
65518
|
+
if (error51) reject(error51);
|
|
65519
|
+
else resolve11();
|
|
65520
|
+
});
|
|
65521
|
+
})
|
|
65522
|
+
};
|
|
65523
|
+
}
|
|
65524
|
+
function readIndexHtml(filePath) {
|
|
65525
|
+
return readFileSync17(filePath, "utf8");
|
|
65526
|
+
}
|
|
65527
|
+
function listen(server, port) {
|
|
65528
|
+
return new Promise((resolve11, reject) => {
|
|
65529
|
+
server.once("error", reject);
|
|
65530
|
+
server.listen(port, "127.0.0.1", () => {
|
|
65531
|
+
server.off("error", reject);
|
|
65532
|
+
resolve11();
|
|
65533
|
+
});
|
|
65534
|
+
});
|
|
65535
|
+
}
|
|
65536
|
+
function escapeHtml(value) {
|
|
65537
|
+
return value.replace(/[&<>"']/g, (char) => {
|
|
65538
|
+
switch (char) {
|
|
65539
|
+
case "&":
|
|
65540
|
+
return "&";
|
|
65541
|
+
case "<":
|
|
65542
|
+
return "<";
|
|
65543
|
+
case ">":
|
|
65544
|
+
return ">";
|
|
65545
|
+
case '"':
|
|
65546
|
+
return """;
|
|
65547
|
+
case "'":
|
|
65548
|
+
return "'";
|
|
65549
|
+
default:
|
|
65550
|
+
return char;
|
|
65551
|
+
}
|
|
65552
|
+
});
|
|
65553
|
+
}
|
|
65554
|
+
function inlineJson(value) {
|
|
65555
|
+
return JSON.stringify(value, null, 2).replace(/<\//g, "<\\/");
|
|
65556
|
+
}
|
|
65557
|
+
function generatePersonaDemoHtml(input) {
|
|
65558
|
+
const installerScriptUrl = input.installerScriptUrl ?? getPersonaInstallerScriptUrl();
|
|
65559
|
+
const pageData = {
|
|
65560
|
+
apiUrl: input.apiUrl,
|
|
65561
|
+
clientToken: input.clientToken,
|
|
65562
|
+
clientTokenId: input.clientTokenId,
|
|
65563
|
+
agentId: input.agentId,
|
|
65564
|
+
agentName: input.agentName,
|
|
65565
|
+
dashboardUrl: input.dashboardUrl,
|
|
65566
|
+
environment: input.environment,
|
|
65567
|
+
localUrl: input.localUrl,
|
|
65568
|
+
allowedOrigins: input.allowedOrigins
|
|
65569
|
+
};
|
|
65570
|
+
return `<!doctype html>
|
|
65571
|
+
<html lang="en">
|
|
65572
|
+
<head>
|
|
65573
|
+
<meta charset="utf-8" />
|
|
65574
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
65575
|
+
<title>Persona Local Playground</title>
|
|
65576
|
+
<style>
|
|
65577
|
+
:root {
|
|
65578
|
+
--paper: #fcfcfa;
|
|
65579
|
+
--paper-deep: #f4f0e8;
|
|
65580
|
+
--ink: #24211f;
|
|
65581
|
+
--muted: #67615b;
|
|
65582
|
+
--line: #d9d2c7;
|
|
65583
|
+
--line-strong: #201a16;
|
|
65584
|
+
--accent: #4c00ff;
|
|
65585
|
+
--accent-soft: color-mix(in srgb, var(--accent) 8%, var(--paper));
|
|
65586
|
+
--live: #b6ff00;
|
|
65587
|
+
--success: #178c4b;
|
|
65588
|
+
--radius: 6px;
|
|
65589
|
+
}
|
|
65590
|
+
* { box-sizing: border-box; }
|
|
65591
|
+
body {
|
|
65592
|
+
margin: 0;
|
|
65593
|
+
min-height: 100vh;
|
|
65594
|
+
color: var(--ink);
|
|
65595
|
+
font-family: Asap, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
65596
|
+
background:
|
|
65597
|
+
linear-gradient(90deg, rgba(36, 33, 31, .045) 1px, transparent 1px) 0 0 / 40px 40px,
|
|
65598
|
+
linear-gradient(rgba(36, 33, 31, .04) 1px, transparent 1px) 0 0 / 40px 40px,
|
|
65599
|
+
radial-gradient(circle at 18% 0%, var(--accent-soft), transparent 30rem),
|
|
65600
|
+
var(--paper);
|
|
65601
|
+
}
|
|
65602
|
+
button { font: inherit; }
|
|
65603
|
+
.shell {
|
|
65604
|
+
width: min(920px, calc(100% - 32px));
|
|
65605
|
+
margin: 0 auto;
|
|
65606
|
+
padding: clamp(28px, 6vw, 64px) 0 112px;
|
|
65607
|
+
}
|
|
65608
|
+
.panel {
|
|
65609
|
+
border: 1px solid var(--line-strong);
|
|
65610
|
+
border-radius: var(--radius);
|
|
65611
|
+
background: color-mix(in srgb, var(--paper) 91%, white);
|
|
65612
|
+
box-shadow: 7px 7px 0 rgba(36, 33, 31, .12);
|
|
65613
|
+
padding: clamp(18px, 3vw, 28px);
|
|
65614
|
+
}
|
|
65615
|
+
.demo-grid {
|
|
65616
|
+
display: grid;
|
|
65617
|
+
grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
|
|
65618
|
+
gap: 18px;
|
|
65619
|
+
align-items: stretch;
|
|
65620
|
+
}
|
|
65621
|
+
.preview {
|
|
65622
|
+
min-height: 280px;
|
|
65623
|
+
display: grid;
|
|
65624
|
+
align-content: space-between;
|
|
65625
|
+
gap: 24px;
|
|
65626
|
+
border: 1px solid var(--line-strong);
|
|
65627
|
+
border-radius: var(--radius);
|
|
65628
|
+
padding: clamp(20px, 3vw, 28px);
|
|
65629
|
+
color: white;
|
|
65630
|
+
background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 86%, black), var(--accent));
|
|
65631
|
+
}
|
|
65632
|
+
.preview h2 {
|
|
65633
|
+
margin: 0;
|
|
65634
|
+
max-width: 560px;
|
|
65635
|
+
font-family: Newsreader, Georgia, "Times New Roman", serif;
|
|
65636
|
+
font-size: clamp(30px, 5vw, 54px);
|
|
65637
|
+
line-height: .96;
|
|
65638
|
+
letter-spacing: -0.04em;
|
|
65639
|
+
}
|
|
65640
|
+
.preview p { max-width: 560px; margin: 12px 0 0; opacity: .9; line-height: 1.6; }
|
|
65641
|
+
.status-pill {
|
|
65642
|
+
justify-self: start;
|
|
65643
|
+
border: 1px solid rgba(255,255,255,.75);
|
|
65644
|
+
border-radius: 999px;
|
|
65645
|
+
padding: 7px 10px;
|
|
65646
|
+
font-size: 12px;
|
|
65647
|
+
font-weight: 800;
|
|
65648
|
+
}
|
|
65649
|
+
.section-title {
|
|
65650
|
+
margin: 0 0 12px;
|
|
65651
|
+
color: var(--muted);
|
|
65652
|
+
font-size: 12px;
|
|
65653
|
+
font-weight: 800;
|
|
65654
|
+
letter-spacing: .12em;
|
|
65655
|
+
text-transform: uppercase;
|
|
65656
|
+
}
|
|
65657
|
+
.tasks { display: grid; gap: 9px; }
|
|
65658
|
+
.task {
|
|
65659
|
+
display: flex;
|
|
65660
|
+
align-items: center;
|
|
65661
|
+
gap: 10px;
|
|
65662
|
+
padding: 11px 12px;
|
|
65663
|
+
border: 1px solid var(--line);
|
|
65664
|
+
border-radius: var(--radius);
|
|
65665
|
+
background: var(--paper);
|
|
65666
|
+
}
|
|
65667
|
+
.task-dot {
|
|
65668
|
+
display: grid;
|
|
65669
|
+
place-items: center;
|
|
65670
|
+
width: 23px;
|
|
65671
|
+
height: 23px;
|
|
65672
|
+
border-radius: 999px;
|
|
65673
|
+
color: var(--paper);
|
|
65674
|
+
background: #9c958e;
|
|
65675
|
+
font-size: 13px;
|
|
65676
|
+
font-weight: 900;
|
|
65677
|
+
}
|
|
65678
|
+
.task[data-done="true"] .task-dot { background: var(--success); }
|
|
65679
|
+
.task[data-done="true"] .task-label { color: var(--muted); text-decoration: line-through; }
|
|
65680
|
+
.activity {
|
|
65681
|
+
margin-top: 18px;
|
|
65682
|
+
padding-top: 16px;
|
|
65683
|
+
border-top: 1px solid var(--line);
|
|
65684
|
+
}
|
|
65685
|
+
.log { display: grid; gap: 8px; max-height: 120px; overflow: auto; }
|
|
65686
|
+
.log-row {
|
|
65687
|
+
color: #4b463f;
|
|
65688
|
+
font-size: 12px;
|
|
65689
|
+
line-height: 1.45;
|
|
65690
|
+
}
|
|
65691
|
+
.log-row strong { color: var(--ink); }
|
|
65692
|
+
.action-bar {
|
|
65693
|
+
display: flex;
|
|
65694
|
+
flex-wrap: wrap;
|
|
65695
|
+
gap: 10px;
|
|
65696
|
+
align-items: center;
|
|
65697
|
+
margin-top: 18px;
|
|
65698
|
+
padding-top: 18px;
|
|
65699
|
+
border-top: 1px solid var(--line);
|
|
65700
|
+
}
|
|
65701
|
+
.cta {
|
|
65702
|
+
display: inline-flex;
|
|
65703
|
+
align-items: center;
|
|
65704
|
+
justify-content: center;
|
|
65705
|
+
gap: 8px;
|
|
65706
|
+
min-height: 42px;
|
|
65707
|
+
border: 1px solid var(--line-strong);
|
|
65708
|
+
border-radius: var(--radius);
|
|
65709
|
+
padding: 10px 13px;
|
|
65710
|
+
color: var(--ink);
|
|
65711
|
+
font-size: 14px;
|
|
65712
|
+
font-weight: 800;
|
|
65713
|
+
text-decoration: none;
|
|
65714
|
+
cursor: pointer;
|
|
65715
|
+
}
|
|
65716
|
+
.cta-primary { background: var(--accent); color: white; }
|
|
65717
|
+
.cta-secondary { background: var(--paper); }
|
|
65718
|
+
.cta-arrow { font-size: 18px; line-height: 1; }
|
|
65719
|
+
details {
|
|
65720
|
+
margin-top: 18px;
|
|
65721
|
+
color: var(--muted);
|
|
65722
|
+
font-size: 13px;
|
|
65723
|
+
}
|
|
65724
|
+
summary {
|
|
65725
|
+
cursor: pointer;
|
|
65726
|
+
width: fit-content;
|
|
65727
|
+
color: var(--ink);
|
|
65728
|
+
font-weight: 700;
|
|
65729
|
+
}
|
|
65730
|
+
.details-grid {
|
|
65731
|
+
display: grid;
|
|
65732
|
+
grid-template-columns: 90px minmax(0, 1fr);
|
|
65733
|
+
gap: 8px 14px;
|
|
65734
|
+
margin-top: 12px;
|
|
65735
|
+
}
|
|
65736
|
+
code {
|
|
65737
|
+
color: #2f2a26;
|
|
65738
|
+
word-break: break-word;
|
|
65739
|
+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
|
|
65740
|
+
font-size: 12px;
|
|
65741
|
+
}
|
|
65742
|
+
@media (max-width: 820px) {
|
|
65743
|
+
.demo-grid { grid-template-columns: 1fr; }
|
|
65744
|
+
.shell { width: min(100% - 24px, 720px); }
|
|
65745
|
+
}
|
|
65746
|
+
@media (prefers-reduced-motion: reduce) {
|
|
65747
|
+
*, *::before, *::after { transition: none !important; }
|
|
65748
|
+
}
|
|
65749
|
+
</style>
|
|
65750
|
+
</head>
|
|
65751
|
+
<body>
|
|
65752
|
+
<!-- Edit this file directly, refresh the browser, and keep customizing your Persona starter. -->
|
|
65753
|
+
<main class="shell">
|
|
65754
|
+
<section class="panel" aria-label="Persona demo workspace">
|
|
65755
|
+
<div class="demo-grid">
|
|
65756
|
+
<div class="preview" id="accent-preview">
|
|
65757
|
+
<div>
|
|
65758
|
+
<h2 id="playground-headline">Local tools. Visible results.</h2>
|
|
65759
|
+
<p id="playground-note">Persona can read this page, request approval, and update the UI from the browser.</p>
|
|
65760
|
+
</div>
|
|
65761
|
+
<span class="status-pill" id="status-pill">Waiting for your first task</span>
|
|
65762
|
+
</div>
|
|
65763
|
+
|
|
65764
|
+
<div>
|
|
65765
|
+
<p class="section-title">Checklist</p>
|
|
65766
|
+
<div class="tasks" id="task-list"></div>
|
|
65767
|
+
|
|
65768
|
+
<div class="activity">
|
|
65769
|
+
<p class="section-title">Activity</p>
|
|
65770
|
+
<div class="log" id="tool-log"></div>
|
|
65771
|
+
</div>
|
|
65772
|
+
</div>
|
|
65773
|
+
</div>
|
|
65774
|
+
|
|
65775
|
+
<div class="action-bar" aria-label="Next actions">
|
|
65776
|
+
<button class="cta cta-primary" id="use-persona-widget" type="button">
|
|
65777
|
+
<span id="use-persona-label">Use Persona widget</span> <span class="cta-arrow" aria-hidden="true">\u2198</span>
|
|
65778
|
+
</button>
|
|
65779
|
+
<a class="cta cta-secondary" href="${escapeHtml(input.dashboardUrl)}" target="_blank" rel="noreferrer">Customize your agent</a>
|
|
65780
|
+
</div>
|
|
65781
|
+
|
|
65782
|
+
<details>
|
|
65783
|
+
<summary>Technical details</summary>
|
|
65784
|
+
<div class="details-grid">
|
|
65785
|
+
<span>Agent</span><code>${escapeHtml(input.agentId)}</code>
|
|
65786
|
+
<span>Token</span><code>${escapeHtml(input.clientTokenId)} (${escapeHtml(input.environment)})</code>
|
|
65787
|
+
<span>Edit</span><code>index.html</code>
|
|
65788
|
+
<span>Origin</span><code>${escapeHtml(input.localUrl)}</code>
|
|
65789
|
+
<span>Tools</span><code>${PERSONA_DEMO_TOOL_NAMES.join(", ")}</code>
|
|
65790
|
+
<span>Dashboard</span><code>${escapeHtml(input.dashboardUrl)}</code>
|
|
65791
|
+
</div>
|
|
65792
|
+
</details>
|
|
65793
|
+
</section>
|
|
65794
|
+
</main>
|
|
65795
|
+
|
|
65796
|
+
<div id="persona-root"></div>
|
|
65797
|
+
|
|
65798
|
+
<!-- 1. Runtime values injected by the CLI. -->
|
|
65799
|
+
<script>
|
|
65800
|
+
window.__RUNTYPE_PERSONA_DEMO__ = ${inlineJson(pageData)};
|
|
65801
|
+
</script>
|
|
65802
|
+
<!-- 2. Minimal WebMCP host bridge for this dependency-free page. -->
|
|
65803
|
+
<script>
|
|
65804
|
+
(function installMinimalModelContext() {
|
|
65805
|
+
if (document.modelContext && typeof document.modelContext.getTools === 'function') {
|
|
65806
|
+
return;
|
|
65807
|
+
}
|
|
65808
|
+
const tools = new Map();
|
|
65809
|
+
document.modelContext = {
|
|
65810
|
+
registerTool(tool) {
|
|
65811
|
+
if (!tool || !tool.name || typeof tool.execute !== 'function') {
|
|
65812
|
+
throw new Error('registerTool requires a name and execute function');
|
|
65813
|
+
}
|
|
65814
|
+
tools.set(tool.name, tool);
|
|
65815
|
+
},
|
|
65816
|
+
async getTools() {
|
|
65817
|
+
return Array.from(tools.values()).map((tool) => ({
|
|
65818
|
+
name: tool.name,
|
|
65819
|
+
title: tool.title || '',
|
|
65820
|
+
description: tool.description || '',
|
|
65821
|
+
inputSchema: JSON.stringify(tool.inputSchema || { type: 'object', properties: {} }),
|
|
65822
|
+
}));
|
|
65823
|
+
},
|
|
65824
|
+
async executeTool(info, inputArgsJson) {
|
|
65825
|
+
const name = typeof info === 'string' ? info : info && info.name;
|
|
65826
|
+
const tool = tools.get(name);
|
|
65827
|
+
if (!tool) throw new Error('Tool not registered: ' + name);
|
|
65828
|
+
const args = inputArgsJson ? JSON.parse(inputArgsJson) : {};
|
|
65829
|
+
const result = await tool.execute(args, {
|
|
65830
|
+
requestUserInteraction: async (callback) => callback(),
|
|
65831
|
+
});
|
|
65832
|
+
return result === undefined ? null : JSON.stringify(result);
|
|
65833
|
+
},
|
|
65834
|
+
};
|
|
65835
|
+
})();
|
|
65836
|
+
|
|
65837
|
+
const demo = window.__RUNTYPE_PERSONA_DEMO__;
|
|
65838
|
+
/* 3. Page state the tools can read and update. */
|
|
65839
|
+
const accentMap = {
|
|
65840
|
+
violet: '#4c00ff',
|
|
65841
|
+
green: '#178c4b',
|
|
65842
|
+
cyan: '#008ca8',
|
|
65843
|
+
orange: '#d95f02',
|
|
65844
|
+
};
|
|
65845
|
+
const state = {
|
|
65846
|
+
accent: 'violet',
|
|
65847
|
+
headline: 'Local tools. Visible results.',
|
|
65848
|
+
note: 'Persona can read this page, request approval, and update the UI from the browser.',
|
|
65849
|
+
status: 'Waiting for your first task',
|
|
65850
|
+
tasks: [
|
|
65851
|
+
{ id: 'widget', label: 'Widget installed', done: true },
|
|
65852
|
+
{ id: 'webmcp', label: 'WebMCP tools connected', done: true },
|
|
65853
|
+
{ id: 'setup', label: 'Setup complete', done: false },
|
|
65854
|
+
],
|
|
65855
|
+
};
|
|
65856
|
+
|
|
65857
|
+
function escapeText(value) {
|
|
65858
|
+
return String(value).replace(/[&<>]/g, (char) => ({ '&': '&', '<': '<', '>': '>' })[char]);
|
|
65859
|
+
}
|
|
65860
|
+
|
|
65861
|
+
function logTool(kind, message) {
|
|
65862
|
+
const log = document.getElementById('tool-log');
|
|
65863
|
+
const row = document.createElement('div');
|
|
65864
|
+
row.className = 'log-row';
|
|
65865
|
+
row.innerHTML = '<strong>' + escapeText(kind) + '</strong> \xB7 ' + escapeText(message);
|
|
65866
|
+
log.prepend(row);
|
|
65867
|
+
}
|
|
65868
|
+
|
|
65869
|
+
function snapshot() {
|
|
65870
|
+
return {
|
|
65871
|
+
accent: state.accent,
|
|
65872
|
+
accentHex: accentMap[state.accent],
|
|
65873
|
+
headline: state.headline,
|
|
65874
|
+
note: state.note,
|
|
65875
|
+
status: state.status,
|
|
65876
|
+
tasks: state.tasks,
|
|
65877
|
+
pageUrl: location.href,
|
|
65878
|
+
allowedOrigins: demo.allowedOrigins,
|
|
65879
|
+
};
|
|
65880
|
+
}
|
|
65881
|
+
|
|
65882
|
+
function render() {
|
|
65883
|
+
document.documentElement.style.setProperty('--accent', accentMap[state.accent]);
|
|
65884
|
+
document.getElementById('playground-headline').textContent = state.headline;
|
|
65885
|
+
document.getElementById('playground-note').textContent = state.note;
|
|
65886
|
+
document.getElementById('status-pill').textContent = state.status;
|
|
65887
|
+
const setupDone = state.tasks.some((task) => task.id === 'setup' && task.done);
|
|
65888
|
+
const ctaLabel = document.getElementById('use-persona-label');
|
|
65889
|
+
if (ctaLabel) ctaLabel.textContent = setupDone ? 'Try another page change' : 'Use Persona widget';
|
|
65890
|
+
const taskList = document.getElementById('task-list');
|
|
65891
|
+
taskList.innerHTML = '';
|
|
65892
|
+
for (const task of state.tasks) {
|
|
65893
|
+
const row = document.createElement('div');
|
|
65894
|
+
row.className = 'task';
|
|
65895
|
+
row.dataset.done = String(task.done);
|
|
65896
|
+
row.innerHTML = '<span class="task-dot">\u2713</span><span class="task-label"></span>';
|
|
65897
|
+
row.querySelector('.task-label').textContent = task.label;
|
|
65898
|
+
taskList.appendChild(row);
|
|
65899
|
+
}
|
|
65900
|
+
}
|
|
65901
|
+
|
|
65902
|
+
function taskLabel(id) {
|
|
65903
|
+
const task = state.tasks.find((item) => item.id === id);
|
|
65904
|
+
return task ? task.label : id;
|
|
65905
|
+
}
|
|
65906
|
+
|
|
65907
|
+
function buildAssistantMessage(args, changed) {
|
|
65908
|
+
if (!changed.length) return 'Done \u2014 no visible page changes were needed.';
|
|
65909
|
+
|
|
65910
|
+
const updates = [];
|
|
65911
|
+
if (args.accent && accentMap[args.accent]) updates.push('the page is now ' + args.accent);
|
|
65912
|
+
if (typeof args.headline === 'string' && args.headline.trim()) updates.push('the headline changed');
|
|
65913
|
+
if (typeof args.note === 'string' && args.note.trim()) updates.push('the note changed');
|
|
65914
|
+
if (typeof args.status === 'string' && args.status.trim()) updates.push('the status changed');
|
|
65915
|
+
if (Array.isArray(args.completedTaskIds) && args.completedTaskIds.length) {
|
|
65916
|
+
const labels = args.completedTaskIds.map((id) => taskLabel(id));
|
|
65917
|
+
updates.push(
|
|
65918
|
+
labels.length === 1 ? labels[0] + ' is checked' : labels.join(', ') + ' are checked'
|
|
65919
|
+
);
|
|
65920
|
+
}
|
|
65921
|
+
|
|
65922
|
+
return 'Done \u2014 ' + updates.join(' and ') + '.';
|
|
65923
|
+
}
|
|
65924
|
+
|
|
65925
|
+
function buildSuggestedReplies() {
|
|
65926
|
+
return [
|
|
65927
|
+
'Change the headline',
|
|
65928
|
+
'Add another page tool',
|
|
65929
|
+
'Show the embed code',
|
|
65930
|
+
'Customize the agent',
|
|
65931
|
+
];
|
|
65932
|
+
}
|
|
65933
|
+
|
|
65934
|
+
/* 4. WebMCP tools exposed to the Persona widget. */
|
|
65935
|
+
document.modelContext.registerTool({
|
|
65936
|
+
name: 'get_playground_state',
|
|
65937
|
+
title: 'Read playground state',
|
|
65938
|
+
description: 'Read the current local Persona playground state: accent, headline, note, status, checklist, URL, and allowed origins. Use this before proposing page changes.',
|
|
65939
|
+
inputSchema: { type: 'object', properties: {} },
|
|
65940
|
+
annotations: { readOnlyHint: true },
|
|
65941
|
+
async execute() {
|
|
65942
|
+
logTool('Read page state', 'Persona inspected the local HTML page');
|
|
65943
|
+
return snapshot();
|
|
65944
|
+
},
|
|
65945
|
+
});
|
|
65946
|
+
|
|
65947
|
+
document.modelContext.registerTool({
|
|
65948
|
+
name: 'update_playground',
|
|
65949
|
+
title: 'Update playground UI',
|
|
65950
|
+
description: 'Update this local HTML playground. Can set accent to violet, green, cyan, or orange; rewrite the headline or note; set a short status; and mark checklist tasks complete by id.',
|
|
65951
|
+
inputSchema: {
|
|
65952
|
+
type: 'object',
|
|
65953
|
+
properties: {
|
|
65954
|
+
accent: { type: 'string', enum: Object.keys(accentMap), description: 'Accent color to apply.' },
|
|
65955
|
+
headline: { type: 'string', description: 'New hero headline.' },
|
|
65956
|
+
note: { type: 'string', description: 'New explanatory note under the headline.' },
|
|
65957
|
+
status: { type: 'string', description: 'Short status shown inside the demo card.' },
|
|
65958
|
+
completedTaskIds: {
|
|
65959
|
+
type: 'array',
|
|
65960
|
+
items: { type: 'string', enum: state.tasks.map((task) => task.id) },
|
|
65961
|
+
description: 'Checklist task ids to mark complete.',
|
|
65962
|
+
},
|
|
65963
|
+
},
|
|
65964
|
+
},
|
|
65965
|
+
async execute(args) {
|
|
65966
|
+
const changed = [];
|
|
65967
|
+
if (args.accent && accentMap[args.accent]) {
|
|
65968
|
+
state.accent = args.accent;
|
|
65969
|
+
changed.push('accent');
|
|
65970
|
+
}
|
|
65971
|
+
if (typeof args.headline === 'string' && args.headline.trim()) {
|
|
65972
|
+
state.headline = args.headline.trim();
|
|
65973
|
+
changed.push('headline');
|
|
65974
|
+
}
|
|
65975
|
+
if (typeof args.note === 'string' && args.note.trim()) {
|
|
65976
|
+
state.note = args.note.trim();
|
|
65977
|
+
changed.push('note');
|
|
65978
|
+
}
|
|
65979
|
+
if (typeof args.status === 'string' && args.status.trim()) {
|
|
65980
|
+
state.status = args.status.trim();
|
|
65981
|
+
changed.push('status');
|
|
65982
|
+
}
|
|
65983
|
+
if (Array.isArray(args.completedTaskIds) && args.completedTaskIds.length) {
|
|
65984
|
+
const completed = new Set(args.completedTaskIds);
|
|
65985
|
+
state.tasks = state.tasks.map((task) => completed.has(task.id) ? { ...task, done: true } : task);
|
|
65986
|
+
changed.push('checklist');
|
|
65987
|
+
}
|
|
65988
|
+
render();
|
|
65989
|
+
logTool('Updated page', changed.length ? changed.join(' + ') : 'No visible changes requested');
|
|
65990
|
+
return {
|
|
65991
|
+
ok: true,
|
|
65992
|
+
changed,
|
|
65993
|
+
responseGuidance: {
|
|
65994
|
+
assistantMessage: buildAssistantMessage(args, changed),
|
|
65995
|
+
suggestedReplies: buildSuggestedReplies(),
|
|
65996
|
+
instructions: 'Do not send a visible assistant message yet. First call suggest_replies with suggestedReplies. After suggest_replies returns, say assistantMessage exactly once, then stop.',
|
|
65997
|
+
},
|
|
65998
|
+
state: snapshot(),
|
|
65999
|
+
};
|
|
66000
|
+
},
|
|
66001
|
+
});
|
|
66002
|
+
|
|
66003
|
+
/* 5. Persona widget config. The installer below reads window.siteAgentConfig. */
|
|
66004
|
+
window.siteAgentConfig = {
|
|
66005
|
+
target: '#persona-root',
|
|
66006
|
+
windowKey: 'personaPlayground',
|
|
66007
|
+
config: {
|
|
66008
|
+
apiUrl: demo.apiUrl,
|
|
66009
|
+
clientToken: demo.clientToken,
|
|
66010
|
+
parserType: 'json',
|
|
66011
|
+
launcher: {
|
|
66012
|
+
enabled: true,
|
|
66013
|
+
autoExpand: true,
|
|
66014
|
+
title: 'Persona Playground',
|
|
66015
|
+
subtitle: 'Local WebMCP demo',
|
|
66016
|
+
width: '430px',
|
|
66017
|
+
},
|
|
66018
|
+
copy: {
|
|
66019
|
+
welcomeTitle: 'Persona Playground',
|
|
66020
|
+
welcomeSubtitle: 'Use the page tools, then pick a next step.',
|
|
66021
|
+
inputPlaceholder: 'Ask Persona to update this page\u2026',
|
|
66022
|
+
},
|
|
66023
|
+
suggestionChips: [
|
|
66024
|
+
'Turn this page green and mark Setup complete.',
|
|
66025
|
+
'What page tools are available?',
|
|
66026
|
+
'Show the embed code.',
|
|
66027
|
+
],
|
|
66028
|
+
features: {
|
|
66029
|
+
showToolCalls: true,
|
|
66030
|
+
showEventStreamToggle: true,
|
|
66031
|
+
suggestReplies: {
|
|
66032
|
+
enabled: true,
|
|
66033
|
+
expose: true,
|
|
66034
|
+
},
|
|
66035
|
+
},
|
|
66036
|
+
webmcp: {
|
|
66037
|
+
enabled: true,
|
|
66038
|
+
autoApprove(info) {
|
|
66039
|
+
const ok = info && info.toolName === 'get_playground_state';
|
|
66040
|
+
logTool('Approval gate', (info ? info.toolName : 'unknown') + (ok ? ' auto-approved' : ' awaiting approval'));
|
|
66041
|
+
return ok;
|
|
66042
|
+
},
|
|
66043
|
+
},
|
|
66044
|
+
},
|
|
66045
|
+
onChatReady(handle) {
|
|
66046
|
+
window.personaPlayground = handle;
|
|
66047
|
+
logTool('Widget ready', 'Persona handle is available at window.personaPlayground');
|
|
66048
|
+
setTimeout(() => {
|
|
66049
|
+
if (handle && typeof handle.open === 'function') handle.open();
|
|
66050
|
+
}, 0);
|
|
66051
|
+
},
|
|
66052
|
+
onError(info) {
|
|
66053
|
+
logTool('Persona error', info && info.phase ? info.phase : 'unknown phase');
|
|
66054
|
+
},
|
|
66055
|
+
};
|
|
66056
|
+
|
|
66057
|
+
document.getElementById('use-persona-widget').addEventListener('click', () => {
|
|
66058
|
+
const handle = window.personaPlayground;
|
|
66059
|
+
if (handle && typeof handle.open === 'function') handle.open();
|
|
66060
|
+
if (handle && typeof handle.setMessage === 'function') {
|
|
66061
|
+
handle.setMessage('Turn this page green and mark Setup complete.');
|
|
66062
|
+
}
|
|
66063
|
+
logTool('CTA', 'Opened Persona widget');
|
|
66064
|
+
});
|
|
66065
|
+
|
|
66066
|
+
render();
|
|
66067
|
+
logTool('Tools connected', 'Registered get_playground_state and update_playground');
|
|
66068
|
+
</script>
|
|
66069
|
+
<!-- 6. Version-pinned Persona installer from @runtypelabs/persona. -->
|
|
66070
|
+
<script src="${escapeHtml(installerScriptUrl)}"></script>
|
|
66071
|
+
</body>
|
|
66072
|
+
</html>`;
|
|
66073
|
+
}
|
|
66074
|
+
function generatePersonaDemoReadme(input) {
|
|
66075
|
+
const port = (() => {
|
|
66076
|
+
try {
|
|
66077
|
+
return new URL(input.localUrl).port || String(PERSONA_DEMO_DEFAULT_PORT);
|
|
66078
|
+
} catch {
|
|
66079
|
+
return String(PERSONA_DEMO_DEFAULT_PORT);
|
|
66080
|
+
}
|
|
66081
|
+
})();
|
|
66082
|
+
return `# Persona Playground
|
|
66083
|
+
|
|
66084
|
+
This folder was generated by \`runtype persona init\`.
|
|
66085
|
+
|
|
66086
|
+
## Next steps
|
|
66087
|
+
|
|
66088
|
+
1. Use the widget: ${input.localUrl}
|
|
66089
|
+
2. Customize your agent: ${input.dashboardUrl}
|
|
66090
|
+
3. Edit the page: ./index.html
|
|
66091
|
+
|
|
66092
|
+
## Run locally
|
|
66093
|
+
|
|
66094
|
+
\`\`\`bash
|
|
66095
|
+
python3 -m http.server ${port} --bind 127.0.0.1
|
|
66096
|
+
\`\`\`
|
|
66097
|
+
|
|
66098
|
+
Then open ${input.localUrl}.
|
|
66099
|
+
|
|
66100
|
+
## What this starter demonstrates
|
|
66101
|
+
|
|
66102
|
+
- \`window.siteAgentConfig\` installs Persona with your client token.
|
|
66103
|
+
- \`document.modelContext\` exposes two local WebMCP tools:
|
|
66104
|
+
- \`get_playground_state\` reads the page state.
|
|
66105
|
+
- \`update_playground\` changes the accent, copy, status, and checklist after approval.
|
|
66106
|
+
- Persona native suggested replies render next-step pills after a successful tool call.
|
|
66107
|
+
|
|
66108
|
+
## Add another page tool
|
|
66109
|
+
|
|
66110
|
+
1. Add a new \`document.modelContext.registerTool({ ... })\` block in \`index.html\`.
|
|
66111
|
+
2. Add the tool name to the WebMCP allowlist for this surface in the Runtype dashboard.
|
|
66112
|
+
3. Refresh the page and ask Persona to use the new tool.
|
|
66113
|
+
|
|
66114
|
+
## Demo resources
|
|
66115
|
+
|
|
66116
|
+
- Agent: ${input.agentId}
|
|
66117
|
+
- Client token: ${input.clientTokenId} (${input.environment})
|
|
66118
|
+
- Allowed origins: ${input.allowedOrigins.join(", ")}
|
|
66119
|
+
`;
|
|
66120
|
+
}
|
|
66121
|
+
|
|
65311
66122
|
// src/commands/persona.ts
|
|
65312
|
-
var FORMAT_CYCLE = [
|
|
65313
|
-
"script-installer",
|
|
65314
|
-
"react",
|
|
65315
|
-
"script-manual",
|
|
65316
|
-
"esm"
|
|
65317
|
-
];
|
|
66123
|
+
var FORMAT_CYCLE = ["script-installer", "react", "script-manual", "esm"];
|
|
65318
66124
|
function defaultTokenName(agentName) {
|
|
65319
66125
|
return `${agentName} Widget`;
|
|
65320
66126
|
}
|
|
66127
|
+
function parsePort(raw, fallback) {
|
|
66128
|
+
if (!raw) return fallback;
|
|
66129
|
+
const port = Number(raw);
|
|
66130
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
66131
|
+
throw new Error(`Invalid port "${raw}". Use a number between 1 and 65535.`);
|
|
66132
|
+
}
|
|
66133
|
+
return port;
|
|
66134
|
+
}
|
|
65321
66135
|
async function promptLine(rl, question, defaultValue) {
|
|
65322
66136
|
const hint = defaultValue ? chalk30.dim(` (${defaultValue})`) : "";
|
|
65323
66137
|
const answer = await new Promise((resolve11) => {
|
|
@@ -65366,7 +66180,16 @@ function snippetWithFormat(format, token, apiUrl, targetSelector) {
|
|
|
65366
66180
|
);
|
|
65367
66181
|
return { format, code };
|
|
65368
66182
|
}
|
|
65369
|
-
|
|
66183
|
+
function printDemoNextSteps(demo, dashboardUrl) {
|
|
66184
|
+
console.log(chalk30.cyan("\nNext steps:"));
|
|
66185
|
+
console.log(` 1. Use the widget: ${chalk30.green(demo.url)}`);
|
|
66186
|
+
console.log(` 2. Customize your agent: ${dashboardUrl}`);
|
|
66187
|
+
console.log(` 3. Edit the page: ${demo.filePath}`);
|
|
66188
|
+
if (demo.readmePath) {
|
|
66189
|
+
console.log(chalk30.dim(` Guide: ${demo.readmePath}`));
|
|
66190
|
+
}
|
|
66191
|
+
}
|
|
66192
|
+
async function runSuccessKeyLoop(initial, apiUrl, targetSelector, demo) {
|
|
65370
66193
|
if (!process.stdin.isTTY) {
|
|
65371
66194
|
return;
|
|
65372
66195
|
}
|
|
@@ -65380,39 +66203,48 @@ async function runSuccessKeyLoop(initial, apiUrl, targetSelector) {
|
|
|
65380
66203
|
console.log(`${chalk30.bold("Snippet format:")} ${currentFormat}`);
|
|
65381
66204
|
console.log(chalk30.dim(`
|
|
65382
66205
|
Dashboard: ${initial.dashboardUrl}`));
|
|
66206
|
+
if (demo) {
|
|
66207
|
+
console.log(`${chalk30.bold("Local demo:")} ${chalk30.green(demo.url)}`);
|
|
66208
|
+
console.log(chalk30.dim(`HTML: ${demo.filePath}`));
|
|
66209
|
+
if (demo.readmePath) {
|
|
66210
|
+
console.log(chalk30.dim(`Guide: ${demo.readmePath}`));
|
|
66211
|
+
}
|
|
66212
|
+
}
|
|
65383
66213
|
if (initial.warnings?.length) {
|
|
65384
66214
|
for (const w of initial.warnings) {
|
|
65385
66215
|
console.log(chalk30.yellow(`\u26A0 ${w.message}`));
|
|
65386
66216
|
}
|
|
65387
66217
|
}
|
|
65388
|
-
|
|
66218
|
+
if (demo) {
|
|
66219
|
+
printDemoNextSteps(demo, initial.dashboardUrl);
|
|
66220
|
+
}
|
|
66221
|
+
console.log(chalk30.cyan("\nActions:"));
|
|
65389
66222
|
console.log(` ${chalk30.green("c")} Copy snippet to clipboard`);
|
|
65390
66223
|
console.log(` ${chalk30.green("p")} Print snippet to the terminal`);
|
|
65391
66224
|
console.log(` ${chalk30.green("f")} Switch snippet format`);
|
|
65392
66225
|
console.log(` ${chalk30.green("o")} Open dashboard in browser`);
|
|
65393
|
-
|
|
65394
|
-
|
|
65395
|
-
if (process.stdin.isTTY) {
|
|
65396
|
-
process.stdin.setRawMode(true);
|
|
66226
|
+
if (demo) {
|
|
66227
|
+
console.log(` ${chalk30.green("d")} Open local demo in browser`);
|
|
65397
66228
|
}
|
|
65398
|
-
|
|
65399
|
-
|
|
65400
|
-
|
|
65401
|
-
|
|
65402
|
-
process.stdin
|
|
65403
|
-
|
|
66229
|
+
console.log(` ${chalk30.green("q")} Quit`);
|
|
66230
|
+
console.log(chalk30.dim("\nType a letter and press Enter. Press Ctrl+C to quit."));
|
|
66231
|
+
const actionKeys = demo ? "c/p/f/o/d/q" : "c/p/f/o/q";
|
|
66232
|
+
const rl = readline3.createInterface({
|
|
66233
|
+
input: process.stdin,
|
|
66234
|
+
output: process.stdout,
|
|
66235
|
+
terminal: true
|
|
66236
|
+
});
|
|
65404
66237
|
await new Promise((resolve11) => {
|
|
65405
|
-
|
|
65406
|
-
|
|
65407
|
-
if (
|
|
65408
|
-
|
|
65409
|
-
|
|
65410
|
-
|
|
65411
|
-
|
|
65412
|
-
|
|
65413
|
-
if (name === "q"
|
|
65414
|
-
|
|
65415
|
-
resolve11();
|
|
66238
|
+
let finished = false;
|
|
66239
|
+
const finish = () => {
|
|
66240
|
+
if (finished) return;
|
|
66241
|
+
finished = true;
|
|
66242
|
+
rl.close();
|
|
66243
|
+
resolve11();
|
|
66244
|
+
};
|
|
66245
|
+
const runAction = async (name) => {
|
|
66246
|
+
if (name === "q") {
|
|
66247
|
+
finish();
|
|
65416
66248
|
return;
|
|
65417
66249
|
}
|
|
65418
66250
|
if (name === "c") {
|
|
@@ -65441,23 +66273,61 @@ Dashboard: ${initial.dashboardUrl}`));
|
|
|
65441
66273
|
}
|
|
65442
66274
|
if (name === "o") {
|
|
65443
66275
|
try {
|
|
65444
|
-
await
|
|
66276
|
+
await openBrowser(initial.dashboardUrl);
|
|
65445
66277
|
} catch {
|
|
65446
66278
|
console.log(chalk30.red("Could not open browser."));
|
|
65447
66279
|
}
|
|
66280
|
+
return;
|
|
65448
66281
|
}
|
|
66282
|
+
if (name === "d" && demo) {
|
|
66283
|
+
try {
|
|
66284
|
+
await openBrowser(demo.url);
|
|
66285
|
+
} catch {
|
|
66286
|
+
console.log(chalk30.red("Could not open browser."));
|
|
66287
|
+
}
|
|
66288
|
+
return;
|
|
66289
|
+
}
|
|
66290
|
+
console.log(chalk30.yellow(`Choose one of: ${actionKeys}`));
|
|
66291
|
+
};
|
|
66292
|
+
const ask = () => {
|
|
66293
|
+
if (finished) return;
|
|
66294
|
+
rl.question(chalk30.dim(`
|
|
66295
|
+
Choose an action (${actionKeys}): `), (answer) => {
|
|
66296
|
+
const names = answer.trim().toLowerCase().split(/[\s,]+/).filter(Boolean).map((part) => part.charAt(0));
|
|
66297
|
+
void (async () => {
|
|
66298
|
+
for (const name of names) {
|
|
66299
|
+
await runAction(name);
|
|
66300
|
+
if (finished) {
|
|
66301
|
+
return;
|
|
66302
|
+
}
|
|
66303
|
+
}
|
|
66304
|
+
if (!finished) {
|
|
66305
|
+
ask();
|
|
66306
|
+
}
|
|
66307
|
+
})();
|
|
66308
|
+
});
|
|
65449
66309
|
};
|
|
65450
|
-
|
|
66310
|
+
rl.on("SIGINT", finish);
|
|
66311
|
+
ask();
|
|
65451
66312
|
});
|
|
65452
66313
|
}
|
|
65453
66314
|
var personaCommand = new Command23("persona").description(
|
|
65454
66315
|
"Set up Persona: create an agent, client token, and embed snippet"
|
|
65455
66316
|
);
|
|
65456
|
-
personaCommand.command("init").description("Create agent + client token and output a Persona embed snippet").option("--agent-name <name>", "Name for the new agent").option("--agent-description <text", "Optional agent description").option("--token-name <name>", "Name for the new client token").option("--environment <env>", "Token environment: test or live", "test").option(
|
|
66317
|
+
personaCommand.command("init").description("Create agent + client token and output a Persona embed snippet").option("--agent-name <name>", "Name for the new agent").option("--agent-description <text", "Optional agent description").option("--token-name <name>", "Name for the new client token").option("--environment <env>", "Token environment: test or live", "test").option(
|
|
66318
|
+
"--origins <origins...>",
|
|
66319
|
+
"Allowed origins (default: * \u2014 broad; prefer explicit URLs in production)"
|
|
66320
|
+
).option(
|
|
65457
66321
|
"--format <fmt>",
|
|
65458
66322
|
"Snippet format: script-installer | script-manual | esm | react",
|
|
65459
66323
|
"script-installer"
|
|
65460
|
-
).option("--print-snippet", "Print the generated snippet to stdout (non-interactive summary mode)").option("--target-selector <selector>", "CSS selector for widget mount target (omit to use body)").option("--
|
|
66324
|
+
).option("--print-snippet", "Print the generated snippet to stdout (non-interactive summary mode)").option("--target-selector <selector>", "CSS selector for widget mount target (omit to use body)").option("--demo", "Create a dependency-free local Persona Playground HTML demo").option("--no-demo", "Skip the local Persona Playground demo").option(
|
|
66325
|
+
"--demo-dir <path>",
|
|
66326
|
+
`Directory for the local demo (default: ${PERSONA_DEMO_DEFAULT_DIR})`
|
|
66327
|
+
).option(
|
|
66328
|
+
"--demo-port <port>",
|
|
66329
|
+
`Preferred localhost port for the local demo (default: ${PERSONA_DEMO_DEFAULT_PORT})`
|
|
66330
|
+
).option("--open", "Open the local demo in a browser when demo mode is enabled").option("--no-open", "Do not open the local demo automatically").option("--force", "Overwrite existing demo files").option("--api-url <url>", "Override API base URL").option("--json", "Structured JSON output (includes snippet body)").option("--yes", "Accept defaults in interactive prompts where sensible").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(
|
|
65461
66331
|
async (options, cmd) => {
|
|
65462
66332
|
const globals = cmd.optsWithGlobals();
|
|
65463
66333
|
const jsonMode = !!(options.json ?? globals.json);
|
|
@@ -65468,7 +66338,9 @@ personaCommand.command("init").description("Create agent + client token and outp
|
|
|
65468
66338
|
} catch (e) {
|
|
65469
66339
|
const msg = e instanceof Error ? e.message : String(e);
|
|
65470
66340
|
if (jsonMode) {
|
|
65471
|
-
console.log(
|
|
66341
|
+
console.log(
|
|
66342
|
+
JSON.stringify({ status: "error", error: msg, code: "INVALID_FORMAT" }, null, 2)
|
|
66343
|
+
);
|
|
65472
66344
|
} else {
|
|
65473
66345
|
console.error(chalk30.red(msg));
|
|
65474
66346
|
}
|
|
@@ -65476,6 +66348,20 @@ personaCommand.command("init").description("Create agent + client token and outp
|
|
|
65476
66348
|
}
|
|
65477
66349
|
const apiUrl = options.apiUrl || globals.apiUrl || getApiUrl();
|
|
65478
66350
|
const targetSelector = options.targetSelector || void 0;
|
|
66351
|
+
let preferredDemoPort;
|
|
66352
|
+
try {
|
|
66353
|
+
preferredDemoPort = parsePort(options.demoPort, PERSONA_DEMO_DEFAULT_PORT);
|
|
66354
|
+
} catch (e) {
|
|
66355
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
66356
|
+
if (jsonMode) {
|
|
66357
|
+
console.log(
|
|
66358
|
+
JSON.stringify({ status: "error", error: msg, code: "INVALID_DEMO_PORT" }, null, 2)
|
|
66359
|
+
);
|
|
66360
|
+
} else {
|
|
66361
|
+
console.error(chalk30.red(msg));
|
|
66362
|
+
}
|
|
66363
|
+
process.exit(1);
|
|
66364
|
+
}
|
|
65479
66365
|
let env;
|
|
65480
66366
|
if (options.environment === "test" || options.environment === "live") {
|
|
65481
66367
|
env = options.environment;
|
|
@@ -65493,12 +66379,20 @@ personaCommand.command("init").description("Create agent + client token and outp
|
|
|
65493
66379
|
let tokenName = options.tokenName?.trim();
|
|
65494
66380
|
let allowedOrigins = options.origins;
|
|
65495
66381
|
let chosenEnv = env;
|
|
66382
|
+
let demoRequested = options.demo === true;
|
|
66383
|
+
let demoDirectory;
|
|
66384
|
+
let demoPort;
|
|
66385
|
+
let demoOrigins;
|
|
66386
|
+
let demoLocalUrl;
|
|
66387
|
+
let forceDemoWrite = !!options.force;
|
|
65496
66388
|
const rl = interactive && process.stdin.isTTY && process.stdout.isTTY ? readline3.createInterface({ input: process.stdin, output: process.stdout }) : null;
|
|
65497
66389
|
if (!interactive) {
|
|
65498
66390
|
if (!agentName) {
|
|
65499
66391
|
const msg = "Non-interactive mode requires --agent-name";
|
|
65500
66392
|
if (jsonMode) {
|
|
65501
|
-
console.log(
|
|
66393
|
+
console.log(
|
|
66394
|
+
JSON.stringify({ status: "error", error: msg, code: "MISSING_AGENT_NAME" }, null, 2)
|
|
66395
|
+
);
|
|
65502
66396
|
} else {
|
|
65503
66397
|
console.error(chalk30.red(msg));
|
|
65504
66398
|
}
|
|
@@ -65525,20 +66419,52 @@ personaCommand.command("init").description("Create agent + client token and outp
|
|
|
65525
66419
|
tokenName = def;
|
|
65526
66420
|
}
|
|
65527
66421
|
}
|
|
66422
|
+
if (options.demo === void 0 && !options.yes) {
|
|
66423
|
+
demoRequested = await promptConfirm2(
|
|
66424
|
+
rl,
|
|
66425
|
+
"Create and open a local Persona Playground HTML demo?",
|
|
66426
|
+
true
|
|
66427
|
+
);
|
|
66428
|
+
} else if (options.demo === void 0 && options.yes) {
|
|
66429
|
+
demoRequested = true;
|
|
66430
|
+
}
|
|
66431
|
+
if (demoRequested) {
|
|
66432
|
+
demoDirectory = resolvePersonaDemoDirectory(options.demoDir);
|
|
66433
|
+
try {
|
|
66434
|
+
ensurePersonaDemoCanWrite(demoDirectory, forceDemoWrite);
|
|
66435
|
+
} catch (e) {
|
|
66436
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
66437
|
+
const ok = await promptConfirm2(rl, `${message} Overwrite it?`, false);
|
|
66438
|
+
if (!ok) {
|
|
66439
|
+
console.log(chalk30.gray("Aborted."));
|
|
66440
|
+
rl.close();
|
|
66441
|
+
process.exit(0);
|
|
66442
|
+
}
|
|
66443
|
+
forceDemoWrite = true;
|
|
66444
|
+
}
|
|
66445
|
+
demoPort = await findAvailablePersonaDemoPort(preferredDemoPort);
|
|
66446
|
+
demoOrigins = buildPersonaDemoOrigins(demoPort);
|
|
66447
|
+
demoLocalUrl = `http://127.0.0.1:${demoPort}/`;
|
|
66448
|
+
}
|
|
65528
66449
|
if (!allowedOrigins?.length) {
|
|
66450
|
+
const defaultOrigins = demoOrigins?.join(" ") ?? "*";
|
|
65529
66451
|
if (options.yes) {
|
|
65530
|
-
allowedOrigins = ["*"];
|
|
66452
|
+
allowedOrigins = demoOrigins ?? ["*"];
|
|
65531
66453
|
} else {
|
|
65532
66454
|
const originsInput = await promptLine(
|
|
65533
66455
|
rl,
|
|
65534
66456
|
"Allowed origins (space-separated URLs, or * for any)",
|
|
65535
|
-
|
|
66457
|
+
defaultOrigins
|
|
65536
66458
|
);
|
|
65537
66459
|
allowedOrigins = originsInput === "*" ? ["*"] : originsInput.split(/\s+/).filter(Boolean);
|
|
65538
66460
|
}
|
|
65539
66461
|
}
|
|
65540
66462
|
if (chosenEnv === "live") {
|
|
65541
|
-
const ok = await promptConfirm2(
|
|
66463
|
+
const ok = await promptConfirm2(
|
|
66464
|
+
rl,
|
|
66465
|
+
chalk30.yellow("Create a LIVE token? This is shown only once."),
|
|
66466
|
+
false
|
|
66467
|
+
);
|
|
65542
66468
|
if (!ok) {
|
|
65543
66469
|
console.log(chalk30.gray("Aborted."));
|
|
65544
66470
|
rl.close();
|
|
@@ -65556,6 +66482,28 @@ personaCommand.command("init").description("Create agent + client token and outp
|
|
|
65556
66482
|
}
|
|
65557
66483
|
}
|
|
65558
66484
|
}
|
|
66485
|
+
if (demoRequested && !demoDirectory) {
|
|
66486
|
+
demoDirectory = resolvePersonaDemoDirectory(options.demoDir);
|
|
66487
|
+
try {
|
|
66488
|
+
ensurePersonaDemoCanWrite(demoDirectory, forceDemoWrite);
|
|
66489
|
+
} catch (e) {
|
|
66490
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
66491
|
+
if (jsonMode) {
|
|
66492
|
+
console.log(
|
|
66493
|
+
JSON.stringify({ status: "error", error: message, code: "DEMO_EXISTS" }, null, 2)
|
|
66494
|
+
);
|
|
66495
|
+
} else {
|
|
66496
|
+
console.error(chalk30.red(message));
|
|
66497
|
+
}
|
|
66498
|
+
process.exit(1);
|
|
66499
|
+
}
|
|
66500
|
+
demoPort = await findAvailablePersonaDemoPort(preferredDemoPort);
|
|
66501
|
+
demoOrigins = buildPersonaDemoOrigins(demoPort);
|
|
66502
|
+
demoLocalUrl = `http://127.0.0.1:${demoPort}/`;
|
|
66503
|
+
}
|
|
66504
|
+
if (demoRequested && demoOrigins) {
|
|
66505
|
+
allowedOrigins = mergePersonaDemoAllowedOrigins(allowedOrigins, demoOrigins);
|
|
66506
|
+
}
|
|
65559
66507
|
if (rl) {
|
|
65560
66508
|
rl.close();
|
|
65561
66509
|
}
|
|
@@ -65607,45 +66555,155 @@ personaCommand.command("init").description("Create agent + client token and outp
|
|
|
65607
66555
|
environment: chosenEnv,
|
|
65608
66556
|
allowedOrigins,
|
|
65609
66557
|
format: formatCli,
|
|
65610
|
-
targetSelector
|
|
66558
|
+
targetSelector,
|
|
66559
|
+
...demoRequested && demoOrigins ? { demo: { origins: demoOrigins, toolNames: [...PERSONA_DEMO_TOOL_NAMES] } } : {}
|
|
65611
66560
|
});
|
|
65612
66561
|
} catch (err) {
|
|
65613
66562
|
const message = err instanceof Error ? err.message : String(err);
|
|
65614
66563
|
if (jsonMode) {
|
|
65615
|
-
console.log(
|
|
66564
|
+
console.log(
|
|
66565
|
+
JSON.stringify({ status: "error", error: message, code: "API_ERROR" }, null, 2)
|
|
66566
|
+
);
|
|
65616
66567
|
} else {
|
|
65617
66568
|
console.error(chalk30.red("Persona init failed"));
|
|
65618
66569
|
console.error(chalk30.red(message));
|
|
65619
66570
|
}
|
|
65620
66571
|
process.exit(1);
|
|
65621
66572
|
}
|
|
66573
|
+
let demoOutput;
|
|
66574
|
+
let demoServer;
|
|
66575
|
+
if (demoRequested && demoDirectory && demoPort && demoOrigins && demoLocalUrl) {
|
|
66576
|
+
const html = generatePersonaDemoHtml({
|
|
66577
|
+
apiUrl,
|
|
66578
|
+
clientToken: success2.clientToken.token,
|
|
66579
|
+
clientTokenId: success2.clientToken.id,
|
|
66580
|
+
agentId: success2.agent.id,
|
|
66581
|
+
agentName: success2.agent.name,
|
|
66582
|
+
dashboardUrl: success2.dashboardUrl,
|
|
66583
|
+
environment: success2.clientToken.environment,
|
|
66584
|
+
localUrl: demoLocalUrl,
|
|
66585
|
+
allowedOrigins: demoOrigins
|
|
66586
|
+
});
|
|
66587
|
+
const readme2 = generatePersonaDemoReadme({
|
|
66588
|
+
apiUrl,
|
|
66589
|
+
clientToken: success2.clientToken.token,
|
|
66590
|
+
clientTokenId: success2.clientToken.id,
|
|
66591
|
+
agentId: success2.agent.id,
|
|
66592
|
+
agentName: success2.agent.name,
|
|
66593
|
+
dashboardUrl: success2.dashboardUrl,
|
|
66594
|
+
environment: success2.clientToken.environment,
|
|
66595
|
+
localUrl: demoLocalUrl,
|
|
66596
|
+
allowedOrigins: demoOrigins
|
|
66597
|
+
});
|
|
66598
|
+
const writeResult = writePersonaDemoPage({
|
|
66599
|
+
directory: demoDirectory,
|
|
66600
|
+
html,
|
|
66601
|
+
readme: readme2,
|
|
66602
|
+
force: forceDemoWrite
|
|
66603
|
+
});
|
|
66604
|
+
demoOutput = {
|
|
66605
|
+
...writeResult,
|
|
66606
|
+
localUrl: demoLocalUrl,
|
|
66607
|
+
port: demoPort,
|
|
66608
|
+
allowedOrigins: demoOrigins,
|
|
66609
|
+
serverRunning: false
|
|
66610
|
+
};
|
|
66611
|
+
const shouldLaunchDemo = !jsonMode && options.open !== false && (interactive || options.open === true);
|
|
66612
|
+
if (shouldLaunchDemo) {
|
|
66613
|
+
try {
|
|
66614
|
+
demoServer = await startPersonaDemoServer({
|
|
66615
|
+
directory: demoDirectory,
|
|
66616
|
+
port: demoPort
|
|
66617
|
+
});
|
|
66618
|
+
demoOutput.serverRunning = true;
|
|
66619
|
+
demoOutput.localUrl = demoServer.url;
|
|
66620
|
+
await openBrowser(demoServer.url);
|
|
66621
|
+
} catch (e) {
|
|
66622
|
+
demoOutput.serverError = e instanceof Error ? e.message : String(e);
|
|
66623
|
+
if (!jsonMode) {
|
|
66624
|
+
console.log(
|
|
66625
|
+
chalk30.yellow(`Could not start/open local demo server: ${demoOutput.serverError}`)
|
|
66626
|
+
);
|
|
66627
|
+
}
|
|
66628
|
+
}
|
|
66629
|
+
}
|
|
66630
|
+
}
|
|
66631
|
+
const output = demoOutput ? {
|
|
66632
|
+
...success2,
|
|
66633
|
+
demo: {
|
|
66634
|
+
...success2.demo,
|
|
66635
|
+
...demoOutput
|
|
66636
|
+
}
|
|
66637
|
+
} : success2;
|
|
65622
66638
|
if (jsonMode) {
|
|
65623
|
-
printJson(
|
|
66639
|
+
printJson(output);
|
|
65624
66640
|
return;
|
|
65625
66641
|
}
|
|
65626
66642
|
if (!tty || options.printSnippet) {
|
|
65627
66643
|
console.log(chalk30.green("\nPersona setup complete\n"));
|
|
65628
|
-
console.log(`${chalk30.bold("Agent ID:")} ${
|
|
65629
|
-
console.log(`${chalk30.bold("Client Token ID:")} ${
|
|
65630
|
-
console.log(`${chalk30.bold("Client Token:")} ${chalk30.yellow(
|
|
65631
|
-
console.log(`${chalk30.bold("Format:")} ${
|
|
66644
|
+
console.log(`${chalk30.bold("Agent ID:")} ${output.agent.id}`);
|
|
66645
|
+
console.log(`${chalk30.bold("Client Token ID:")} ${output.clientToken.id}`);
|
|
66646
|
+
console.log(`${chalk30.bold("Client Token:")} ${chalk30.yellow(output.clientToken.token)}`);
|
|
66647
|
+
console.log(`${chalk30.bold("Format:")} ${output.snippet.format}`);
|
|
65632
66648
|
console.log(chalk30.dim(`
|
|
65633
|
-
Dashboard: ${
|
|
66649
|
+
Dashboard: ${output.dashboardUrl}`));
|
|
66650
|
+
if (demoOutput) {
|
|
66651
|
+
console.log(`${chalk30.bold("Demo HTML:")} ${demoOutput.filePath}`);
|
|
66652
|
+
console.log(`${chalk30.bold("Demo README:")} ${demoOutput.readmePath}`);
|
|
66653
|
+
console.log(`${chalk30.bold("Demo URL:")} ${chalk30.green(demoOutput.localUrl)}`);
|
|
66654
|
+
if (demoOutput.serverRunning) {
|
|
66655
|
+
console.log(chalk30.dim("Local demo server is running. Press Ctrl+C to stop it."));
|
|
66656
|
+
} else {
|
|
66657
|
+
console.log(
|
|
66658
|
+
chalk30.dim(
|
|
66659
|
+
`Run: cd ${demoOutput.directory} && python3 -m http.server ${demoOutput.port} --bind 127.0.0.1`
|
|
66660
|
+
)
|
|
66661
|
+
);
|
|
66662
|
+
}
|
|
66663
|
+
printDemoNextSteps(
|
|
66664
|
+
{
|
|
66665
|
+
url: demoOutput.localUrl,
|
|
66666
|
+
filePath: demoOutput.filePath,
|
|
66667
|
+
readmePath: demoOutput.readmePath
|
|
66668
|
+
},
|
|
66669
|
+
output.dashboardUrl
|
|
66670
|
+
);
|
|
66671
|
+
}
|
|
65634
66672
|
if (success2.warnings?.length) {
|
|
65635
66673
|
for (const w of success2.warnings) {
|
|
65636
66674
|
console.log(chalk30.yellow(`\u26A0 ${w.message}`));
|
|
65637
66675
|
}
|
|
65638
66676
|
}
|
|
65639
|
-
|
|
66677
|
+
if (!demoOutput) {
|
|
66678
|
+
console.log(chalk30.cyan("\nRecommended next step: npm install @runtypelabs/persona"));
|
|
66679
|
+
}
|
|
65640
66680
|
if (options.printSnippet) {
|
|
65641
66681
|
console.log(chalk30.cyan("\n--- snippet ---\n"));
|
|
65642
66682
|
console.log(success2.snippet.code);
|
|
65643
66683
|
} else {
|
|
65644
|
-
console.log(
|
|
66684
|
+
console.log(
|
|
66685
|
+
chalk30.dim(
|
|
66686
|
+
"\nUse --print-snippet to print the embed code, or run interactively for copy shortcuts."
|
|
66687
|
+
)
|
|
66688
|
+
);
|
|
65645
66689
|
}
|
|
65646
66690
|
return;
|
|
65647
66691
|
}
|
|
65648
|
-
|
|
66692
|
+
try {
|
|
66693
|
+
await runSuccessKeyLoop(
|
|
66694
|
+
success2,
|
|
66695
|
+
apiUrl,
|
|
66696
|
+
targetSelector,
|
|
66697
|
+
demoOutput ? {
|
|
66698
|
+
url: demoOutput.localUrl,
|
|
66699
|
+
filePath: demoOutput.filePath,
|
|
66700
|
+
readmePath: demoOutput.readmePath
|
|
66701
|
+
} : void 0
|
|
66702
|
+
);
|
|
66703
|
+
} finally {
|
|
66704
|
+
await demoServer?.close().catch(() => {
|
|
66705
|
+
});
|
|
66706
|
+
}
|
|
65649
66707
|
}
|
|
65650
66708
|
);
|
|
65651
66709
|
|
|
@@ -65817,7 +66875,7 @@ import chalk32 from "chalk";
|
|
|
65817
66875
|
import React23 from "react";
|
|
65818
66876
|
import { render as render23 } from "ink";
|
|
65819
66877
|
import { useState as useState40, useEffect as useEffect34 } from "react";
|
|
65820
|
-
import
|
|
66878
|
+
import open5 from "open";
|
|
65821
66879
|
var billingCommand = new Command25("billing").description("View billing and subscription info");
|
|
65822
66880
|
billingCommand.command("status").description("Show current plan and usage").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
|
|
65823
66881
|
const apiKey = await ensureAuth();
|
|
@@ -65920,7 +66978,7 @@ billingCommand.command("portal").description("Open the billing portal in your br
|
|
|
65920
66978
|
if (data.url) {
|
|
65921
66979
|
console.log("Opening billing portal...");
|
|
65922
66980
|
console.log(data.url);
|
|
65923
|
-
await
|
|
66981
|
+
await open5(data.url);
|
|
65924
66982
|
} else {
|
|
65925
66983
|
console.log("No portal URL returned. You may need to set up billing first.");
|
|
65926
66984
|
}
|
|
@@ -65942,7 +67000,7 @@ billingCommand.command("portal").description("Open the billing portal in your br
|
|
|
65942
67000
|
try {
|
|
65943
67001
|
const data = await client.post("/billing/portal");
|
|
65944
67002
|
if (data.url) {
|
|
65945
|
-
await
|
|
67003
|
+
await open5(data.url);
|
|
65946
67004
|
setMsg("Billing portal opened in browser");
|
|
65947
67005
|
setSuccess(true);
|
|
65948
67006
|
} else {
|
|
@@ -66792,7 +67850,7 @@ var tailCommand = new Command28("tail").description("Stream live execution logs
|
|
|
66792
67850
|
// src/commands/validate-product.ts
|
|
66793
67851
|
import { Command as Command29, Option } from "commander";
|
|
66794
67852
|
import chalk36 from "chalk";
|
|
66795
|
-
import { readFileSync as
|
|
67853
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
66796
67854
|
function createValidateProductCommand() {
|
|
66797
67855
|
return new Command29("validate-product").description("Validate a product (FPO) or FPO template locally (no API call)").argument(
|
|
66798
67856
|
"[input]",
|
|
@@ -66872,7 +67930,7 @@ async function readInput(input) {
|
|
|
66872
67930
|
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
66873
67931
|
return trimmed;
|
|
66874
67932
|
}
|
|
66875
|
-
return
|
|
67933
|
+
return readFileSync18(input, "utf-8");
|
|
66876
67934
|
}
|
|
66877
67935
|
async function readStdin() {
|
|
66878
67936
|
if (process.stdin.isTTY) {
|
|
@@ -66975,7 +68033,7 @@ function printIssues(title, issues, color) {
|
|
|
66975
68033
|
import { Command as Command30 } from "commander";
|
|
66976
68034
|
import chalk37 from "chalk";
|
|
66977
68035
|
import * as fs16 from "fs";
|
|
66978
|
-
import * as
|
|
68036
|
+
import * as path17 from "path";
|
|
66979
68037
|
import { RuntypeApiError as RuntypeApiError4 } from "@runtypelabs/sdk";
|
|
66980
68038
|
function bashSingleQuote(s) {
|
|
66981
68039
|
return "'" + s.replace(/'/g, "'\\''") + "'";
|
|
@@ -67945,8 +69003,8 @@ var deployCommand = new Command30("deploy").description("Export an agent or flow
|
|
|
67945
69003
|
const apiKey = await ensureAuth();
|
|
67946
69004
|
if (!apiKey) return;
|
|
67947
69005
|
const client = createCliClient(apiKey);
|
|
67948
|
-
const outDir =
|
|
67949
|
-
const projectName = options.name ?? slugify2(
|
|
69006
|
+
const outDir = path17.resolve(options.output);
|
|
69007
|
+
const projectName = options.name ?? slugify2(path17.basename(outDir));
|
|
67950
69008
|
console.log(chalk37.cyan(`
|
|
67951
69009
|
Scaffolding ${target} deployment to ${outDir}
|
|
67952
69010
|
`));
|
|
@@ -68011,18 +69069,18 @@ Scaffolding ${target} deployment to ${outDir}
|
|
|
68011
69069
|
}
|
|
68012
69070
|
slugSet.add(slug);
|
|
68013
69071
|
}
|
|
68014
|
-
fs16.mkdirSync(
|
|
68015
|
-
fs16.mkdirSync(
|
|
69072
|
+
fs16.mkdirSync(path17.join(outDir, "agents"), { recursive: true });
|
|
69073
|
+
fs16.mkdirSync(path17.join(outDir, "packages"), { recursive: true });
|
|
68016
69074
|
for (const { name, def } of agentDefs) {
|
|
68017
69075
|
const filename = `${slugify2(name)}.json`;
|
|
68018
|
-
fs16.writeFileSync(
|
|
69076
|
+
fs16.writeFileSync(path17.join(outDir, "agents", filename), JSON.stringify(def, null, 2));
|
|
68019
69077
|
console.log(` Wrote agents/${filename}`);
|
|
68020
69078
|
}
|
|
68021
69079
|
const agentNames = agentDefs.map((a) => a.name);
|
|
68022
69080
|
let monorepoRoot = process.cwd();
|
|
68023
69081
|
for (let i = 0; i < 8; i++) {
|
|
68024
|
-
if (fs16.existsSync(
|
|
68025
|
-
const parent =
|
|
69082
|
+
if (fs16.existsSync(path17.join(monorepoRoot, "pnpm-workspace.yaml"))) break;
|
|
69083
|
+
const parent = path17.dirname(monorepoRoot);
|
|
68026
69084
|
if (parent === monorepoRoot) break;
|
|
68027
69085
|
monorepoRoot = parent;
|
|
68028
69086
|
}
|
|
@@ -68032,35 +69090,35 @@ Scaffolding ${target} deployment to ${outDir}
|
|
|
68032
69090
|
}
|
|
68033
69091
|
const secretNames = Array.from(allSecrets);
|
|
68034
69092
|
if (target === "cloudflare") {
|
|
68035
|
-
fs16.mkdirSync(
|
|
68036
|
-
fs16.writeFileSync(
|
|
68037
|
-
fs16.writeFileSync(
|
|
68038
|
-
fs16.writeFileSync(
|
|
68039
|
-
fs16.writeFileSync(
|
|
68040
|
-
const setupPath =
|
|
69093
|
+
fs16.mkdirSync(path17.join(outDir, "src"), { recursive: true });
|
|
69094
|
+
fs16.writeFileSync(path17.join(outDir, "src", "index.ts"), workerIndexTs(agentSlugs));
|
|
69095
|
+
fs16.writeFileSync(path17.join(outDir, "wrangler.toml"), wranglerToml(projectName));
|
|
69096
|
+
fs16.writeFileSync(path17.join(outDir, "package.json"), workerPackageJson(projectName, "workspace:*"));
|
|
69097
|
+
fs16.writeFileSync(path17.join(outDir, "tsconfig.json"), workerTsconfigJson());
|
|
69098
|
+
const setupPath = path17.join(outDir, "setup.sh");
|
|
68041
69099
|
fs16.writeFileSync(setupPath, workerSetupSh(monorepoRoot));
|
|
68042
69100
|
fs16.chmodSync(setupPath, 493);
|
|
68043
|
-
fs16.writeFileSync(
|
|
69101
|
+
fs16.writeFileSync(path17.join(outDir, "README.md"), workerReadme(agentNames, secretNames));
|
|
68044
69102
|
} else if (target === "vercel") {
|
|
68045
|
-
fs16.mkdirSync(
|
|
68046
|
-
fs16.writeFileSync(
|
|
68047
|
-
fs16.writeFileSync(
|
|
68048
|
-
fs16.writeFileSync(
|
|
68049
|
-
fs16.writeFileSync(
|
|
68050
|
-
const setupPath =
|
|
69103
|
+
fs16.mkdirSync(path17.join(outDir, "api"), { recursive: true });
|
|
69104
|
+
fs16.writeFileSync(path17.join(outDir, "api", "[[...route]].ts"), vercelRouteTs(agentSlugs));
|
|
69105
|
+
fs16.writeFileSync(path17.join(outDir, "vercel.json"), vercelJson());
|
|
69106
|
+
fs16.writeFileSync(path17.join(outDir, "package.json"), vercelPackageJson(projectName, "workspace:*"));
|
|
69107
|
+
fs16.writeFileSync(path17.join(outDir, "tsconfig.json"), vercelTsconfigJson());
|
|
69108
|
+
const setupPath = path17.join(outDir, "setup.sh");
|
|
68051
69109
|
fs16.writeFileSync(setupPath, vercelSetupSh(monorepoRoot));
|
|
68052
69110
|
fs16.chmodSync(setupPath, 493);
|
|
68053
|
-
fs16.writeFileSync(
|
|
69111
|
+
fs16.writeFileSync(path17.join(outDir, "README.md"), vercelReadme(agentNames, secretNames));
|
|
68054
69112
|
} else {
|
|
68055
|
-
fs16.writeFileSync(
|
|
68056
|
-
fs16.writeFileSync(
|
|
68057
|
-
fs16.writeFileSync(
|
|
68058
|
-
fs16.writeFileSync(
|
|
68059
|
-
fs16.writeFileSync(
|
|
68060
|
-
const setupPath =
|
|
69113
|
+
fs16.writeFileSync(path17.join(outDir, "server.ts"), serverTs());
|
|
69114
|
+
fs16.writeFileSync(path17.join(outDir, "Dockerfile"), dockerfile());
|
|
69115
|
+
fs16.writeFileSync(path17.join(outDir, ".dockerignore"), dockerignore());
|
|
69116
|
+
fs16.writeFileSync(path17.join(outDir, "tsconfig.json"), tsconfigJson());
|
|
69117
|
+
fs16.writeFileSync(path17.join(outDir, "package.json"), packageJson(projectName, "workspace:*"));
|
|
69118
|
+
const setupPath = path17.join(outDir, "setup.sh");
|
|
68061
69119
|
fs16.writeFileSync(setupPath, setupSh(monorepoRoot));
|
|
68062
69120
|
fs16.chmodSync(setupPath, 493);
|
|
68063
|
-
fs16.writeFileSync(
|
|
69121
|
+
fs16.writeFileSync(path17.join(outDir, "README.md"), readme(agentNames, secretNames));
|
|
68064
69122
|
}
|
|
68065
69123
|
console.log("");
|
|
68066
69124
|
console.log(chalk37.green(`\u2713 Scaffold written to ${outDir}`));
|
|
@@ -68118,19 +69176,19 @@ import { Command as Command31 } from "commander";
|
|
|
68118
69176
|
import chalk39 from "chalk";
|
|
68119
69177
|
|
|
68120
69178
|
// src/lib/skills-install.ts
|
|
68121
|
-
import { mkdirSync as
|
|
68122
|
-
import
|
|
69179
|
+
import { mkdirSync as mkdirSync10, readFileSync as readFileSync19, writeFileSync as writeFileSync8 } from "fs";
|
|
69180
|
+
import path18 from "path";
|
|
68123
69181
|
import readline4 from "readline";
|
|
68124
69182
|
import chalk38 from "chalk";
|
|
68125
69183
|
var SKILLS_REPO = "runtypelabs/skills";
|
|
68126
69184
|
var SKILLS_INSTALL_RETRY_HINT = "Retry with `runtype skills install`, or install manually: npx skills add runtypelabs/skills";
|
|
68127
69185
|
var METADATA_FILENAME = "agents-skills-install.json";
|
|
68128
69186
|
function metadataPath() {
|
|
68129
|
-
return
|
|
69187
|
+
return path18.join(getRuntypeHomeDir(), METADATA_FILENAME);
|
|
68130
69188
|
}
|
|
68131
69189
|
function readSkillsInstallMetadata() {
|
|
68132
69190
|
try {
|
|
68133
|
-
const raw =
|
|
69191
|
+
const raw = readFileSync19(metadataPath(), "utf8");
|
|
68134
69192
|
const parsed = JSON.parse(raw);
|
|
68135
69193
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && parsed.version === 1 && typeof parsed.accepted === "boolean") {
|
|
68136
69194
|
return parsed;
|
|
@@ -68142,8 +69200,8 @@ function readSkillsInstallMetadata() {
|
|
|
68142
69200
|
}
|
|
68143
69201
|
function writeSkillsInstallMetadata(metadata) {
|
|
68144
69202
|
try {
|
|
68145
|
-
|
|
68146
|
-
|
|
69203
|
+
mkdirSync10(path18.dirname(metadataPath()), { recursive: true });
|
|
69204
|
+
writeFileSync8(metadataPath(), JSON.stringify(metadata, null, 2));
|
|
68147
69205
|
} catch {
|
|
68148
69206
|
}
|
|
68149
69207
|
}
|
|
@@ -68399,7 +69457,7 @@ skillsCommand.command("install").description(`Install Runtype skills (${SKILLS_R
|
|
|
68399
69457
|
);
|
|
68400
69458
|
|
|
68401
69459
|
// src/commands/apps.ts
|
|
68402
|
-
import { readdirSync as readdirSync6, readFileSync as
|
|
69460
|
+
import { readdirSync as readdirSync6, readFileSync as readFileSync20, lstatSync, statSync as statSync7, existsSync as existsSync15 } from "fs";
|
|
68403
69461
|
import { join as join12, relative as relative5 } from "path";
|
|
68404
69462
|
import { Command as Command32 } from "commander";
|
|
68405
69463
|
import chalk40 from "chalk";
|
|
@@ -68420,7 +69478,7 @@ function collectBundleFiles(dir) {
|
|
|
68420
69478
|
if (entry === "node_modules") continue;
|
|
68421
69479
|
walk(full);
|
|
68422
69480
|
} else {
|
|
68423
|
-
zippable[relative5(dir, full).split("\\").join("/")] =
|
|
69481
|
+
zippable[relative5(dir, full).split("\\").join("/")] = readFileSync20(full);
|
|
68424
69482
|
}
|
|
68425
69483
|
}
|
|
68426
69484
|
};
|
|
@@ -68501,7 +69559,7 @@ appsCommand.command("deploy <dir>").description("Zip a bundle directory, upload
|
|
|
68501
69559
|
const jsonMode = !!(options.json ?? globals.json);
|
|
68502
69560
|
const apiKey = await ensureAuth();
|
|
68503
69561
|
if (!apiKey) return;
|
|
68504
|
-
if (!
|
|
69562
|
+
if (!existsSync15(dir) || !statSync7(dir).isDirectory()) {
|
|
68505
69563
|
fail(`Not a directory: ${dir}`, jsonMode, "INVALID_DIR");
|
|
68506
69564
|
}
|
|
68507
69565
|
let bundleFiles = {};
|