sim 2.2.33-preview.322.1 → 2.3.0-preview.324.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/THIRD_PARTY_LICENSES +9 -0
- package/dist/commands/protocol/workspace-source-dir.d.ts +8 -2
- package/dist/contract/types.d.ts +5 -0
- package/dist/generated/v2-api.d.ts +9 -9
- package/dist/http/client.d.ts +6 -6
- package/dist/index.js +186 -71
- package/dist/runtime.js +186 -71
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -24206,6 +24206,16 @@ function toRecord(value) {
|
|
|
24206
24206
|
function toRecordOrNull(value) {
|
|
24207
24207
|
return isRecordLike(value) ? value : null;
|
|
24208
24208
|
}
|
|
24209
|
+
function canonicalJson(value) {
|
|
24210
|
+
if (value instanceof Date)
|
|
24211
|
+
return JSON.stringify(value.toISOString());
|
|
24212
|
+
if (value === null || typeof value !== "object")
|
|
24213
|
+
return JSON.stringify(value) ?? "null";
|
|
24214
|
+
if (Array.isArray(value))
|
|
24215
|
+
return `[${Array.from(value, canonicalJson).join(",")}]`;
|
|
24216
|
+
const entries = Object.entries(value).filter(([, entry]) => entry !== undefined).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
24217
|
+
return `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`).join(",")}}`;
|
|
24218
|
+
}
|
|
24209
24219
|
|
|
24210
24220
|
// src/terminal/line-input.ts
|
|
24211
24221
|
import { createInterface } from "node:readline/promises";
|
|
@@ -35527,7 +35537,8 @@ var CLI_CONTRACT = {
|
|
|
35527
35537
|
getWorkflowState: { command: "workflows state get" },
|
|
35528
35538
|
getWorkflowOutline: {
|
|
35529
35539
|
command: "workflows outline",
|
|
35530
|
-
describe: "Show a workflow’s draft as a compact read-only outline"
|
|
35540
|
+
describe: "Show a workflow’s draft as a compact read-only outline",
|
|
35541
|
+
dataKeys: true
|
|
35531
35542
|
},
|
|
35532
35543
|
getWorkflowSource: {
|
|
35533
35544
|
command: "workflows source get",
|
|
@@ -37293,6 +37304,12 @@ function inferHeader(key, format) {
|
|
|
37293
37304
|
const trimmed = format === "duration" || format === "bytes" ? key.replace(/(?:Ms|Bytes)$/, "") : format === "bool" ? key.replace(/^is(?=[A-Z])/, "") : key;
|
|
37294
37305
|
return humanizeKey(trimmed || key);
|
|
37295
37306
|
}
|
|
37307
|
+
function inferredFields(record, dataKeys) {
|
|
37308
|
+
return Object.entries(record).map(([key, value]) => [
|
|
37309
|
+
dataKeys ? key : inferHeader(key, inferFormat(key, value)),
|
|
37310
|
+
inferredCell(key, value)
|
|
37311
|
+
]);
|
|
37312
|
+
}
|
|
37296
37313
|
function columnsFrom(specs) {
|
|
37297
37314
|
return specs.map((spec) => ({
|
|
37298
37315
|
header: spec.header,
|
|
@@ -37415,10 +37432,7 @@ function renderResult(operation, format, raw, spec, options = {}, envelope) {
|
|
|
37415
37432
|
printList(format, data, spec.columns ? columnsFrom(spec.columns) : inferColumns(data, spec.expand));
|
|
37416
37433
|
return;
|
|
37417
37434
|
}
|
|
37418
|
-
const fields = spec.fields ? fieldsFrom(data, spec.fields, options) : data && typeof data === "object" ?
|
|
37419
|
-
inferHeader(key, inferFormat(key, value)),
|
|
37420
|
-
inferredCell(key, value)
|
|
37421
|
-
]) : [];
|
|
37435
|
+
const fields = spec.fields ? fieldsFrom(data, spec.fields, options) : data && typeof data === "object" ? inferredFields(data, spec.dataKeys === true) : [];
|
|
37422
37436
|
printRecord(format, fields, data);
|
|
37423
37437
|
if (spec.expandedTrace && options.expandedTrace) {
|
|
37424
37438
|
const traceSpans = at(data, "traceSpans");
|
|
@@ -41203,6 +41217,7 @@ function attachWorkflowRunGet(runs) {
|
|
|
41203
41217
|
var SOURCE_LIMITS = {
|
|
41204
41218
|
maxBlocks: 2000,
|
|
41205
41219
|
maxEdges: 1e4,
|
|
41220
|
+
maxVariables: 2000,
|
|
41206
41221
|
maxFiles: 2001,
|
|
41207
41222
|
maxTotalBytes: 4000000,
|
|
41208
41223
|
maxDepth: 200
|
|
@@ -44743,25 +44758,23 @@ class LockReader {
|
|
|
44743
44758
|
}
|
|
44744
44759
|
}
|
|
44745
44760
|
}
|
|
44761
|
+
const cyclic = blocksOnParentCycles(blocks);
|
|
44746
44762
|
for (const [key, block] of Object.entries(blocks)) {
|
|
44747
44763
|
if (block.parent === null)
|
|
44748
44764
|
continue;
|
|
44749
44765
|
if (!Object.hasOwn(blocks, block.parent)) {
|
|
44750
44766
|
this.report("E_LOCK_PARENT", ["blocks", key, "parent"], `Parent "${block.parent}" is not a block in this lock.`);
|
|
44751
|
-
|
|
44752
|
-
|
|
44753
|
-
const visited = new Set;
|
|
44754
|
-
let current = block.parent;
|
|
44755
|
-
while (current !== null && Object.hasOwn(blocks, current) && !visited.has(current)) {
|
|
44756
|
-
if (current === key) {
|
|
44757
|
-
this.report("E_LOCK_PARENT", ["blocks", key, "parent"], `"${key}" contains itself.`);
|
|
44758
|
-
break;
|
|
44759
|
-
}
|
|
44760
|
-
visited.add(current);
|
|
44761
|
-
current = blocks[current].parent;
|
|
44767
|
+
} else if (cyclic.has(key)) {
|
|
44768
|
+
this.report("E_LOCK_PARENT", ["blocks", key, "parent"], `"${key}" contains itself.`);
|
|
44762
44769
|
}
|
|
44763
44770
|
}
|
|
44764
44771
|
}
|
|
44772
|
+
overCap(raw, max, at) {
|
|
44773
|
+
if (!isRecordLike(raw) || Object.keys(raw).length <= max)
|
|
44774
|
+
return false;
|
|
44775
|
+
this.report("E_LOCK_SHAPE", at, `Expected at most ${max} entries.`);
|
|
44776
|
+
return true;
|
|
44777
|
+
}
|
|
44765
44778
|
variables(raw) {
|
|
44766
44779
|
const variables = this.idRecord(raw, ["variables"]);
|
|
44767
44780
|
for (const key of Object.keys(variables)) {
|
|
@@ -44772,6 +44785,29 @@ class LockReader {
|
|
|
44772
44785
|
return variables;
|
|
44773
44786
|
}
|
|
44774
44787
|
}
|
|
44788
|
+
function blocksOnParentCycles(blocks) {
|
|
44789
|
+
const cyclic = new Set;
|
|
44790
|
+
const finished = new Set;
|
|
44791
|
+
for (const start of Object.keys(blocks)) {
|
|
44792
|
+
const path = [];
|
|
44793
|
+
const onPath = new Map;
|
|
44794
|
+
let current = start;
|
|
44795
|
+
while (current !== null && Object.hasOwn(blocks, current) && !finished.has(current)) {
|
|
44796
|
+
const index = onPath.get(current);
|
|
44797
|
+
if (index !== undefined) {
|
|
44798
|
+
for (const key of path.slice(index))
|
|
44799
|
+
cyclic.add(key);
|
|
44800
|
+
break;
|
|
44801
|
+
}
|
|
44802
|
+
onPath.set(current, path.length);
|
|
44803
|
+
path.push(current);
|
|
44804
|
+
current = blocks[current].parent;
|
|
44805
|
+
}
|
|
44806
|
+
for (const key of path)
|
|
44807
|
+
finished.add(key);
|
|
44808
|
+
}
|
|
44809
|
+
return cyclic;
|
|
44810
|
+
}
|
|
44775
44811
|
function upgradeWorkflowLock(json) {
|
|
44776
44812
|
return json.version === 1 ? { ...json, version: 1 } : null;
|
|
44777
44813
|
}
|
|
@@ -44823,16 +44859,20 @@ function parseWorkflowLock(input) {
|
|
|
44823
44859
|
reader.report("E_LOCK_VERSION", ["version"], "Unsupported lock version; expected 1.");
|
|
44824
44860
|
return { diagnostics: reader.diagnostics };
|
|
44825
44861
|
}
|
|
44862
|
+
const blocksOverCap = reader.overCap(json.blocks, SOURCE_LIMITS.maxBlocks, ["blocks"]);
|
|
44863
|
+
const variablesOverCap = reader.overCap(json.variables, SOURCE_LIMITS.maxVariables, ["variables"]);
|
|
44864
|
+
if (blocksOverCap || variablesOverCap)
|
|
44865
|
+
return { diagnostics: reader.diagnostics };
|
|
44826
44866
|
const extensions = reader.extensions(json, LOCK_FIELDS, []);
|
|
44827
44867
|
const blockEntries = [];
|
|
44828
|
-
if (isRecordLike(json.blocks)) {
|
|
44868
|
+
if (!isRecordLike(json.blocks)) {
|
|
44869
|
+
reader.report("E_LOCK_SHAPE", ["blocks"], '"blocks" must be an object.');
|
|
44870
|
+
} else {
|
|
44829
44871
|
for (const [key, raw] of Object.entries(json.blocks)) {
|
|
44830
44872
|
const block = reader.block(key, raw);
|
|
44831
44873
|
if (block)
|
|
44832
44874
|
blockEntries.push([key, block]);
|
|
44833
44875
|
}
|
|
44834
|
-
} else {
|
|
44835
|
-
reader.report("E_LOCK_SHAPE", ["blocks"], '"blocks" must be an object.');
|
|
44836
44876
|
}
|
|
44837
44877
|
const blocks = Object.fromEntries(blockEntries);
|
|
44838
44878
|
reader.crossCheckBlocks(blocks);
|
|
@@ -45554,10 +45594,35 @@ function checkLiteralRefs(ctx, node, text, site) {
|
|
|
45554
45594
|
checkIterationTag(ctx, rangeOf(ctx, node), site.decl.key, segments);
|
|
45555
45595
|
continue;
|
|
45556
45596
|
}
|
|
45557
|
-
const
|
|
45558
|
-
|
|
45559
|
-
|
|
45597
|
+
const tag = {
|
|
45598
|
+
token: token.value,
|
|
45599
|
+
segments,
|
|
45600
|
+
normalized,
|
|
45601
|
+
at: rangeOf(ctx, node),
|
|
45560
45602
|
blockKey: site.decl.key
|
|
45603
|
+
};
|
|
45604
|
+
if (!ctx.declsByKey.has(normalized) && segments.length > 1)
|
|
45605
|
+
ctx.unresolvedTags.push(tag);
|
|
45606
|
+
else
|
|
45607
|
+
reportNotNormalized(ctx, tag);
|
|
45608
|
+
}
|
|
45609
|
+
}
|
|
45610
|
+
function reportNotNormalized(ctx, tag) {
|
|
45611
|
+
const target = ctx.declsByKey.get(tag.normalized);
|
|
45612
|
+
ctx.reporter.report("W_REF_NOT_NORMALIZED", target ? `${tag.token} is not written with the block key ${tag.normalized}; the text is kept as written.` : `${tag.token} names no block; the text is kept as written.`, tag.at, {
|
|
45613
|
+
hint: () => target?.ident ? `Write \${${formatMemberPath(target.ident, tag.segments.slice(1))}} in a template, so a rename follows the block.` : "Reference a declared block through its ident, so a rename follows the block.",
|
|
45614
|
+
blockKey: tag.blockKey
|
|
45615
|
+
});
|
|
45616
|
+
}
|
|
45617
|
+
function checkUnresolvedTags(ctx, renamed) {
|
|
45618
|
+
for (const tag of ctx.unresolvedTags) {
|
|
45619
|
+
if (renamed.has(tag.normalized)) {
|
|
45620
|
+
reportNotNormalized(ctx, tag);
|
|
45621
|
+
continue;
|
|
45622
|
+
}
|
|
45623
|
+
ctx.reporter.report("W_UNRESOLVED_REF", `${tag.token} names no block, so it does not resolve at run time.`, tag.at, {
|
|
45624
|
+
hint: "Reference a declared block through its ident, so a rename follows the block.",
|
|
45625
|
+
blockKey: tag.blockKey
|
|
45561
45626
|
});
|
|
45562
45627
|
}
|
|
45563
45628
|
}
|
|
@@ -45790,7 +45855,7 @@ function compileRef(ctx, node, site) {
|
|
|
45790
45855
|
const key = normalizeWorkflowBlockName(name);
|
|
45791
45856
|
if (!ctx.variables.has(key)) {
|
|
45792
45857
|
ctx.reporter.report("E_UNKNOWN_VARIABLE", `No workflow variable is keyed ${name}.`, rangeOf(ctx, first), {
|
|
45793
|
-
hint: didYouMean(key, ctx.variables.keys(), (known) => `vars.${known}`),
|
|
45858
|
+
hint: () => didYouMean(key, ctx.variables.keys(), (known) => `vars.${known}`),
|
|
45794
45859
|
blockKey: site.decl.key
|
|
45795
45860
|
});
|
|
45796
45861
|
return null;
|
|
@@ -45857,11 +45922,14 @@ function segmentsOf(ctx, members, site) {
|
|
|
45857
45922
|
}
|
|
45858
45923
|
function checkEnvName(ctx, name, at, blockKey) {
|
|
45859
45924
|
ctx.envReferences.add(name);
|
|
45860
|
-
|
|
45925
|
+
const envNames = ctx.envNames;
|
|
45926
|
+
if (!envNames || envNames.has(name))
|
|
45861
45927
|
return;
|
|
45862
|
-
const near = didYouMean(name, ctx.envNames);
|
|
45863
45928
|
ctx.reporter.report("W_ENV_UNKNOWN", `The workspace has no env variable ${name}, so it resolves to nothing at run time.`, at, {
|
|
45864
|
-
hint:
|
|
45929
|
+
hint: () => {
|
|
45930
|
+
const near = didYouMean(name, envNames);
|
|
45931
|
+
return ctx.envDeclaredIn ? `${near ? `${near} Otherwise d` : "D"}eclare ${name} in ${ctx.envDeclaredIn} and set its value with \`sim secrets set ${name} --scope workspace\`.` : near ?? `Add ${name} under the workspace's or your environment variables, or use a name .sim/sdk/workspace.d.ts lists.`;
|
|
45932
|
+
},
|
|
45865
45933
|
blockKey
|
|
45866
45934
|
});
|
|
45867
45935
|
}
|
|
@@ -46004,7 +46072,7 @@ function checkCodeFileRefs(ctx, renamed) {
|
|
|
46004
46072
|
const suggested = byIdent ?? byName;
|
|
46005
46073
|
const rewritten = (key) => spell([{ kind: "name", name: key }, ...rest]);
|
|
46006
46074
|
ctx.reporter.report("W_UNRESOLVED_REF", `${written} names no block, so it does not resolve at run time.`, at, {
|
|
46007
|
-
hint: suggested ? `${ref.tag ? "A tag" : REF_ROOT} names a block by its key: write ${rewritten(suggested.key)}.` : ctx.knownKeys.has(head.name) ? formerBlockHint(ctx, head.name, renamed, rewritten, spell) : () => didYouMean(head.name, ctx.declsByKey.keys(), (key) => spell([{ kind: "name", name: key }])),
|
|
46075
|
+
hint: suggested ? `${ref.tag ? "A tag" : REF_ROOT} names a block by its key: write ${rewritten(suggested.key)}.` : ctx.knownKeys.has(head.name) ? () => formerBlockHint(ctx, head.name, renamed, rewritten, spell) : () => didYouMean(head.name, ctx.declsByKey.keys(), (key) => spell([{ kind: "name", name: key }])),
|
|
46008
46076
|
blockKey
|
|
46009
46077
|
});
|
|
46010
46078
|
}
|
|
@@ -47339,6 +47407,7 @@ var import_parser2 = __toESM(require_lib(), 1);
|
|
|
47339
47407
|
var DEFAULT_LIMITS = {
|
|
47340
47408
|
maxBlocks: SOURCE_LIMITS.maxBlocks,
|
|
47341
47409
|
maxEdges: SOURCE_LIMITS.maxEdges,
|
|
47410
|
+
maxVariables: SOURCE_LIMITS.maxVariables,
|
|
47342
47411
|
maxTotalBytes: SOURCE_LIMITS.maxTotalBytes,
|
|
47343
47412
|
maxDepth: SOURCE_LIMITS.maxDepth,
|
|
47344
47413
|
maxCodeFileRefs: SOURCE_LIMITS.maxBlocks
|
|
@@ -49253,22 +49322,42 @@ function compileContainer(ctx, decl) {
|
|
|
49253
49322
|
function compileBlock(ctx, decl) {
|
|
49254
49323
|
if (decl.duplicate || decl.builder.kind === "unknown")
|
|
49255
49324
|
return null;
|
|
49256
|
-
if (decl.builder.kind !== "container")
|
|
49325
|
+
if (decl.builder.kind !== "container") {
|
|
49257
49326
|
checkLegacyType(ctx, decl);
|
|
49327
|
+
checkUnplaceableType(ctx, decl);
|
|
49328
|
+
}
|
|
49258
49329
|
return decl.builder.kind === "container" ? compileContainer(ctx, decl) : compileRegularBlock(ctx, decl);
|
|
49259
49330
|
}
|
|
49331
|
+
function lockBinds(ctx, decl) {
|
|
49332
|
+
const lock = ctx.storedUnread;
|
|
49333
|
+
return lock !== undefined && (Object.hasOwn(lock.blocks, decl.key) || decl.ident !== null && ctx.storedUnreadIdents.has(decl.ident));
|
|
49334
|
+
}
|
|
49335
|
+
function checkUnplaceableType(ctx, decl) {
|
|
49336
|
+
const { builder } = decl;
|
|
49337
|
+
if (builder.kind !== "generic" && builder.kind !== "catalog")
|
|
49338
|
+
return;
|
|
49339
|
+
const notAddable = builder.block?.addable === false;
|
|
49340
|
+
const uncatalogued = builder.kind === "generic" && !builder.block;
|
|
49341
|
+
if (!(notAddable || uncatalogued) || ctx.storedTypes.has(builder.type) || lockBinds(ctx, decl)) {
|
|
49342
|
+
return;
|
|
49343
|
+
}
|
|
49344
|
+
if (notAddable) {
|
|
49345
|
+
ctx.reporter.report("W_TYPE_NOT_ADDABLE", `${builder.type} can stay where a workflow already uses it, but an apply cannot add a new block of it.`, rangeOf(ctx, decl.call), { hint: "Use a block type this workspace offers.", blockKey: decl.key });
|
|
49346
|
+
return;
|
|
49347
|
+
}
|
|
49348
|
+
ctx.reporter.report("W_UNKNOWN_BLOCK_TYPE", `${builder.type} is not a block type this workspace offers, so an apply cannot add the block.`, rangeOf(ctx, decl.call), {
|
|
49349
|
+
hint: () => didYouMean(builder.type, Object.keys(ctx.catalog.blocks)) ?? "Use a block type from the catalog, or a builder such as api() or fn().",
|
|
49350
|
+
blockKey: decl.key
|
|
49351
|
+
});
|
|
49352
|
+
}
|
|
49260
49353
|
function checkLegacyType(ctx, decl) {
|
|
49261
49354
|
const block = catalogBlockOf(decl);
|
|
49262
49355
|
const sunset = block?.lifecycle?.sunset;
|
|
49263
49356
|
if (!block || !sunset)
|
|
49264
49357
|
return;
|
|
49265
49358
|
const stored = ctx.stored ? getOwn(ctx.stored.blocks, decl.key) : undefined;
|
|
49266
|
-
if (stored?.type === block.type)
|
|
49359
|
+
if (stored?.type === block.type || lockBinds(ctx, decl))
|
|
49267
49360
|
return;
|
|
49268
|
-
const lock = ctx.storedUnread;
|
|
49269
|
-
if (lock && (Object.hasOwn(lock.blocks, decl.key) || Object.values(lock.blocks).some((entry) => entry.ident === decl.ident))) {
|
|
49270
|
-
return;
|
|
49271
|
-
}
|
|
49272
49361
|
const replacement = sunset.replacedBy;
|
|
49273
49362
|
const namespaces = replacement ? [
|
|
49274
49363
|
...new Set(catalogBuildersOfType(ctx.catalog, replacement).map(([path]) => {
|
|
@@ -50314,6 +50403,8 @@ var COMPILE_CATALOG_CODES = [
|
|
|
50314
50403
|
"E_UNKNOWN_OPERATION",
|
|
50315
50404
|
"W_UNKNOWN_MODEL",
|
|
50316
50405
|
"W_LEGACY_BLOCK_TYPE",
|
|
50406
|
+
"W_UNKNOWN_BLOCK_TYPE",
|
|
50407
|
+
"W_TYPE_NOT_ADDABLE",
|
|
50317
50408
|
"I_SCHEDULE_UTC",
|
|
50318
50409
|
"E_STORED_VALUE_MISSING",
|
|
50319
50410
|
"W_VALUE_KIND",
|
|
@@ -50474,7 +50565,10 @@ var PARAM_REFUSALS = new Map([
|
|
|
50474
50565
|
["W_UNKNOWN_OPTION", "E_APPLY_INVALID_SUBBLOCK_FIELD"]
|
|
50475
50566
|
]);
|
|
50476
50567
|
var ENTRY_REFUSALS = new Map([
|
|
50477
|
-
["W_UNKNOWN_OUTPUT_PATH", "E_APPLY_UNRESOLVED_REF"]
|
|
50568
|
+
["W_UNKNOWN_OUTPUT_PATH", "E_APPLY_UNRESOLVED_REF"],
|
|
50569
|
+
["W_UNRESOLVED_REF", "E_APPLY_UNRESOLVED_REF"],
|
|
50570
|
+
["W_UNKNOWN_BLOCK_TYPE", "E_APPLY_INVALID_BLOCK_TYPE"],
|
|
50571
|
+
["W_TYPE_NOT_ADDABLE", "E_APPLY_TYPE_NOT_ADDABLE"]
|
|
50478
50572
|
]);
|
|
50479
50573
|
var CODE_FILE_REFUSALS = new Map([
|
|
50480
50574
|
["W_UNRESOLVED_REF", "E_APPLY_UNRESOLVED_REF"],
|
|
@@ -50486,7 +50580,9 @@ var REFUSABLE_WARNING_CODES = new Set([
|
|
|
50486
50580
|
"W_REF_OUT_OF_SCOPE",
|
|
50487
50581
|
"W_UNKNOWN_OUTPUT_PATH",
|
|
50488
50582
|
"W_UNRESOLVED_REF",
|
|
50489
|
-
"W_CODE_FILE_REF_SYNTAX"
|
|
50583
|
+
"W_CODE_FILE_REF_SYNTAX",
|
|
50584
|
+
"W_UNKNOWN_BLOCK_TYPE",
|
|
50585
|
+
"W_TYPE_NOT_ADDABLE"
|
|
50490
50586
|
]);
|
|
50491
50587
|
var EDIT_REFUSALS = [
|
|
50492
50588
|
...[...CHANGED_BLOCK_REFUSALS].map(([warning, refusal]) => ({
|
|
@@ -51230,6 +51326,11 @@ function compileVariables(ctx, node) {
|
|
|
51230
51326
|
unsupported(ctx, node, "variables is an object literal.", "Write variables: { name: { type: 'string', value: '' } }.");
|
|
51231
51327
|
return;
|
|
51232
51328
|
}
|
|
51329
|
+
const overLimit = node.properties[ctx.limits.maxVariables];
|
|
51330
|
+
if (overLimit) {
|
|
51331
|
+
ctx.reporter.report("E_LIMIT_EXCEEDED", `The workflow declares ${node.properties.length} variables; the limit is ${ctx.limits.maxVariables}.`, rangeOf(ctx, overLimit), { hint: "Keep related values together in one object or array variable." });
|
|
51332
|
+
return;
|
|
51333
|
+
}
|
|
51233
51334
|
const entries = objectEntries(ctx, node);
|
|
51234
51335
|
const addItem = ctx.comments.list(node.start ?? 0, node.end ?? 0, {
|
|
51235
51336
|
owner: encodeAnchor({ kind: "header" }),
|
|
@@ -51429,6 +51530,7 @@ function compileEntry(input, file, text, reporter) {
|
|
|
51429
51530
|
if (!ast)
|
|
51430
51531
|
return emptyResult(reporter, parsed.sdkMajor);
|
|
51431
51532
|
checkStorableLiterals(file, text, ast, reporter);
|
|
51533
|
+
const storedUnread = input.stored === undefined ? input.storedUnread : undefined;
|
|
51432
51534
|
const ctx = {
|
|
51433
51535
|
file,
|
|
51434
51536
|
reporter,
|
|
@@ -51448,12 +51550,15 @@ function compileEntry(input, file, text, reporter) {
|
|
|
51448
51550
|
metaSpans: {},
|
|
51449
51551
|
knownKeys: input.knownKeys ?? new Set,
|
|
51450
51552
|
stored: input.stored,
|
|
51451
|
-
storedUnread
|
|
51553
|
+
storedUnread,
|
|
51554
|
+
storedTypes: new Set(Object.values(input.stored?.blocks ?? {}).map((block) => block.type)),
|
|
51555
|
+
storedUnreadIdents: new Set(Object.values(storedUnread?.blocks ?? {}).map((entry) => entry.ident)),
|
|
51452
51556
|
envNames: input.envNames,
|
|
51453
51557
|
envDeclaredIn: input.envDeclaredIn,
|
|
51454
51558
|
envReferences: new Set,
|
|
51455
51559
|
jsonFields: [],
|
|
51456
51560
|
dynamicOutputRefs: [],
|
|
51561
|
+
unresolvedTags: [],
|
|
51457
51562
|
errorOutputRefs: [],
|
|
51458
51563
|
refusedBranches: new Map,
|
|
51459
51564
|
valueConsts: new Set
|
|
@@ -51529,6 +51634,7 @@ function compileEntry(input, file, text, reporter) {
|
|
|
51529
51634
|
const unreadRenames = unread ? lockIdentRenames(hints, unread, (key) => Object.hasOwn(unread.blocks, key)) : new Map;
|
|
51530
51635
|
const renamed = new Map([...unreadRenames, ...input.renamedKeys ?? []]);
|
|
51531
51636
|
checkCodeFileRefs(ctx, renamed);
|
|
51637
|
+
checkUnresolvedTags(ctx, renamed);
|
|
51532
51638
|
const stored = storedView(input.stored, renamed);
|
|
51533
51639
|
const refTypes = {
|
|
51534
51640
|
catalog: input.catalog,
|
|
@@ -55527,8 +55633,7 @@ export default workflow('Support', { description: 'Answers an order question.' }
|
|
|
55527
55633
|
})
|
|
55528
55634
|
` };
|
|
55529
55635
|
// ../workflow-sdk/src/codegen/workspace-text.generated.ts
|
|
55530
|
-
var WORKSPACE_SDK_DTS = {
|
|
55531
|
-
"credentials.d.ts": `/**
|
|
55636
|
+
var WORKSPACE_SDK_DTS = { "credentials.d.ts": `/**
|
|
55532
55637
|
* Credential declarations: \`credentials.ts\` at the root of a workspace source directory names the
|
|
55533
55638
|
* saved credentials its workflows use, each by the provider it is for. Never a token: connect one
|
|
55534
55639
|
* with \`sim credentials connect <provider> --name "<display name>"\`.
|
|
@@ -55572,8 +55677,7 @@ export declare function defineCredentials<const T extends Record<string, Credent
|
|
|
55572
55677
|
export type DeclaredCredentials<T> = {
|
|
55573
55678
|
[K in keyof T]: T[K] extends { provider: infer P } ? { provider: P } : never
|
|
55574
55679
|
}
|
|
55575
|
-
`,
|
|
55576
|
-
"deployment.d.ts": `/**
|
|
55680
|
+
`, "deployment.d.ts": `/**
|
|
55577
55681
|
* Deployment declarations: \`deployments/<workflow key>.ts\` in a workspace source directory deploys
|
|
55578
55682
|
* \`workflows/<workflow key>/\`, so its schedule, webhook, API and chat triggers run.
|
|
55579
55683
|
*
|
|
@@ -55655,9 +55759,7 @@ export interface DeploymentDeclaration {
|
|
|
55655
55759
|
|
|
55656
55760
|
/** Declares a workflow's deployment. Its default export is the whole file. */
|
|
55657
55761
|
export declare function defineDeployment(deployment: DeploymentDeclaration): DeploymentDeclaration
|
|
55658
|
-
`,
|
|
55659
|
-
"file.d.ts": "/**\n * Workspace files need no declaration: every file under `files/` is one workspace file, at the\n * folder path and name it has there (`files/reports/q1.pdf` is `q1.pdf` in the `reports`\n * folder), synced by content hash. Each apply that changes a file's bytes records a new version\n * of it, so an earlier one can be restored in the Files tab. Files over 10 MB, or whose name no\n * directory can hold (a reserved character, or a path that differs only in letter case from\n * another file or folder), are left out of a get (listed in `.sim/skipped.json`) and never written\n * by an apply; a file the directory no longer holds is deleted only with `--allow-delete`.\n */\nexport {}\n",
|
|
55660
|
-
"index.d.ts": `/**
|
|
55762
|
+
`, "file.d.ts": "/**\n * Workspace files need no declaration: every file under `files/` is one workspace file, at the\n * folder path and name it has there (`files/reports/q1.pdf` is `q1.pdf` in the `reports`\n * folder), synced by content hash. Each apply that changes a file's bytes records a new version\n * of it, so an earlier one can be restored in the Files tab. Files over 10 MB, or whose name no\n * directory can hold (a reserved character, or a path that differs only in letter case from\n * another file or folder), are left out of a get (listed in `.sim/skipped.json`) and never written\n * by an apply; a file the directory no longer holds is deleted only with `--allow-delete`.\n */\nexport {}\n", "index.d.ts": `/**
|
|
55661
55763
|
* The workspace declaration SDK: \`import { … } from '@sim/workflow-sdk/workspace'\` in the
|
|
55662
55764
|
* declaration files of a workspace source directory (\`tables/<key>.ts\`, …). Like the workflow
|
|
55663
55765
|
* SDK, nothing here runs: the server reads each file statically.
|
|
@@ -55671,8 +55773,7 @@ export * from './secrets'
|
|
|
55671
55773
|
export * from './skill'
|
|
55672
55774
|
export * from './table'
|
|
55673
55775
|
export * from './tool'
|
|
55674
|
-
`,
|
|
55675
|
-
"knowledge.d.ts": `/**
|
|
55776
|
+
`, "knowledge.d.ts": `/**
|
|
55676
55777
|
* Knowledge base declarations: \`knowledge/<key>/knowledge.ts\` in a workspace source directory,
|
|
55677
55778
|
* beside \`knowledge/<key>/docs/\`, which holds one file per document.
|
|
55678
55779
|
*
|
|
@@ -55731,9 +55832,7 @@ export interface KnowledgeBaseDeclaration {
|
|
|
55731
55832
|
export declare function defineKnowledgeBase(
|
|
55732
55833
|
knowledgeBase: KnowledgeBaseDeclaration
|
|
55733
55834
|
): KnowledgeBaseDeclaration
|
|
55734
|
-
`,
|
|
55735
|
-
"mcp.d.ts": "/**\n * MCP server declarations: `mcp/<key>.ts` declares one server the workspace's agents call tools\n * on.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineMcpServer, env } from '@sim/workflow-sdk/workspace'\n *\n * export default defineMcpServer({\n * name: 'GitHub',\n * url: 'https://api.githubcopilot.com/mcp/',\n * headers: { Authorization: 'Bearer {{GITHUB_TOKEN}}', 'X-Team': env.GITHUB_TEAM },\n * })\n * ```\n *\n * A workflow names the server by its key and one of its tools by name:\n * `mcp('github').tool('create_issue')`. Secrets never sit in source: a credential header\n * (`Authorization`, `Cookie`, or a name with `key`, `token`, `secret`, `auth`, …) holds env\n * references (`env.NAME`, or `{{NAME}}` in its text after a scheme such as `Bearer`) or\n * `stored()`, which keeps the value the server holds. The server's id derives from its URL, so a\n * `url` with another host or path replaces the server; a new query string updates it in place.\n */\nimport type { EnvRef } from '@sim/workflow-sdk'\n\nexport { env, stored } from '@sim/workflow-sdk'\n\n/** A header value: text (`{{NAME}}` names an env variable), `env.NAME`, or `stored()`. */\nexport type McpHeaderValue = string | EnvRef\n\n/** How the server authenticates. */\nexport interface McpServerAuth {\n /** `headers` (the default) sends the declared headers; `oauth` signs in with an OAuth grant. */\n type: 'none' | 'headers' | 'oauth'\n /** A pre-registered OAuth client, for a server without dynamic client registration. */\n clientId?: string\n}\n\n/** An MCP server declaration. */\nexport interface McpServerDeclaration {\n /** The display name; the key when left out. */\n name?: string\n description?: string\n /** An `http://` or `https://` URL. A new host or path replaces the server; a new query does not. */\n url: string\n transport?: 'streamable-http'\n headers?: { [name: string]: McpHeaderValue }\n /** `{ type: 'headers' }` when left out. The OAuth client secret is set in the server settings. */\n auth?: McpServerAuth\n /** Milliseconds a request waits; 30000 when left out. */\n timeout?: number\n /** 3 when left out. */\n retries?: number\n /** `true` when left out. */\n enabled?: boolean\n}\n\n/** Declares an MCP server. Its default export is the whole file. */\nexport declare function defineMcpServer(server: McpServerDeclaration): McpServerDeclaration\n",
|
|
55736
|
-
"secrets.d.ts": `/**
|
|
55835
|
+
`, "mcp.d.ts": "/**\n * MCP server declarations: `mcp/<key>.ts` declares one server the workspace's agents call tools\n * on.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineMcpServer, env } from '@sim/workflow-sdk/workspace'\n *\n * export default defineMcpServer({\n * name: 'GitHub',\n * url: 'https://api.githubcopilot.com/mcp/',\n * headers: { Authorization: 'Bearer {{GITHUB_TOKEN}}', 'X-Team': env.GITHUB_TEAM },\n * })\n * ```\n *\n * A workflow names the server by its key and one of its tools by name:\n * `mcp('github').tool('create_issue')`. Secrets never sit in source: a credential header\n * (`Authorization`, `Cookie`, or a name with `key`, `token`, `secret`, `auth`, …) holds env\n * references (`env.NAME`, or `{{NAME}}` in its text after a scheme such as `Bearer`) or\n * `stored()`, which keeps the value the server holds. The server's id derives from its URL, so a\n * `url` with another host or path replaces the server; a new query string updates it in place.\n */\nimport type { EnvRef } from '@sim/workflow-sdk'\n\nexport { env, stored } from '@sim/workflow-sdk'\n\n/** A header value: text (`{{NAME}}` names an env variable), `env.NAME`, or `stored()`. */\nexport type McpHeaderValue = string | EnvRef\n\n/** How the server authenticates. */\nexport interface McpServerAuth {\n /** `headers` (the default) sends the declared headers; `oauth` signs in with an OAuth grant. */\n type: 'none' | 'headers' | 'oauth'\n /** A pre-registered OAuth client, for a server without dynamic client registration. */\n clientId?: string\n}\n\n/** An MCP server declaration. */\nexport interface McpServerDeclaration {\n /** The display name; the key when left out. */\n name?: string\n description?: string\n /** An `http://` or `https://` URL. A new host or path replaces the server; a new query does not. */\n url: string\n transport?: 'streamable-http'\n headers?: { [name: string]: McpHeaderValue }\n /** `{ type: 'headers' }` when left out. The OAuth client secret is set in the server settings. */\n auth?: McpServerAuth\n /** Milliseconds a request waits; 30000 when left out. */\n timeout?: number\n /** 3 when left out. */\n retries?: number\n /** `true` when left out. */\n enabled?: boolean\n}\n\n/** Declares an MCP server. Its default export is the whole file. */\nexport declare function defineMcpServer(server: McpServerDeclaration): McpServerDeclaration\n", "secrets.d.ts": `/**
|
|
55737
55836
|
* Secret declarations: \`secrets.ts\` at the root of a workspace source directory names the
|
|
55738
55837
|
* workspace secrets its workflows read, by name and what each is for. Never a value: set one with
|
|
55739
55838
|
* \`sim secrets set <NAME> --scope workspace\`, or in the workspace's secrets settings.
|
|
@@ -55767,9 +55866,7 @@ export declare function defineSecrets<const T extends Record<string, SecretDecla
|
|
|
55767
55866
|
|
|
55768
55867
|
/** The env names a \`secrets.ts\` declaration adds, as \`workspace.d.ts\` merges them into \`env\`. */
|
|
55769
55868
|
export type DeclaredSecretNames<T> = { [K in keyof T]: true }
|
|
55770
|
-
`,
|
|
55771
|
-
"skill.d.ts": '/**\n * Skills are markdown, not TypeScript: `skills/<key>.md` is a frontmatter block of `name` and\n * `description`, then the skill\'s content.\n *\n * ```md\n * ---\n * name: tone\n * description: "Answer in the support team\'s voice: short, warm, specific."\n * ---\n * Write like a person, not a policy.\n * ```\n *\n * A value is plain text on one line, or a JSON string (`"…"`) when it holds a line break,\n * surrounding spaces, quotes, `: ` or ` #`, ends in `:`, or starts with anything but a letter,\n * digit or `(`. Quote a value YAML would read as a boolean, number or date (`"yes"`, `"1e3"`) too,\n * so other markdown tools read it as text. The name is kebab-case; a workflow names the skill by\n * its key, `skill(\'tone\')`. This module declares nothing.\n */\nexport {}\n',
|
|
55772
|
-
"table.d.ts": `/**
|
|
55869
|
+
`, "skill.d.ts": '/**\n * Skills are markdown, not TypeScript: `skills/<key>.md` is a frontmatter block of `name` and\n * `description`, then the skill\'s content.\n *\n * ```md\n * ---\n * name: tone\n * description: "Answer in the support team\'s voice: short, warm, specific."\n * ---\n * Write like a person, not a policy.\n * ```\n *\n * A value is plain text on one line, or a JSON string (`"…"`) when it holds a line break,\n * surrounding spaces, quotes, `: ` or ` #`, ends in `:`, or starts with anything but a letter,\n * digit or `(`. Quote a value YAML would read as a boolean, number or date (`"yes"`, `"1e3"`) too,\n * so other markdown tools read it as text. The name is kebab-case; a workflow names the skill by\n * its key, `skill(\'tone\')`. This module declares nothing.\n */\nexport {}\n', "table.d.ts": `/**
|
|
55773
55870
|
* Table declarations: \`tables/<key>.ts\` in a workspace source directory.
|
|
55774
55871
|
*
|
|
55775
55872
|
* \`\`\`ts
|
|
@@ -55914,8 +56011,7 @@ type CellOf<C> = C extends Column<infer V, infer _N, infer R>
|
|
|
55914
56011
|
export type RowOf<T> = T extends TableDeclaration<infer C>
|
|
55915
56012
|
? { [K in keyof C as StoredName<K, C[K]>]: CellOf<C[K]> }
|
|
55916
56013
|
: never
|
|
55917
|
-
`,
|
|
55918
|
-
"tool.d.ts": `/**
|
|
56014
|
+
`, "tool.d.ts": `/**
|
|
55919
56015
|
* Custom tool declarations: \`tools/<key>.ts\`, with the tool's code beside it in \`tools/<key>.js\`.
|
|
55920
56016
|
*
|
|
55921
56017
|
* \`\`\`ts
|
|
@@ -55982,8 +56078,7 @@ export interface ToolDeclaration {
|
|
|
55982
56078
|
|
|
55983
56079
|
/** Declares a custom tool. Its default export is the whole file. */
|
|
55984
56080
|
export declare function defineTool(tool: ToolDeclaration): ToolDeclaration
|
|
55985
|
-
`
|
|
55986
|
-
};
|
|
56081
|
+
` };
|
|
55987
56082
|
// src/commands/protocol/source-primer.ts
|
|
55988
56083
|
var MAX_SNIPPETS = 12;
|
|
55989
56084
|
var MAX_SNIPPET_BYTES = 4096;
|
|
@@ -62434,18 +62529,8 @@ function coerceRowCells(data, columns, policyFor) {
|
|
|
62434
62529
|
}
|
|
62435
62530
|
}
|
|
62436
62531
|
}
|
|
62437
|
-
function canonicalCellJson(value) {
|
|
62438
|
-
if (value instanceof Date)
|
|
62439
|
-
return JSON.stringify(value.toISOString());
|
|
62440
|
-
if (value === null || typeof value !== "object")
|
|
62441
|
-
return JSON.stringify(value) ?? "null";
|
|
62442
|
-
if (Array.isArray(value))
|
|
62443
|
-
return `[${value.map(canonicalCellJson).join(",")}]`;
|
|
62444
|
-
const entries = Object.entries(value).filter(([, entry]) => entry !== undefined).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
62445
|
-
return `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${canonicalCellJson(entry)}`).join(",")}}`;
|
|
62446
|
-
}
|
|
62447
62532
|
function uniqueValueKey(value, column) {
|
|
62448
|
-
return
|
|
62533
|
+
return canonicalJson(cellRuleOf(column).valueForEquality?.(value) ?? value);
|
|
62449
62534
|
}
|
|
62450
62535
|
function scanBatchUniqueValues(rows, uniqueColumns) {
|
|
62451
62536
|
const rowErrors = [];
|
|
@@ -63778,10 +63863,31 @@ async function assertWorkspaceDir(dir) {
|
|
|
63778
63863
|
function keepFile(kind) {
|
|
63779
63864
|
return isFileKind(kind) ? null : `${KIND_DIRS[kind]}/${KEEP_FILE}`;
|
|
63780
63865
|
}
|
|
63866
|
+
function toolOfCodeFile(path) {
|
|
63867
|
+
if (kindOfPath(path) !== "custom-tool")
|
|
63868
|
+
return null;
|
|
63869
|
+
const [key] = toolCodec.group([path]).groups.keys();
|
|
63870
|
+
if (key === undefined)
|
|
63871
|
+
return null;
|
|
63872
|
+
const declaration = toolDeclarationPath(key);
|
|
63873
|
+
return path === declaration ? null : { key, declaration };
|
|
63874
|
+
}
|
|
63875
|
+
function isUnnamedToolCode(files, path) {
|
|
63876
|
+
const tool = toolOfCodeFile(path);
|
|
63877
|
+
const text = tool ? files[tool.declaration] : undefined;
|
|
63878
|
+
if (!tool || text === undefined)
|
|
63879
|
+
return false;
|
|
63880
|
+
return toolCodec.parse(tool.key, { [tool.declaration]: text }, []).decl !== undefined;
|
|
63881
|
+
}
|
|
63781
63882
|
function dropUnnamedCodeFiles(files) {
|
|
63782
63883
|
const named = new Map;
|
|
63783
63884
|
const unnamed = [];
|
|
63784
63885
|
for (const path of Object.keys(files)) {
|
|
63886
|
+
if (isUnnamedToolCode(files, path)) {
|
|
63887
|
+
unnamed.push(path);
|
|
63888
|
+
delete files[path];
|
|
63889
|
+
continue;
|
|
63890
|
+
}
|
|
63785
63891
|
if (kindOfPath(path) !== "workflow")
|
|
63786
63892
|
continue;
|
|
63787
63893
|
const segments = path.split("/");
|
|
@@ -65900,14 +66006,20 @@ function droppedResourceFiles(sent, reprinted) {
|
|
|
65900
66006
|
}
|
|
65901
66007
|
async function saveApplied(dir, data, submission, written, records) {
|
|
65902
66008
|
assertWorkspacePaths(Object.keys(data.files));
|
|
65903
|
-
const
|
|
65904
|
-
|
|
65905
|
-
|
|
65906
|
-
|
|
66009
|
+
const toolCode = [];
|
|
66010
|
+
const orphaned = await orphanedWorkflowFiles(dir, data.files, written.digests);
|
|
66011
|
+
for (const path of droppedResourceFiles(submission.files, data.files)) {
|
|
66012
|
+
const tool = toolOfCodeFile(path);
|
|
66013
|
+
if (tool)
|
|
66014
|
+
toolCode.push({ path, declaration: tool.declaration });
|
|
66015
|
+
else
|
|
66016
|
+
orphaned.push(path);
|
|
66017
|
+
}
|
|
65907
66018
|
const kept = { ...written.digests, ...appliedBlobDigests(submission, data.base) };
|
|
65908
66019
|
const deleted = await deletedRecordedPaths(dir, written.digests, submission.kinds, data.base);
|
|
65909
|
-
for (const path of [...orphaned, ...deleted])
|
|
66020
|
+
for (const path of [...orphaned, ...deleted, ...toolCode.map(({ path }) => path)]) {
|
|
65910
66021
|
delete kept[path];
|
|
66022
|
+
}
|
|
65911
66023
|
const record = writtenRecord(data.files, kept, new Map([...recordedStats(written), ...submission.hashed]));
|
|
65912
66024
|
await updateSourceDir(dir, {
|
|
65913
66025
|
write: [
|
|
@@ -65919,6 +66031,9 @@ async function saveApplied(dir, data, submission, written, records) {
|
|
|
65919
66031
|
],
|
|
65920
66032
|
remove: [...orphaned, ...removedWorkflowRecords(deleted)]
|
|
65921
66033
|
});
|
|
66034
|
+
for (const { path, declaration } of toolCode) {
|
|
66035
|
+
printError(`warning: ${path} is no longer named by ${declaration} (its code is now kept as stored() or printed inline), so it was left on disk as written and no apply sends it: delete it, or name it again with codeFile(). Never commit one that holds a credential.`);
|
|
66036
|
+
}
|
|
65922
66037
|
}
|
|
65923
66038
|
function baseWorkflowOf(base) {
|
|
65924
66039
|
return isRecordLike(base) && typeof base.workflowId === "string" ? base.workflowId : null;
|