sim 2.1.5-dev.77.1 → 2.1.5-dev.78.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +139 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12236,7 +12236,7 @@ var CLI_CONTRACT = {
|
|
|
12236
12236
|
},
|
|
12237
12237
|
deleteTableView: { confirm: "This deletes the saved view and its filters." },
|
|
12238
12238
|
deleteWorkflowGroup: {
|
|
12239
|
-
confirm: "This deletes the group
|
|
12239
|
+
confirm: "This deletes the group AND its output columns with all of their row data; the workflow it pointed at is untouched.",
|
|
12240
12240
|
fields: [
|
|
12241
12241
|
{ header: "id" },
|
|
12242
12242
|
{ header: "deleted", format: "bool" },
|
|
@@ -13102,7 +13102,7 @@ var CLI_CONTRACT = {
|
|
|
13102
13102
|
selectedOutputs: {
|
|
13103
13103
|
name: "select-output",
|
|
13104
13104
|
list: true,
|
|
13105
|
-
describe: "Include
|
|
13105
|
+
describe: "Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted"
|
|
13106
13106
|
}
|
|
13107
13107
|
},
|
|
13108
13108
|
fields: [
|
|
@@ -14072,6 +14072,22 @@ function countOf(value) {
|
|
|
14072
14072
|
function lengthOf(value) {
|
|
14073
14073
|
return Array.isArray(value) ? value.length : 0;
|
|
14074
14074
|
}
|
|
14075
|
+
var RESULT_NOTES = {
|
|
14076
|
+
replaceWorkflowChatDeployment: (payload, body) => {
|
|
14077
|
+
const authType = payload.authType ?? body?.authType ?? "public";
|
|
14078
|
+
return authType === "public" ? "note: auth type is public — anyone with the link can chat; pass --auth-type password|email to restrict it." : null;
|
|
14079
|
+
}
|
|
14080
|
+
};
|
|
14081
|
+
function writeResultNote(operation, payload, body) {
|
|
14082
|
+
const note = RESULT_NOTES[operation];
|
|
14083
|
+
if (!note)
|
|
14084
|
+
return;
|
|
14085
|
+
const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
14086
|
+
const message = note(record, body);
|
|
14087
|
+
if (message)
|
|
14088
|
+
process.stderr.write(source_default.dim(`${message}
|
|
14089
|
+
`));
|
|
14090
|
+
}
|
|
14075
14091
|
function bulkFailureMessage(operation, payload, body) {
|
|
14076
14092
|
const check = BULK_OUTCOME_CHECKS[operation];
|
|
14077
14093
|
if (!check)
|
|
@@ -14197,6 +14213,7 @@ async function executeOperation(operation, commandSpec, operationSpec, invocatio
|
|
|
14197
14213
|
});
|
|
14198
14214
|
const payload = result?.data ?? result;
|
|
14199
14215
|
renderResult(operation, profile.output, payload, commandSpec, { expandedTrace: requestFlags.trace === true }, result);
|
|
14216
|
+
writeResultNote(operation, payload, request.body);
|
|
14200
14217
|
const failure = runFailureMessage(operation, payload) ?? bulkFailureMessage(operation, payload, request.body);
|
|
14201
14218
|
if (failure)
|
|
14202
14219
|
throw new SimApiError(failure, 0);
|
|
@@ -16026,6 +16043,118 @@ function attachWorkflowRunFollow(workflows) {
|
|
|
16026
16043
|
run.option("--manual", "Run the current saved workflow state instead of the active deployment").option("--trigger <blockId>", "Enter the run through this runnable trigger; runs the current saved workflow state (implies --manual)").option("--mock-payload", "Use the selected trigger's server-derived mock payload; runs the current saved workflow state (implies --manual)").option("--from-block <blockId>", "Run manually from this saved workflow block").option("--source-run <runId>", "Prior run whose persisted state supplies upstream outputs (requires --from-block)").option("--follow", "Stream the run as it happens; progress on stderr, result on stdout. The stream reports only success and output, so the result omits the run id and timings a non-streaming run returns").option("--include-thinking", "Show model reasoning while following (requires --follow)").option("--include-tool-calls", "Show tool calls while following (requires --follow)").action(followOrDelegate(previous));
|
|
16027
16044
|
}
|
|
16028
16045
|
|
|
16046
|
+
// src/commands/protocol/workflow-run-get.ts
|
|
16047
|
+
var BLOCK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
16048
|
+
var SELECT_OUTPUT_FLAG = "select-output";
|
|
16049
|
+
function normalizeBlockName(name) {
|
|
16050
|
+
return name.toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
|
16051
|
+
}
|
|
16052
|
+
function isRecord2(value) {
|
|
16053
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16054
|
+
}
|
|
16055
|
+
async function loadWorkflowBlocks(client, workflowId) {
|
|
16056
|
+
const operation = V2_OPERATIONS.getWorkflowState;
|
|
16057
|
+
const raw = await client.request(resolvePath(operation.path, { workflowId }), {
|
|
16058
|
+
method: operation.method
|
|
16059
|
+
});
|
|
16060
|
+
const state = isRecord2(raw) && isRecord2(raw.data) ? raw.data : raw;
|
|
16061
|
+
const blocks = isRecord2(state) && isRecord2(state.blocks) ? Object.entries(state.blocks) : [];
|
|
16062
|
+
return blocks.map(([key, block]) => ({
|
|
16063
|
+
id: isRecord2(block) && typeof block.id === "string" ? block.id : key,
|
|
16064
|
+
name: isRecord2(block) && typeof block.name === "string" ? block.name : ""
|
|
16065
|
+
}));
|
|
16066
|
+
}
|
|
16067
|
+
function splitSelector(selector) {
|
|
16068
|
+
const dot = selector.indexOf(".");
|
|
16069
|
+
return dot === -1 ? { head: selector, path: "" } : { head: selector.slice(0, dot), path: selector.slice(dot) };
|
|
16070
|
+
}
|
|
16071
|
+
function isIdHeaded(selector) {
|
|
16072
|
+
return BLOCK_ID.test(splitSelector(selector).head);
|
|
16073
|
+
}
|
|
16074
|
+
function resolveSelection(typed, blocks, workflowId) {
|
|
16075
|
+
const resolved = [];
|
|
16076
|
+
const typedBy = new Map;
|
|
16077
|
+
const unresolved = [];
|
|
16078
|
+
for (const selector of typed) {
|
|
16079
|
+
const { head, path } = splitSelector(selector);
|
|
16080
|
+
let blockId = head;
|
|
16081
|
+
if (!BLOCK_ID.test(head)) {
|
|
16082
|
+
const wanted = normalizeBlockName(head);
|
|
16083
|
+
const matches = blocks.filter((block) => block.id === head || normalizeBlockName(block.name) === wanted);
|
|
16084
|
+
if (matches.length === 0) {
|
|
16085
|
+
unresolved.push(selector);
|
|
16086
|
+
continue;
|
|
16087
|
+
}
|
|
16088
|
+
if (matches.length > 1) {
|
|
16089
|
+
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} ${selector} names ${matches.length} blocks (${matches.map((block) => block.id).join(", ")}); pass the block id instead`, 0);
|
|
16090
|
+
}
|
|
16091
|
+
blockId = matches[0].id;
|
|
16092
|
+
}
|
|
16093
|
+
const rewritten = `${blockId}${path}`;
|
|
16094
|
+
resolved.push(rewritten);
|
|
16095
|
+
if (!typedBy.has(rewritten))
|
|
16096
|
+
typedBy.set(rewritten, selector);
|
|
16097
|
+
}
|
|
16098
|
+
if (unresolved.length > 0) {
|
|
16099
|
+
const names = blocks.map((block) => block.name).filter((name) => name !== "");
|
|
16100
|
+
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} did not resolve to any block on this run: ${unresolved.join(", ")}. Pass a block id or its name — "blockId", "blockId.path", "blockName" or "blockName.path"; names match ignoring case, spaces and dots. Blocks on workflow ${workflowId}: ${names.length > 0 ? names.join(", ") : "none"}.`, 0);
|
|
16101
|
+
}
|
|
16102
|
+
return { resolved, typedBy };
|
|
16103
|
+
}
|
|
16104
|
+
function keyByTyped(payload, typedBy) {
|
|
16105
|
+
if (!isRecord2(payload) || !isRecord2(payload.blockOutputs))
|
|
16106
|
+
return payload;
|
|
16107
|
+
const blockOutputs = {};
|
|
16108
|
+
for (const [key, value] of Object.entries(payload.blockOutputs)) {
|
|
16109
|
+
blockOutputs[typedBy.get(key) ?? key] = value;
|
|
16110
|
+
}
|
|
16111
|
+
return { ...payload, blockOutputs };
|
|
16112
|
+
}
|
|
16113
|
+
async function readRunByName(runId, typed, command) {
|
|
16114
|
+
const flags = command.optsWithGlobals();
|
|
16115
|
+
const { client, profile } = clientFrom(command);
|
|
16116
|
+
const operation = V2_OPERATIONS.getWorkflowRun;
|
|
16117
|
+
const spec = CLI_CONTRACT.getWorkflowRun ?? {};
|
|
16118
|
+
buildRequest("getWorkflowRun", [runId], flags, profile.workspaceId);
|
|
16119
|
+
const workflowId = String(flags.workflow);
|
|
16120
|
+
const selection = resolveSelection(typed, await loadWorkflowBlocks(client, workflowId), workflowId);
|
|
16121
|
+
const request = buildRequest("getWorkflowRun", [runId], { ...flags, selectOutput: selection.resolved }, profile.workspaceId);
|
|
16122
|
+
let result;
|
|
16123
|
+
try {
|
|
16124
|
+
result = await client.request(request.path, {
|
|
16125
|
+
method: operation.method,
|
|
16126
|
+
headers: request.headers,
|
|
16127
|
+
query: request.query,
|
|
16128
|
+
body: request.body
|
|
16129
|
+
});
|
|
16130
|
+
} catch (error) {
|
|
16131
|
+
throw retypeApiError(error, "getWorkflowRun", spec, operation);
|
|
16132
|
+
}
|
|
16133
|
+
renderResult("getWorkflowRun", profile.output, keyByTyped(result?.data ?? result, selection.typedBy), spec, {}, result);
|
|
16134
|
+
}
|
|
16135
|
+
function attachWorkflowRunGet(runs) {
|
|
16136
|
+
const get = runs.commands.find((command) => command.name() === "get");
|
|
16137
|
+
const held = get?._actionHandler;
|
|
16138
|
+
if (!get || typeof held !== "function") {
|
|
16139
|
+
throw new Error("workflows runs get must be registered before block names can be attached to it");
|
|
16140
|
+
}
|
|
16141
|
+
const previous = held;
|
|
16142
|
+
get.action(async (runId, _options, command) => {
|
|
16143
|
+
const raw = command.optsWithGlobals().selectOutput;
|
|
16144
|
+
if (raw === undefined) {
|
|
16145
|
+
await previous(command.processedArgs);
|
|
16146
|
+
return;
|
|
16147
|
+
}
|
|
16148
|
+
const typed = readListValues(raw, SELECT_OUTPUT_FLAG);
|
|
16149
|
+
command.setOptionValue("selectOutput", typed);
|
|
16150
|
+
if (typed.every(isIdHeaded)) {
|
|
16151
|
+
await previous(command.processedArgs);
|
|
16152
|
+
return;
|
|
16153
|
+
}
|
|
16154
|
+
await readRunByName(runId, typed, command);
|
|
16155
|
+
});
|
|
16156
|
+
}
|
|
16157
|
+
|
|
16029
16158
|
// src/commands/protocol/workflow-run-wait.ts
|
|
16030
16159
|
var TERMINAL_STATUSES = new Set(["completed", "failed", "cancelled"]);
|
|
16031
16160
|
var WAIT_EXIT_CODES = {
|
|
@@ -16040,21 +16169,21 @@ var MAX_POLL_DELAY_MS = 15000;
|
|
|
16040
16169
|
var POLL_BACKOFF_FACTOR = 2;
|
|
16041
16170
|
var DEFAULT_WAIT_TIMEOUT_SECONDS = 3600;
|
|
16042
16171
|
var WAIT_TIMEOUT_FLAG = "--wait-timeout <seconds>";
|
|
16043
|
-
function
|
|
16172
|
+
function isRecord3(value) {
|
|
16044
16173
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16045
16174
|
}
|
|
16046
16175
|
function optionalString(value) {
|
|
16047
16176
|
return typeof value === "string" && value !== "" ? value : null;
|
|
16048
16177
|
}
|
|
16049
16178
|
function runData(raw) {
|
|
16050
|
-
return
|
|
16179
|
+
return isRecord3(raw) && isRecord3(raw.data) ? raw.data : raw;
|
|
16051
16180
|
}
|
|
16052
16181
|
function readRun(raw) {
|
|
16053
|
-
const run =
|
|
16054
|
-
if (!
|
|
16182
|
+
const run = isRecord3(raw) && isRecord3(raw.data) ? raw.data : raw;
|
|
16183
|
+
if (!isRecord3(run) || typeof run.status !== "string") {
|
|
16055
16184
|
throw new SimApiError("Run status response carried no status.", 0);
|
|
16056
16185
|
}
|
|
16057
|
-
const paused =
|
|
16186
|
+
const paused = isRecord3(run.paused) ? run.paused : null;
|
|
16058
16187
|
return {
|
|
16059
16188
|
status: run.status,
|
|
16060
16189
|
pauseKind: paused ? optionalString(paused.pauseKind) : null,
|
|
@@ -16191,7 +16320,9 @@ function attachProtocolCommands(program2) {
|
|
|
16191
16320
|
createFolder: "createWorkflowFolder"
|
|
16192
16321
|
});
|
|
16193
16322
|
attachWorkflowRunFollow(workflows);
|
|
16194
|
-
|
|
16323
|
+
const runs = group(workflows, "runs");
|
|
16324
|
+
attachWorkflowRunGet(runs);
|
|
16325
|
+
attachWorkflowRunWait(runs);
|
|
16195
16326
|
attachLogsFollow(group(program2, "logs"));
|
|
16196
16327
|
attachChat(program2);
|
|
16197
16328
|
}
|