sim 2.3.0-preview.331.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/protocol/source-status.d.ts +2 -0
- package/dist/commands/protocol/source-strict.d.ts +8 -0
- package/dist/commands/protocol/workflow-run-follow.d.ts +1 -16
- package/dist/commands/protocol/workflow-run-get.d.ts +0 -12
- package/dist/index.js +129 -92
- package/dist/runtime.js +129 -92
- package/package.json +2 -1
|
@@ -118,6 +118,8 @@ export interface PathFilter {
|
|
|
118
118
|
*/
|
|
119
119
|
assertEachMatches(paths: Iterable<string>): void;
|
|
120
120
|
}
|
|
121
|
+
/** A relative filter as given, with `/` separators and its leading `./` and trailing `/` dropped. */
|
|
122
|
+
export declare function givenFilterPath(filter: string): string;
|
|
121
123
|
/**
|
|
122
124
|
* The filter of `filters` against `dir`: a filter selects the path it names, every path under a
|
|
123
125
|
* folder it names, or (as `kind:key` given to `keyOf`) every file of that resource.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The warnings a check fails on as errors: an apply saves each as written although the block it
|
|
3
|
+
* names is broken. One table, so `check --help` and the directory guides name the same findings.
|
|
4
|
+
*/
|
|
5
|
+
/** Each strict warning code with what it finds, as the guides phrase it. */
|
|
6
|
+
export declare const STRICT_FINDINGS: ReadonlyMap<string, string>;
|
|
7
|
+
/** Every {@link STRICT_FINDINGS} phrase as one clause: `a, b, … or z`. */
|
|
8
|
+
export declare const STRICT_FINDINGS_CLAUSE: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
2
|
/** The sink live commentary is written to; `process.stderr` satisfies it. */
|
|
3
|
-
|
|
3
|
+
interface CommentaryWriter {
|
|
4
4
|
write(text: string): unknown;
|
|
5
5
|
}
|
|
6
6
|
export interface FollowOptions {
|
|
@@ -8,21 +8,6 @@ export interface FollowOptions {
|
|
|
8
8
|
includeToolCalls: boolean;
|
|
9
9
|
stderr: CommentaryWriter;
|
|
10
10
|
}
|
|
11
|
-
type WorkflowRunSelection = {
|
|
12
|
-
source: 'manual';
|
|
13
|
-
entry?: {
|
|
14
|
-
type: 'trigger';
|
|
15
|
-
blockId?: string;
|
|
16
|
-
useMockPayload?: boolean;
|
|
17
|
-
} | {
|
|
18
|
-
type: 'block';
|
|
19
|
-
blockId: string;
|
|
20
|
-
sourceRunId: string;
|
|
21
|
-
};
|
|
22
|
-
stopAfterBlockId?: string;
|
|
23
|
-
};
|
|
24
|
-
/** Projects friendly CLI flags into the API's strict nested run selector. */
|
|
25
|
-
export declare function resolveWorkflowRunSelection(flags: Record<string, unknown>): WorkflowRunSelection | undefined;
|
|
26
11
|
/**
|
|
27
12
|
* Renders one execute stream, returning the `final` envelope.
|
|
28
13
|
*
|
|
@@ -6,18 +6,6 @@ import type { Command } from 'commander';
|
|
|
6
6
|
* selector head is a name it cannot resolve.
|
|
7
7
|
*/
|
|
8
8
|
export declare const BLOCK_ID: RegExp;
|
|
9
|
-
/**
|
|
10
|
-
* A block name as the executor compares one: lowercased, whitespace and dots
|
|
11
|
-
* removed.
|
|
12
|
-
*
|
|
13
|
-
* `normalizeWorkflowBlockName` in `@sim/workflow-types`, restated. It is the
|
|
14
|
-
* rule `workflows run --select-output` resolves names with server-side and the
|
|
15
|
-
* one every block-name conflict check applies, so `Summarize Result` and
|
|
16
|
-
* `summarizeresult` name the same block on both commands. Restated rather than
|
|
17
|
-
* imported because this package ships standalone and carries no workspace
|
|
18
|
-
* dependency.
|
|
19
|
-
*/
|
|
20
|
-
export declare function normalizeBlockName(name: string): string;
|
|
21
9
|
/**
|
|
22
10
|
* Teaches the generated `workflows runs get` leaf the block names
|
|
23
11
|
* `workflows run --select-output` already takes.
|
package/dist/index.js
CHANGED
|
@@ -41085,6 +41085,13 @@ function childNodes(node) {
|
|
|
41085
41085
|
}
|
|
41086
41086
|
return children;
|
|
41087
41087
|
}
|
|
41088
|
+
function memberName(node) {
|
|
41089
|
+
if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression")
|
|
41090
|
+
return null;
|
|
41091
|
+
if (!node.computed && node.property.type === "Identifier")
|
|
41092
|
+
return node.property.name;
|
|
41093
|
+
return node.property.type === "StringLiteral" ? node.property.value : null;
|
|
41094
|
+
}
|
|
41088
41095
|
function memberSegment(member) {
|
|
41089
41096
|
const property = member.property;
|
|
41090
41097
|
if (!member.computed) {
|
|
@@ -41951,6 +41958,49 @@ function collectStringLeaves(value, out) {
|
|
|
41951
41958
|
collectStringLeaves(item, out);
|
|
41952
41959
|
}
|
|
41953
41960
|
|
|
41961
|
+
// ../utils/src/paste.ts
|
|
41962
|
+
var PASTE_LIMITS = {
|
|
41963
|
+
DEFAULT_BYTES: 32 * 1024 * 1024,
|
|
41964
|
+
RICH_MARKDOWN_BYTES: 5 * 1024 * 1024,
|
|
41965
|
+
TEXT_EDITOR_BYTES: 50 * 1024 * 1024,
|
|
41966
|
+
CHAT_CHARACTERS: 1e6,
|
|
41967
|
+
CHAT_BYTES: 4000000,
|
|
41968
|
+
TERMINAL_BYTES: 8 * 1024 * 1024,
|
|
41969
|
+
STRUCTURED_BYTES: 32 * 1024 * 1024
|
|
41970
|
+
};
|
|
41971
|
+
var PASTE_RENDER_THRESHOLDS = {
|
|
41972
|
+
ENHANCED_TEXT_CHARACTERS: 256 * 1024
|
|
41973
|
+
};
|
|
41974
|
+
function utf8ByteLengthRange(value, start = 0, end = value.length, stopAfter = Number.POSITIVE_INFINITY) {
|
|
41975
|
+
let bytes = 0;
|
|
41976
|
+
const safeStart = Math.min(Math.max(start, 0), value.length);
|
|
41977
|
+
const safeEnd = Math.min(Math.max(end, safeStart), value.length);
|
|
41978
|
+
for (let index = safeStart;index < safeEnd; index++) {
|
|
41979
|
+
const code = value.charCodeAt(index);
|
|
41980
|
+
if (code <= 127) {
|
|
41981
|
+
bytes += 1;
|
|
41982
|
+
} else if (code <= 2047) {
|
|
41983
|
+
bytes += 2;
|
|
41984
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
41985
|
+
const next = value.charCodeAt(index + 1);
|
|
41986
|
+
if (index + 1 < safeEnd && next >= 56320 && next <= 57343) {
|
|
41987
|
+
bytes += 4;
|
|
41988
|
+
index += 1;
|
|
41989
|
+
} else {
|
|
41990
|
+
bytes += 3;
|
|
41991
|
+
}
|
|
41992
|
+
} else {
|
|
41993
|
+
bytes += 3;
|
|
41994
|
+
}
|
|
41995
|
+
if (bytes > stopAfter)
|
|
41996
|
+
return bytes;
|
|
41997
|
+
}
|
|
41998
|
+
return bytes;
|
|
41999
|
+
}
|
|
42000
|
+
function utf8ByteLength(value, stopAfter = Number.POSITIVE_INFINITY) {
|
|
42001
|
+
return utf8ByteLengthRange(value, 0, value.length, stopAfter);
|
|
42002
|
+
}
|
|
42003
|
+
|
|
41954
42004
|
// ../workflow-code/src/limits.ts
|
|
41955
42005
|
var SOURCE_LIMITS = {
|
|
41956
42006
|
maxBlocks: 2000,
|
|
@@ -41974,25 +42024,6 @@ var CODE_FILE_PATH = new RegExp(`^${SOURCE_CODE_DIR}/[A-Za-z0-9_$-][A-Za-z0-9_.$
|
|
|
41974
42024
|
function isCodeFilePath(path) {
|
|
41975
42025
|
return CODE_FILE_PATH.test(path);
|
|
41976
42026
|
}
|
|
41977
|
-
function isLowSurrogate(code) {
|
|
41978
|
-
return code >= 56320 && code <= 57343;
|
|
41979
|
-
}
|
|
41980
|
-
function utf8Bytes(text, cap = Number.POSITIVE_INFINITY) {
|
|
41981
|
-
let bytes = 0;
|
|
41982
|
-
for (let i = 0;i < text.length && bytes <= cap; i++) {
|
|
41983
|
-
const code = text.charCodeAt(i);
|
|
41984
|
-
if (code < 128)
|
|
41985
|
-
bytes += 1;
|
|
41986
|
-
else if (code < 2048)
|
|
41987
|
-
bytes += 2;
|
|
41988
|
-
else if (code >= 55296 && code <= 56319 && isLowSurrogate(text.charCodeAt(i + 1))) {
|
|
41989
|
-
bytes += 4;
|
|
41990
|
-
i++;
|
|
41991
|
-
} else
|
|
41992
|
-
bytes += 3;
|
|
41993
|
-
}
|
|
41994
|
-
return bytes;
|
|
41995
|
-
}
|
|
41996
42027
|
|
|
41997
42028
|
// ../workflow-code/src/code-files/lexer.ts
|
|
41998
42029
|
var REGEX_ALLOWED_AFTER = new Set("(,=:[!&|?{};+-*%^~<>/".split(""));
|
|
@@ -43919,6 +43950,7 @@ function positionalTitle(kind, index, count) {
|
|
|
43919
43950
|
var PARALLEL_BATCH_MIN = 1;
|
|
43920
43951
|
var PARALLEL_BATCH_MAX = 20;
|
|
43921
43952
|
var DEFAULT_LOOP_ITERATIONS = 5;
|
|
43953
|
+
var DEFAULT_PARALLEL_COUNT = 5;
|
|
43922
43954
|
function effectiveBatchSize(batchSize) {
|
|
43923
43955
|
if (batchSize === undefined || Number.isNaN(batchSize))
|
|
43924
43956
|
return PARALLEL_BATCH_MAX;
|
|
@@ -44402,14 +44434,6 @@ function compileMemberSegment(ctx, member, site) {
|
|
|
44402
44434
|
}
|
|
44403
44435
|
return unsupported(ctx, member, "Element access needs a literal key.", HINTS.elementAccess, site.decl.key);
|
|
44404
44436
|
}
|
|
44405
|
-
function memberName(member) {
|
|
44406
|
-
const property = member.property;
|
|
44407
|
-
if (!member.computed && property.type === "Identifier")
|
|
44408
|
-
return property.name;
|
|
44409
|
-
if (member.computed && property.type === "StringLiteral")
|
|
44410
|
-
return property.value;
|
|
44411
|
-
return null;
|
|
44412
|
-
}
|
|
44413
44437
|
function outputKnown(outputs, segments) {
|
|
44414
44438
|
let level = outputs;
|
|
44415
44439
|
for (const segment of segments) {
|
|
@@ -45211,7 +45235,6 @@ function compileResponseParam(ctx, site, params, key, property) {
|
|
|
45211
45235
|
}
|
|
45212
45236
|
|
|
45213
45237
|
// ../workflow-code/src/forms/subflow.ts
|
|
45214
|
-
var DEFAULT_PARALLEL_COUNT = 5;
|
|
45215
45238
|
var LOOP_COUNT = {
|
|
45216
45239
|
field: "iterations",
|
|
45217
45240
|
kind: "number",
|
|
@@ -45385,6 +45408,9 @@ function quoteString(text) {
|
|
|
45385
45408
|
function printKey(key) {
|
|
45386
45409
|
return isIdentifierName(key) ? key : quoteString(key);
|
|
45387
45410
|
}
|
|
45411
|
+
function printNumber(value) {
|
|
45412
|
+
return String(value).replace("e+", "e");
|
|
45413
|
+
}
|
|
45388
45414
|
|
|
45389
45415
|
// ../workflow-code/src/print/doc.ts
|
|
45390
45416
|
var line = { type: "line", soft: false, hard: false, literal: false };
|
|
@@ -46074,7 +46100,7 @@ function sdkHeader(text) {
|
|
|
46074
46100
|
}
|
|
46075
46101
|
function parseWorkflowSource(file, text, limits, reporter) {
|
|
46076
46102
|
const parsed = { ast: null, ...sdkHeader(text) };
|
|
46077
|
-
if (
|
|
46103
|
+
if (utf8ByteLength(text, limits.maxTotalBytes) > limits.maxTotalBytes) {
|
|
46078
46104
|
reporter.report("E_LIMIT_EXCEEDED", `The file is larger than ${limits.maxTotalBytes} bytes, the limit for all source files together.`, { file, start: 0, end: 0 }, { hint: "Split the workflow, moving parts into child workflows." });
|
|
46079
46105
|
return parsed;
|
|
46080
46106
|
}
|
|
@@ -47004,7 +47030,7 @@ function readCodeFile(ctx, compiled, language, decl) {
|
|
|
47004
47030
|
function parseCodeFile(ctx, path, text, language, at, decl) {
|
|
47005
47031
|
const { limits } = ctx;
|
|
47006
47032
|
const before = ctx.codeFiles.bytes;
|
|
47007
|
-
ctx.codeFiles.bytes +=
|
|
47033
|
+
ctx.codeFiles.bytes += utf8ByteLength(text, limits.maxTotalBytes);
|
|
47008
47034
|
if (ctx.codeFiles.bytes > limits.maxTotalBytes) {
|
|
47009
47035
|
if (before > limits.maxTotalBytes)
|
|
47010
47036
|
return null;
|
|
@@ -47895,9 +47921,7 @@ function checkLoopCondition(ctx, decl, text, property) {
|
|
|
47895
47921
|
}
|
|
47896
47922
|
if (failure === null)
|
|
47897
47923
|
return;
|
|
47898
|
-
|
|
47899
|
-
const message = typeof raw === "string" ? raw : "Invalid JavaScript";
|
|
47900
|
-
ctx.reporter.report("W_LOOP_CONDITION_SYNTAX", `${decl.name}'s condition is not a JavaScript expression (${message.replace(/\s*\(\d+:\d+\)$/, "")}), so the run fails when it evaluates it.`, at, {
|
|
47924
|
+
ctx.reporter.report("W_LOOP_CONDITION_SYNTAX", `${decl.name}'s condition is not a JavaScript expression (${babelMessage(babelErrorShape(failure))}), so the run fails when it evaluates it.`, at, {
|
|
47901
47925
|
hint: "Write one JavaScript expression the loop repeats while it is true, e.g. condition: '<loop.index> < 3'.",
|
|
47902
47926
|
blockKey: decl.key
|
|
47903
47927
|
});
|
|
@@ -48746,13 +48770,6 @@ function merge2(a, b) {
|
|
|
48746
48770
|
return a;
|
|
48747
48771
|
return a !== "string" && b !== "string" ? "typed" : undefined;
|
|
48748
48772
|
}
|
|
48749
|
-
function memberName2(node) {
|
|
48750
|
-
if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression")
|
|
48751
|
-
return null;
|
|
48752
|
-
if (!node.computed && node.property.type === "Identifier")
|
|
48753
|
-
return node.property.name;
|
|
48754
|
-
return node.property.type === "StringLiteral" ? node.property.value : null;
|
|
48755
|
-
}
|
|
48756
48773
|
|
|
48757
48774
|
class Inference {
|
|
48758
48775
|
bindings;
|
|
@@ -48798,7 +48815,7 @@ class Inference {
|
|
|
48798
48815
|
return "number";
|
|
48799
48816
|
case "MemberExpression":
|
|
48800
48817
|
case "OptionalMemberExpression":
|
|
48801
|
-
return
|
|
48818
|
+
return memberName(node) === "length" && (this.kind(node.object) === "string" || this.isArray(node.object)) ? "number" : undefined;
|
|
48802
48819
|
case "CallExpression":
|
|
48803
48820
|
case "OptionalCallExpression":
|
|
48804
48821
|
return this.call(node.callee);
|
|
@@ -48830,7 +48847,7 @@ class Inference {
|
|
|
48830
48847
|
return "boolean";
|
|
48831
48848
|
return;
|
|
48832
48849
|
}
|
|
48833
|
-
const method =
|
|
48850
|
+
const method = memberName(callee);
|
|
48834
48851
|
if (method === null || !("object" in callee))
|
|
48835
48852
|
return;
|
|
48836
48853
|
if (callee.object.type === "Identifier") {
|
|
@@ -48854,7 +48871,7 @@ class Inference {
|
|
|
48854
48871
|
if (node.type === "ArrayExpression")
|
|
48855
48872
|
return true;
|
|
48856
48873
|
if (node.type === "CallExpression" || node.type === "OptionalCallExpression") {
|
|
48857
|
-
const method =
|
|
48874
|
+
const method = memberName(node.callee);
|
|
48858
48875
|
if (method === null || !("object" in node.callee))
|
|
48859
48876
|
return false;
|
|
48860
48877
|
if (node.callee.object.type === "Identifier" && node.callee.object.name === "Object") {
|
|
@@ -49234,16 +49251,9 @@ var CODE_FILE_REFUSALS = new Map([
|
|
|
49234
49251
|
["W_UNKNOWN_OUTPUT_PATH", "E_APPLY_UNRESOLVED_REF"],
|
|
49235
49252
|
["W_CODE_FILE_REF_SYNTAX", "E_APPLY_CODE_FILE_REF_SYNTAX"]
|
|
49236
49253
|
]);
|
|
49237
|
-
var REFUSABLE_WARNING_CODES = new Set([
|
|
49238
|
-
|
|
49239
|
-
|
|
49240
|
-
"W_LOOP_CONDITION_SYNTAX",
|
|
49241
|
-
"W_UNKNOWN_OUTPUT_PATH",
|
|
49242
|
-
"W_UNRESOLVED_REF",
|
|
49243
|
-
"W_CODE_FILE_REF_SYNTAX",
|
|
49244
|
-
"W_UNKNOWN_BLOCK_TYPE",
|
|
49245
|
-
"W_TYPE_NOT_ADDABLE"
|
|
49246
|
-
]);
|
|
49254
|
+
var REFUSABLE_WARNING_CODES = new Set([CHANGED_BLOCK_REFUSALS, PARAM_REFUSALS, ENTRY_REFUSALS, CODE_FILE_REFUSALS].flatMap((rules) => [
|
|
49255
|
+
...rules.keys()
|
|
49256
|
+
]));
|
|
49247
49257
|
var EDIT_REFUSALS = [
|
|
49248
49258
|
...[...CHANGED_BLOCK_REFUSALS].map(([warning, refusal]) => ({
|
|
49249
49259
|
warning,
|
|
@@ -50172,7 +50182,7 @@ function compileWorkflow(input) {
|
|
|
50172
50182
|
}
|
|
50173
50183
|
function compileEntry(input, file, text, reporter) {
|
|
50174
50184
|
const limits = { ...DEFAULT_LIMITS, ...input.limits };
|
|
50175
|
-
if (
|
|
50185
|
+
if (utf8ByteLength(text, limits.maxTotalBytes) <= limits.maxTotalBytes)
|
|
50176
50186
|
checkStorableText(file, text, reporter);
|
|
50177
50187
|
const parsed = parseWorkflowSource(file, text, limits, reporter);
|
|
50178
50188
|
if (parsed.sdkMajor === null) {
|
|
@@ -50197,7 +50207,13 @@ function compileEntry(input, file, text, reporter) {
|
|
|
50197
50207
|
catalog: input.catalog,
|
|
50198
50208
|
files: input.files,
|
|
50199
50209
|
limits,
|
|
50200
|
-
codeFiles: {
|
|
50210
|
+
codeFiles: {
|
|
50211
|
+
reads: new Map,
|
|
50212
|
+
refs: 0,
|
|
50213
|
+
bytes: utf8ByteLength(text),
|
|
50214
|
+
chains: [],
|
|
50215
|
+
sharedReads: []
|
|
50216
|
+
},
|
|
50201
50217
|
comments: new CommentCollector(file, reporter),
|
|
50202
50218
|
decls: [],
|
|
50203
50219
|
declsByKey: new Map,
|
|
@@ -51805,7 +51821,7 @@ function builderTypes(catalog, entry) {
|
|
|
51805
51821
|
};
|
|
51806
51822
|
}
|
|
51807
51823
|
function stripComments(text) {
|
|
51808
|
-
return text.replace(/\/\*\*[\s\S]*?\*\//g, "").replace(
|
|
51824
|
+
return text.replace(/\/\*\*[\s\S]*?\*\//g, "").replace(/^[ \t]*\/\/.*$/gm, "");
|
|
51809
51825
|
}
|
|
51810
51826
|
function coreImports(text) {
|
|
51811
51827
|
const code = stripComments(text);
|
|
@@ -54106,7 +54122,7 @@ async function withSourceCommandLock(dir, run, options = {}) {
|
|
|
54106
54122
|
var import_parser5 = __toESM(require_lib(), 1);
|
|
54107
54123
|
var CODE_FILE_EXPORT = "codeFile";
|
|
54108
54124
|
function codeFileReferences(text) {
|
|
54109
|
-
if (
|
|
54125
|
+
if (utf8ByteLength(text, SOURCE_LIMITS.maxTotalBytes) > SOURCE_LIMITS.maxTotalBytes)
|
|
54110
54126
|
return [];
|
|
54111
54127
|
if (bracketDepthOverflow(text, SOURCE_LIMITS.maxDepth) !== -1)
|
|
54112
54128
|
return [];
|
|
@@ -54665,9 +54681,6 @@ async function printRunFailureSite(dir, workflowId, error) {
|
|
|
54665
54681
|
// src/commands/protocol/workflow-run-get.ts
|
|
54666
54682
|
var BLOCK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
54667
54683
|
var SELECT_OUTPUT_FLAG = "select-output";
|
|
54668
|
-
function normalizeBlockName(name) {
|
|
54669
|
-
return name.toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
|
54670
|
-
}
|
|
54671
54684
|
async function loadWorkflowBlocks(client, workflowId) {
|
|
54672
54685
|
const raw = await client.request("getWorkflowState", { params: { workflowId } });
|
|
54673
54686
|
const state = isRecordLike(raw) && isRecordLike(raw.data) ? raw.data : raw;
|
|
@@ -54692,8 +54705,8 @@ function resolveSelection(typed, blocks, workflowId) {
|
|
|
54692
54705
|
const { head, path } = splitSelector(selector);
|
|
54693
54706
|
let blockId = head;
|
|
54694
54707
|
if (!BLOCK_ID.test(head)) {
|
|
54695
|
-
const wanted =
|
|
54696
|
-
const matches = blocks.filter((block) => block.id === head ||
|
|
54708
|
+
const wanted = normalizeWorkflowBlockName(head);
|
|
54709
|
+
const matches = blocks.filter((block) => block.id === head || normalizeWorkflowBlockName(block.name) === wanted);
|
|
54697
54710
|
if (matches.length === 0) {
|
|
54698
54711
|
unresolved.push(selector);
|
|
54699
54712
|
continue;
|
|
@@ -55207,7 +55220,7 @@ function stopBlockSelection(selection, flags) {
|
|
|
55207
55220
|
return null;
|
|
55208
55221
|
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0)
|
|
55209
55222
|
return null;
|
|
55210
|
-
return [BLOCK_ID.test(stopAfter) ? stopAfter :
|
|
55223
|
+
return [BLOCK_ID.test(stopAfter) ? stopAfter : normalizeWorkflowBlockName(stopAfter)];
|
|
55211
55224
|
}
|
|
55212
55225
|
function followOrDelegate(previous) {
|
|
55213
55226
|
return async (workflowId, _options, command) => {
|
|
@@ -57515,6 +57528,25 @@ function removedWorkflowRecords(paths) {
|
|
|
57515
57528
|
return [...paths].flatMap((path) => path.startsWith(`${KIND_DIRS.workflow}/`) && path.endsWith(`/${SOURCE_BASE_FILE}`) ? [`${path.slice(0, -SOURCE_BASE_FILE.length)}${SOURCE_STORED_EDGES_FILE}`] : []);
|
|
57516
57529
|
}
|
|
57517
57530
|
|
|
57531
|
+
// src/commands/protocol/source-strict.ts
|
|
57532
|
+
var STRICT_FINDINGS = new Map([
|
|
57533
|
+
["W_REQUIRED_MISSING", "a missing required field"],
|
|
57534
|
+
["W_UNKNOWN_OPTION", "an unknown option"],
|
|
57535
|
+
["W_UNKNOWN_OUTPUT_PATH", "an unknown output path"],
|
|
57536
|
+
["W_VALUE_KIND", "a wrong value kind"],
|
|
57537
|
+
["W_OUT_OF_RANGE", "an out-of-range value"],
|
|
57538
|
+
["W_LITERAL_SECRET", "a literal secret"],
|
|
57539
|
+
["W_TABLE_UNKNOWN_COLUMN", "a table write to an unknown column"],
|
|
57540
|
+
["W_CHILD_INPUT_UNKNOWN", "an input a child workflow does not declare"],
|
|
57541
|
+
["W_CHILD_RESULT_PATH", "a path a child workflow's result does not hold"],
|
|
57542
|
+
["W_BRANCH_UNWIRED", "an unwired condition or router branch"],
|
|
57543
|
+
["W_UNRESOLVED_REF", "a reference that names nothing"],
|
|
57544
|
+
["W_REF_OUT_OF_SCOPE", "an iteration field read outside its loop or parallel"],
|
|
57545
|
+
["W_LOOP_CONDITION_SYNTAX", "a loop condition that is not a JavaScript expression"]
|
|
57546
|
+
]);
|
|
57547
|
+
var phrases = [...STRICT_FINDINGS.values()];
|
|
57548
|
+
var STRICT_FINDINGS_CLAUSE = `${phrases.slice(0, -1).join(", ")} or ${phrases.at(-1)}`;
|
|
57549
|
+
|
|
57518
57550
|
// src/commands/protocol/workflow-dir.ts
|
|
57519
57551
|
var CODE_FILE_EXTENSION = new RegExp(`\\.(?:${Object.values(CODE_FILE_EXTENSIONS).join("|")})$`);
|
|
57520
57552
|
async function requireText(directory, path, hint) {
|
|
@@ -57605,7 +57637,7 @@ The primer above is enough to edit; read a section here when a step needs it.
|
|
|
57605
57637
|
## Edit loop in detail
|
|
57606
57638
|
|
|
57607
57639
|
1. Edit \`${SOURCE_ENTRY_FILE}\` (and \`functions/*\`). \`${SOURCE_EXAMPLES_DIR}/\` holds correct examples to copy from: \`cookbook.ts\` (agent with structured output, condition, function, table query and upsert, knowledge search, Slack, human in the loop, loop, response), \`integrations.ts\` (webhook trigger, weekday cron schedule, HTTP request with headers, table update by row id, Gmail, an error path) and \`agents.ts\` (router, agent tools: custom tool, MCP tool, integration operation, child workflow; run a child workflow; parallel). Their resource keys are examples; this workspace's are in \`${WORKSPACE_TYPES_FILE}\`.
|
|
57608
|
-
2. \`sim workflows source check --dir .\`: compiles offline with the server's compiler, in milliseconds. It catches what \`tsc\` cannot (duplicate names, cycles, literal secrets), and fails (exit 1) on
|
|
57640
|
+
2. \`sim workflows source check --dir .\`: compiles offline with the server's compiler, in milliseconds. It catches what \`tsc\` cannot (duplicate names, cycles, literal secrets), and fails (exit 1) on ${STRICT_FINDINGS_CLAUSE} in a block you added (\`--strict\`: in every block). It also adds the blocks the source now uses to \`tsconfig.json\`.
|
|
57609
57641
|
3. \`${typecheckCommand()}\`: about a second; catches what step 2 and the dry run do not (such as a reference to a start input the trigger does not declare). It runs the TypeScript release the declarations are built for (the directory has no \`package.json\`; plain \`bunx tsc\` would run whatever version it finds). \`tsconfig.json\` includes only the blocks the source used at the last check, get or apply: a builder from another block fails with \`has no exported member\` until you run step 2 (or use \`${typecheckCommand(TSCONFIG_FULL_FILE)}\`, every current block). The dry run is the authority: a printed line you did not edit that \`tsc\` flags and the dry run accepts is fine.
|
|
57610
57642
|
4. \`sim workflows source status --dir .\`: the files you changed (\`sim workflows source diff --dir .\` shows the edits), whether the workflow changed on the server since the get, and the command to run next (\`--offline\`: skip the server). Then \`sim workflows source apply --dir . --dry-run\` until it exits 0.
|
|
57611
57643
|
5. \`sim workflows source apply --dir . --yes\`: saves the draft, refusing errors, block deletions without \`--allow-delete\` and a stale directory, so it needs no separate dry run (without \`--yes\` and a terminal it prints the plan and exits ${SOURCE_PLANNED_EXIT_CODE}). \`--deploy\` also deploys it; without it, a deployed workflow's next \`sim workflows deploy <id> --expected-draft-fingerprint <fingerprint>\` is printed, which deploys only the draft this apply saved. It then rewrites \`${SOURCE_ENTRY_FILE}\` in canonical form (order, quoting, defaults left out).
|
|
@@ -57638,7 +57670,7 @@ The \`// @sim-sdk 1\` header must be the first line, and the file has exactly on
|
|
|
57638
57670
|
- \`sim workflows source params <builder>\`: one builder's params (required first, enums, defaults) and outputs; a namespace (\`gmail\`) lists its builders; a miss names the closest. Builders are named for the service, not the block type: \`gmail_v2\` is \`gmail.*\`, \`workflow_input\` is \`runWorkflow\`, the HTTP request block is \`api\`, and \`legacy.*\` builders are old versions not to write.
|
|
57639
57671
|
- \`${SOURCE_SDK_DIR}/core.d.ts\`: the SDK (\`workflow\`, \`t\`, \`env\`, \`credential\`, \`table\`, \`loop\`, \`parallel\`, \`BlockMeta\`).
|
|
57640
57672
|
- \`${SOURCE_SDK_DIR}/blocks/<block type>.d.ts\`: the builders of a block the source uses, with their params and outputs (check adds the file of a block an edit starts using). Do not read them, or \`${SOURCE_SDK_DIR}/models.d.ts\`, whole: \`params\` prints the part you need, and \`grep\` finds a model id.
|
|
57641
|
-
- \`${WORKSPACE_TYPES_FILE}\`: this workspace's tables, knowledge bases, credentials, workflows and env names.
|
|
57673
|
+
- \`${WORKSPACE_TYPES_FILE}\`: this workspace's tables, knowledge bases, credentials, workflows, skills, custom tools, MCP servers and env names.
|
|
57642
57674
|
|
|
57643
57675
|
## Rules
|
|
57644
57676
|
|
|
@@ -58181,7 +58213,7 @@ function readDeclaration(file, raw, options) {
|
|
|
58181
58213
|
const at = (start, end) => locator.located(locator.span(start, end));
|
|
58182
58214
|
const nodeAt = (node) => at(node.start ?? 0, node.end ?? node.start ?? 0);
|
|
58183
58215
|
const fail = () => ({ spans, diagnostics });
|
|
58184
|
-
const bytes =
|
|
58216
|
+
const bytes = utf8ByteLength(text, WORKSPACE_SOURCE_LIMITS.maxDeclarationBytes);
|
|
58185
58217
|
if (bytes > WORKSPACE_SOURCE_LIMITS.maxDeclarationBytes) {
|
|
58186
58218
|
diagnostics.push(diagnostic2("E_LIMIT_EXCEEDED", `The file is larger than ${WORKSPACE_SOURCE_LIMITS.maxDeclarationBytes} bytes.`, { ...at(0, 0) }));
|
|
58187
58219
|
return fail();
|
|
@@ -58565,9 +58597,6 @@ function objectField(fields, canonical) {
|
|
|
58565
58597
|
|
|
58566
58598
|
// ../workspace-code/src/declaration/print.ts
|
|
58567
58599
|
var INLINE_WIDTH = 80;
|
|
58568
|
-
function printNumber(value) {
|
|
58569
|
-
return String(value).replace("e+", "e");
|
|
58570
|
-
}
|
|
58571
58600
|
function call(name, ...args) {
|
|
58572
58601
|
return { [CALL_KEY]: name, args };
|
|
58573
58602
|
}
|
|
@@ -59047,7 +59076,7 @@ function filePathProblem(key) {
|
|
|
59047
59076
|
return `"${segment}" ends with a space or a dot`;
|
|
59048
59077
|
if (RESERVED_NAME.test(segment))
|
|
59049
59078
|
return `"${segment}" is a reserved device name`;
|
|
59050
|
-
if (
|
|
59079
|
+
if (utf8ByteLength(segment) > MAX_SEGMENT_BYTES) {
|
|
59051
59080
|
return `"${segment.slice(0, 32)}…" is over ${MAX_SEGMENT_BYTES} bytes`;
|
|
59052
59081
|
}
|
|
59053
59082
|
}
|
|
@@ -64215,7 +64244,7 @@ Secrets never appear in source: a workflow reads an environment variable as \`en
|
|
|
64215
64244
|
## Edit loop in detail
|
|
64216
64245
|
|
|
64217
64246
|
1. Edit the files.
|
|
64218
|
-
2. \`sim workspaces source check --dir .\`: compiles every workflow offline with the server's compiler, against what this directory declares: an unknown resource key (skills included) or table column, a child workflow's inputs, and an env name \`${KIND_DIRS.secret}\` lacks (a warning); and checks each \`${KIND_DIRS.table}/<key>.rows.jsonl\` line against its table as the apply would. It fails (exit 1) on errors and on
|
|
64247
|
+
2. \`sim workspaces source check --dir .\`: compiles every workflow offline with the server's compiler, against what this directory declares: an unknown resource key (skills included) or table column, a child workflow's inputs, and an env name \`${KIND_DIRS.secret}\` lacks (a warning); and checks each \`${KIND_DIRS.table}/<key>.rows.jsonl\` line against its table as the apply would. It fails (exit 1) on errors and on ${STRICT_FINDINGS_CLAUSE} in a block you added (\`--strict\`: in every block), regenerates \`.sim/sdk/workspace.d.ts\` and adds the blocks the workflows now use to \`tsconfig.json\`. In a workflow folder, \`sim workflows source check --dir .\` checks that one workflow the same way. Fix and rerun until it exits 0.
|
|
64219
64248
|
3. Run \`${typecheckCommand()}\` after every edit, before any dry run or apply, and fix what it reports: it takes about a second and catches what step 2 and the dry run do not (such as a reference to a start input the trigger does not declare). It type-checks the files with the TypeScript release the declarations are built for. \`tsconfig.json\` includes only the blocks the workflows used at the last check or get, which keeps it fast: a builder from another block fails with \`has no exported member\` until you run step 2 (or check with \`${typecheckCommand(TSCONFIG_FULL_FILE)}\`, every current block). \`sim workflows source params <builder>\` prints one builder's params and outputs; do not read the declarations whole. The dry run is the authority: a printed file you did not edit that \`tsc\` flags and the dry run accepts is fine, so leave it as it is.
|
|
64220
64249
|
4. \`sim workspaces source status --dir .\` before applying: your changes by resource (\`sim workspaces source diff --dir .\` shows the edits), what changed on the server since the get (a workflow edited in the editor included), the conflicts, and the command to run next. Exit 0 nothing changed, ${SOURCE_LOCAL_CHANGES_EXIT_CODE} only your edits, ${SOURCE_DRIFT_EXIT_CODE} the server changed since (\`--offline\`: skip the server). Then \`sim workspaces source apply --dir . --dry-run\`: shows the plan (\`+\` create, \`~\` update, \`=\` adopt an existing resource of the same name, \`-\` delete) and every error; fix and rerun until it exits 0.
|
|
64221
64250
|
5. \`sim workspaces source apply --dir . --yes\`: writes it and rewrites this directory from what was stored; it prints the plan it applied (without \`--yes\` and a terminal it prints the plan and exits ${SOURCE_PLANNED_EXIT_CODE}, writing nothing).
|
|
@@ -64385,12 +64414,22 @@ function tableRowFindings(key, decl, text) {
|
|
|
64385
64414
|
}));
|
|
64386
64415
|
return [...read, ...refused];
|
|
64387
64416
|
}
|
|
64388
|
-
|
|
64417
|
+
function* columnCalls(source) {
|
|
64418
|
+
const head = /\bcolumn\.(\w+)\s*\(/g;
|
|
64419
|
+
for (let match = head.exec(source);match !== null; match = head.exec(source)) {
|
|
64420
|
+
const open = match.index + match[0].length;
|
|
64421
|
+
const close = source.indexOf(")", open);
|
|
64422
|
+
if (close === -1)
|
|
64423
|
+
return;
|
|
64424
|
+
yield [match[1], source.slice(open, close)];
|
|
64425
|
+
head.lastIndex = close + 1;
|
|
64426
|
+
}
|
|
64427
|
+
}
|
|
64389
64428
|
function declaredTable(key, paths, files) {
|
|
64390
64429
|
const text = Object.fromEntries(paths.map((path) => [path, files[path] ?? ""]));
|
|
64391
64430
|
const owned = new Map;
|
|
64392
64431
|
for (const source of Object.values(text)) {
|
|
64393
|
-
for (const [
|
|
64432
|
+
for (const [type, args] of columnCalls(source)) {
|
|
64394
64433
|
const owns = owned.get(type) ?? new Set;
|
|
64395
64434
|
for (const option of TABLE_COLUMN_METADATA_KEYS) {
|
|
64396
64435
|
if (new RegExp(`\\b${option}\\s*:`).test(args))
|
|
@@ -64614,21 +64653,7 @@ function parseKinds(value) {
|
|
|
64614
64653
|
|
|
64615
64654
|
// src/commands/protocol/source-check.ts
|
|
64616
64655
|
var SERVER_ONLY_CODES = new Set(["E_STORED_VALUE_MISSING"]);
|
|
64617
|
-
var STRICT_CODES = new Set(
|
|
64618
|
-
"W_REQUIRED_MISSING",
|
|
64619
|
-
"W_UNKNOWN_OPTION",
|
|
64620
|
-
"W_UNKNOWN_OUTPUT_PATH",
|
|
64621
|
-
"W_VALUE_KIND",
|
|
64622
|
-
"W_OUT_OF_RANGE",
|
|
64623
|
-
"W_LITERAL_SECRET",
|
|
64624
|
-
"W_TABLE_UNKNOWN_COLUMN",
|
|
64625
|
-
"W_CHILD_INPUT_UNKNOWN",
|
|
64626
|
-
"W_CHILD_RESULT_PATH",
|
|
64627
|
-
"W_BRANCH_UNWIRED",
|
|
64628
|
-
"W_UNRESOLVED_REF",
|
|
64629
|
-
"W_REF_OUT_OF_SCOPE",
|
|
64630
|
-
"W_LOOP_CONDITION_SYNTAX"
|
|
64631
|
-
]);
|
|
64656
|
+
var STRICT_CODES = new Set(STRICT_FINDINGS.keys());
|
|
64632
64657
|
var STORED_EXEMPT_CODES = new Set(["W_BRANCH_UNWIRED"]);
|
|
64633
64658
|
var EDIT_SCOPED_CODES = new Set(["W_JSON_REF_UNTYPED"]);
|
|
64634
64659
|
function strictMode(options) {
|
|
@@ -65366,10 +65391,19 @@ function serverResourceChanges(diagnostics) {
|
|
|
65366
65391
|
return [...changes.values()].sort((a, b) => compareStrings(a.kind, b.kind) || compareStrings(a.key, b.key));
|
|
65367
65392
|
}
|
|
65368
65393
|
function sourceStatus(local, server) {
|
|
65394
|
+
const firstOfResource = new Map;
|
|
65395
|
+
const firstOfKind = new Map;
|
|
65396
|
+
for (const entry of local) {
|
|
65397
|
+
const address = `${entry.kind}:${entry.key}`;
|
|
65398
|
+
if (!firstOfResource.has(address))
|
|
65399
|
+
firstOfResource.set(address, entry);
|
|
65400
|
+
if (!firstOfKind.has(entry.kind))
|
|
65401
|
+
firstOfKind.set(entry.kind, entry);
|
|
65402
|
+
}
|
|
65369
65403
|
const conflicts = [];
|
|
65370
65404
|
const drift = [];
|
|
65371
65405
|
for (const change of server) {
|
|
65372
|
-
const mine =
|
|
65406
|
+
const mine = isFileKind(change.kind) ? firstOfKind.get(change.kind) : firstOfResource.get(`${change.kind}:${change.key}`);
|
|
65373
65407
|
if (mine)
|
|
65374
65408
|
conflicts.push({ ...change, change: mine.change });
|
|
65375
65409
|
else
|
|
@@ -66069,10 +66103,13 @@ function realPath(path) {
|
|
|
66069
66103
|
return parent === path ? path : join10(realPath(parent), basename4(path));
|
|
66070
66104
|
}
|
|
66071
66105
|
}
|
|
66106
|
+
function givenFilterPath(filter) {
|
|
66107
|
+
return stripTrailingSlashes(filter.replace(/\\/g, "/").replace(/^(\.\/)+/, ""));
|
|
66108
|
+
}
|
|
66072
66109
|
function filterForms(filter, dir) {
|
|
66073
66110
|
const forms = new Set;
|
|
66074
66111
|
if (!isAbsolute3(filter)) {
|
|
66075
|
-
const given =
|
|
66112
|
+
const given = givenFilterPath(filter);
|
|
66076
66113
|
forms.add(given === "" ? "." : given);
|
|
66077
66114
|
}
|
|
66078
66115
|
const resolved = relative2(realPath(resolve6(dir)), realPath(resolve6(filter))).split(sep).join("/");
|
|
@@ -67548,7 +67585,7 @@ function planLine2(plan) {
|
|
|
67548
67585
|
function fitsWhole(files) {
|
|
67549
67586
|
const paths = Object.keys(files).filter((path) => kindOfPath(path) === "workflow");
|
|
67550
67587
|
const folders = KIND_LAYOUTS.workflow.group(paths).groups.size;
|
|
67551
|
-
const bytes = paths.reduce((sum, path) => sum +
|
|
67588
|
+
const bytes = paths.reduce((sum, path) => sum + utf8ByteLength(files[path]), 0);
|
|
67552
67589
|
return folders <= WORKSPACE_SOURCE_LIMITS.maxWorkflows && bytes <= WORKSPACE_SOURCE_LIMITS.maxWorkflowBytes;
|
|
67553
67590
|
}
|
|
67554
67591
|
function unmanagedNext(status, managed, dir, workspaceScope) {
|
|
@@ -67670,7 +67707,7 @@ function filteredKinds(filters) {
|
|
|
67670
67707
|
const kinds = new Set;
|
|
67671
67708
|
for (const filter of filters) {
|
|
67672
67709
|
const named = filter.split(":", 1)[0];
|
|
67673
|
-
const kind = isWorkspaceKind(named) ? named : kindOfPath(filter
|
|
67710
|
+
const kind = isWorkspaceKind(named) ? named : kindOfPath(givenFilterPath(filter));
|
|
67674
67711
|
if (kind === null)
|
|
67675
67712
|
return;
|
|
67676
67713
|
kinds.add(kind);
|
package/dist/runtime.js
CHANGED
|
@@ -41134,6 +41134,13 @@ function childNodes(node) {
|
|
|
41134
41134
|
}
|
|
41135
41135
|
return children;
|
|
41136
41136
|
}
|
|
41137
|
+
function memberName(node) {
|
|
41138
|
+
if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression")
|
|
41139
|
+
return null;
|
|
41140
|
+
if (!node.computed && node.property.type === "Identifier")
|
|
41141
|
+
return node.property.name;
|
|
41142
|
+
return node.property.type === "StringLiteral" ? node.property.value : null;
|
|
41143
|
+
}
|
|
41137
41144
|
function memberSegment(member) {
|
|
41138
41145
|
const property = member.property;
|
|
41139
41146
|
if (!member.computed) {
|
|
@@ -42000,6 +42007,49 @@ function collectStringLeaves(value, out) {
|
|
|
42000
42007
|
collectStringLeaves(item, out);
|
|
42001
42008
|
}
|
|
42002
42009
|
|
|
42010
|
+
// ../utils/src/paste.ts
|
|
42011
|
+
var PASTE_LIMITS = {
|
|
42012
|
+
DEFAULT_BYTES: 32 * 1024 * 1024,
|
|
42013
|
+
RICH_MARKDOWN_BYTES: 5 * 1024 * 1024,
|
|
42014
|
+
TEXT_EDITOR_BYTES: 50 * 1024 * 1024,
|
|
42015
|
+
CHAT_CHARACTERS: 1e6,
|
|
42016
|
+
CHAT_BYTES: 4000000,
|
|
42017
|
+
TERMINAL_BYTES: 8 * 1024 * 1024,
|
|
42018
|
+
STRUCTURED_BYTES: 32 * 1024 * 1024
|
|
42019
|
+
};
|
|
42020
|
+
var PASTE_RENDER_THRESHOLDS = {
|
|
42021
|
+
ENHANCED_TEXT_CHARACTERS: 256 * 1024
|
|
42022
|
+
};
|
|
42023
|
+
function utf8ByteLengthRange(value, start = 0, end = value.length, stopAfter = Number.POSITIVE_INFINITY) {
|
|
42024
|
+
let bytes = 0;
|
|
42025
|
+
const safeStart = Math.min(Math.max(start, 0), value.length);
|
|
42026
|
+
const safeEnd = Math.min(Math.max(end, safeStart), value.length);
|
|
42027
|
+
for (let index = safeStart;index < safeEnd; index++) {
|
|
42028
|
+
const code = value.charCodeAt(index);
|
|
42029
|
+
if (code <= 127) {
|
|
42030
|
+
bytes += 1;
|
|
42031
|
+
} else if (code <= 2047) {
|
|
42032
|
+
bytes += 2;
|
|
42033
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
42034
|
+
const next = value.charCodeAt(index + 1);
|
|
42035
|
+
if (index + 1 < safeEnd && next >= 56320 && next <= 57343) {
|
|
42036
|
+
bytes += 4;
|
|
42037
|
+
index += 1;
|
|
42038
|
+
} else {
|
|
42039
|
+
bytes += 3;
|
|
42040
|
+
}
|
|
42041
|
+
} else {
|
|
42042
|
+
bytes += 3;
|
|
42043
|
+
}
|
|
42044
|
+
if (bytes > stopAfter)
|
|
42045
|
+
return bytes;
|
|
42046
|
+
}
|
|
42047
|
+
return bytes;
|
|
42048
|
+
}
|
|
42049
|
+
function utf8ByteLength(value, stopAfter = Number.POSITIVE_INFINITY) {
|
|
42050
|
+
return utf8ByteLengthRange(value, 0, value.length, stopAfter);
|
|
42051
|
+
}
|
|
42052
|
+
|
|
42003
42053
|
// ../workflow-code/src/limits.ts
|
|
42004
42054
|
var SOURCE_LIMITS = {
|
|
42005
42055
|
maxBlocks: 2000,
|
|
@@ -42023,25 +42073,6 @@ var CODE_FILE_PATH = new RegExp(`^${SOURCE_CODE_DIR}/[A-Za-z0-9_$-][A-Za-z0-9_.$
|
|
|
42023
42073
|
function isCodeFilePath(path) {
|
|
42024
42074
|
return CODE_FILE_PATH.test(path);
|
|
42025
42075
|
}
|
|
42026
|
-
function isLowSurrogate(code) {
|
|
42027
|
-
return code >= 56320 && code <= 57343;
|
|
42028
|
-
}
|
|
42029
|
-
function utf8Bytes(text, cap = Number.POSITIVE_INFINITY) {
|
|
42030
|
-
let bytes = 0;
|
|
42031
|
-
for (let i = 0;i < text.length && bytes <= cap; i++) {
|
|
42032
|
-
const code = text.charCodeAt(i);
|
|
42033
|
-
if (code < 128)
|
|
42034
|
-
bytes += 1;
|
|
42035
|
-
else if (code < 2048)
|
|
42036
|
-
bytes += 2;
|
|
42037
|
-
else if (code >= 55296 && code <= 56319 && isLowSurrogate(text.charCodeAt(i + 1))) {
|
|
42038
|
-
bytes += 4;
|
|
42039
|
-
i++;
|
|
42040
|
-
} else
|
|
42041
|
-
bytes += 3;
|
|
42042
|
-
}
|
|
42043
|
-
return bytes;
|
|
42044
|
-
}
|
|
42045
42076
|
|
|
42046
42077
|
// ../workflow-code/src/code-files/lexer.ts
|
|
42047
42078
|
var REGEX_ALLOWED_AFTER = new Set("(,=:[!&|?{};+-*%^~<>/".split(""));
|
|
@@ -43968,6 +43999,7 @@ function positionalTitle(kind, index, count) {
|
|
|
43968
43999
|
var PARALLEL_BATCH_MIN = 1;
|
|
43969
44000
|
var PARALLEL_BATCH_MAX = 20;
|
|
43970
44001
|
var DEFAULT_LOOP_ITERATIONS = 5;
|
|
44002
|
+
var DEFAULT_PARALLEL_COUNT = 5;
|
|
43971
44003
|
function effectiveBatchSize(batchSize) {
|
|
43972
44004
|
if (batchSize === undefined || Number.isNaN(batchSize))
|
|
43973
44005
|
return PARALLEL_BATCH_MAX;
|
|
@@ -44451,14 +44483,6 @@ function compileMemberSegment(ctx, member, site) {
|
|
|
44451
44483
|
}
|
|
44452
44484
|
return unsupported(ctx, member, "Element access needs a literal key.", HINTS.elementAccess, site.decl.key);
|
|
44453
44485
|
}
|
|
44454
|
-
function memberName(member) {
|
|
44455
|
-
const property = member.property;
|
|
44456
|
-
if (!member.computed && property.type === "Identifier")
|
|
44457
|
-
return property.name;
|
|
44458
|
-
if (member.computed && property.type === "StringLiteral")
|
|
44459
|
-
return property.value;
|
|
44460
|
-
return null;
|
|
44461
|
-
}
|
|
44462
44486
|
function outputKnown(outputs, segments) {
|
|
44463
44487
|
let level = outputs;
|
|
44464
44488
|
for (const segment of segments) {
|
|
@@ -45260,7 +45284,6 @@ function compileResponseParam(ctx, site, params, key, property) {
|
|
|
45260
45284
|
}
|
|
45261
45285
|
|
|
45262
45286
|
// ../workflow-code/src/forms/subflow.ts
|
|
45263
|
-
var DEFAULT_PARALLEL_COUNT = 5;
|
|
45264
45287
|
var LOOP_COUNT = {
|
|
45265
45288
|
field: "iterations",
|
|
45266
45289
|
kind: "number",
|
|
@@ -45434,6 +45457,9 @@ function quoteString(text) {
|
|
|
45434
45457
|
function printKey(key) {
|
|
45435
45458
|
return isIdentifierName(key) ? key : quoteString(key);
|
|
45436
45459
|
}
|
|
45460
|
+
function printNumber(value) {
|
|
45461
|
+
return String(value).replace("e+", "e");
|
|
45462
|
+
}
|
|
45437
45463
|
|
|
45438
45464
|
// ../workflow-code/src/print/doc.ts
|
|
45439
45465
|
var line = { type: "line", soft: false, hard: false, literal: false };
|
|
@@ -46123,7 +46149,7 @@ function sdkHeader(text) {
|
|
|
46123
46149
|
}
|
|
46124
46150
|
function parseWorkflowSource(file, text, limits, reporter) {
|
|
46125
46151
|
const parsed = { ast: null, ...sdkHeader(text) };
|
|
46126
|
-
if (
|
|
46152
|
+
if (utf8ByteLength(text, limits.maxTotalBytes) > limits.maxTotalBytes) {
|
|
46127
46153
|
reporter.report("E_LIMIT_EXCEEDED", `The file is larger than ${limits.maxTotalBytes} bytes, the limit for all source files together.`, { file, start: 0, end: 0 }, { hint: "Split the workflow, moving parts into child workflows." });
|
|
46128
46154
|
return parsed;
|
|
46129
46155
|
}
|
|
@@ -47053,7 +47079,7 @@ function readCodeFile(ctx, compiled, language, decl) {
|
|
|
47053
47079
|
function parseCodeFile(ctx, path, text, language, at, decl) {
|
|
47054
47080
|
const { limits } = ctx;
|
|
47055
47081
|
const before = ctx.codeFiles.bytes;
|
|
47056
|
-
ctx.codeFiles.bytes +=
|
|
47082
|
+
ctx.codeFiles.bytes += utf8ByteLength(text, limits.maxTotalBytes);
|
|
47057
47083
|
if (ctx.codeFiles.bytes > limits.maxTotalBytes) {
|
|
47058
47084
|
if (before > limits.maxTotalBytes)
|
|
47059
47085
|
return null;
|
|
@@ -47944,9 +47970,7 @@ function checkLoopCondition(ctx, decl, text, property) {
|
|
|
47944
47970
|
}
|
|
47945
47971
|
if (failure === null)
|
|
47946
47972
|
return;
|
|
47947
|
-
|
|
47948
|
-
const message = typeof raw === "string" ? raw : "Invalid JavaScript";
|
|
47949
|
-
ctx.reporter.report("W_LOOP_CONDITION_SYNTAX", `${decl.name}'s condition is not a JavaScript expression (${message.replace(/\s*\(\d+:\d+\)$/, "")}), so the run fails when it evaluates it.`, at, {
|
|
47973
|
+
ctx.reporter.report("W_LOOP_CONDITION_SYNTAX", `${decl.name}'s condition is not a JavaScript expression (${babelMessage(babelErrorShape(failure))}), so the run fails when it evaluates it.`, at, {
|
|
47950
47974
|
hint: "Write one JavaScript expression the loop repeats while it is true, e.g. condition: '<loop.index> < 3'.",
|
|
47951
47975
|
blockKey: decl.key
|
|
47952
47976
|
});
|
|
@@ -48795,13 +48819,6 @@ function merge2(a, b) {
|
|
|
48795
48819
|
return a;
|
|
48796
48820
|
return a !== "string" && b !== "string" ? "typed" : undefined;
|
|
48797
48821
|
}
|
|
48798
|
-
function memberName2(node) {
|
|
48799
|
-
if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression")
|
|
48800
|
-
return null;
|
|
48801
|
-
if (!node.computed && node.property.type === "Identifier")
|
|
48802
|
-
return node.property.name;
|
|
48803
|
-
return node.property.type === "StringLiteral" ? node.property.value : null;
|
|
48804
|
-
}
|
|
48805
48822
|
|
|
48806
48823
|
class Inference {
|
|
48807
48824
|
bindings;
|
|
@@ -48847,7 +48864,7 @@ class Inference {
|
|
|
48847
48864
|
return "number";
|
|
48848
48865
|
case "MemberExpression":
|
|
48849
48866
|
case "OptionalMemberExpression":
|
|
48850
|
-
return
|
|
48867
|
+
return memberName(node) === "length" && (this.kind(node.object) === "string" || this.isArray(node.object)) ? "number" : undefined;
|
|
48851
48868
|
case "CallExpression":
|
|
48852
48869
|
case "OptionalCallExpression":
|
|
48853
48870
|
return this.call(node.callee);
|
|
@@ -48879,7 +48896,7 @@ class Inference {
|
|
|
48879
48896
|
return "boolean";
|
|
48880
48897
|
return;
|
|
48881
48898
|
}
|
|
48882
|
-
const method =
|
|
48899
|
+
const method = memberName(callee);
|
|
48883
48900
|
if (method === null || !("object" in callee))
|
|
48884
48901
|
return;
|
|
48885
48902
|
if (callee.object.type === "Identifier") {
|
|
@@ -48903,7 +48920,7 @@ class Inference {
|
|
|
48903
48920
|
if (node.type === "ArrayExpression")
|
|
48904
48921
|
return true;
|
|
48905
48922
|
if (node.type === "CallExpression" || node.type === "OptionalCallExpression") {
|
|
48906
|
-
const method =
|
|
48923
|
+
const method = memberName(node.callee);
|
|
48907
48924
|
if (method === null || !("object" in node.callee))
|
|
48908
48925
|
return false;
|
|
48909
48926
|
if (node.callee.object.type === "Identifier" && node.callee.object.name === "Object") {
|
|
@@ -49283,16 +49300,9 @@ var CODE_FILE_REFUSALS = new Map([
|
|
|
49283
49300
|
["W_UNKNOWN_OUTPUT_PATH", "E_APPLY_UNRESOLVED_REF"],
|
|
49284
49301
|
["W_CODE_FILE_REF_SYNTAX", "E_APPLY_CODE_FILE_REF_SYNTAX"]
|
|
49285
49302
|
]);
|
|
49286
|
-
var REFUSABLE_WARNING_CODES = new Set([
|
|
49287
|
-
|
|
49288
|
-
|
|
49289
|
-
"W_LOOP_CONDITION_SYNTAX",
|
|
49290
|
-
"W_UNKNOWN_OUTPUT_PATH",
|
|
49291
|
-
"W_UNRESOLVED_REF",
|
|
49292
|
-
"W_CODE_FILE_REF_SYNTAX",
|
|
49293
|
-
"W_UNKNOWN_BLOCK_TYPE",
|
|
49294
|
-
"W_TYPE_NOT_ADDABLE"
|
|
49295
|
-
]);
|
|
49303
|
+
var REFUSABLE_WARNING_CODES = new Set([CHANGED_BLOCK_REFUSALS, PARAM_REFUSALS, ENTRY_REFUSALS, CODE_FILE_REFUSALS].flatMap((rules) => [
|
|
49304
|
+
...rules.keys()
|
|
49305
|
+
]));
|
|
49296
49306
|
var EDIT_REFUSALS = [
|
|
49297
49307
|
...[...CHANGED_BLOCK_REFUSALS].map(([warning, refusal]) => ({
|
|
49298
49308
|
warning,
|
|
@@ -50221,7 +50231,7 @@ function compileWorkflow(input) {
|
|
|
50221
50231
|
}
|
|
50222
50232
|
function compileEntry(input, file, text, reporter) {
|
|
50223
50233
|
const limits = { ...DEFAULT_LIMITS, ...input.limits };
|
|
50224
|
-
if (
|
|
50234
|
+
if (utf8ByteLength(text, limits.maxTotalBytes) <= limits.maxTotalBytes)
|
|
50225
50235
|
checkStorableText(file, text, reporter);
|
|
50226
50236
|
const parsed = parseWorkflowSource(file, text, limits, reporter);
|
|
50227
50237
|
if (parsed.sdkMajor === null) {
|
|
@@ -50246,7 +50256,13 @@ function compileEntry(input, file, text, reporter) {
|
|
|
50246
50256
|
catalog: input.catalog,
|
|
50247
50257
|
files: input.files,
|
|
50248
50258
|
limits,
|
|
50249
|
-
codeFiles: {
|
|
50259
|
+
codeFiles: {
|
|
50260
|
+
reads: new Map,
|
|
50261
|
+
refs: 0,
|
|
50262
|
+
bytes: utf8ByteLength(text),
|
|
50263
|
+
chains: [],
|
|
50264
|
+
sharedReads: []
|
|
50265
|
+
},
|
|
50250
50266
|
comments: new CommentCollector(file, reporter),
|
|
50251
50267
|
decls: [],
|
|
50252
50268
|
declsByKey: new Map,
|
|
@@ -51854,7 +51870,7 @@ function builderTypes(catalog, entry) {
|
|
|
51854
51870
|
};
|
|
51855
51871
|
}
|
|
51856
51872
|
function stripComments(text) {
|
|
51857
|
-
return text.replace(/\/\*\*[\s\S]*?\*\//g, "").replace(
|
|
51873
|
+
return text.replace(/\/\*\*[\s\S]*?\*\//g, "").replace(/^[ \t]*\/\/.*$/gm, "");
|
|
51858
51874
|
}
|
|
51859
51875
|
function coreImports(text) {
|
|
51860
51876
|
const code = stripComments(text);
|
|
@@ -54155,7 +54171,7 @@ async function withSourceCommandLock(dir, run, options = {}) {
|
|
|
54155
54171
|
var import_parser5 = __toESM(require_lib(), 1);
|
|
54156
54172
|
var CODE_FILE_EXPORT = "codeFile";
|
|
54157
54173
|
function codeFileReferences(text) {
|
|
54158
|
-
if (
|
|
54174
|
+
if (utf8ByteLength(text, SOURCE_LIMITS.maxTotalBytes) > SOURCE_LIMITS.maxTotalBytes)
|
|
54159
54175
|
return [];
|
|
54160
54176
|
if (bracketDepthOverflow(text, SOURCE_LIMITS.maxDepth) !== -1)
|
|
54161
54177
|
return [];
|
|
@@ -54714,9 +54730,6 @@ async function printRunFailureSite(dir, workflowId, error) {
|
|
|
54714
54730
|
// src/commands/protocol/workflow-run-get.ts
|
|
54715
54731
|
var BLOCK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
54716
54732
|
var SELECT_OUTPUT_FLAG = "select-output";
|
|
54717
|
-
function normalizeBlockName(name) {
|
|
54718
|
-
return name.toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
|
54719
|
-
}
|
|
54720
54733
|
async function loadWorkflowBlocks(client, workflowId) {
|
|
54721
54734
|
const raw = await client.request("getWorkflowState", { params: { workflowId } });
|
|
54722
54735
|
const state = isRecordLike(raw) && isRecordLike(raw.data) ? raw.data : raw;
|
|
@@ -54741,8 +54754,8 @@ function resolveSelection(typed, blocks, workflowId) {
|
|
|
54741
54754
|
const { head, path } = splitSelector(selector);
|
|
54742
54755
|
let blockId = head;
|
|
54743
54756
|
if (!BLOCK_ID.test(head)) {
|
|
54744
|
-
const wanted =
|
|
54745
|
-
const matches = blocks.filter((block) => block.id === head ||
|
|
54757
|
+
const wanted = normalizeWorkflowBlockName(head);
|
|
54758
|
+
const matches = blocks.filter((block) => block.id === head || normalizeWorkflowBlockName(block.name) === wanted);
|
|
54746
54759
|
if (matches.length === 0) {
|
|
54747
54760
|
unresolved.push(selector);
|
|
54748
54761
|
continue;
|
|
@@ -55256,7 +55269,7 @@ function stopBlockSelection(selection, flags) {
|
|
|
55256
55269
|
return null;
|
|
55257
55270
|
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0)
|
|
55258
55271
|
return null;
|
|
55259
|
-
return [BLOCK_ID.test(stopAfter) ? stopAfter :
|
|
55272
|
+
return [BLOCK_ID.test(stopAfter) ? stopAfter : normalizeWorkflowBlockName(stopAfter)];
|
|
55260
55273
|
}
|
|
55261
55274
|
function followOrDelegate(previous) {
|
|
55262
55275
|
return async (workflowId, _options, command) => {
|
|
@@ -57564,6 +57577,25 @@ function removedWorkflowRecords(paths) {
|
|
|
57564
57577
|
return [...paths].flatMap((path) => path.startsWith(`${KIND_DIRS.workflow}/`) && path.endsWith(`/${SOURCE_BASE_FILE}`) ? [`${path.slice(0, -SOURCE_BASE_FILE.length)}${SOURCE_STORED_EDGES_FILE}`] : []);
|
|
57565
57578
|
}
|
|
57566
57579
|
|
|
57580
|
+
// src/commands/protocol/source-strict.ts
|
|
57581
|
+
var STRICT_FINDINGS = new Map([
|
|
57582
|
+
["W_REQUIRED_MISSING", "a missing required field"],
|
|
57583
|
+
["W_UNKNOWN_OPTION", "an unknown option"],
|
|
57584
|
+
["W_UNKNOWN_OUTPUT_PATH", "an unknown output path"],
|
|
57585
|
+
["W_VALUE_KIND", "a wrong value kind"],
|
|
57586
|
+
["W_OUT_OF_RANGE", "an out-of-range value"],
|
|
57587
|
+
["W_LITERAL_SECRET", "a literal secret"],
|
|
57588
|
+
["W_TABLE_UNKNOWN_COLUMN", "a table write to an unknown column"],
|
|
57589
|
+
["W_CHILD_INPUT_UNKNOWN", "an input a child workflow does not declare"],
|
|
57590
|
+
["W_CHILD_RESULT_PATH", "a path a child workflow's result does not hold"],
|
|
57591
|
+
["W_BRANCH_UNWIRED", "an unwired condition or router branch"],
|
|
57592
|
+
["W_UNRESOLVED_REF", "a reference that names nothing"],
|
|
57593
|
+
["W_REF_OUT_OF_SCOPE", "an iteration field read outside its loop or parallel"],
|
|
57594
|
+
["W_LOOP_CONDITION_SYNTAX", "a loop condition that is not a JavaScript expression"]
|
|
57595
|
+
]);
|
|
57596
|
+
var phrases = [...STRICT_FINDINGS.values()];
|
|
57597
|
+
var STRICT_FINDINGS_CLAUSE = `${phrases.slice(0, -1).join(", ")} or ${phrases.at(-1)}`;
|
|
57598
|
+
|
|
57567
57599
|
// src/commands/protocol/workflow-dir.ts
|
|
57568
57600
|
var CODE_FILE_EXTENSION = new RegExp(`\\.(?:${Object.values(CODE_FILE_EXTENSIONS).join("|")})$`);
|
|
57569
57601
|
async function requireText(directory, path, hint) {
|
|
@@ -57654,7 +57686,7 @@ The primer above is enough to edit; read a section here when a step needs it.
|
|
|
57654
57686
|
## Edit loop in detail
|
|
57655
57687
|
|
|
57656
57688
|
1. Edit \`${SOURCE_ENTRY_FILE}\` (and \`functions/*\`). \`${SOURCE_EXAMPLES_DIR}/\` holds correct examples to copy from: \`cookbook.ts\` (agent with structured output, condition, function, table query and upsert, knowledge search, Slack, human in the loop, loop, response), \`integrations.ts\` (webhook trigger, weekday cron schedule, HTTP request with headers, table update by row id, Gmail, an error path) and \`agents.ts\` (router, agent tools: custom tool, MCP tool, integration operation, child workflow; run a child workflow; parallel). Their resource keys are examples; this workspace's are in \`${WORKSPACE_TYPES_FILE}\`.
|
|
57657
|
-
2. \`sim workflows source check --dir .\`: compiles offline with the server's compiler, in milliseconds. It catches what \`tsc\` cannot (duplicate names, cycles, literal secrets), and fails (exit 1) on
|
|
57689
|
+
2. \`sim workflows source check --dir .\`: compiles offline with the server's compiler, in milliseconds. It catches what \`tsc\` cannot (duplicate names, cycles, literal secrets), and fails (exit 1) on ${STRICT_FINDINGS_CLAUSE} in a block you added (\`--strict\`: in every block). It also adds the blocks the source now uses to \`tsconfig.json\`.
|
|
57658
57690
|
3. \`${typecheckCommand()}\`: about a second; catches what step 2 and the dry run do not (such as a reference to a start input the trigger does not declare). It runs the TypeScript release the declarations are built for (the directory has no \`package.json\`; plain \`bunx tsc\` would run whatever version it finds). \`tsconfig.json\` includes only the blocks the source used at the last check, get or apply: a builder from another block fails with \`has no exported member\` until you run step 2 (or use \`${typecheckCommand(TSCONFIG_FULL_FILE)}\`, every current block). The dry run is the authority: a printed line you did not edit that \`tsc\` flags and the dry run accepts is fine.
|
|
57659
57691
|
4. \`sim workflows source status --dir .\`: the files you changed (\`sim workflows source diff --dir .\` shows the edits), whether the workflow changed on the server since the get, and the command to run next (\`--offline\`: skip the server). Then \`sim workflows source apply --dir . --dry-run\` until it exits 0.
|
|
57660
57692
|
5. \`sim workflows source apply --dir . --yes\`: saves the draft, refusing errors, block deletions without \`--allow-delete\` and a stale directory, so it needs no separate dry run (without \`--yes\` and a terminal it prints the plan and exits ${SOURCE_PLANNED_EXIT_CODE}). \`--deploy\` also deploys it; without it, a deployed workflow's next \`sim workflows deploy <id> --expected-draft-fingerprint <fingerprint>\` is printed, which deploys only the draft this apply saved. It then rewrites \`${SOURCE_ENTRY_FILE}\` in canonical form (order, quoting, defaults left out).
|
|
@@ -57687,7 +57719,7 @@ The \`// @sim-sdk 1\` header must be the first line, and the file has exactly on
|
|
|
57687
57719
|
- \`sim workflows source params <builder>\`: one builder's params (required first, enums, defaults) and outputs; a namespace (\`gmail\`) lists its builders; a miss names the closest. Builders are named for the service, not the block type: \`gmail_v2\` is \`gmail.*\`, \`workflow_input\` is \`runWorkflow\`, the HTTP request block is \`api\`, and \`legacy.*\` builders are old versions not to write.
|
|
57688
57720
|
- \`${SOURCE_SDK_DIR}/core.d.ts\`: the SDK (\`workflow\`, \`t\`, \`env\`, \`credential\`, \`table\`, \`loop\`, \`parallel\`, \`BlockMeta\`).
|
|
57689
57721
|
- \`${SOURCE_SDK_DIR}/blocks/<block type>.d.ts\`: the builders of a block the source uses, with their params and outputs (check adds the file of a block an edit starts using). Do not read them, or \`${SOURCE_SDK_DIR}/models.d.ts\`, whole: \`params\` prints the part you need, and \`grep\` finds a model id.
|
|
57690
|
-
- \`${WORKSPACE_TYPES_FILE}\`: this workspace's tables, knowledge bases, credentials, workflows and env names.
|
|
57722
|
+
- \`${WORKSPACE_TYPES_FILE}\`: this workspace's tables, knowledge bases, credentials, workflows, skills, custom tools, MCP servers and env names.
|
|
57691
57723
|
|
|
57692
57724
|
## Rules
|
|
57693
57725
|
|
|
@@ -58230,7 +58262,7 @@ function readDeclaration(file, raw, options) {
|
|
|
58230
58262
|
const at = (start, end) => locator.located(locator.span(start, end));
|
|
58231
58263
|
const nodeAt = (node) => at(node.start ?? 0, node.end ?? node.start ?? 0);
|
|
58232
58264
|
const fail = () => ({ spans, diagnostics });
|
|
58233
|
-
const bytes =
|
|
58265
|
+
const bytes = utf8ByteLength(text, WORKSPACE_SOURCE_LIMITS.maxDeclarationBytes);
|
|
58234
58266
|
if (bytes > WORKSPACE_SOURCE_LIMITS.maxDeclarationBytes) {
|
|
58235
58267
|
diagnostics.push(diagnostic2("E_LIMIT_EXCEEDED", `The file is larger than ${WORKSPACE_SOURCE_LIMITS.maxDeclarationBytes} bytes.`, { ...at(0, 0) }));
|
|
58236
58268
|
return fail();
|
|
@@ -58614,9 +58646,6 @@ function objectField(fields, canonical) {
|
|
|
58614
58646
|
|
|
58615
58647
|
// ../workspace-code/src/declaration/print.ts
|
|
58616
58648
|
var INLINE_WIDTH = 80;
|
|
58617
|
-
function printNumber(value) {
|
|
58618
|
-
return String(value).replace("e+", "e");
|
|
58619
|
-
}
|
|
58620
58649
|
function call(name, ...args) {
|
|
58621
58650
|
return { [CALL_KEY]: name, args };
|
|
58622
58651
|
}
|
|
@@ -59096,7 +59125,7 @@ function filePathProblem(key) {
|
|
|
59096
59125
|
return `"${segment}" ends with a space or a dot`;
|
|
59097
59126
|
if (RESERVED_NAME.test(segment))
|
|
59098
59127
|
return `"${segment}" is a reserved device name`;
|
|
59099
|
-
if (
|
|
59128
|
+
if (utf8ByteLength(segment) > MAX_SEGMENT_BYTES) {
|
|
59100
59129
|
return `"${segment.slice(0, 32)}…" is over ${MAX_SEGMENT_BYTES} bytes`;
|
|
59101
59130
|
}
|
|
59102
59131
|
}
|
|
@@ -64264,7 +64293,7 @@ Secrets never appear in source: a workflow reads an environment variable as \`en
|
|
|
64264
64293
|
## Edit loop in detail
|
|
64265
64294
|
|
|
64266
64295
|
1. Edit the files.
|
|
64267
|
-
2. \`sim workspaces source check --dir .\`: compiles every workflow offline with the server's compiler, against what this directory declares: an unknown resource key (skills included) or table column, a child workflow's inputs, and an env name \`${KIND_DIRS.secret}\` lacks (a warning); and checks each \`${KIND_DIRS.table}/<key>.rows.jsonl\` line against its table as the apply would. It fails (exit 1) on errors and on
|
|
64296
|
+
2. \`sim workspaces source check --dir .\`: compiles every workflow offline with the server's compiler, against what this directory declares: an unknown resource key (skills included) or table column, a child workflow's inputs, and an env name \`${KIND_DIRS.secret}\` lacks (a warning); and checks each \`${KIND_DIRS.table}/<key>.rows.jsonl\` line against its table as the apply would. It fails (exit 1) on errors and on ${STRICT_FINDINGS_CLAUSE} in a block you added (\`--strict\`: in every block), regenerates \`.sim/sdk/workspace.d.ts\` and adds the blocks the workflows now use to \`tsconfig.json\`. In a workflow folder, \`sim workflows source check --dir .\` checks that one workflow the same way. Fix and rerun until it exits 0.
|
|
64268
64297
|
3. Run \`${typecheckCommand()}\` after every edit, before any dry run or apply, and fix what it reports: it takes about a second and catches what step 2 and the dry run do not (such as a reference to a start input the trigger does not declare). It type-checks the files with the TypeScript release the declarations are built for. \`tsconfig.json\` includes only the blocks the workflows used at the last check or get, which keeps it fast: a builder from another block fails with \`has no exported member\` until you run step 2 (or check with \`${typecheckCommand(TSCONFIG_FULL_FILE)}\`, every current block). \`sim workflows source params <builder>\` prints one builder's params and outputs; do not read the declarations whole. The dry run is the authority: a printed file you did not edit that \`tsc\` flags and the dry run accepts is fine, so leave it as it is.
|
|
64269
64298
|
4. \`sim workspaces source status --dir .\` before applying: your changes by resource (\`sim workspaces source diff --dir .\` shows the edits), what changed on the server since the get (a workflow edited in the editor included), the conflicts, and the command to run next. Exit 0 nothing changed, ${SOURCE_LOCAL_CHANGES_EXIT_CODE} only your edits, ${SOURCE_DRIFT_EXIT_CODE} the server changed since (\`--offline\`: skip the server). Then \`sim workspaces source apply --dir . --dry-run\`: shows the plan (\`+\` create, \`~\` update, \`=\` adopt an existing resource of the same name, \`-\` delete) and every error; fix and rerun until it exits 0.
|
|
64270
64299
|
5. \`sim workspaces source apply --dir . --yes\`: writes it and rewrites this directory from what was stored; it prints the plan it applied (without \`--yes\` and a terminal it prints the plan and exits ${SOURCE_PLANNED_EXIT_CODE}, writing nothing).
|
|
@@ -64434,12 +64463,22 @@ function tableRowFindings(key, decl, text) {
|
|
|
64434
64463
|
}));
|
|
64435
64464
|
return [...read, ...refused];
|
|
64436
64465
|
}
|
|
64437
|
-
|
|
64466
|
+
function* columnCalls(source) {
|
|
64467
|
+
const head = /\bcolumn\.(\w+)\s*\(/g;
|
|
64468
|
+
for (let match = head.exec(source);match !== null; match = head.exec(source)) {
|
|
64469
|
+
const open = match.index + match[0].length;
|
|
64470
|
+
const close = source.indexOf(")", open);
|
|
64471
|
+
if (close === -1)
|
|
64472
|
+
return;
|
|
64473
|
+
yield [match[1], source.slice(open, close)];
|
|
64474
|
+
head.lastIndex = close + 1;
|
|
64475
|
+
}
|
|
64476
|
+
}
|
|
64438
64477
|
function declaredTable(key, paths, files) {
|
|
64439
64478
|
const text = Object.fromEntries(paths.map((path) => [path, files[path] ?? ""]));
|
|
64440
64479
|
const owned = new Map;
|
|
64441
64480
|
for (const source of Object.values(text)) {
|
|
64442
|
-
for (const [
|
|
64481
|
+
for (const [type, args] of columnCalls(source)) {
|
|
64443
64482
|
const owns = owned.get(type) ?? new Set;
|
|
64444
64483
|
for (const option of TABLE_COLUMN_METADATA_KEYS) {
|
|
64445
64484
|
if (new RegExp(`\\b${option}\\s*:`).test(args))
|
|
@@ -64663,21 +64702,7 @@ function parseKinds(value) {
|
|
|
64663
64702
|
|
|
64664
64703
|
// src/commands/protocol/source-check.ts
|
|
64665
64704
|
var SERVER_ONLY_CODES = new Set(["E_STORED_VALUE_MISSING"]);
|
|
64666
|
-
var STRICT_CODES = new Set(
|
|
64667
|
-
"W_REQUIRED_MISSING",
|
|
64668
|
-
"W_UNKNOWN_OPTION",
|
|
64669
|
-
"W_UNKNOWN_OUTPUT_PATH",
|
|
64670
|
-
"W_VALUE_KIND",
|
|
64671
|
-
"W_OUT_OF_RANGE",
|
|
64672
|
-
"W_LITERAL_SECRET",
|
|
64673
|
-
"W_TABLE_UNKNOWN_COLUMN",
|
|
64674
|
-
"W_CHILD_INPUT_UNKNOWN",
|
|
64675
|
-
"W_CHILD_RESULT_PATH",
|
|
64676
|
-
"W_BRANCH_UNWIRED",
|
|
64677
|
-
"W_UNRESOLVED_REF",
|
|
64678
|
-
"W_REF_OUT_OF_SCOPE",
|
|
64679
|
-
"W_LOOP_CONDITION_SYNTAX"
|
|
64680
|
-
]);
|
|
64705
|
+
var STRICT_CODES = new Set(STRICT_FINDINGS.keys());
|
|
64681
64706
|
var STORED_EXEMPT_CODES = new Set(["W_BRANCH_UNWIRED"]);
|
|
64682
64707
|
var EDIT_SCOPED_CODES = new Set(["W_JSON_REF_UNTYPED"]);
|
|
64683
64708
|
function strictMode(options) {
|
|
@@ -65415,10 +65440,19 @@ function serverResourceChanges(diagnostics) {
|
|
|
65415
65440
|
return [...changes.values()].sort((a, b) => compareStrings(a.kind, b.kind) || compareStrings(a.key, b.key));
|
|
65416
65441
|
}
|
|
65417
65442
|
function sourceStatus(local, server) {
|
|
65443
|
+
const firstOfResource = new Map;
|
|
65444
|
+
const firstOfKind = new Map;
|
|
65445
|
+
for (const entry of local) {
|
|
65446
|
+
const address = `${entry.kind}:${entry.key}`;
|
|
65447
|
+
if (!firstOfResource.has(address))
|
|
65448
|
+
firstOfResource.set(address, entry);
|
|
65449
|
+
if (!firstOfKind.has(entry.kind))
|
|
65450
|
+
firstOfKind.set(entry.kind, entry);
|
|
65451
|
+
}
|
|
65418
65452
|
const conflicts = [];
|
|
65419
65453
|
const drift = [];
|
|
65420
65454
|
for (const change of server) {
|
|
65421
|
-
const mine =
|
|
65455
|
+
const mine = isFileKind(change.kind) ? firstOfKind.get(change.kind) : firstOfResource.get(`${change.kind}:${change.key}`);
|
|
65422
65456
|
if (mine)
|
|
65423
65457
|
conflicts.push({ ...change, change: mine.change });
|
|
65424
65458
|
else
|
|
@@ -66118,10 +66152,13 @@ function realPath(path) {
|
|
|
66118
66152
|
return parent === path ? path : join10(realPath(parent), basename4(path));
|
|
66119
66153
|
}
|
|
66120
66154
|
}
|
|
66155
|
+
function givenFilterPath(filter) {
|
|
66156
|
+
return stripTrailingSlashes(filter.replace(/\\/g, "/").replace(/^(\.\/)+/, ""));
|
|
66157
|
+
}
|
|
66121
66158
|
function filterForms(filter, dir) {
|
|
66122
66159
|
const forms = new Set;
|
|
66123
66160
|
if (!isAbsolute3(filter)) {
|
|
66124
|
-
const given =
|
|
66161
|
+
const given = givenFilterPath(filter);
|
|
66125
66162
|
forms.add(given === "" ? "." : given);
|
|
66126
66163
|
}
|
|
66127
66164
|
const resolved = relative2(realPath(resolve6(dir)), realPath(resolve6(filter))).split(sep).join("/");
|
|
@@ -67597,7 +67634,7 @@ function planLine2(plan) {
|
|
|
67597
67634
|
function fitsWhole(files) {
|
|
67598
67635
|
const paths = Object.keys(files).filter((path) => kindOfPath(path) === "workflow");
|
|
67599
67636
|
const folders = KIND_LAYOUTS.workflow.group(paths).groups.size;
|
|
67600
|
-
const bytes = paths.reduce((sum, path) => sum +
|
|
67637
|
+
const bytes = paths.reduce((sum, path) => sum + utf8ByteLength(files[path]), 0);
|
|
67601
67638
|
return folders <= WORKSPACE_SOURCE_LIMITS.maxWorkflows && bytes <= WORKSPACE_SOURCE_LIMITS.maxWorkflowBytes;
|
|
67602
67639
|
}
|
|
67603
67640
|
function unmanagedNext(status, managed, dir, workspaceScope) {
|
|
@@ -67719,7 +67756,7 @@ function filteredKinds(filters) {
|
|
|
67719
67756
|
const kinds = new Set;
|
|
67720
67757
|
for (const filter of filters) {
|
|
67721
67758
|
const named = filter.split(":", 1)[0];
|
|
67722
|
-
const kind = isWorkspaceKind(named) ? named : kindOfPath(filter
|
|
67759
|
+
const kind = isWorkspaceKind(named) ? named : kindOfPath(givenFilterPath(filter));
|
|
67723
67760
|
if (kind === null)
|
|
67724
67761
|
return;
|
|
67725
67762
|
kinds.add(kind);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sim",
|
|
3
|
-
"version": "2.3.0
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Sim CLI - talk to the Sim API from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@sim/utils": "0.1.0",
|
|
62
62
|
"@sim/workflow-code": "0.1.0",
|
|
63
63
|
"@sim/workflow-sdk": "0.1.0",
|
|
64
|
+
"@sim/workflow-types": "0.1.0",
|
|
64
65
|
"@sim/workspace-code": "0.1.0",
|
|
65
66
|
"@types/js-yaml": "4.0.9",
|
|
66
67
|
"@types/node": "24.19.2",
|