lua-cli 3.39.0 → 3.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-exports.d.ts +18 -18
- package/dist/api-exports.js +529 -283
- package/dist/api-exports.js.map +1 -1
- package/dist/index.js +705 -436
- package/dist/index.js.map +1 -1
- package/dist/voice/test/index.d.ts +18 -18
- package/dist/workflow-builder.js +478 -241
- package/dist/workflow-builder.js.map +1 -1
- package/package.json +6 -5
- package/template/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -840,6 +840,7 @@ var init_package_root = __esm({
|
|
|
840
840
|
import { z } from "zod";
|
|
841
841
|
import { z as z2 } from "zod";
|
|
842
842
|
import { z as z3 } from "zod";
|
|
843
|
+
import { z as z4 } from "zod";
|
|
843
844
|
function isChannelConversationChannel(channel) {
|
|
844
845
|
return !!channel && CHANNEL_CONVERSATION_CHANNELS.includes(channel);
|
|
845
846
|
}
|
|
@@ -936,9 +937,9 @@ function isMcpDraftCreateTool(tool) {
|
|
|
936
937
|
function mcpSendSiblingForDraftTool(tool, availableToolIds) {
|
|
937
938
|
const candidates = [
|
|
938
939
|
...availableToolIds
|
|
939
|
-
].filter((
|
|
940
|
-
id,
|
|
941
|
-
serverName:
|
|
940
|
+
].filter((id2) => id2.endsWith(REVIEWABLE_MCP_SEND_TOOL_SUFFIX)).map((id2) => ({
|
|
941
|
+
id: id2,
|
|
942
|
+
serverName: id2.slice(0, -REVIEWABLE_MCP_SEND_TOOL_SUFFIX.length)
|
|
942
943
|
})).filter(({ serverName }) => tool.startsWith(`${serverName}_`)).sort((a, b) => b.serverName.length - a.serverName.length);
|
|
943
944
|
return candidates[0]?.id;
|
|
944
945
|
}
|
|
@@ -1099,8 +1100,8 @@ function transformChatHistoryContentParts(parts) {
|
|
|
1099
1100
|
}
|
|
1100
1101
|
return content;
|
|
1101
1102
|
}
|
|
1102
|
-
function isSyntheticSideRow(
|
|
1103
|
-
return
|
|
1103
|
+
function isSyntheticSideRow(id2) {
|
|
1104
|
+
return id2.startsWith(SCREENSHOT_MESSAGE_ID_PREFIX) || id2.startsWith(RICH_PARTS_MESSAGE_ID_PREFIX);
|
|
1104
1105
|
}
|
|
1105
1106
|
function mergeRichPartMirrorMessages(messages, sameTurnGroup) {
|
|
1106
1107
|
const merged = [];
|
|
@@ -1420,12 +1421,12 @@ function isWorkflowArmEntryType(type) {
|
|
|
1420
1421
|
function workflowContainerRunsHitlArm(container) {
|
|
1421
1422
|
return typeof container === "string" && WORKFLOW_HITL_ARM_CONTAINERS.includes(container);
|
|
1422
1423
|
}
|
|
1423
|
-
function workflowHitlArmUnsupportedMessage(type,
|
|
1424
|
+
function workflowHitlArmUnsupportedMessage(type, id2, container) {
|
|
1424
1425
|
const legal = WORKFLOW_HITL_ARM_CONTAINERS.map((c) => `\`${c}\``).join(" / ");
|
|
1425
|
-
return `the engine does not run \`${type}\` inside a \`${container}\` yet (node "${
|
|
1426
|
+
return `the engine does not run \`${type}\` inside a \`${container}\` yet (node "${id2}") \u2014 place it at the top level, as a ${legal} arm, or inside a child \`workflow\``;
|
|
1426
1427
|
}
|
|
1427
|
-
function workflowHitlArmShapeMessage(type,
|
|
1428
|
-
return shape === "mapped-arm" ? `\`${type}\` arm "${
|
|
1428
|
+
function workflowHitlArmShapeMessage(type, id2, shape) {
|
|
1429
|
+
return shape === "mapped-arm" ? `\`${type}\` arm "${id2}" takes the previous output as its payload \u2014 it cannot head a [mapping, step] chain; map before the container instead` : `a chunked foreach hands each child a slice of items, not one \u2014 \`${type}\` body "${id2}" takes one item; drop \`chunk\``;
|
|
1429
1430
|
}
|
|
1430
1431
|
function isModelIdSentinel(input) {
|
|
1431
1432
|
const lower = (input ?? "").trim().toLowerCase();
|
|
@@ -2103,12 +2104,12 @@ function decodeLogCursor(raw) {
|
|
|
2103
2104
|
return null;
|
|
2104
2105
|
}
|
|
2105
2106
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
2106
|
-
const { t, id } = parsed;
|
|
2107
|
+
const { t, id: id2 } = parsed;
|
|
2107
2108
|
if (typeof t !== "number" || !Number.isSafeInteger(t) || t < 0) return null;
|
|
2108
|
-
if (typeof
|
|
2109
|
+
if (typeof id2 !== "string" || !id2 || id2.length > LOG_CURSOR_MAX_ID_LENGTH) return null;
|
|
2109
2110
|
return {
|
|
2110
2111
|
t,
|
|
2111
|
-
id
|
|
2112
|
+
id: id2
|
|
2112
2113
|
};
|
|
2113
2114
|
}
|
|
2114
2115
|
function parseLogTimeBound(raw, now = /* @__PURE__ */ new Date()) {
|
|
@@ -2346,62 +2347,62 @@ function isKnownProfile(profiles, profileId) {
|
|
|
2346
2347
|
function hasCapability(profiles, profileId, required) {
|
|
2347
2348
|
return capabilitiesFor(profiles, profileId).includes(required);
|
|
2348
2349
|
}
|
|
2349
|
-
function workflowJobId(
|
|
2350
|
-
switch (
|
|
2350
|
+
function workflowJobId(id2) {
|
|
2351
|
+
switch (id2.kind) {
|
|
2351
2352
|
case "start":
|
|
2352
|
-
return `wft_${
|
|
2353
|
+
return `wft_${id2.runId}_0`;
|
|
2353
2354
|
case "start-redrive":
|
|
2354
|
-
return `wft_${
|
|
2355
|
+
return `wft_${id2.runId}_start_r${id2.now}`;
|
|
2355
2356
|
case "tick":
|
|
2356
|
-
return `wft_${
|
|
2357
|
+
return `wft_${id2.runId}_${id2.seq}`;
|
|
2357
2358
|
case "timer":
|
|
2358
|
-
return `wft_${
|
|
2359
|
+
return `wft_${id2.runId}_timer_${id2.stepId}_${id2.attempt}`;
|
|
2359
2360
|
case "timer-remainder":
|
|
2360
|
-
return `wft_${
|
|
2361
|
+
return `wft_${id2.runId}_timer_${id2.stepId}_${id2.attempt}_r${id2.now}`;
|
|
2361
2362
|
case "timer-deferral":
|
|
2362
|
-
return `wft_${
|
|
2363
|
+
return `wft_${id2.runId}_timer_${id2.stepId}_${id2.attempt}_d${id2.now}`;
|
|
2363
2364
|
case "timer-sibling":
|
|
2364
|
-
return `wft_${
|
|
2365
|
+
return `wft_${id2.runId}_timer_${id2.stepId}_${id2.attempt}_w${id2.now}`;
|
|
2365
2366
|
case "retry":
|
|
2366
|
-
return `wft_${
|
|
2367
|
+
return `wft_${id2.runId}_retry_${id2.stepId}_${id2.attempt}`;
|
|
2367
2368
|
case "respawn":
|
|
2368
|
-
return `wft_${
|
|
2369
|
+
return `wft_${id2.runId}_respawn_${id2.stepId}_${id2.attempt}_s${id2.segment}_r${id2.now}`;
|
|
2369
2370
|
case "redrive":
|
|
2370
|
-
return `wft_${
|
|
2371
|
+
return `wft_${id2.runId}_redrive_${id2.stepId}_${id2.attempt}_r${id2.now}`;
|
|
2371
2372
|
case "redispatch":
|
|
2372
|
-
return `wft_${
|
|
2373
|
+
return `wft_${id2.runId}_redispatch_${id2.stepId}_${id2.attempt}_x${id2.executionId ?? "none"}_r${id2.now}`;
|
|
2373
2374
|
case "expiry":
|
|
2374
|
-
return `wft_${
|
|
2375
|
+
return `wft_${id2.runId}_expire_${id2.stepId}_${id2.attempt}_t${id2.suspendedAt}${id2.hop > 0 ? `_h${id2.hop}` : ""}`;
|
|
2375
2376
|
case "step-terminal":
|
|
2376
|
-
return `wft_${
|
|
2377
|
+
return `wft_${id2.runId}_term_${id2.stepId}_${id2.attempt}_r${id2.now}`;
|
|
2377
2378
|
case "handback":
|
|
2378
|
-
return `wft_${
|
|
2379
|
+
return `wft_${id2.runId}_handback_${id2.stepId}_${id2.attempt}_${id2.now}`;
|
|
2379
2380
|
case "foreach-rate":
|
|
2380
|
-
return `wft_${
|
|
2381
|
+
return `wft_${id2.runId}_fe_${id2.stepId}_${id2.attempt}_${id2.bucket}`;
|
|
2381
2382
|
case "budget-expiry":
|
|
2382
|
-
return `wft_${
|
|
2383
|
+
return `wft_${id2.runId}_expiry_budget_r${id2.now}`;
|
|
2383
2384
|
case "budget-resume":
|
|
2384
|
-
return `wft_${
|
|
2385
|
+
return `wft_${id2.runId}_resume_budget_${id2.now}`;
|
|
2385
2386
|
case "deadline":
|
|
2386
|
-
return `wft_${
|
|
2387
|
+
return `wft_${id2.runId}_deadline_${id2.deadlineAt}`;
|
|
2387
2388
|
case "deadline-remainder":
|
|
2388
|
-
return `wft_${
|
|
2389
|
+
return `wft_${id2.runId}_deadline_${id2.deadlineAt}_r${id2.now}`;
|
|
2389
2390
|
case "readmit":
|
|
2390
|
-
return `wft_${
|
|
2391
|
+
return `wft_${id2.runId}_readmit_${id2.now}`;
|
|
2391
2392
|
case "cancel":
|
|
2392
|
-
return `wft_${
|
|
2393
|
+
return `wft_${id2.runId}_cancel`;
|
|
2393
2394
|
case "reconcile":
|
|
2394
|
-
return `wft_${
|
|
2395
|
+
return `wft_${id2.runId}_reconcile_${id2.now}`;
|
|
2395
2396
|
case "replay":
|
|
2396
|
-
return `wft_${
|
|
2397
|
+
return `wft_${id2.runId}_replay_g${id2.leaseGeneration}`;
|
|
2397
2398
|
case "migration":
|
|
2398
|
-
return `wfm_${
|
|
2399
|
+
return `wfm_${id2.migrationId}`;
|
|
2399
2400
|
default:
|
|
2400
|
-
return assertNever(
|
|
2401
|
+
return assertNever(id2);
|
|
2401
2402
|
}
|
|
2402
2403
|
}
|
|
2403
|
-
function assertNever(
|
|
2404
|
-
throw new Error(`workflowJobId: unknown wake kind ${JSON.stringify(
|
|
2404
|
+
function assertNever(id2) {
|
|
2405
|
+
throw new Error(`workflowJobId: unknown wake kind ${JSON.stringify(id2)}`);
|
|
2405
2406
|
}
|
|
2406
2407
|
function agentStepJobId(msg) {
|
|
2407
2408
|
return `${msg.runId}_${msg.stepId}_${msg.attempt}_x${msg.executionId}`;
|
|
@@ -2439,11 +2440,11 @@ function isArchiveWindowTooOld(run, retentionDays, now = Date.now(), marginDays
|
|
|
2439
2440
|
function workflowOrgPurgingKey(orgId) {
|
|
2440
2441
|
return `wf:org:${orgId}:purging`;
|
|
2441
2442
|
}
|
|
2442
|
-
function isCloudTaskRunId(
|
|
2443
|
-
return
|
|
2443
|
+
function isCloudTaskRunId(id2) {
|
|
2444
|
+
return id2.startsWith(CLOUD_TASK_RUN_ID_PREFIX);
|
|
2444
2445
|
}
|
|
2445
|
-
function isScheduledWorkflowRunId(
|
|
2446
|
-
return
|
|
2446
|
+
function isScheduledWorkflowRunId(id2) {
|
|
2447
|
+
return id2.startsWith(WORKFLOW_SCHEDULED_RUN_ID_PREFIX);
|
|
2447
2448
|
}
|
|
2448
2449
|
function scheduledWorkflowRunId(jobId, scheduledTime) {
|
|
2449
2450
|
const key = typeof scheduledTime === "number" ? String(scheduledTime) : scheduledTimeKey(scheduledTime);
|
|
@@ -2804,7 +2805,13 @@ function effectiveAgentFeatures(base, override, rule) {
|
|
|
2804
2805
|
if (rule === "wholesale") return override || base || void 0;
|
|
2805
2806
|
return effectiveAgentFeatureRows(base, override).rows;
|
|
2806
2807
|
}
|
|
2807
|
-
|
|
2808
|
+
function parseOnboardingFlow(value3) {
|
|
2809
|
+
return onboardingFlowSchema.parse(value3);
|
|
2810
|
+
}
|
|
2811
|
+
function parsePublishedOnboardingResponse(value3) {
|
|
2812
|
+
return getPublishedOnboardingResponseSchema.parse(value3);
|
|
2813
|
+
}
|
|
2814
|
+
var __defProp2, __name2, PLUMBING_THREAD_CHANNELS, CHANNEL_CONVERSATION_CHANNELS, HIDDEN_THREAD_CHANNELS, REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST, REVIEWABLE_STANDING_START_TOOLS, REVIEWABLE_MCP_SEND_TOOL_SUFFIX, MCP_TOOL_READ_VERB_RE, MCP_DRAFT_CREATE_VERBS, NON_INTERACTIVE_CHANNELS, RICH_PARTS_MESSAGE_ID_PREFIX, SCREENSHOT_MESSAGE_ID_PREFIX, BROWSER_COMMANDS, BROWSER_COMMAND_NAMES, LOG_FIELDS_MAX_KEYS, LOG_FIELD_MAX_VALUE_BYTES, LOG_FIELDS_MAX_BYTES, LOG_FIELD_KEY_PATTERN, LOG_FIELD_SECRET_SHAPED_KEY_PATTERNS, LOG_FIELDS_CLAMPED_KEY, LOG_FIELD_ARRAY_COUNT_SUFFIX, LuaLogFieldsError, DESKTOP_FILE_COMMANDS, DESKTOP_FILE_COMMAND_SET, WORKFLOW_RETRY_BACKOFFS, WORKFLOW_RETRY_MIN_ATTEMPTS, WORKFLOW_RETRY_POLICY_KEYS, WORKFLOW_RETRY_MAX_ATTEMPTS, WORKFLOW_RETRY_ENGINE_KEYS, WORKFLOW_JOB_RESOURCES, WORKFLOW_SIDE_EFFECTS, WORKFLOW_AGENT_EFFORTS, WORKFLOW_MODEL_CLASSES, WORKFLOW_TASK_CLASSES, WORKFLOW_MODEL_TRAITS, WORKFLOW_MODEL_REASON_MAX_LENGTH, WORKFLOW_MODELS_COMPOSE_MODES, WORKFLOW_MODELS_PIN_MODES, WORKFLOW_MODELS_FALLBACK_MODES, WORKFLOW_MODELS_CONSENT_ACTIONS_MIN, WORKFLOW_DEFAULT_TASK_CLASS_MAP, WORKFLOW_MODELS_MAX_CLASS_DEFAULT, WORKFLOW_AUTONOMY_FORMS, WORKFLOW_AUTONOMY_NUMERIC_KEYS, WORKFLOW_AUTONOMY_ENVELOPE_KEYS, WORKFLOW_AUTONOMY_ENABLED_DEFAULT, WORKFLOW_AUTONOMY_DEFAULTS, WORKFLOW_AUTONOMY_CEILINGS, WORKFLOW_AUTONOMY_MAX_RUNS_PER_HOUR_ENV, WORKFLOW_AUTONOMY_MAX_RUNS_PER_HOUR_CEILING, WORKFLOW_AUTONOMY_FORMS_DEFAULT, WORKFLOW_AUTONOMY_MIN_VALUE, WORKFLOW_JOB_RANGES, WORKFLOW_JOB_RANGE_MEMBERS, WORKFLOW_SINGLE_STEP_TYPES, WORKFLOW_HITL_ENTRY_TYPES, WORKFLOW_ARM_ENTRY_TYPES, WORKFLOW_HITL_ARM_CONTAINERS, WORKFLOW_GRAPH_ENTRY_STEP_KINDS, WORKFLOW_ARM_ENTRY_STEP_KINDS, WORKFLOW_BUDGET_MAX_DURATION_SECONDS, MODEL_ID_BYOK_PROVIDERS, MODEL_CLASS_REF_PREFIX, MODEL_SNAPSHOT_SUFFIX, REASONING_EFFORT_VALUES, IMPLICIT_MODEL_SELECTION_SOURCES, PLATFORM_FALLBACK_MODEL_SOURCE, AGENT_NAME_TOKEN, DEFAULT_PERSONA_GUIDE, PERSONAL_SPACE_STARTING_PERSONA, AGENT_LOG_SOURCES, AGENT_LOG_ENVIRONMENTS, AGENT_LOG_FIELDS_MAX_WIRE_KEYS, LOG_DRAIN_TYPES_PHASE1, LOG_DRAIN_TYPES_PHASE2, LOG_DRAIN_TYPES_IMPLEMENTED, LOG_DRAIN_FORMATS, LOG_DRAIN_SEVERITIES, LOG_DRAIN_SOURCES, LOG_DRAIN_CONTENT_SOURCES, LOG_DRAIN_DEFAULT_SOURCES, LOG_DRAIN_MAX_PER_ORG, LOG_DRAIN_MAX_PER_ORG_ENTERPRISE, LOG_DRAIN_DATADOG_SITES, LOG_DRAIN_NEWRELIC_SITES, LOG_DRAIN_ENDPOINT_TEMPLATES, LOG_DRAIN_PRESET_SITES, LOG_DRAIN_BUCKET_NAME_PATTERN, LOG_DRAIN_BUCKET_HOST_PATTERNS, LOG_DRAIN_PRESET_HOST_SUFFIXES, DRAIN_CONTENT_ACK_ERROR_CODE, DRAIN_CONTENT_ACK_FIELD, DrainContentAckRequiredError, LOG_DRAIN_PRESET_PATHS, PRESET_SEGMENT_RE, LOG_DRAIN_QUOTAS, LOG_DRAIN_QUOTA_WARN_RATIO, LOG_DRAIN_QUOTA_DROP_DEBUG_RATIO, LOG_DRAIN_QUOTA_DROP_INFO_RATIO, LOG_DRAIN_QUOTA_PAUSE_RATIO, LOG_EXPORT_SOURCES, LOG_EXPORT_MAX_WINDOW_DAYS, LOG_EXPORT_MAX_WINDOW_MS, LOG_EXPORT_URL_TTL_SECONDS, LOG_EXPORT_FILE_RETENTION_DAYS, LOG_EXPORT_FILE_RETENTION_MS, LOG_EXPORT_PART_MAX_BYTES, LOG_DRAIN_NOTICE_RATE_LIMIT_MS, LOG_DRAIN_VERIFICATION_STALE_MS, LOG_DRAIN_DIGEST_INTERVAL_MS, LOG_DRAIN_DIGEST_MAX_ENTRIES, LOG_DRAIN_NOTICE_ERROR_MAX_CHARS, LOG_DRAIN_USAGE_LINE_ITEM, LOG_DRAIN_BYTES_PER_GIB, DEFAULT_LOG_DRAIN_PLAN_CONFIG, TIERS, LOG_CURSOR_MAX_LENGTH, LOG_CURSOR_MAX_ID_LENGTH, LOG_RELATIVE_TIME_PATTERN, LOG_ISO_TIME_PATTERN, RELATIVE_UNIT_MS, CORE_DRAINING_CODE, CORE_DRAINING_DEFAULT_RETRY_MS, CORE_DRAINING_MAX_RETRY_MS, VoiceNameSchema, PluginProviderSchema, RealtimeProviderSchema, PluginClassSchema, ModelDescriptorSchema, InferenceModelSchema, PluginModelSchema, RealtimeModelSchema, LuaVoiceModelSchema, TurnDetectionSchema, InterruptionSchema, BuiltinAudioClipSchema, AudioConfigSchema, BackgroundAudioEntrySchema, BackgroundAudioSchema, LuaVoiceConfigInnerSchema, LuaVoiceConfigSchema, LuaVoiceRefSchema, EventType, LUA_JOB_DEFAULT_TIMEOUT_SECONDS, LUA_JOB_MIN_TIMEOUT_SECONDS, LUA_JOB_MAX_TIMEOUT_SECONDS, KEYS, MAX_BODY_BYTES, MAX_ID_LENGTH, UTC_ISO, TEMPLATE_TRIGGER_URL_ENV_PREFIX, TEMPLATE_INSTALL_POLICY_PER_WORKSPACE_VALUES, SUBJECT_TYPES, SubjectTypeSchema, CREDENTIAL_TYPES, CredentialTypeSchema, DEVICE_OPERATIONS, DeviceOperationSchema, DEVICE_SCOPE_BY_OPERATION, DeviceBindingSchema, TYPED_API_KEY, IdSchema, SESSION_AUTH_TIME_MAX_S, PrincipalDescriptorSchema, ActorDescriptorSchema, PrincipalOwnerSchema, CredentialLifecycleSchema, GeneralCredentialDescriptorSchema, DeviceCredentialDescriptorSchema, GeneralPrincipalContextSchema, DeviceCredentialPrincipalContextSchema, RawPrincipalContextSchema, PrincipalContextSchema, DeviceCredentialClaimSchema, LUA_CLIENT_HEADER, LUA_CLIENT_APPS, SEMVER_PATTERN, WEB_RELEASE_PATTERN, CLIENT_HEADER_PATTERN, LUA_SESSION_ID_CLAIM, SESSION_REVOKED_CODE, AUTHZ_PROJECTION_VERSION, ProjectedScopeSchema, DisplayRoleSchema, AuthorizationPrincipalSchema, CredentialContextSchema, ProjectionAnomalySchema, ProjectedOrgSchema, ProjectedResourceSchema, CapabilityProfilesSchema, RoleCatalogSchema, EffectiveAuthorizationSchema, ResourcePageSchema, SYSTEM_USER_PREFIX, WORKFLOW_RUN_IN_FLIGHT, WORKFLOW_RUN_IDLE, WORKFLOW_RUN_TERMINAL, WORKFLOW_RUN_STATUSES, WORKFLOW_RUN_GATE_KINDS, WORKFLOW_STEP_STATUSES, WORKFLOW_STEP_IN_FLIGHT, WORKFLOW_SIGNAL_EVENT_SITES, ARCHIVE_WINDOW_MARGIN_DAYS, WORKFLOW_ORG_PURGING_TTL_S, WORKFLOW_ORG_PURGE_FORCE_AFTER_MS, IDEMPOTENCY_HOLDING_STATUSES, WORKFLOW_SCHEDULED_RUN_ID_PREFIX, CLOUD_TASK_RUN_ID_PREFIX, WORKFLOW_SCHEDULE_KEY_MAX, WORKFLOW_SCHEDULE_IDEMPOTENCY_KEY_PREFIX, WORKFLOW_OPERATION_ID_PREFIX, WORKFLOW_JOURNAL_PROTOCOL_VERSION, WORKFLOW_CONNECTION_KEY_RE, WORKFLOW_JOB_MODEL_SOURCE_LABELS, WORKFLOW_SUSPEND_KINDS, WORKFLOW_RUN_NOTIFICATION_SUSPENDED_KINDS, WORKFLOW_SIGNAL_PAYLOAD_MAX_BYTES, WORKFLOW_RESOLVE_OUTPUT_MAX_BYTES, WORKFLOW_GOAL_JUDGE_SELF, REDACTED_PLACEHOLDER, PROVIDER_MESSAGE_MAX_CHARS, ERROR_MESSAGE_MAX_CHARS, SECRET_LITERAL_PATTERNS, SECRET_NAME, SECRET_PAIR_PATTERNS, GROUP_COUNT, WORKFLOW_SECRET_KEY_RE, WORKFLOW_RESERVED_SECRET_KEYS, SCRUB_INPUT_MAX_CHARS, SCRUB_CUT_BACKOFF_CHARS, WORKFLOW_AUDIT_EVENTS, WORKFLOW_AUDIT_METADATA_MAX_BYTES, INDENT, WRAP_WIDTH, NOUNS, GET_TOOL_NAMES, PREAMBLE, WORKFLOW_APPROVAL_OUTPUT_DECISIONS, WORKFLOW_APPROVAL_OUTPUT_SCHEMA, JSON_FENCE_RE, DEFAULT_ON_AGENT_FEATURES, SUBAGENT_PER_KEY_FLAG_ENV, PER_KEY_FLAG_VALUES, ONBOARDING_FLOW_KEY, ONBOARDING_SCHEMA_VERSION, id, copy, onboardingHeadingSchema, onboardingRichTextInlineSchema, onboardingRichTextSchema, onboardingDestinationSchema, onboardingArtworkSchema, onboardingAnswerSchema, onboardingQuestionSchema, onboardingTemplateSectionSchema, onboardingTemplateContentSchema, onboardingUnavailableOutcomeSchema, onboardingFlowSchema, onboardingActorSchema, onboardingEditorSchema, onboardingPublicationSummarySchema, onboardingValidationIssueSchema, onboardingValidationResponseSchema, onboardingAssetSchema, onboardingPublicAssetSchema, getOnboardingConfigResponseSchema, saveOnboardingDraftRequestSchema, validateOnboardingRequestSchema, publishOnboardingRequestSchema, rollbackOnboardingRequestSchema, onboardingTemplateCatalogItemSchema, getPublishedOnboardingResponseSchema;
|
|
2808
2815
|
var init_dist = __esm({
|
|
2809
2816
|
"../shared-types/dist/index.mjs"() {
|
|
2810
2817
|
"use strict";
|
|
@@ -5071,6 +5078,236 @@ listed here; never invent a target.`;
|
|
|
5071
5078
|
__name2(agentFeatureMergeRuleFromEnv, "agentFeatureMergeRuleFromEnv");
|
|
5072
5079
|
__name(effectiveAgentFeatures, "effectiveAgentFeatures");
|
|
5073
5080
|
__name2(effectiveAgentFeatures, "effectiveAgentFeatures");
|
|
5081
|
+
ONBOARDING_FLOW_KEY = "alpha-choose-meet";
|
|
5082
|
+
ONBOARDING_SCHEMA_VERSION = 1;
|
|
5083
|
+
id = z4.string().min(1).max(80).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/);
|
|
5084
|
+
copy = /* @__PURE__ */ __name2((max) => z4.string().max(max), "copy");
|
|
5085
|
+
onboardingHeadingSchema = z4.discriminatedUnion("kind", [
|
|
5086
|
+
z4.object({
|
|
5087
|
+
kind: z4.literal("plain"),
|
|
5088
|
+
text: copy(240)
|
|
5089
|
+
}).strict(),
|
|
5090
|
+
z4.object({
|
|
5091
|
+
kind: z4.literal("highlighted"),
|
|
5092
|
+
before: copy(240),
|
|
5093
|
+
highlight: copy(240),
|
|
5094
|
+
after: copy(240)
|
|
5095
|
+
}).strict()
|
|
5096
|
+
]);
|
|
5097
|
+
onboardingRichTextInlineSchema = z4.discriminatedUnion("kind", [
|
|
5098
|
+
z4.object({
|
|
5099
|
+
kind: z4.literal("text"),
|
|
5100
|
+
text: copy(2e3),
|
|
5101
|
+
marks: z4.array(z4.enum([
|
|
5102
|
+
"bold",
|
|
5103
|
+
"italic"
|
|
5104
|
+
])).max(2).refine((marks) => new Set(marks).size === marks.length, "Text marks must be unique").optional()
|
|
5105
|
+
}).strict(),
|
|
5106
|
+
z4.object({
|
|
5107
|
+
kind: z4.literal("lineBreak")
|
|
5108
|
+
}).strict()
|
|
5109
|
+
]);
|
|
5110
|
+
onboardingRichTextSchema = z4.object({
|
|
5111
|
+
blocks: z4.array(z4.object({
|
|
5112
|
+
kind: z4.literal("paragraph"),
|
|
5113
|
+
content: z4.array(onboardingRichTextInlineSchema).max(100)
|
|
5114
|
+
}).strict()).max(40)
|
|
5115
|
+
}).strict();
|
|
5116
|
+
onboardingDestinationSchema = z4.discriminatedUnion("kind", [
|
|
5117
|
+
z4.object({
|
|
5118
|
+
kind: z4.literal("question"),
|
|
5119
|
+
questionId: id
|
|
5120
|
+
}).strict(),
|
|
5121
|
+
z4.object({
|
|
5122
|
+
kind: z4.literal("template"),
|
|
5123
|
+
templateContentId: id
|
|
5124
|
+
}).strict(),
|
|
5125
|
+
z4.object({
|
|
5126
|
+
kind: z4.literal("unavailable"),
|
|
5127
|
+
unavailableId: id
|
|
5128
|
+
}).strict()
|
|
5129
|
+
]);
|
|
5130
|
+
onboardingArtworkSchema = z4.discriminatedUnion("kind", [
|
|
5131
|
+
z4.object({
|
|
5132
|
+
kind: z4.literal("builtinRing")
|
|
5133
|
+
}).strict(),
|
|
5134
|
+
z4.object({
|
|
5135
|
+
kind: z4.literal("uploaded"),
|
|
5136
|
+
assetId: id,
|
|
5137
|
+
accessibility: z4.discriminatedUnion("kind", [
|
|
5138
|
+
z4.object({
|
|
5139
|
+
kind: z4.literal("decorative")
|
|
5140
|
+
}).strict(),
|
|
5141
|
+
z4.object({
|
|
5142
|
+
kind: z4.literal("described"),
|
|
5143
|
+
altText: copy(500)
|
|
5144
|
+
}).strict()
|
|
5145
|
+
])
|
|
5146
|
+
}).strict()
|
|
5147
|
+
]);
|
|
5148
|
+
onboardingAnswerSchema = z4.object({
|
|
5149
|
+
id,
|
|
5150
|
+
label: copy(160),
|
|
5151
|
+
supportingText: copy(500).optional(),
|
|
5152
|
+
destination: onboardingDestinationSchema.nullable()
|
|
5153
|
+
}).strict();
|
|
5154
|
+
onboardingQuestionSchema = z4.object({
|
|
5155
|
+
id,
|
|
5156
|
+
heading: onboardingHeadingSchema,
|
|
5157
|
+
helperText: onboardingRichTextSchema.optional(),
|
|
5158
|
+
continueButtonLabel: copy(80),
|
|
5159
|
+
answers: z4.array(onboardingAnswerSchema).max(30)
|
|
5160
|
+
}).strict();
|
|
5161
|
+
onboardingTemplateSectionSchema = z4.object({
|
|
5162
|
+
id,
|
|
5163
|
+
label: copy(100),
|
|
5164
|
+
body: onboardingRichTextSchema
|
|
5165
|
+
}).strict();
|
|
5166
|
+
onboardingTemplateContentSchema = z4.object({
|
|
5167
|
+
id,
|
|
5168
|
+
templateId: copy(160),
|
|
5169
|
+
displayName: copy(100),
|
|
5170
|
+
eyebrow: copy(100).optional(),
|
|
5171
|
+
heading: onboardingHeadingSchema,
|
|
5172
|
+
description: onboardingRichTextSchema,
|
|
5173
|
+
badges: z4.array(copy(80)).max(12),
|
|
5174
|
+
sections: z4.array(onboardingTemplateSectionSchema).max(20),
|
|
5175
|
+
artwork: onboardingArtworkSchema,
|
|
5176
|
+
hireButtonLabel: copy(80),
|
|
5177
|
+
changeRoleButtonLabel: copy(80),
|
|
5178
|
+
nextStepText: onboardingRichTextSchema
|
|
5179
|
+
}).strict();
|
|
5180
|
+
onboardingUnavailableOutcomeSchema = z4.object({
|
|
5181
|
+
id,
|
|
5182
|
+
heading: onboardingHeadingSchema,
|
|
5183
|
+
explanation: onboardingRichTextSchema,
|
|
5184
|
+
backButtonLabel: copy(80),
|
|
5185
|
+
alternative: z4.object({
|
|
5186
|
+
templateContentId: id,
|
|
5187
|
+
introduction: onboardingRichTextSchema,
|
|
5188
|
+
buttonLabel: copy(80)
|
|
5189
|
+
}).strict().optional()
|
|
5190
|
+
}).strict();
|
|
5191
|
+
onboardingFlowSchema = z4.object({
|
|
5192
|
+
key: z4.literal(ONBOARDING_FLOW_KEY),
|
|
5193
|
+
schemaVersion: z4.literal(ONBOARDING_SCHEMA_VERSION),
|
|
5194
|
+
entryQuestionId: id.nullable(),
|
|
5195
|
+
questions: z4.array(onboardingQuestionSchema).max(100),
|
|
5196
|
+
templateContents: z4.array(onboardingTemplateContentSchema).max(100),
|
|
5197
|
+
unavailableOutcomes: z4.array(onboardingUnavailableOutcomeSchema).max(100)
|
|
5198
|
+
}).strict();
|
|
5199
|
+
onboardingActorSchema = z4.object({
|
|
5200
|
+
subjectId: z4.string(),
|
|
5201
|
+
email: z4.string().email()
|
|
5202
|
+
}).strict();
|
|
5203
|
+
onboardingEditorSchema = onboardingActorSchema.extend({
|
|
5204
|
+
editedAt: z4.string().datetime({
|
|
5205
|
+
offset: true
|
|
5206
|
+
})
|
|
5207
|
+
}).strict();
|
|
5208
|
+
onboardingPublicationSummarySchema = z4.object({
|
|
5209
|
+
publicationId: id,
|
|
5210
|
+
revision: z4.number().int().positive(),
|
|
5211
|
+
sourceDraftVersion: z4.number().int().nonnegative(),
|
|
5212
|
+
contentHash: z4.string().regex(/^[a-f0-9]{64}$/),
|
|
5213
|
+
publishedAt: z4.string().datetime({
|
|
5214
|
+
offset: true
|
|
5215
|
+
}),
|
|
5216
|
+
publishedBy: onboardingActorSchema,
|
|
5217
|
+
questionCount: z4.number().int().nonnegative(),
|
|
5218
|
+
templateCount: z4.number().int().nonnegative(),
|
|
5219
|
+
unavailableCount: z4.number().int().nonnegative()
|
|
5220
|
+
}).strict();
|
|
5221
|
+
onboardingValidationIssueSchema = z4.object({
|
|
5222
|
+
code: z4.string(),
|
|
5223
|
+
path: z4.string(),
|
|
5224
|
+
message: z4.string()
|
|
5225
|
+
}).strict();
|
|
5226
|
+
onboardingValidationResponseSchema = z4.discriminatedUnion("valid", [
|
|
5227
|
+
z4.object({
|
|
5228
|
+
valid: z4.literal(true),
|
|
5229
|
+
summary: z4.object({
|
|
5230
|
+
questionCount: z4.number().int().nonnegative(),
|
|
5231
|
+
templateCount: z4.number().int().nonnegative(),
|
|
5232
|
+
unavailableCount: z4.number().int().nonnegative()
|
|
5233
|
+
}).strict()
|
|
5234
|
+
}).strict(),
|
|
5235
|
+
z4.object({
|
|
5236
|
+
valid: z4.literal(false),
|
|
5237
|
+
issues: z4.array(onboardingValidationIssueSchema)
|
|
5238
|
+
}).strict()
|
|
5239
|
+
]);
|
|
5240
|
+
onboardingAssetSchema = z4.object({
|
|
5241
|
+
assetId: id,
|
|
5242
|
+
url: z4.string().url(),
|
|
5243
|
+
width: z4.number().int().positive(),
|
|
5244
|
+
height: z4.number().int().positive(),
|
|
5245
|
+
contentType: z4.enum([
|
|
5246
|
+
"image/png",
|
|
5247
|
+
"image/jpeg",
|
|
5248
|
+
"image/webp"
|
|
5249
|
+
]),
|
|
5250
|
+
bytes: z4.number().int().positive(),
|
|
5251
|
+
sha256: z4.string().regex(/^[a-f0-9]{64}$/),
|
|
5252
|
+
createdAt: z4.string().datetime({
|
|
5253
|
+
offset: true
|
|
5254
|
+
}),
|
|
5255
|
+
uploadedBy: onboardingActorSchema
|
|
5256
|
+
}).strict();
|
|
5257
|
+
onboardingPublicAssetSchema = onboardingAssetSchema.pick({
|
|
5258
|
+
assetId: true,
|
|
5259
|
+
url: true,
|
|
5260
|
+
width: true,
|
|
5261
|
+
height: true,
|
|
5262
|
+
contentType: true
|
|
5263
|
+
}).strict();
|
|
5264
|
+
getOnboardingConfigResponseSchema = z4.object({
|
|
5265
|
+
flowKey: z4.literal(ONBOARDING_FLOW_KEY),
|
|
5266
|
+
draftVersion: z4.number().int().nonnegative(),
|
|
5267
|
+
draft: onboardingFlowSchema,
|
|
5268
|
+
assets: z4.array(onboardingAssetSchema),
|
|
5269
|
+
lastEditor: onboardingEditorSchema.nullable(),
|
|
5270
|
+
activePublication: onboardingPublicationSummarySchema.nullable()
|
|
5271
|
+
}).strict();
|
|
5272
|
+
saveOnboardingDraftRequestSchema = z4.object({
|
|
5273
|
+
expectedDraftVersion: z4.number().int().nonnegative(),
|
|
5274
|
+
draft: onboardingFlowSchema
|
|
5275
|
+
}).strict();
|
|
5276
|
+
validateOnboardingRequestSchema = z4.object({
|
|
5277
|
+
draft: onboardingFlowSchema
|
|
5278
|
+
}).strict();
|
|
5279
|
+
publishOnboardingRequestSchema = z4.object({
|
|
5280
|
+
expectedDraftVersion: z4.number().int().nonnegative(),
|
|
5281
|
+
expectedActivePublicationId: id.nullable()
|
|
5282
|
+
}).strict();
|
|
5283
|
+
rollbackOnboardingRequestSchema = z4.object({
|
|
5284
|
+
publicationId: id,
|
|
5285
|
+
expectedActivePublicationId: id.nullable()
|
|
5286
|
+
}).strict();
|
|
5287
|
+
onboardingTemplateCatalogItemSchema = z4.object({
|
|
5288
|
+
templateId: z4.string(),
|
|
5289
|
+
name: z4.string(),
|
|
5290
|
+
description: z4.string().optional()
|
|
5291
|
+
}).strict();
|
|
5292
|
+
getPublishedOnboardingResponseSchema = z4.discriminatedUnion("status", [
|
|
5293
|
+
z4.object({
|
|
5294
|
+
status: z4.literal("available"),
|
|
5295
|
+
publicationId: id,
|
|
5296
|
+
revision: z4.number().int().positive(),
|
|
5297
|
+
contentHash: z4.string().regex(/^[a-f0-9]{64}$/),
|
|
5298
|
+
flow: onboardingFlowSchema,
|
|
5299
|
+
assets: z4.array(onboardingPublicAssetSchema)
|
|
5300
|
+
}).strict(),
|
|
5301
|
+
z4.object({
|
|
5302
|
+
status: z4.literal("unavailable"),
|
|
5303
|
+
reason: z4.literal("not_published"),
|
|
5304
|
+
message: z4.string()
|
|
5305
|
+
}).strict()
|
|
5306
|
+
]);
|
|
5307
|
+
__name(parseOnboardingFlow, "parseOnboardingFlow");
|
|
5308
|
+
__name2(parseOnboardingFlow, "parseOnboardingFlow");
|
|
5309
|
+
__name(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
|
|
5310
|
+
__name2(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
|
|
5074
5311
|
}
|
|
5075
5312
|
});
|
|
5076
5313
|
|
|
@@ -5111,7 +5348,7 @@ var init_lua_fetch = __esm({
|
|
|
5111
5348
|
});
|
|
5112
5349
|
|
|
5113
5350
|
// src/services/firebase-session.ts
|
|
5114
|
-
import { z as
|
|
5351
|
+
import { z as z5 } from "zod";
|
|
5115
5352
|
function rejectedRefreshReason(message) {
|
|
5116
5353
|
const normalised = message.toUpperCase();
|
|
5117
5354
|
return REJECTED_REFRESH_REASONS.find((reason) => normalised.includes(reason));
|
|
@@ -5257,20 +5494,20 @@ var init_firebase_session = __esm({
|
|
|
5257
5494
|
this.name = "FirebaseSessionRejectedError";
|
|
5258
5495
|
}
|
|
5259
5496
|
};
|
|
5260
|
-
customTokenResponseSchema =
|
|
5261
|
-
idToken:
|
|
5262
|
-
refreshToken:
|
|
5263
|
-
expiresIn:
|
|
5264
|
-
localId:
|
|
5497
|
+
customTokenResponseSchema = z5.object({
|
|
5498
|
+
idToken: z5.string().min(1),
|
|
5499
|
+
refreshToken: z5.string().min(1),
|
|
5500
|
+
expiresIn: z5.coerce.number().positive().finite(),
|
|
5501
|
+
localId: z5.string().min(1).optional()
|
|
5265
5502
|
});
|
|
5266
|
-
refreshResponseSchema =
|
|
5267
|
-
id_token:
|
|
5268
|
-
refresh_token:
|
|
5269
|
-
expires_in:
|
|
5270
|
-
user_id:
|
|
5503
|
+
refreshResponseSchema = z5.object({
|
|
5504
|
+
id_token: z5.string().min(1),
|
|
5505
|
+
refresh_token: z5.string().min(1),
|
|
5506
|
+
expires_in: z5.coerce.number().positive().finite(),
|
|
5507
|
+
user_id: z5.string().min(1)
|
|
5271
5508
|
});
|
|
5272
|
-
firebaseIdTokenPayloadSchema =
|
|
5273
|
-
sub:
|
|
5509
|
+
firebaseIdTokenPayloadSchema = z5.object({
|
|
5510
|
+
sub: z5.string().min(1)
|
|
5274
5511
|
});
|
|
5275
5512
|
__name(requireFirebaseWebApiKey, "requireFirebaseWebApiKey");
|
|
5276
5513
|
__name(claimsOfFirebaseIdToken, "claimsOfFirebaseIdToken");
|
|
@@ -5287,7 +5524,7 @@ var init_firebase_session = __esm({
|
|
|
5287
5524
|
import { createHash, randomUUID } from "crypto";
|
|
5288
5525
|
import { mkdir, open, readFile, rename, rm, stat, unlink, writeFile } from "fs/promises";
|
|
5289
5526
|
import { join as join3 } from "path";
|
|
5290
|
-
import { z as
|
|
5527
|
+
import { z as z6 } from "zod";
|
|
5291
5528
|
function environmentKey(environment) {
|
|
5292
5529
|
return createHash("sha256").update(`${environment.apiUrl}
|
|
5293
5530
|
${environment.authUrl}
|
|
@@ -5304,15 +5541,15 @@ var init_firebase_session_store = __esm({
|
|
|
5304
5541
|
"src/services/firebase-session-store.ts"() {
|
|
5305
5542
|
"use strict";
|
|
5306
5543
|
init_constants();
|
|
5307
|
-
storedFirebaseSessionSchema =
|
|
5308
|
-
version:
|
|
5309
|
-
kind:
|
|
5310
|
-
generation:
|
|
5311
|
-
refreshToken:
|
|
5312
|
-
firebaseUid:
|
|
5313
|
-
apiUrl:
|
|
5314
|
-
authUrl:
|
|
5315
|
-
firebaseWebApiKey:
|
|
5544
|
+
storedFirebaseSessionSchema = z6.object({
|
|
5545
|
+
version: z6.literal(1),
|
|
5546
|
+
kind: z6.literal("firebase-session"),
|
|
5547
|
+
generation: z6.string().min(1),
|
|
5548
|
+
refreshToken: z6.string().min(1),
|
|
5549
|
+
firebaseUid: z6.string().min(1),
|
|
5550
|
+
apiUrl: z6.string().url(),
|
|
5551
|
+
authUrl: z6.string().url(),
|
|
5552
|
+
firebaseWebApiKey: z6.string().min(1)
|
|
5316
5553
|
});
|
|
5317
5554
|
currentFirebaseSessionEnvironment = /* @__PURE__ */ __name(() => ({
|
|
5318
5555
|
apiUrl: BASE_URLS.API,
|
|
@@ -5679,9 +5916,9 @@ var init_request_credential = __esm({
|
|
|
5679
5916
|
function effectiveJobTools(jobTools, readOnly) {
|
|
5680
5917
|
const base = jobTools?.length ? jobTools : WORKFLOW_JOB_DEFAULT_TOOLS;
|
|
5681
5918
|
const out = [];
|
|
5682
|
-
for (const
|
|
5683
|
-
if (readOnly && WORKFLOW_JOB_READ_ONLY_DROPPED.includes(
|
|
5684
|
-
if (!out.includes(
|
|
5919
|
+
for (const id2 of base) {
|
|
5920
|
+
if (readOnly && WORKFLOW_JOB_READ_ONLY_DROPPED.includes(id2)) continue;
|
|
5921
|
+
if (!out.includes(id2)) out.push(id2);
|
|
5685
5922
|
}
|
|
5686
5923
|
return out;
|
|
5687
5924
|
}
|
|
@@ -5725,7 +5962,7 @@ var init_workflow_job_tools = __esm({
|
|
|
5725
5962
|
|
|
5726
5963
|
// ../workflow-graph/dist/index.mjs
|
|
5727
5964
|
import { createHash as createHash2 } from "crypto";
|
|
5728
|
-
import { z as
|
|
5965
|
+
import { z as z7 } from "zod";
|
|
5729
5966
|
import { z as z22 } from "zod";
|
|
5730
5967
|
import { createHash as createHash22 } from "crypto";
|
|
5731
5968
|
function isMapConfigObject(v) {
|
|
@@ -5852,9 +6089,9 @@ function malformedMapMembers(cfg) {
|
|
|
5852
6089
|
}
|
|
5853
6090
|
return out;
|
|
5854
6091
|
}
|
|
5855
|
-
function mapMemberMalformedMessage(
|
|
6092
|
+
function mapMemberMalformedMessage(id2, m) {
|
|
5856
6093
|
const keys = m.keys.map((k) => `\`${k}\``).join(", ");
|
|
5857
|
-
return `"${
|
|
6094
|
+
return `"${id2}".${m.member} carries descriptor key${m.keys.length === 1 ? "" : "s"} ${keys} but is not an exact binding form ({initData:true, path} | {step, path[, rows]} | {value} | {template} | {requestContextPath} | {knowledge}) \u2014 it is passed to the step verbatim as a literal; fix the descriptor, or wrap it in {value: \u2026} if the literal is intended`;
|
|
5858
6095
|
}
|
|
5859
6096
|
function resolveDescriptor(key, m, ctx) {
|
|
5860
6097
|
if (!isMapDescriptor(m)) return {
|
|
@@ -6208,11 +6445,11 @@ function retryBackoffs() {
|
|
|
6208
6445
|
}
|
|
6209
6446
|
return WORKFLOW_RETRY_BACKOFFS;
|
|
6210
6447
|
}
|
|
6211
|
-
function sleepUntilUnsupportedMessage(
|
|
6212
|
-
return `the engine does not execute \`sleepUntil\` yet (node "${
|
|
6448
|
+
function sleepUntilUnsupportedMessage(id2) {
|
|
6449
|
+
return `the engine does not execute \`sleepUntil\` yet (node "${id2}") \u2014 replace it with a \`sleep\` node with a \`duration\` in ms, e.g. { type: 'sleep', id: '${id2}', duration: ${SLEEP_UNTIL_REPLACEMENT.duration} }`;
|
|
6213
6450
|
}
|
|
6214
|
-
function armSubrunUnsupportedMessage(
|
|
6215
|
-
return `the engine does not execute the implicit \`${workflowId}\` arm subrun (node "${
|
|
6451
|
+
function armSubrunUnsupportedMessage(id2, workflowId) {
|
|
6452
|
+
return `the engine does not execute the implicit \`${workflowId}\` arm subrun (node "${id2}") \u2014 a [map, step] container arm is the step itself with the map as its \`input\` since lua-cli 3.32.4; re-run \`lua compile\` with the current CLI (a hand-written artifact: put the map on the arm node's \`input\` and drop the \`workflow\` wrapper)`;
|
|
6216
6453
|
}
|
|
6217
6454
|
function fillPolicy(node, defaultTimeout) {
|
|
6218
6455
|
if (node.tier === void 0 && node.workspace !== void 0 && node.workspace !== "inherit") node.tier = "job";
|
|
@@ -6472,20 +6709,20 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
|
|
|
6472
6709
|
const seen = /* @__PURE__ */ new Map();
|
|
6473
6710
|
let nodeCount = 0;
|
|
6474
6711
|
const upstream = /* @__PURE__ */ new Set();
|
|
6475
|
-
const checkId = /* @__PURE__ */ __name4((
|
|
6712
|
+
const checkId = /* @__PURE__ */ __name4((id2, path26) => {
|
|
6476
6713
|
nodeCount += 1;
|
|
6477
|
-
if (seen.has(
|
|
6478
|
-
err("duplicate-step-id", `step id "${
|
|
6714
|
+
if (seen.has(id2)) {
|
|
6715
|
+
err("duplicate-step-id", `step id "${id2}" is declared twice (first at ${seen.get(id2)})`, path26, id2);
|
|
6479
6716
|
} else {
|
|
6480
|
-
seen.set(
|
|
6717
|
+
seen.set(id2, path26);
|
|
6481
6718
|
}
|
|
6482
6719
|
}, "checkId");
|
|
6483
6720
|
const checkPolicyEnums = /* @__PURE__ */ __name4((node, path26) => {
|
|
6484
|
-
const
|
|
6721
|
+
const id2 = singleId(node);
|
|
6485
6722
|
const check = /* @__PURE__ */ __name4((member, allowed) => {
|
|
6486
6723
|
const value22 = node[member];
|
|
6487
6724
|
if (value22 === void 0 || typeof value22 === "string" && allowed.includes(value22)) return;
|
|
6488
|
-
err("invalid-envelope", `\`${member}\` must be ${allowed.map((a) => `'${a}'`).join(" | ")} (got ${JSON.stringify(value22)})`, `${path26}.${member}`,
|
|
6725
|
+
err("invalid-envelope", `\`${member}\` must be ${allowed.map((a) => `'${a}'`).join(" | ")} (got ${JSON.stringify(value22)})`, `${path26}.${member}`, id2);
|
|
6489
6726
|
}, "check");
|
|
6490
6727
|
check("sideEffects", WORKFLOW_SIDE_EFFECTS);
|
|
6491
6728
|
check("jobResources", WORKFLOW_JOB_RESOURCES);
|
|
@@ -6493,46 +6730,46 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
|
|
|
6493
6730
|
const checkRetry = /* @__PURE__ */ __name4((node, path26) => {
|
|
6494
6731
|
const r = node.retry;
|
|
6495
6732
|
if (!r) return;
|
|
6496
|
-
const
|
|
6733
|
+
const id2 = singleId(node);
|
|
6497
6734
|
const unknown = unknownWorkflowRetryMembers(r);
|
|
6498
|
-
if (unknown.length) err("invalid-envelope", workflowRetryUnknownMembersMessage(unknown), `${path26}.retry`,
|
|
6735
|
+
if (unknown.length) err("invalid-envelope", workflowRetryUnknownMembersMessage(unknown), `${path26}.retry`, id2);
|
|
6499
6736
|
if (!isWithinWorkflowRetryAttempts(r.maxAttempts)) {
|
|
6500
6737
|
const over = typeof r.maxAttempts === "number" && r.maxAttempts > WORKFLOW_RETRY_MAX_ATTEMPTS;
|
|
6501
|
-
err(over ? "cap-exceeded" : "invalid-envelope", workflowRetryMaxAttemptsMessage(r.maxAttempts), `${path26}.retry.maxAttempts`,
|
|
6738
|
+
err(over ? "cap-exceeded" : "invalid-envelope", workflowRetryMaxAttemptsMessage(r.maxAttempts), `${path26}.retry.maxAttempts`, id2);
|
|
6502
6739
|
}
|
|
6503
6740
|
const backoffs = retryBackoffs();
|
|
6504
6741
|
if (r.backoff !== void 0 && !backoffs.includes(r.backoff)) {
|
|
6505
6742
|
const list = backoffs.map((b) => `'${b}'`).join(" | ");
|
|
6506
|
-
err("backoff-invalid", `retry.backoff must be ${list}`, `${path26}.retry.backoff`,
|
|
6743
|
+
err("backoff-invalid", `retry.backoff must be ${list}`, `${path26}.retry.backoff`, id2);
|
|
6507
6744
|
}
|
|
6508
6745
|
if (r.backoffSeconds !== void 0 && r.backoffSeconds < 0) {
|
|
6509
|
-
err("backoff-invalid", "retry.backoffSeconds must be \u2265 0", `${path26}.retry.backoffSeconds`,
|
|
6746
|
+
err("backoff-invalid", "retry.backoffSeconds must be \u2265 0", `${path26}.retry.backoffSeconds`, id2);
|
|
6510
6747
|
}
|
|
6511
6748
|
if (r.maxBackoffSeconds !== void 0) {
|
|
6512
6749
|
if (r.backoff !== "exponential") {
|
|
6513
|
-
err("backoff-invalid", "retry.maxBackoffSeconds is only meaningful with backoff:'exponential'", `${path26}.retry`,
|
|
6750
|
+
err("backoff-invalid", "retry.maxBackoffSeconds is only meaningful with backoff:'exponential'", `${path26}.retry`, id2);
|
|
6514
6751
|
} else if (r.maxBackoffSeconds <= 0 || r.backoffSeconds !== void 0 && r.maxBackoffSeconds < r.backoffSeconds) {
|
|
6515
|
-
err("backoff-invalid", "retry.maxBackoffSeconds must be > 0 and \u2265 backoffSeconds", `${path26}.retry.maxBackoffSeconds`,
|
|
6752
|
+
err("backoff-invalid", "retry.maxBackoffSeconds must be > 0 and \u2265 backoffSeconds", `${path26}.retry.maxBackoffSeconds`, id2);
|
|
6516
6753
|
}
|
|
6517
6754
|
}
|
|
6518
6755
|
}, "checkRetry");
|
|
6519
6756
|
const checkTimeout = /* @__PURE__ */ __name4((node, path26) => {
|
|
6520
6757
|
const t = node.timeoutSeconds;
|
|
6521
6758
|
if (t === void 0) return;
|
|
6522
|
-
const
|
|
6759
|
+
const id2 = singleId(node);
|
|
6523
6760
|
if (!Number.isInteger(t) || t < 1) {
|
|
6524
|
-
err("timeout-out-of-range", `timeoutSeconds must be an integer \u2265 1 (got ${t})`, `${path26}.timeoutSeconds`,
|
|
6761
|
+
err("timeout-out-of-range", `timeoutSeconds must be an integer \u2265 1 (got ${t})`, `${path26}.timeoutSeconds`, id2);
|
|
6525
6762
|
return;
|
|
6526
6763
|
}
|
|
6527
6764
|
if (node.tier === "job") {
|
|
6528
6765
|
const cap = node.type === "agent" ? caps.maxJobTimeoutSeconds : caps.maxJobSegmentSeconds;
|
|
6529
6766
|
if (t > cap) {
|
|
6530
|
-
err("job-timeout-exceeds-cap", `timeoutSeconds ${t} exceeds the Job-tier cap of ${cap} s`, `${path26}.timeoutSeconds`,
|
|
6767
|
+
err("job-timeout-exceeds-cap", `timeoutSeconds ${t} exceeds the Job-tier cap of ${cap} s`, `${path26}.timeoutSeconds`, id2);
|
|
6531
6768
|
} else if (node.type === "agent" && t > caps.maxJobSegmentSeconds && !node.workspace) {
|
|
6532
|
-
err("long-job-requires-workspace", `steps longer than 4 h checkpoint to the run workspace \u2014 add workspace:{mount:'rw'} (and workspace on createWorkflow) or split the step`, `${path26}.timeoutSeconds`,
|
|
6769
|
+
err("long-job-requires-workspace", `steps longer than 4 h checkpoint to the run workspace \u2014 add workspace:{mount:'rw'} (and workspace on createWorkflow) or split the step`, `${path26}.timeoutSeconds`, id2);
|
|
6533
6770
|
}
|
|
6534
6771
|
} else if (t > caps.maxWorkerTimeoutSeconds) {
|
|
6535
|
-
err("timeout-exceeds-tier", `timeoutSeconds ${t} exceeds the worker tier's ${caps.maxWorkerTimeoutSeconds} s \u2014 steps longer than 10 min run on the Job tier: add tier:'job' (up to ${caps.maxJobSegmentSeconds} s)`, `${path26}.timeoutSeconds`,
|
|
6772
|
+
err("timeout-exceeds-tier", `timeoutSeconds ${t} exceeds the worker tier's ${caps.maxWorkerTimeoutSeconds} s \u2014 steps longer than 10 min run on the Job tier: add tier:'job' (up to ${caps.maxJobSegmentSeconds} s)`, `${path26}.timeoutSeconds`, id2);
|
|
6536
6773
|
}
|
|
6537
6774
|
}, "checkTimeout");
|
|
6538
6775
|
const checkSpecialistRole = /* @__PURE__ */ __name4((node, path26) => {
|
|
@@ -6596,32 +6833,32 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
|
|
|
6596
6833
|
return void 0;
|
|
6597
6834
|
}, "jobClassifiablePin");
|
|
6598
6835
|
const checkTier = /* @__PURE__ */ __name4((node, path26) => {
|
|
6599
|
-
const
|
|
6836
|
+
const id2 = singleId(node);
|
|
6600
6837
|
if (node.workspace && node.workspace !== "inherit" && node.tier !== void 0 && node.tier !== "job") {
|
|
6601
|
-
err("workspace-requires-job-tier", "a step mounting a workspace must be tier:'job'", `${path26}.workspace`,
|
|
6838
|
+
err("workspace-requires-job-tier", "a step mounting a workspace must be tier:'job'", `${path26}.workspace`, id2);
|
|
6602
6839
|
}
|
|
6603
6840
|
if (node.harness !== void 0 && node.tier !== "job") {
|
|
6604
|
-
err("harness-requires-job-tier", "`harness` is only legal on a tier:'job' agent step", `${path26}.harness`,
|
|
6841
|
+
err("harness-requires-job-tier", "`harness` is only legal on a tier:'job' agent step", `${path26}.harness`, id2);
|
|
6605
6842
|
}
|
|
6606
6843
|
const provider = node.type === "agent" ? classifyModelProvider(jobClassifiablePin(node.model)) : null;
|
|
6607
6844
|
if (node.harness === "claude-code" && provider !== null && provider !== "anthropic") {
|
|
6608
|
-
err("harness-provider-mismatch", `harness:'claude-code' needs an Anthropic model (model "${node.type === "agent" ? node.model : ""}" is ${provider})`, `${path26}.harness`,
|
|
6845
|
+
err("harness-provider-mismatch", `harness:'claude-code' needs an Anthropic model (model "${node.type === "agent" ? node.model : ""}" is ${provider})`, `${path26}.harness`, id2);
|
|
6609
6846
|
}
|
|
6610
6847
|
if (isJobTier(node) && provider !== null && opts.policy?.jobProviders && !opts.policy.jobProviders.includes(provider)) {
|
|
6611
|
-
err("job-tier-provider-unsupported", `model provider '${provider}' is outside LUA_WF_JOB_PROVIDERS [${opts.policy.jobProviders.join(", ")}]`, `${path26}.model`,
|
|
6848
|
+
err("job-tier-provider-unsupported", `model provider '${provider}' is outside LUA_WF_JOB_PROVIDERS [${opts.policy.jobProviders.join(", ")}]`, `${path26}.model`, id2);
|
|
6612
6849
|
}
|
|
6613
6850
|
}, "checkTier");
|
|
6614
6851
|
const checkModel = /* @__PURE__ */ __name4((node, path26) => {
|
|
6615
6852
|
if (node.type !== "agent" || typeof node.model !== "string") return;
|
|
6616
|
-
const
|
|
6853
|
+
const id2 = singleId(node);
|
|
6617
6854
|
const parsed = parseModelTemplate(node.model);
|
|
6618
6855
|
if (parsed.kind === "invalid") {
|
|
6619
|
-
err("model-template-invalid", parsed.message, `${path26}.model`,
|
|
6856
|
+
err("model-template-invalid", parsed.message, `${path26}.model`, id2);
|
|
6620
6857
|
return;
|
|
6621
6858
|
}
|
|
6622
6859
|
if (parsed.kind === "template" && parsed.template.default === void 0) {
|
|
6623
6860
|
if (isJobTier(node)) {
|
|
6624
|
-
err("model-template-default-required", modelTemplateDefaultRequiredMessage(node.model), `${path26}.model`,
|
|
6861
|
+
err("model-template-default-required", modelTemplateDefaultRequiredMessage(node.model), `${path26}.model`, id2);
|
|
6625
6862
|
}
|
|
6626
6863
|
return;
|
|
6627
6864
|
}
|
|
@@ -6634,12 +6871,12 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
|
|
|
6634
6871
|
if (registry === "unavailable") {
|
|
6635
6872
|
const trimmed2 = pin.trim();
|
|
6636
6873
|
if (trimmed2 && !normalizeModelId(trimmed2, []).ok) {
|
|
6637
|
-
warn("model-unresolved", inContext(`model "${trimmed2}" could not be checked against the approved-model registry (unavailable at push) \u2014 it dispatches only if it resolves there (a provider/model registry code, or a bare id exactly one approved model carries)`), `${path26}.model`,
|
|
6874
|
+
warn("model-unresolved", inContext(`model "${trimmed2}" could not be checked against the approved-model registry (unavailable at push) \u2014 it dispatches only if it resolves there (a provider/model registry code, or a bare id exactly one approved model carries)`), `${path26}.model`, id2);
|
|
6638
6875
|
}
|
|
6639
6876
|
return;
|
|
6640
6877
|
}
|
|
6641
6878
|
const resolved = normalizeModelId(pin, registry);
|
|
6642
|
-
if (!resolved.ok) err("model-unresolved", inContext(modelUnresolvedMessage(resolved)), `${path26}.model`,
|
|
6879
|
+
if (!resolved.ok) err("model-unresolved", inContext(modelUnresolvedMessage(resolved)), `${path26}.model`, id2);
|
|
6643
6880
|
}, "checkModel");
|
|
6644
6881
|
const checkTaskClass = /* @__PURE__ */ __name4((node, path26) => {
|
|
6645
6882
|
if (node.type !== "agent" || node.taskClass === void 0) return;
|
|
@@ -6648,46 +6885,46 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
|
|
|
6648
6885
|
err("task-class-without-model", `taskClass '${String(node.taskClass)}' needs a \`model\` on a pushed definition \u2014 write a class (model: 'class/fast' | 'class/balanced' | 'class/strong') or an approved provider/model code; nothing maps a task class to a model at dispatch, so a step with neither would run on the agent\u2019s own model`, `${path26}.taskClass`, singleId(node));
|
|
6649
6886
|
}, "checkTaskClass");
|
|
6650
6887
|
const checkWorkspace = /* @__PURE__ */ __name4((node, path26) => {
|
|
6651
|
-
const
|
|
6888
|
+
const id2 = singleId(node);
|
|
6652
6889
|
const ws = workspaceOf(node);
|
|
6653
6890
|
if (isJobTier(node) && opts.policy && opts.policy.jobTier !== true) {
|
|
6654
|
-
err("job-tier-disabled", `"${
|
|
6891
|
+
err("job-tier-disabled", `"${id2}" runs on the Job tier but the org's workflowPolicy.jobTier is off \u2014 an org admin enables it (lua features workflows.caps.jobTier true)`, `${path26}.tier`, id2);
|
|
6655
6892
|
}
|
|
6656
6893
|
const tools = jobToolsOf(node);
|
|
6657
6894
|
if (tools !== void 0) {
|
|
6658
6895
|
if (!isJobTier(node)) {
|
|
6659
|
-
err("job-tools-require-job-tier", "`jobTools` needs tier:'job'", `${path26}.jobTools`,
|
|
6896
|
+
err("job-tools-require-job-tier", "`jobTools` needs tier:'job'", `${path26}.jobTools`, id2);
|
|
6660
6897
|
}
|
|
6661
6898
|
const unknown = (Array.isArray(tools) ? tools : [
|
|
6662
6899
|
tools
|
|
6663
6900
|
]).filter((t) => !WORKFLOW_JOB_TOOLS.includes(t));
|
|
6664
6901
|
if (unknown.length > 0) {
|
|
6665
|
-
err("job-tools-unknown", `jobTools ${JSON.stringify(unknown)} outside WORKFLOW_JOB_TOOLS [${WORKFLOW_JOB_TOOLS.join(", ")}]`, `${path26}.jobTools`,
|
|
6902
|
+
err("job-tools-unknown", `jobTools ${JSON.stringify(unknown)} outside WORKFLOW_JOB_TOOLS [${WORKFLOW_JOB_TOOLS.join(", ")}]`, `${path26}.jobTools`, id2);
|
|
6666
6903
|
}
|
|
6667
6904
|
if (node.type === "agent" && (Array.isArray(tools) ? tools : [
|
|
6668
6905
|
tools
|
|
6669
6906
|
]).includes("gh")) {
|
|
6670
|
-
warn("gh-on-coding-turn", `"${
|
|
6907
|
+
warn("gh-on-coding-turn", `"${id2}" grants the gh tool on a coding turn \u2014 the pod can open/merge PRs on the workspace repo (purpose:'gh' token, pull_requests:write + contents:write)`, `${path26}.jobTools`, id2);
|
|
6671
6908
|
}
|
|
6672
6909
|
}
|
|
6673
6910
|
if (node.type === "agent" && ws && ws !== "inherit" && ws.mount === "ro" && Array.isArray(tools) && effectiveJobTools(tools, true).length === 0) {
|
|
6674
|
-
warn("ro-step-has-no-tools", `"${
|
|
6911
|
+
warn("ro-step-has-no-tools", `"${id2}" mounts the workspace read-only and every jobTool it declares (${JSON.stringify(tools)}) is one the ro mount drops [${WORKFLOW_JOB_READ_ONLY_DROPPED.join(", ")}] \u2014 the coding turn would run with no tools at all; keep a read-only tool (read/glob/grep, gh) or mount rw`, `${path26}.jobTools`, id2);
|
|
6675
6912
|
}
|
|
6676
6913
|
if (ws && ws !== "inherit") {
|
|
6677
6914
|
if (!envelopeWorkspace && !opts.mayInherit) {
|
|
6678
|
-
err("workspace-not-declared", `"${
|
|
6915
|
+
err("workspace-not-declared", `"${id2}" mounts a workspace but the workflow declares none \u2014 add workspace:{kind, \u2026} on createWorkflow`, `${path26}.workspace`, id2);
|
|
6679
6916
|
}
|
|
6680
6917
|
if (ws.isolation === "worktree" && envelopeWorkspace?.kind === "empty") {
|
|
6681
|
-
err("worktree-requires-git-workspace", `"${
|
|
6918
|
+
err("worktree-requires-git-workspace", `"${id2}": isolation:'worktree' needs a kind:'git' workspace (the envelope declares kind:'empty')`, `${path26}.workspace.isolation`, id2);
|
|
6682
6919
|
}
|
|
6683
6920
|
}
|
|
6684
6921
|
if (node.type === "workflow" && ws === "inherit") {
|
|
6685
6922
|
if (!envelopeWorkspace) {
|
|
6686
|
-
err("workspace-inherit-without-parent-workspace", `"${
|
|
6923
|
+
err("workspace-inherit-without-parent-workspace", `"${id2}": workspace:'inherit' but the parent workflow declares no workspace \u2014 there is nothing to inherit`, `${path26}.workspace`, id2);
|
|
6687
6924
|
}
|
|
6688
6925
|
const child = opts.resolveWorkflow?.(node.workflowId);
|
|
6689
6926
|
if (child?.workspace) {
|
|
6690
|
-
err("workspace-inherit-conflict", `"${
|
|
6927
|
+
err("workspace-inherit-conflict", `"${id2}": workspace:'inherit' on "${node.workflowId}", which declares its own workspace`, `${path26}.workspace`, id2);
|
|
6691
6928
|
}
|
|
6692
6929
|
}
|
|
6693
6930
|
}, "checkWorkspace");
|
|
@@ -6696,20 +6933,20 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
|
|
|
6696
6933
|
const schema = node.type === "step" ? node.step.outputSchema : node.type === "agent" ? node.outputSchema : void 0;
|
|
6697
6934
|
if (schema !== void 0) outputSchemas.set(singleId(node), schema);
|
|
6698
6935
|
}, "recordOutputSchema");
|
|
6699
|
-
const checkMapMembers = /* @__PURE__ */ __name4((cfg, basePath,
|
|
6936
|
+
const checkMapMembers = /* @__PURE__ */ __name4((cfg, basePath, id2) => {
|
|
6700
6937
|
for (const m of malformedMapMembers(cfg)) {
|
|
6701
|
-
warn(MAP_MEMBER_MALFORMED_CODE, mapMemberMalformedMessage(
|
|
6938
|
+
warn(MAP_MEMBER_MALFORMED_CODE, mapMemberMalformedMessage(id2, m), `${basePath}.${m.member}`, id2);
|
|
6702
6939
|
}
|
|
6703
6940
|
}, "checkMapMembers");
|
|
6704
6941
|
const checkInputShape = /* @__PURE__ */ __name4((node, path26) => {
|
|
6705
6942
|
const input = node.input;
|
|
6706
6943
|
if (input === void 0) return;
|
|
6707
|
-
const
|
|
6944
|
+
const id2 = singleId(node);
|
|
6708
6945
|
if (input !== null && typeof input === "object" && !Array.isArray(input)) {
|
|
6709
|
-
checkMapMembers(input, `${path26}.input`,
|
|
6946
|
+
checkMapMembers(input, `${path26}.input`, id2);
|
|
6710
6947
|
return;
|
|
6711
6948
|
}
|
|
6712
|
-
err("invalid-envelope", `\`input\` must be an object map \u2014 each member a binding descriptor ({initData:true, path} | {step, path} | {value} | {template} | {requestContextPath}) or a JSON literal (got ${JSON.stringify(input)})`, `${path26}.input`,
|
|
6949
|
+
err("invalid-envelope", `\`input\` must be an object map \u2014 each member a binding descriptor ({initData:true, path} | {step, path} | {value} | {template} | {requestContextPath}) or a JSON literal (got ${JSON.stringify(input)})`, `${path26}.input`, id2);
|
|
6713
6950
|
}, "checkInputShape");
|
|
6714
6951
|
const checkBodyInput = /* @__PURE__ */ __name4((body, path26, container) => {
|
|
6715
6952
|
if (body.type === "workflow" || body.input === void 0) return;
|
|
@@ -7000,7 +7237,7 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
|
|
|
7000
7237
|
default:
|
|
7001
7238
|
err("invalid-envelope", `unknown entry type "${entry.type}"`, path26);
|
|
7002
7239
|
}
|
|
7003
|
-
for (const
|
|
7240
|
+
for (const id2 of declared) upstream.add(id2);
|
|
7004
7241
|
});
|
|
7005
7242
|
if (nodeCount > caps.maxNodes) {
|
|
7006
7243
|
err("cap-exceeded", `${nodeCount} nodes exceeds the static cap of ${caps.maxNodes}`, "definition.graph");
|
|
@@ -7075,19 +7312,19 @@ function hashGraph(g) {
|
|
|
7075
7312
|
function compilePlan(g) {
|
|
7076
7313
|
const steps = {};
|
|
7077
7314
|
const order = [];
|
|
7078
|
-
const addNode = /* @__PURE__ */ __name4((
|
|
7079
|
-
if (
|
|
7080
|
-
throw new WorkflowPlanError("duplicate-step-id", `Duplicate step id "${
|
|
7315
|
+
const addNode = /* @__PURE__ */ __name4((id2, node) => {
|
|
7316
|
+
if (id2 in steps) {
|
|
7317
|
+
throw new WorkflowPlanError("duplicate-step-id", `Duplicate step id "${id2}" in definition.graph`);
|
|
7081
7318
|
}
|
|
7082
|
-
steps[
|
|
7083
|
-
order.push(
|
|
7319
|
+
steps[id2] = node;
|
|
7320
|
+
order.push(id2);
|
|
7084
7321
|
}, "addNode");
|
|
7085
7322
|
let prevTails = [];
|
|
7086
7323
|
const foreachJoinToEntry = /* @__PURE__ */ new Map();
|
|
7087
7324
|
g.definition.graph.forEach((entry, entryIndex) => {
|
|
7088
7325
|
if (isArmStep(entry)) {
|
|
7089
|
-
const
|
|
7090
|
-
addNode(
|
|
7326
|
+
const id2 = armStepId(entry);
|
|
7327
|
+
addNode(id2, {
|
|
7091
7328
|
kind: armStepKind(entry),
|
|
7092
7329
|
dependsOn: prevTails,
|
|
7093
7330
|
downstream: [],
|
|
@@ -7095,7 +7332,7 @@ function compilePlan(g) {
|
|
|
7095
7332
|
entry
|
|
7096
7333
|
});
|
|
7097
7334
|
prevTails = [
|
|
7098
|
-
|
|
7335
|
+
id2
|
|
7099
7336
|
];
|
|
7100
7337
|
return;
|
|
7101
7338
|
}
|
|
@@ -7234,10 +7471,10 @@ function compilePlan(g) {
|
|
|
7234
7471
|
throw new WorkflowPlanError("unknown-entry-type", `Unknown graph entry type "${entry.type}" at definition.graph[${entryIndex}]`);
|
|
7235
7472
|
}
|
|
7236
7473
|
});
|
|
7237
|
-
for (const
|
|
7238
|
-
for (const dep of steps[
|
|
7474
|
+
for (const id2 of order) {
|
|
7475
|
+
for (const dep of steps[id2].dependsOn) {
|
|
7239
7476
|
const target = steps[dep] ?? (foreachJoinToEntry.has(dep) ? steps[foreachJoinToEntry.get(dep)] : void 0);
|
|
7240
|
-
target?.downstream.push(
|
|
7477
|
+
target?.downstream.push(id2);
|
|
7241
7478
|
}
|
|
7242
7479
|
}
|
|
7243
7480
|
return {
|
|
@@ -7403,15 +7640,15 @@ function renderRef(ref) {
|
|
|
7403
7640
|
return ref.path;
|
|
7404
7641
|
}
|
|
7405
7642
|
function step(s) {
|
|
7406
|
-
const
|
|
7643
|
+
const id2 = stepIdOf(s);
|
|
7407
7644
|
return {
|
|
7408
7645
|
path: /* @__PURE__ */ __name4((p) => ({
|
|
7409
|
-
path: p === "" ? `stepResults.${
|
|
7646
|
+
path: p === "" ? `stepResults.${id2}` : `stepResults.${id2}.${p}`
|
|
7410
7647
|
}), "path")
|
|
7411
7648
|
};
|
|
7412
7649
|
}
|
|
7413
|
-
function stepOf(
|
|
7414
|
-
return step(
|
|
7650
|
+
function stepOf(id2) {
|
|
7651
|
+
return step(id2);
|
|
7415
7652
|
}
|
|
7416
7653
|
function init(path26) {
|
|
7417
7654
|
return {
|
|
@@ -7493,18 +7730,18 @@ function resolvePlacements(calls) {
|
|
|
7493
7730
|
const declared = /* @__PURE__ */ new Map();
|
|
7494
7731
|
const placedBy = /* @__PURE__ */ new Map();
|
|
7495
7732
|
const allIds = /* @__PURE__ */ new Map();
|
|
7496
|
-
const claimId = /* @__PURE__ */ __name4((
|
|
7497
|
-
const first = allIds.get(
|
|
7733
|
+
const claimId = /* @__PURE__ */ __name4((id2, callIndex) => {
|
|
7734
|
+
const first = allIds.get(id2);
|
|
7498
7735
|
if (first !== void 0 && first !== callIndex) {
|
|
7499
7736
|
issues.push({
|
|
7500
7737
|
code: "duplicate-step-id",
|
|
7501
|
-
message: `step id "${
|
|
7738
|
+
message: `step id "${id2}" is declared more than once (calls #${first} and #${callIndex})`,
|
|
7502
7739
|
callIndex,
|
|
7503
|
-
stepId:
|
|
7740
|
+
stepId: id2
|
|
7504
7741
|
});
|
|
7505
7742
|
return;
|
|
7506
7743
|
}
|
|
7507
|
-
allIds.set(
|
|
7744
|
+
allIds.set(id2, callIndex);
|
|
7508
7745
|
}, "claimId");
|
|
7509
7746
|
calls.forEach((call, i) => {
|
|
7510
7747
|
switch (call.kind) {
|
|
@@ -7516,7 +7753,7 @@ function resolvePlacements(calls) {
|
|
|
7516
7753
|
});
|
|
7517
7754
|
break;
|
|
7518
7755
|
case "entry":
|
|
7519
|
-
for (const
|
|
7756
|
+
for (const id2 of entryIds(call.entry)) claimId(id2, i);
|
|
7520
7757
|
break;
|
|
7521
7758
|
case "parallel":
|
|
7522
7759
|
for (const arm of call.arms) if ("node" in arm) claimId(nodeIdOf(arm.node), i);
|
|
@@ -7535,42 +7772,42 @@ function resolvePlacements(calls) {
|
|
|
7535
7772
|
});
|
|
7536
7773
|
const armMapPlacementIssue = /* @__PURE__ */ __name4((node, ref, i, container) => {
|
|
7537
7774
|
if (!ref.armMap || node.type === "mapping" || isHitlNode2(node)) return void 0;
|
|
7538
|
-
const
|
|
7775
|
+
const id2 = nodeIdOf(node);
|
|
7539
7776
|
if ((container === "foreach" || container === "loop") && node.type !== "workflow") {
|
|
7540
7777
|
return {
|
|
7541
7778
|
code: "mapping-placement",
|
|
7542
|
-
message: container === "foreach" ? `foreach body "${
|
|
7779
|
+
message: container === "foreach" ? `foreach body "${id2}": a [map, step] body is not supported \u2014 the body receives each item as its input; map the items before the foreach instead (foreach(step, { items: \u2026 }) or a .map() before it)` : `loop body "${id2}": a [map, step] body is not supported \u2014 the body receives the previous output as its input; put the .map() before the loop instead`,
|
|
7543
7780
|
callIndex: i,
|
|
7544
|
-
stepId:
|
|
7781
|
+
stepId: id2
|
|
7545
7782
|
};
|
|
7546
7783
|
}
|
|
7547
7784
|
if (node.input !== void 0) {
|
|
7548
7785
|
return {
|
|
7549
7786
|
code: "mapping-placement",
|
|
7550
|
-
message: `"${
|
|
7787
|
+
message: `"${id2}": the [map, step] arm mapping and the node's own input map would both bind its input \u2014 keep one (drop the arm map, or the \`input\` on the declaration)`,
|
|
7551
7788
|
callIndex: i,
|
|
7552
|
-
stepId:
|
|
7789
|
+
stepId: id2
|
|
7553
7790
|
};
|
|
7554
7791
|
}
|
|
7555
7792
|
return void 0;
|
|
7556
7793
|
}, "armMapPlacementIssue");
|
|
7557
7794
|
const hitlPlacementIssue = /* @__PURE__ */ __name4((node, ref, i, container) => {
|
|
7558
7795
|
if (!isHitlNode2(node)) return void 0;
|
|
7559
|
-
const
|
|
7796
|
+
const id2 = node.id;
|
|
7560
7797
|
if (ref.armMap) {
|
|
7561
7798
|
return {
|
|
7562
7799
|
code: "node-type-unsupported-in-container",
|
|
7563
|
-
message: workflowHitlArmShapeMessage(node.type,
|
|
7800
|
+
message: workflowHitlArmShapeMessage(node.type, id2, "mapped-arm"),
|
|
7564
7801
|
callIndex: i,
|
|
7565
|
-
stepId:
|
|
7802
|
+
stepId: id2
|
|
7566
7803
|
};
|
|
7567
7804
|
}
|
|
7568
7805
|
if (container !== "place" && !workflowContainerRunsHitlArm(container)) {
|
|
7569
7806
|
return {
|
|
7570
7807
|
code: "node-type-unsupported-in-container",
|
|
7571
|
-
message: workflowHitlArmUnsupportedMessage(node.type,
|
|
7808
|
+
message: workflowHitlArmUnsupportedMessage(node.type, id2, container),
|
|
7572
7809
|
callIndex: i,
|
|
7573
|
-
stepId:
|
|
7810
|
+
stepId: id2
|
|
7574
7811
|
};
|
|
7575
7812
|
}
|
|
7576
7813
|
return void 0;
|
|
@@ -7676,8 +7913,8 @@ function resolvePlacements(calls) {
|
|
|
7676
7913
|
graph.push(call.entry);
|
|
7677
7914
|
return;
|
|
7678
7915
|
case "declare": {
|
|
7679
|
-
const
|
|
7680
|
-
if (placedBy.has(
|
|
7916
|
+
const id2 = nodeIdOf(call.node);
|
|
7917
|
+
if (placedBy.has(id2)) return;
|
|
7681
7918
|
graph.push(call.node);
|
|
7682
7919
|
return;
|
|
7683
7920
|
}
|
|
@@ -7808,14 +8045,14 @@ function seedLedgerFromRun(run, steps, targetPlan, opts = {}) {
|
|
|
7808
8045
|
const seeded = [];
|
|
7809
8046
|
const unseeded = [];
|
|
7810
8047
|
const known = new Set(Object.keys(targetPlan.steps));
|
|
7811
|
-
const parentOf = /* @__PURE__ */ __name4((
|
|
7812
|
-
const m = /^(.*)(\[\d+\]|#\d+)$/.exec(
|
|
8048
|
+
const parentOf = /* @__PURE__ */ __name4((id2) => {
|
|
8049
|
+
const m = /^(.*)(\[\d+\]|#\d+)$/.exec(id2);
|
|
7813
8050
|
return m ? m[1] : void 0;
|
|
7814
8051
|
}, "parentOf");
|
|
7815
|
-
const dependsOf = /* @__PURE__ */ __name4((
|
|
7816
|
-
const node = targetPlan.steps[
|
|
8052
|
+
const dependsOf = /* @__PURE__ */ __name4((id2) => {
|
|
8053
|
+
const node = targetPlan.steps[id2];
|
|
7817
8054
|
if (node) return node.dependsOn;
|
|
7818
|
-
const parent = parentOf(
|
|
8055
|
+
const parent = parentOf(id2);
|
|
7819
8056
|
return parent && targetPlan.steps[parent] ? [
|
|
7820
8057
|
parent
|
|
7821
8058
|
] : [];
|
|
@@ -7828,23 +8065,23 @@ function seedLedgerFromRun(run, steps, targetPlan, opts = {}) {
|
|
|
7828
8065
|
walk22.push(s.stepId);
|
|
7829
8066
|
}
|
|
7830
8067
|
}
|
|
7831
|
-
for (const
|
|
7832
|
-
const row2 = byId.get(
|
|
8068
|
+
for (const id2 of walk22) {
|
|
8069
|
+
const row2 = byId.get(id2);
|
|
7833
8070
|
if (!row2 || row2.status !== "completed") continue;
|
|
7834
|
-
if (!dependsOf(
|
|
7835
|
-
unseeded.push(
|
|
8071
|
+
if (!dependsOf(id2).every((d) => seededIds.has(d))) {
|
|
8072
|
+
unseeded.push(id2);
|
|
7836
8073
|
continue;
|
|
7837
8074
|
}
|
|
7838
|
-
seededIds.add(
|
|
8075
|
+
seededIds.add(id2);
|
|
7839
8076
|
seeded.push({
|
|
7840
|
-
stepId:
|
|
8077
|
+
stepId: id2,
|
|
7841
8078
|
output: row2.output,
|
|
7842
8079
|
attempt: row2.attempt ?? 1,
|
|
7843
8080
|
effects: row2.effects ?? {}
|
|
7844
8081
|
});
|
|
7845
8082
|
}
|
|
7846
8083
|
const dropped = steps.filter((s) => s.status === "completed" && !known.has(s.stepId) && !(parentOf(s.stepId) && known.has(parentOf(s.stepId)))).map((s) => s.stepId);
|
|
7847
|
-
const firstPending = targetPlan.order.find((
|
|
8084
|
+
const firstPending = targetPlan.order.find((id2) => !seededIds.has(id2));
|
|
7848
8085
|
const graphChanged = !!(opts.targetGraphHash && run.graphHash && opts.targetGraphHash !== run.graphHash);
|
|
7849
8086
|
return {
|
|
7850
8087
|
sourceRunId: run.id,
|
|
@@ -7899,37 +8136,37 @@ function replayLedger(g, ledger) {
|
|
|
7899
8136
|
startedAt: 0,
|
|
7900
8137
|
...ledger.requestContext
|
|
7901
8138
|
};
|
|
7902
|
-
const ctxFor = /* @__PURE__ */ __name4((
|
|
8139
|
+
const ctxFor = /* @__PURE__ */ __name4((id2) => ({
|
|
7903
8140
|
initData: ledger.initData,
|
|
7904
|
-
stepResults: ancestorResults(plan,
|
|
8141
|
+
stepResults: ancestorResults(plan, id2, rows22),
|
|
7905
8142
|
state: ledger.state ?? {},
|
|
7906
8143
|
requestContext
|
|
7907
8144
|
}), "ctxFor");
|
|
7908
8145
|
const verdicts = [];
|
|
7909
|
-
for (const
|
|
7910
|
-
const node = plan.steps[
|
|
7911
|
-
const recorded = rows22.get(
|
|
8146
|
+
for (const id2 of plan.order) {
|
|
8147
|
+
const node = plan.steps[id2];
|
|
8148
|
+
const recorded = rows22.get(id2);
|
|
7912
8149
|
if (!recorded || recorded.status === "pending" || recorded.status === "skipped") continue;
|
|
7913
8150
|
if (node.kind === "branch") {
|
|
7914
8151
|
const entry = node.entry;
|
|
7915
|
-
const taken = selectBranchArms(branchSpecFromConditional(entry), ctxFor(
|
|
8152
|
+
const taken = selectBranchArms(branchSpecFromConditional(entry), ctxFor(id2));
|
|
7916
8153
|
const recordedTaken = recorded.taken ?? inferTaken(entry, rows22);
|
|
7917
8154
|
verdicts.push({
|
|
7918
|
-
stepId:
|
|
8155
|
+
stepId: id2,
|
|
7919
8156
|
kind: "branch",
|
|
7920
8157
|
recorded: recordedTaken,
|
|
7921
8158
|
local: taken,
|
|
7922
8159
|
diverged: canonical(recordedTaken) !== canonical(taken)
|
|
7923
8160
|
});
|
|
7924
|
-
} else if (node.kind === "map" && !
|
|
8161
|
+
} else if (node.kind === "map" && !id2.endsWith(".join") && recorded.status === "completed") {
|
|
7925
8162
|
const entry = node.entry;
|
|
7926
|
-
const resolved = resolveMapping(parseMapConfig(entry.mapConfig,
|
|
8163
|
+
const resolved = resolveMapping(parseMapConfig(entry.mapConfig, id2), ctxFor(id2));
|
|
7927
8164
|
const local = "error" in resolved ? {
|
|
7928
8165
|
error: resolved.error,
|
|
7929
8166
|
key: resolved.key
|
|
7930
8167
|
} : resolved.value;
|
|
7931
8168
|
verdicts.push({
|
|
7932
|
-
stepId:
|
|
8169
|
+
stepId: id2,
|
|
7933
8170
|
kind: "map",
|
|
7934
8171
|
recorded: recorded.output,
|
|
7935
8172
|
local,
|
|
@@ -7938,11 +8175,11 @@ function replayLedger(g, ledger) {
|
|
|
7938
8175
|
} else if (node.kind === "foreach") {
|
|
7939
8176
|
const entry = node.entry;
|
|
7940
8177
|
const source = node.dependsOn[0];
|
|
7941
|
-
const items = source ? ctxFor(
|
|
8178
|
+
const items = source ? ctxFor(id2).stepResults[source] : void 0;
|
|
7942
8179
|
const local = Array.isArray(items) ? items.length : void 0;
|
|
7943
8180
|
const recordedCount = recorded.itemCount ?? countChildren(entry, rows22);
|
|
7944
8181
|
verdicts.push({
|
|
7945
|
-
stepId:
|
|
8182
|
+
stepId: id2,
|
|
7946
8183
|
kind: "foreach",
|
|
7947
8184
|
recorded: recordedCount,
|
|
7948
8185
|
local,
|
|
@@ -7951,7 +8188,7 @@ function replayLedger(g, ledger) {
|
|
|
7951
8188
|
} else if (node.kind === "subrun" && recorded.status === "completed" && recorded.child) {
|
|
7952
8189
|
const local = subrunSettledOutput(recorded.child);
|
|
7953
8190
|
verdicts.push({
|
|
7954
|
-
stepId:
|
|
8191
|
+
stepId: id2,
|
|
7955
8192
|
kind: "subrun",
|
|
7956
8193
|
recorded: recorded.output,
|
|
7957
8194
|
local,
|
|
@@ -7977,7 +8214,7 @@ function replayResultOf(row2, node) {
|
|
|
7977
8214
|
}
|
|
7978
8215
|
return void 0;
|
|
7979
8216
|
}
|
|
7980
|
-
function ancestorResults(plan,
|
|
8217
|
+
function ancestorResults(plan, id2, rows22) {
|
|
7981
8218
|
const out = {};
|
|
7982
8219
|
const joinAliased = /* @__PURE__ */ new Set();
|
|
7983
8220
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -8026,7 +8263,7 @@ function ancestorResults(plan, id, rows22) {
|
|
|
8026
8263
|
walk22(node.dependsOn);
|
|
8027
8264
|
}
|
|
8028
8265
|
}, "walk");
|
|
8029
|
-
walk22(plan.steps[
|
|
8266
|
+
walk22(plan.steps[id2]?.dependsOn ?? []);
|
|
8030
8267
|
return out;
|
|
8031
8268
|
}
|
|
8032
8269
|
function inferTaken(entry, rows22) {
|
|
@@ -8036,15 +8273,15 @@ function inferTaken(entry, rows22) {
|
|
|
8036
8273
|
entry.otherwise
|
|
8037
8274
|
] : []
|
|
8038
8275
|
];
|
|
8039
|
-
return arms.map(branchArmId).filter((
|
|
8040
|
-
const r = rows22.get(
|
|
8276
|
+
return arms.map(branchArmId).filter((id2) => {
|
|
8277
|
+
const r = rows22.get(id2);
|
|
8041
8278
|
return r !== void 0 && r.status !== "skipped" && r.status !== "pending";
|
|
8042
8279
|
});
|
|
8043
8280
|
}
|
|
8044
8281
|
function countChildren(entry, rows22) {
|
|
8045
8282
|
const body = branchArmId(entry.step);
|
|
8046
8283
|
let n2 = 0;
|
|
8047
|
-
for (const
|
|
8284
|
+
for (const id2 of rows22.keys()) if (id2.startsWith(`${body}[`)) n2 += 1;
|
|
8048
8285
|
return n2;
|
|
8049
8286
|
}
|
|
8050
8287
|
function isTerminalRunStatus(status) {
|
|
@@ -9312,8 +9549,8 @@ var init_dist2 = __esm({
|
|
|
9312
9549
|
fromKnowledge = /* @__PURE__ */ __name4((k) => ({
|
|
9313
9550
|
knowledge: k
|
|
9314
9551
|
}), "fromKnowledge");
|
|
9315
|
-
SideEffectsSchema =
|
|
9316
|
-
JobResourcesSchema =
|
|
9552
|
+
SideEffectsSchema = z7.enum(WORKFLOW_SIDE_EFFECTS);
|
|
9553
|
+
JobResourcesSchema = z7.enum(WORKFLOW_JOB_RESOURCES);
|
|
9317
9554
|
WORKFLOW_MODEL_TEMPLATE_ROOT = "initData";
|
|
9318
9555
|
WORKFLOW_MODEL_TEMPLATE_RE = /^\$\{\s*initData\.([A-Za-z0-9_.\-[\]]+)\s*(?:\|([^}]*))?\}$/;
|
|
9319
9556
|
PATH_SEGMENT_RE = /^[A-Za-z0-9_-]+(?:\[(?:0|[1-9]\d*)\])*$/;
|
|
@@ -9746,7 +9983,7 @@ var init_dist2 = __esm({
|
|
|
9746
9983
|
__name(replayLedger, "replayLedger");
|
|
9747
9984
|
__name4(replayLedger, "replayLedger");
|
|
9748
9985
|
JOIN = ".join";
|
|
9749
|
-
entryOfJoin = /* @__PURE__ */ __name4((
|
|
9986
|
+
entryOfJoin = /* @__PURE__ */ __name4((id2) => id2.endsWith(JOIN) ? id2.slice(0, -JOIN.length) : void 0, "entryOfJoin");
|
|
9750
9987
|
__name(replayResultOf, "replayResultOf");
|
|
9751
9988
|
__name4(replayResultOf, "replayResultOf");
|
|
9752
9989
|
__name(ancestorResults, "ancestorResults");
|
|
@@ -10035,8 +10272,8 @@ function createStep(s) {
|
|
|
10035
10272
|
function step2(s) {
|
|
10036
10273
|
return step(typeof s === "string" ? s : s.id);
|
|
10037
10274
|
}
|
|
10038
|
-
function stepOf2(
|
|
10039
|
-
return stepOf(
|
|
10275
|
+
function stepOf2(id2) {
|
|
10276
|
+
return stepOf(id2);
|
|
10040
10277
|
}
|
|
10041
10278
|
function schemaToJson(schema) {
|
|
10042
10279
|
if (schema === void 0 || schema === null) return void 0;
|
|
@@ -10243,16 +10480,16 @@ var init_workflow = __esm({
|
|
|
10243
10480
|
if (!isPredicate(p)) throw new LuaWorkflowBuildError("closure-predicate", `${where}: not a LuaPredicate`, "build predicates with eq/gt/inSet/exists/and/or/not");
|
|
10244
10481
|
return p;
|
|
10245
10482
|
}, "assertPredicate");
|
|
10246
|
-
assertRetry = /* @__PURE__ */ __name((r,
|
|
10483
|
+
assertRetry = /* @__PURE__ */ __name((r, id2) => {
|
|
10247
10484
|
if (!r) return;
|
|
10248
10485
|
if (!isWithinWorkflowRetryAttempts(r.maxAttempts)) {
|
|
10249
10486
|
const over = typeof r.maxAttempts === "number" && r.maxAttempts > WORKFLOW_RETRY_MAX_ATTEMPTS;
|
|
10250
|
-
throw new LuaWorkflowBuildError(over ? "cap-exceeded" : "invalid-envelope", `"${
|
|
10487
|
+
throw new LuaWorkflowBuildError(over ? "cap-exceeded" : "invalid-envelope", `"${id2}": ${workflowRetryMaxAttemptsMessage(r.maxAttempts)}`);
|
|
10251
10488
|
}
|
|
10252
|
-
if (r.backoff !== void 0 && !WORKFLOW_RETRY_BACKOFFS.includes(r.backoff)) throw new LuaWorkflowBuildError("backoff-invalid", `"${
|
|
10489
|
+
if (r.backoff !== void 0 && !WORKFLOW_RETRY_BACKOFFS.includes(r.backoff)) throw new LuaWorkflowBuildError("backoff-invalid", `"${id2}": retry.backoff must be ${WORKFLOW_RETRY_BACKOFFS.map((b) => `'${b}'`).join(" | ")}`);
|
|
10253
10490
|
if (r.maxBackoffSeconds !== void 0) {
|
|
10254
|
-
if (r.backoff !== "exponential") throw new LuaWorkflowBuildError("backoff-invalid", `"${
|
|
10255
|
-
if (r.maxBackoffSeconds <= 0 || r.backoffSeconds !== void 0 && r.maxBackoffSeconds < r.backoffSeconds) throw new LuaWorkflowBuildError("backoff-invalid", `"${
|
|
10491
|
+
if (r.backoff !== "exponential") throw new LuaWorkflowBuildError("backoff-invalid", `"${id2}": retry.maxBackoffSeconds is only meaningful with backoff:'exponential'`);
|
|
10492
|
+
if (r.maxBackoffSeconds <= 0 || r.backoffSeconds !== void 0 && r.maxBackoffSeconds < r.backoffSeconds) throw new LuaWorkflowBuildError("backoff-invalid", `"${id2}": retry.maxBackoffSeconds must be > 0 and \u2265 backoffSeconds`);
|
|
10256
10493
|
}
|
|
10257
10494
|
}, "assertRetry");
|
|
10258
10495
|
assertTimeout = /* @__PURE__ */ __name((node) => {
|
|
@@ -10450,8 +10687,8 @@ var init_workflow = __esm({
|
|
|
10450
10687
|
ref: arm
|
|
10451
10688
|
};
|
|
10452
10689
|
if (arm && typeof arm === "object" && isHitlEntry(arm)) {
|
|
10453
|
-
const
|
|
10454
|
-
throw new LuaWorkflowBuildError("invalid-step", `${where}: an approval / waitForSignal arm is placed by id \u2014 declare it with .approval(${JSON.stringify(
|
|
10690
|
+
const id2 = arm.id;
|
|
10691
|
+
throw new LuaWorkflowBuildError("invalid-step", `${where}: an approval / waitForSignal arm is placed by id \u2014 declare it with .approval(${JSON.stringify(id2 ?? "id")}, \u2026) / .waitForSignal(\u2026) and pass the id string`);
|
|
10455
10692
|
}
|
|
10456
10693
|
return {
|
|
10457
10694
|
node: this.registerStep(arm, where)
|
|
@@ -10571,14 +10808,14 @@ var init_workflow = __esm({
|
|
|
10571
10808
|
assertNoClosure(mapping, "map()");
|
|
10572
10809
|
this.recordEnvRefs(mapping);
|
|
10573
10810
|
this.mapCount += 1;
|
|
10574
|
-
let
|
|
10575
|
-
if (
|
|
10811
|
+
let id2 = opts?.id;
|
|
10812
|
+
if (id2 === void 0) {
|
|
10576
10813
|
this.unnamedMaps += 1;
|
|
10577
|
-
|
|
10814
|
+
id2 = `map_${this.mapCount}`;
|
|
10578
10815
|
}
|
|
10579
10816
|
const node = {
|
|
10580
10817
|
type: "mapping",
|
|
10581
|
-
id,
|
|
10818
|
+
id: id2,
|
|
10582
10819
|
mapConfig: canonicalJson(mapping)
|
|
10583
10820
|
};
|
|
10584
10821
|
return this.push({
|
|
@@ -10589,12 +10826,12 @@ var init_workflow = __esm({
|
|
|
10589
10826
|
sleep(ms, opts) {
|
|
10590
10827
|
if (typeof ms !== "number" || !Number.isFinite(ms) || ms < 0) throw new LuaWorkflowBuildError("invalid-envelope", "sleep(ms) takes a literal non-negative number");
|
|
10591
10828
|
this.sleepCount += 1;
|
|
10592
|
-
const
|
|
10829
|
+
const id2 = opts?.id ?? `sleep_${this.sleepCount}`;
|
|
10593
10830
|
return this.push({
|
|
10594
10831
|
kind: "entry",
|
|
10595
10832
|
entry: defined({
|
|
10596
10833
|
type: "sleep",
|
|
10597
|
-
id,
|
|
10834
|
+
id: id2,
|
|
10598
10835
|
duration: ms,
|
|
10599
10836
|
businessHours: opts?.businessHours
|
|
10600
10837
|
})
|
|
@@ -10602,13 +10839,13 @@ var init_workflow = __esm({
|
|
|
10602
10839
|
}
|
|
10603
10840
|
sleepUntil(iso, opts) {
|
|
10604
10841
|
this.sleepCount += 1;
|
|
10605
|
-
const
|
|
10842
|
+
const id2 = opts?.id ?? `sleep_${this.sleepCount}`;
|
|
10606
10843
|
if (typeof iso === "string") {
|
|
10607
10844
|
return this.push({
|
|
10608
10845
|
kind: "entry",
|
|
10609
10846
|
entry: defined({
|
|
10610
10847
|
type: "sleepUntil",
|
|
10611
|
-
id,
|
|
10848
|
+
id: id2,
|
|
10612
10849
|
date: iso,
|
|
10613
10850
|
businessHours: opts?.businessHours,
|
|
10614
10851
|
round: opts?.round
|
|
@@ -10621,7 +10858,7 @@ var init_workflow = __esm({
|
|
|
10621
10858
|
kind: "entry",
|
|
10622
10859
|
entry: {
|
|
10623
10860
|
type: "mapping",
|
|
10624
|
-
id: `${
|
|
10861
|
+
id: `${id2}_at`,
|
|
10625
10862
|
mapConfig: canonicalJson({
|
|
10626
10863
|
date: {
|
|
10627
10864
|
template: iso.template
|
|
@@ -10633,9 +10870,9 @@ var init_workflow = __esm({
|
|
|
10633
10870
|
kind: "entry",
|
|
10634
10871
|
entry: defined({
|
|
10635
10872
|
type: "sleepUntil",
|
|
10636
|
-
id,
|
|
10873
|
+
id: id2,
|
|
10637
10874
|
dateFrom: {
|
|
10638
|
-
step: `${
|
|
10875
|
+
step: `${id2}_at`,
|
|
10639
10876
|
path: "date"
|
|
10640
10877
|
},
|
|
10641
10878
|
businessHours: opts?.businessHours,
|
|
@@ -10643,35 +10880,35 @@ var init_workflow = __esm({
|
|
|
10643
10880
|
})
|
|
10644
10881
|
});
|
|
10645
10882
|
}
|
|
10646
|
-
agentStep(
|
|
10647
|
-
this.assertId(
|
|
10883
|
+
agentStep(id2, opts) {
|
|
10884
|
+
this.assertId(id2, "agentStep()");
|
|
10648
10885
|
if (!opts || typeof opts.agentId !== "string" && !(opts.agentId && typeof opts.agentId === "object" && "__envRef" in opts.agentId)) {
|
|
10649
|
-
throw new LuaWorkflowBuildError("invalid-envelope", `agentStep("${
|
|
10886
|
+
throw new LuaWorkflowBuildError("invalid-envelope", `agentStep("${id2}") needs an agentId`);
|
|
10650
10887
|
}
|
|
10651
10888
|
const tier = opts.tier ?? (opts.workspace ? "job" : void 0);
|
|
10652
|
-
if (opts.workspace && opts.tier !== void 0 && opts.tier !== "job") throw new LuaWorkflowBuildError("workspace-requires-job-tier", `"${
|
|
10653
|
-
if (opts.harness !== void 0 && tier !== "job") throw new LuaWorkflowBuildError("harness-requires-job-tier", `"${
|
|
10654
|
-
if (opts.toolScope?.jobTools && tier !== "job") throw new LuaWorkflowBuildError("cap-exceeded", `"${
|
|
10889
|
+
if (opts.workspace && opts.tier !== void 0 && opts.tier !== "job") throw new LuaWorkflowBuildError("workspace-requires-job-tier", `"${id2}": a step mounting a workspace must be tier:'job'`);
|
|
10890
|
+
if (opts.harness !== void 0 && tier !== "job") throw new LuaWorkflowBuildError("harness-requires-job-tier", `"${id2}": harness is only legal on a tier:'job' agent step`);
|
|
10891
|
+
if (opts.toolScope?.jobTools && tier !== "job") throw new LuaWorkflowBuildError("cap-exceeded", `"${id2}": toolScope.jobTools require tier:'job' (job-tools-require-job-tier)`);
|
|
10655
10892
|
for (const m of WORKFLOW_JOB_RANGE_MEMBERS) {
|
|
10656
10893
|
if (opts[m] === void 0) continue;
|
|
10657
|
-
if (tier !== "job") throw new LuaWorkflowBuildError("max-turns-requires-job-tier", `"${
|
|
10894
|
+
if (tier !== "job") throw new LuaWorkflowBuildError("max-turns-requires-job-tier", `"${id2}": ${m} is only legal on a tier:'job' agent step`);
|
|
10658
10895
|
if (!isWithinWorkflowJobRange(m, opts[m])) {
|
|
10659
10896
|
const { min, max } = WORKFLOW_JOB_RANGES[m];
|
|
10660
|
-
throw new LuaWorkflowBuildError("max-turns-invalid", `"${
|
|
10897
|
+
throw new LuaWorkflowBuildError("max-turns-invalid", `"${id2}": ${m} must be an integer ${min}..${max}`);
|
|
10661
10898
|
}
|
|
10662
10899
|
}
|
|
10663
10900
|
assertTimeout({
|
|
10664
|
-
id,
|
|
10901
|
+
id: id2,
|
|
10665
10902
|
timeoutSeconds: opts.timeoutSeconds,
|
|
10666
10903
|
tier,
|
|
10667
10904
|
workspace: opts.workspace,
|
|
10668
10905
|
kind: "agent"
|
|
10669
10906
|
});
|
|
10670
|
-
assertRetry(opts.retry,
|
|
10907
|
+
assertRetry(opts.retry, id2);
|
|
10671
10908
|
this.recordEnvRefs(opts.agentId, opts.prompt);
|
|
10672
10909
|
const node = defined({
|
|
10673
10910
|
type: "agent",
|
|
10674
|
-
id,
|
|
10911
|
+
id: id2,
|
|
10675
10912
|
agentId: opts.agentId,
|
|
10676
10913
|
promptTemplate: templateText(opts.prompt),
|
|
10677
10914
|
outputSchema: schemaToJson(opts.outputSchema),
|
|
@@ -10699,30 +10936,30 @@ var init_workflow = __esm({
|
|
|
10699
10936
|
node
|
|
10700
10937
|
});
|
|
10701
10938
|
}
|
|
10702
|
-
specialistStep(
|
|
10703
|
-
this.assertId(
|
|
10939
|
+
specialistStep(id2, opts) {
|
|
10940
|
+
this.assertId(id2, "specialistStep()");
|
|
10704
10941
|
const role = opts?.role;
|
|
10705
|
-
if (!role || typeof role !== "object") throw new LuaWorkflowBuildError("invalid-envelope", `specialistStep("${
|
|
10942
|
+
if (!role || typeof role !== "object") throw new LuaWorkflowBuildError("invalid-envelope", `specialistStep("${id2}") needs a role`);
|
|
10706
10943
|
if (role.ref !== void 0 && (role.name !== void 0 || role.instructions !== void 0 || role.tools !== void 0)) {
|
|
10707
|
-
throw new LuaWorkflowBuildError("role-ref-and-inline", `"${
|
|
10944
|
+
throw new LuaWorkflowBuildError("role-ref-and-inline", `"${id2}": role is EITHER { ref } OR the inline { name, instructions, tools } shape`);
|
|
10708
10945
|
}
|
|
10709
10946
|
if (role.ref === void 0) {
|
|
10710
10947
|
if (typeof role.instructions !== "string" || role.instructions.length > WORKFLOW_SPECIALIST_ROLE_MAX_INSTRUCTIONS) {
|
|
10711
|
-
throw new LuaWorkflowBuildError("ephemeral-role-too-long", `"${
|
|
10948
|
+
throw new LuaWorkflowBuildError("ephemeral-role-too-long", `"${id2}": role.instructions must be \u2264 ${WORKFLOW_SPECIALIST_ROLE_MAX_INSTRUCTIONS} chars`);
|
|
10712
10949
|
}
|
|
10713
|
-
if (!Array.isArray(role.tools)) throw new LuaWorkflowBuildError("invalid-envelope", `"${
|
|
10714
|
-
if (role.tools.length > 64) throw new LuaWorkflowBuildError("cap-exceeded", `"${
|
|
10950
|
+
if (!Array.isArray(role.tools)) throw new LuaWorkflowBuildError("invalid-envelope", `"${id2}": role.tools must be an array ([] = no tools)`);
|
|
10951
|
+
if (role.tools.length > 64) throw new LuaWorkflowBuildError("cap-exceeded", `"${id2}": role.tools exceeds 64 entries`);
|
|
10715
10952
|
}
|
|
10716
10953
|
assertTimeout({
|
|
10717
|
-
id,
|
|
10954
|
+
id: id2,
|
|
10718
10955
|
timeoutSeconds: opts.timeoutSeconds,
|
|
10719
10956
|
kind: "agent"
|
|
10720
10957
|
});
|
|
10721
|
-
assertRetry(opts.retry,
|
|
10958
|
+
assertRetry(opts.retry, id2);
|
|
10722
10959
|
this.recordEnvRefs(opts.prompt);
|
|
10723
10960
|
const node = defined({
|
|
10724
10961
|
type: "agent",
|
|
10725
|
-
id,
|
|
10962
|
+
id: id2,
|
|
10726
10963
|
agentId: "$self",
|
|
10727
10964
|
role: role.ref !== void 0 ? {
|
|
10728
10965
|
ref: role.ref
|
|
@@ -10745,20 +10982,20 @@ var init_workflow = __esm({
|
|
|
10745
10982
|
node
|
|
10746
10983
|
});
|
|
10747
10984
|
}
|
|
10748
|
-
toolStep(
|
|
10749
|
-
this.assertId(
|
|
10750
|
-
if (!tool || typeof tool !== "object" || typeof tool.name !== "string") throw new LuaWorkflowBuildError("invalid-envelope", `toolStep("${
|
|
10751
|
-
assertNoClosure(opts.input, `toolStep("${
|
|
10985
|
+
toolStep(id2, tool, opts = {}) {
|
|
10986
|
+
this.assertId(id2, "toolStep()");
|
|
10987
|
+
if (!tool || typeof tool !== "object" || typeof tool.name !== "string") throw new LuaWorkflowBuildError("invalid-envelope", `toolStep("${id2}") needs a LuaTool`);
|
|
10988
|
+
assertNoClosure(opts.input, `toolStep("${id2}").input`);
|
|
10752
10989
|
this.recordEnvRefs(opts.input);
|
|
10753
10990
|
assertTimeout({
|
|
10754
|
-
id,
|
|
10991
|
+
id: id2,
|
|
10755
10992
|
timeoutSeconds: opts.timeoutSeconds,
|
|
10756
10993
|
kind: "tool"
|
|
10757
10994
|
});
|
|
10758
|
-
assertRetry(opts.retry,
|
|
10995
|
+
assertRetry(opts.retry, id2);
|
|
10759
10996
|
const node = defined({
|
|
10760
10997
|
type: "tool",
|
|
10761
|
-
id,
|
|
10998
|
+
id: id2,
|
|
10762
10999
|
toolId: tool.name,
|
|
10763
11000
|
input: opts.input,
|
|
10764
11001
|
timeoutSeconds: opts.timeoutSeconds,
|
|
@@ -10772,34 +11009,34 @@ var init_workflow = __esm({
|
|
|
10772
11009
|
node
|
|
10773
11010
|
});
|
|
10774
11011
|
}
|
|
10775
|
-
approval(
|
|
10776
|
-
this.assertId(
|
|
10777
|
-
if (!opts || typeof opts.title !== "string") throw new LuaWorkflowBuildError("invalid-envelope", `approval("${
|
|
11012
|
+
approval(id2, opts) {
|
|
11013
|
+
this.assertId(id2, "approval()");
|
|
11014
|
+
if (!opts || typeof opts.title !== "string") throw new LuaWorkflowBuildError("invalid-envelope", `approval("${id2}") needs a title`);
|
|
10778
11015
|
if (opts.approver === "creator" && opts.excludeInitiator === true) {
|
|
10779
|
-
throw new LuaWorkflowBuildError("approver-excludes-only-candidate", `"${
|
|
11016
|
+
throw new LuaWorkflowBuildError("approver-excludes-only-candidate", `"${id2}": approver:'creator' with excludeInitiator:true always excludes the only candidate`);
|
|
10780
11017
|
}
|
|
10781
11018
|
const editable = approvalEditable(opts);
|
|
10782
|
-
if (opts.fourEyes !== void 0 && !editable) throw new LuaWorkflowBuildError("four-eyes-requires-editable", `"${
|
|
11019
|
+
if (opts.fourEyes !== void 0 && !editable) throw new LuaWorkflowBuildError("four-eyes-requires-editable", `"${id2}": \`fourEyes\` requires editable:true`);
|
|
10783
11020
|
if (opts.editable === false && Array.isArray(opts.editablePaths) && opts.editablePaths.length > 0) {
|
|
10784
|
-
throw new LuaWorkflowBuildError("editable-path-invalid", `"${
|
|
11021
|
+
throw new LuaWorkflowBuildError("editable-path-invalid", `"${id2}": \`editablePaths\` beside editable:false is contradictory \u2014 drop the paths or set editable:true`);
|
|
10785
11022
|
} else if ((opts.editablePaths !== void 0 || opts.editedPayloadSchema !== void 0) && !editable) {
|
|
10786
|
-
throw new LuaWorkflowBuildError("editable-path-invalid", `"${
|
|
11023
|
+
throw new LuaWorkflowBuildError("editable-path-invalid", `"${id2}": \`editablePaths\` / \`editedPayloadSchema\` require editable:true (a non-empty editablePaths implies it)`);
|
|
10787
11024
|
}
|
|
10788
11025
|
for (const p of opts.editablePaths ?? []) {
|
|
10789
|
-
if (!EDITABLE_PATH_RE2.test(p)) throw new LuaWorkflowBuildError("editable-path-invalid", `"${
|
|
11026
|
+
if (!EDITABLE_PATH_RE2.test(p)) throw new LuaWorkflowBuildError("editable-path-invalid", `"${id2}": editablePaths entry "${p}" is outside the grammar seg(.seg)* with [*]/[n] selectors`);
|
|
10790
11027
|
}
|
|
10791
11028
|
if (Array.isArray(opts.onTimeout)) {
|
|
10792
11029
|
const chain = opts.onTimeout;
|
|
10793
11030
|
const hops = chain.filter((h) => typeof h === "object");
|
|
10794
|
-
if (hops.length > 3) throw new LuaWorkflowBuildError("escalation-chain-too-long", `"${
|
|
11031
|
+
if (hops.length > 3) throw new LuaWorkflowBuildError("escalation-chain-too-long", `"${id2}": an onTimeout chain carries at most 3 escalation hops`);
|
|
10795
11032
|
const last = chain[chain.length - 1];
|
|
10796
|
-
if (last === void 0 || typeof last === "object") throw new LuaWorkflowBuildError("escalation-chain-not-terminal", `"${
|
|
11033
|
+
if (last === void 0 || typeof last === "object") throw new LuaWorkflowBuildError("escalation-chain-not-terminal", `"${id2}": an onTimeout chain must end in a terminal member`);
|
|
10797
11034
|
}
|
|
10798
|
-
if (typeof opts.details === "function") throw new LuaWorkflowBuildError("closure-binding", `approval("${
|
|
11035
|
+
if (typeof opts.details === "function") throw new LuaWorkflowBuildError("closure-binding", `approval("${id2}").details must be template(...)`);
|
|
10799
11036
|
this.recordEnvRefs(opts.details, opts.timeoutHours, opts.approver);
|
|
10800
11037
|
const node = defined({
|
|
10801
11038
|
type: "approval",
|
|
10802
|
-
id,
|
|
11039
|
+
id: id2,
|
|
10803
11040
|
title: opts.title,
|
|
10804
11041
|
details: opts.details ? templateText(opts.details) : void 0,
|
|
10805
11042
|
approver: opts.approver,
|
|
@@ -10821,13 +11058,13 @@ var init_workflow = __esm({
|
|
|
10821
11058
|
node
|
|
10822
11059
|
});
|
|
10823
11060
|
}
|
|
10824
|
-
waitForSignal(
|
|
10825
|
-
this.assertId(
|
|
10826
|
-
if (!opts || typeof opts.signal !== "string" || opts.signal.length === 0) throw new LuaWorkflowBuildError("invalid-envelope", `waitForSignal("${
|
|
11061
|
+
waitForSignal(id2, opts) {
|
|
11062
|
+
this.assertId(id2, "waitForSignal()");
|
|
11063
|
+
if (!opts || typeof opts.signal !== "string" || opts.signal.length === 0) throw new LuaWorkflowBuildError("invalid-envelope", `waitForSignal("${id2}") needs a signal name`);
|
|
10827
11064
|
this.recordEnvRefs(opts.timeoutHours);
|
|
10828
11065
|
const node = defined({
|
|
10829
11066
|
type: "waitForSignal",
|
|
10830
|
-
id,
|
|
11067
|
+
id: id2,
|
|
10831
11068
|
signal: opts.signal,
|
|
10832
11069
|
schema: schemaToJson(opts.schema),
|
|
10833
11070
|
timeoutHours: opts.timeoutHours,
|
|
@@ -10840,28 +11077,28 @@ var init_workflow = __esm({
|
|
|
10840
11077
|
node
|
|
10841
11078
|
});
|
|
10842
11079
|
}
|
|
10843
|
-
workflow(
|
|
10844
|
-
this.assertId(
|
|
10845
|
-
assertRetry(opts?.retry,
|
|
11080
|
+
workflow(id2, ref, input, opts) {
|
|
11081
|
+
this.assertId(id2, "workflow()");
|
|
11082
|
+
assertRetry(opts?.retry, id2);
|
|
10846
11083
|
const name = typeof ref === "string" ? ref : ref instanceof LuaWorkflow ? ref.getName() : void 0;
|
|
10847
|
-
if (!name) throw new LuaWorkflowBuildError("invalid-envelope", `workflow("${
|
|
11084
|
+
if (!name) throw new LuaWorkflowBuildError("invalid-envelope", `workflow("${id2}") needs a LuaWorkflow or a workflow name`);
|
|
10848
11085
|
if (opts?.workspace === "inherit") {
|
|
10849
|
-
if (!this.config.workspace) throw new LuaWorkflowBuildError("workspace-inherit-without-parent-workspace", `"${
|
|
10850
|
-
if (ref instanceof LuaWorkflow && ref.getConfig().workspace) throw new LuaWorkflowBuildError("workspace-inherit-conflict", `"${
|
|
11086
|
+
if (!this.config.workspace) throw new LuaWorkflowBuildError("workspace-inherit-without-parent-workspace", `"${id2}": workspace:'inherit' but the parent createWorkflow declares no workspace`);
|
|
11087
|
+
if (ref instanceof LuaWorkflow && ref.getConfig().workspace) throw new LuaWorkflowBuildError("workspace-inherit-conflict", `"${id2}": workspace:'inherit' on a workflow that declares its own workspace`);
|
|
10851
11088
|
}
|
|
10852
|
-
assertNoClosure(input, `workflow("${
|
|
11089
|
+
assertNoClosure(input, `workflow("${id2}").input`);
|
|
10853
11090
|
this.recordEnvRefs(input);
|
|
10854
11091
|
this.nestedRefs.push(opts?.workspace === "inherit" ? {
|
|
10855
|
-
id,
|
|
11092
|
+
id: id2,
|
|
10856
11093
|
name,
|
|
10857
11094
|
workspace: "inherit"
|
|
10858
11095
|
} : {
|
|
10859
|
-
id,
|
|
11096
|
+
id: id2,
|
|
10860
11097
|
name
|
|
10861
11098
|
});
|
|
10862
11099
|
const node = defined({
|
|
10863
11100
|
type: "workflow",
|
|
10864
|
-
id,
|
|
11101
|
+
id: id2,
|
|
10865
11102
|
workflowId: name,
|
|
10866
11103
|
input,
|
|
10867
11104
|
workspace: opts?.workspace,
|
|
@@ -10940,8 +11177,8 @@ var init_workflow = __esm({
|
|
|
10940
11177
|
});
|
|
10941
11178
|
}
|
|
10942
11179
|
}
|
|
10943
|
-
assertId(
|
|
10944
|
-
if (typeof
|
|
11180
|
+
assertId(id2, where) {
|
|
11181
|
+
if (typeof id2 !== "string" || !STEP_ID_RE.test(id2)) throw new LuaWorkflowBuildError("invalid-step-id", `${where}: id "${String(id2)}" must match ${STEP_ID_RE}`);
|
|
10945
11182
|
}
|
|
10946
11183
|
};
|
|
10947
11184
|
EDITABLE_PATH_RE2 = /^[A-Za-z_][A-Za-z0-9_]*(\[(\*|\d+)\])?(\.[A-Za-z_][A-Za-z0-9_]*(\[(\*|\d+)\])?)*$/;
|
|
@@ -11197,7 +11434,7 @@ async function* parseSseStream(body, signal) {
|
|
|
11197
11434
|
const decoder = new TextDecoder();
|
|
11198
11435
|
let buffer = "";
|
|
11199
11436
|
const flush = /* @__PURE__ */ __name((block) => {
|
|
11200
|
-
let
|
|
11437
|
+
let id2;
|
|
11201
11438
|
let event = "message";
|
|
11202
11439
|
const data = [];
|
|
11203
11440
|
for (const rawLine of block.split("\n")) {
|
|
@@ -11207,11 +11444,11 @@ async function* parseSseStream(body, signal) {
|
|
|
11207
11444
|
const field = colon === -1 ? line : line.slice(0, colon);
|
|
11208
11445
|
let value3 = colon === -1 ? "" : line.slice(colon + 1);
|
|
11209
11446
|
if (value3.startsWith(" ")) value3 = value3.slice(1);
|
|
11210
|
-
if (field === "id")
|
|
11447
|
+
if (field === "id") id2 = value3;
|
|
11211
11448
|
else if (field === "event") event = value3;
|
|
11212
11449
|
else if (field === "data") data.push(value3);
|
|
11213
11450
|
}
|
|
11214
|
-
if (data.length === 0 &&
|
|
11451
|
+
if (data.length === 0 && id2 === void 0 && event === "message") return void 0;
|
|
11215
11452
|
const joined = data.join("\n");
|
|
11216
11453
|
let parsed = joined;
|
|
11217
11454
|
try {
|
|
@@ -11220,7 +11457,7 @@ async function* parseSseStream(body, signal) {
|
|
|
11220
11457
|
parsed = joined;
|
|
11221
11458
|
}
|
|
11222
11459
|
return {
|
|
11223
|
-
id,
|
|
11460
|
+
id: id2,
|
|
11224
11461
|
event,
|
|
11225
11462
|
data: parsed
|
|
11226
11463
|
};
|
|
@@ -12739,11 +12976,17 @@ var init_base_handler = __esm({
|
|
|
12739
12976
|
/**
|
|
12740
12977
|
* Phase 2 of parallel sync: apply fetched data to YAML.
|
|
12741
12978
|
* Optionally creates missing primitives on server if apiKey+agentId provided.
|
|
12979
|
+
*
|
|
12980
|
+
* PRO-2150 — `apiCredentials.registerOnly` drops the two writes that overwrite what the developer
|
|
12981
|
+
* pinned (the server-only orphan stubs in Part 1, and the version reconciliation half of Part 2)
|
|
12982
|
+
* while keeping id linking and create-on-server. `lua chat` uses it: it needs the skills'/processors'
|
|
12983
|
+
* server ids to exist before the sandbox push, and nothing else.
|
|
12742
12984
|
*/
|
|
12743
12985
|
async applySyncToYaml(serverData, config, manifest, apiCredentials) {
|
|
12744
12986
|
const messages = [];
|
|
12745
12987
|
let yamlUpdated = false;
|
|
12746
12988
|
let orphanedCount = 0;
|
|
12989
|
+
const registerOnly = apiCredentials?.registerOnly === true;
|
|
12747
12990
|
try {
|
|
12748
12991
|
if (!serverData.serverItems) {
|
|
12749
12992
|
if (serverData.fetchError) {
|
|
@@ -12771,10 +13014,10 @@ var init_base_handler = __esm({
|
|
|
12771
13014
|
messages.push(msg);
|
|
12772
13015
|
console.log(msg);
|
|
12773
13016
|
}
|
|
12774
|
-
const orphans = serverData.serverItems.filter((item) => {
|
|
12775
|
-
const
|
|
13017
|
+
const orphans = registerOnly ? [] : serverData.serverItems.filter((item) => {
|
|
13018
|
+
const id2 = item.id;
|
|
12776
13019
|
const name = item.name;
|
|
12777
|
-
return !yamlById.has(
|
|
13020
|
+
return !yamlById.has(id2) && !yamlByName.has(name) && this.isActive(item) && this.shouldConsiderForOrphan(item);
|
|
12778
13021
|
});
|
|
12779
13022
|
if (orphans.length > 0) {
|
|
12780
13023
|
const stubs = orphans.map((item) => this.cleanItem({
|
|
@@ -12798,7 +13041,9 @@ var init_base_handler = __esm({
|
|
|
12798
13041
|
`);
|
|
12799
13042
|
orphanedCount = orphans.length;
|
|
12800
13043
|
}
|
|
12801
|
-
const { items: updatedItems, changed, msgs } = this.syncFromServer(yamlItems, serverByName
|
|
13044
|
+
const { items: updatedItems, changed, msgs } = this.syncFromServer(yamlItems, serverByName, {
|
|
13045
|
+
syncVersions: !registerOnly
|
|
13046
|
+
});
|
|
12802
13047
|
messages.push(...msgs);
|
|
12803
13048
|
if (changed) {
|
|
12804
13049
|
yamlUpdated = true;
|
|
@@ -12990,7 +13235,7 @@ var init_base_handler = __esm({
|
|
|
12990
13235
|
const result = /* @__PURE__ */ new Map();
|
|
12991
13236
|
const { serverItems } = await this.fetchServerState(apiKey, agentId);
|
|
12992
13237
|
if (!serverItems) {
|
|
12993
|
-
entityIds.forEach((
|
|
13238
|
+
entityIds.forEach((id2) => result.set(id2, null));
|
|
12994
13239
|
return result;
|
|
12995
13240
|
}
|
|
12996
13241
|
for (const entityId of entityIds) {
|
|
@@ -13024,8 +13269,8 @@ var init_base_handler = __esm({
|
|
|
13024
13269
|
const yamlById = /* @__PURE__ */ new Map();
|
|
13025
13270
|
const yamlByName = /* @__PURE__ */ new Map();
|
|
13026
13271
|
for (const item of yamlItems) {
|
|
13027
|
-
const
|
|
13028
|
-
if (
|
|
13272
|
+
const id2 = this.getItemId(item);
|
|
13273
|
+
if (id2) yamlById.set(id2, item);
|
|
13029
13274
|
yamlByName.set(item.name, item);
|
|
13030
13275
|
}
|
|
13031
13276
|
const serverByName = /* @__PURE__ */ new Map();
|
|
@@ -13041,7 +13286,8 @@ var init_base_handler = __esm({
|
|
|
13041
13286
|
/**
|
|
13042
13287
|
* For each YAML item, match to server by name, populate missing IDs, update versions.
|
|
13043
13288
|
*/
|
|
13044
|
-
syncFromServer(yamlItems, serverByName) {
|
|
13289
|
+
syncFromServer(yamlItems, serverByName, options) {
|
|
13290
|
+
const syncVersions = options?.syncVersions !== false;
|
|
13045
13291
|
const msgs = [];
|
|
13046
13292
|
let changed = false;
|
|
13047
13293
|
const idField = this.yamlConfig.idField;
|
|
@@ -13062,7 +13308,7 @@ var init_base_handler = __esm({
|
|
|
13062
13308
|
};
|
|
13063
13309
|
}
|
|
13064
13310
|
const versions = serverItem.versions;
|
|
13065
|
-
if (Array.isArray(versions) && versions.length > 0) {
|
|
13311
|
+
if (syncVersions && Array.isArray(versions) && versions.length > 0) {
|
|
13066
13312
|
const activeVersion = this.getActiveVersion(serverItem);
|
|
13067
13313
|
const currentVersion = item.version;
|
|
13068
13314
|
if (activeVersion && activeVersion !== currentVersion) {
|
|
@@ -13116,11 +13362,15 @@ var init_base_handler = __esm({
|
|
|
13116
13362
|
};
|
|
13117
13363
|
}
|
|
13118
13364
|
}
|
|
13119
|
-
/**
|
|
13120
|
-
|
|
13365
|
+
/**
|
|
13366
|
+
* Phase 2 of parallel sync: apply fetched data to YAML (orphan detection only for non-versioned).
|
|
13367
|
+
* PRO-2150: `registerOnly` suppresses the server-only stub rows — the only write this override makes.
|
|
13368
|
+
*/
|
|
13369
|
+
async applySyncToYaml(serverData, config, manifest, apiCredentials) {
|
|
13121
13370
|
const messages = [];
|
|
13122
13371
|
let yamlUpdated = false;
|
|
13123
13372
|
let orphanedCount = 0;
|
|
13373
|
+
const registerOnly = apiCredentials?.registerOnly === true;
|
|
13124
13374
|
try {
|
|
13125
13375
|
if (!serverData.serverItems) {
|
|
13126
13376
|
if (serverData.fetchError) {
|
|
@@ -13146,10 +13396,10 @@ var init_base_handler = __esm({
|
|
|
13146
13396
|
i
|
|
13147
13397
|
]));
|
|
13148
13398
|
const manifestNames = manifest ? new Set(getPrimitivesByKind(manifest, this.kind).map((p) => p.name)) : /* @__PURE__ */ new Set();
|
|
13149
|
-
const orphans = serverData.serverItems.filter((item) => {
|
|
13150
|
-
const
|
|
13399
|
+
const orphans = registerOnly ? [] : serverData.serverItems.filter((item) => {
|
|
13400
|
+
const id2 = item.id;
|
|
13151
13401
|
const name = item.name;
|
|
13152
|
-
return !yamlById.has(
|
|
13402
|
+
return !yamlById.has(id2) && !yamlByName.has(name) && !manifestNames.has(name) && this.isActive(item);
|
|
13153
13403
|
});
|
|
13154
13404
|
if (orphans.length > 0) {
|
|
13155
13405
|
const stubs = orphans.map((item) => this.cleanItem({
|
|
@@ -13211,17 +13461,17 @@ var init_base_handler = __esm({
|
|
|
13211
13461
|
* using the handler's configured idField. Creates a new YAML entry if none
|
|
13212
13462
|
* exists yet (first-push case).
|
|
13213
13463
|
*/
|
|
13214
|
-
persistItemId(name,
|
|
13464
|
+
persistItemId(name, id2) {
|
|
13215
13465
|
const config = readYamlConfig();
|
|
13216
13466
|
const items = this.getFromYaml(config);
|
|
13217
13467
|
const idField = this.yamlConfig.idField;
|
|
13218
13468
|
const existing = items.find((i) => i.name === name);
|
|
13219
13469
|
if (existing) {
|
|
13220
|
-
existing[idField] =
|
|
13470
|
+
existing[idField] = id2;
|
|
13221
13471
|
} else {
|
|
13222
13472
|
items.push({
|
|
13223
13473
|
name,
|
|
13224
|
-
[idField]:
|
|
13474
|
+
[idField]: id2
|
|
13225
13475
|
});
|
|
13226
13476
|
}
|
|
13227
13477
|
this.updateYaml(items, config);
|
|
@@ -15276,7 +15526,7 @@ async function ensureSchemaConverterReady() {
|
|
|
15276
15526
|
await loadVendor();
|
|
15277
15527
|
}
|
|
15278
15528
|
async function zodToJsonSchema2(schemaNode) {
|
|
15279
|
-
const { z:
|
|
15529
|
+
const { z: z9, zodToJsonSchema: convertSchema } = await loadVendor();
|
|
15280
15530
|
try {
|
|
15281
15531
|
const sourceFile = schemaNode.getSourceFile();
|
|
15282
15532
|
const project = sourceFile.getProject();
|
|
@@ -15289,7 +15539,7 @@ async function zodToJsonSchema2(schemaNode) {
|
|
|
15289
15539
|
environment: {
|
|
15290
15540
|
preset: "NODE",
|
|
15291
15541
|
extra: {
|
|
15292
|
-
z:
|
|
15542
|
+
z: z9
|
|
15293
15543
|
}
|
|
15294
15544
|
},
|
|
15295
15545
|
policy: {
|
|
@@ -15337,10 +15587,10 @@ function cleanJsonSchema(schema) {
|
|
|
15337
15587
|
return cleanSchema;
|
|
15338
15588
|
}
|
|
15339
15589
|
async function zodStringToJsonSchema(zodSchemaCode) {
|
|
15340
|
-
const { z:
|
|
15590
|
+
const { z: z9, zodToJsonSchema: convertSchema } = await loadVendor();
|
|
15341
15591
|
try {
|
|
15342
15592
|
const evalFunction = new Function("z", `return ${zodSchemaCode}`);
|
|
15343
|
-
const zodSchema = evalFunction(
|
|
15593
|
+
const zodSchema = evalFunction(z9);
|
|
15344
15594
|
const jsonSchema = convertSchema(zodSchema, {
|
|
15345
15595
|
target: "jsonSchema7"
|
|
15346
15596
|
});
|
|
@@ -19764,24 +20014,24 @@ function buildSandboxGlobals() {
|
|
|
19764
20014
|
undefined: void 0
|
|
19765
20015
|
};
|
|
19766
20016
|
}
|
|
19767
|
-
function isRequireBlocklisted(
|
|
19768
|
-
return REQUIRE_BLOCKLIST.has(
|
|
20017
|
+
function isRequireBlocklisted(id2) {
|
|
20018
|
+
return REQUIRE_BLOCKLIST.has(id2) || BLOCKLISTED_PACKAGES.some((name) => id2.startsWith(`${name}/`));
|
|
19769
20019
|
}
|
|
19770
20020
|
function buildSandboxRequire(opts) {
|
|
19771
20021
|
const realRequire = createRequire(path6.join(opts.cwd, "package.json"));
|
|
19772
|
-
const wrapped = /* @__PURE__ */ __name6((
|
|
19773
|
-
if (isRequireBlocklisted(
|
|
20022
|
+
const wrapped = /* @__PURE__ */ __name6((id2) => {
|
|
20023
|
+
if (isRequireBlocklisted(id2)) {
|
|
19774
20024
|
const evt = {
|
|
19775
20025
|
event: "sandbox_require_blocklisted",
|
|
19776
|
-
module:
|
|
20026
|
+
module: id2,
|
|
19777
20027
|
mode: opts.mode
|
|
19778
20028
|
};
|
|
19779
20029
|
opts.onSecurityEvent?.(evt);
|
|
19780
20030
|
if (opts.mode === "enforce") {
|
|
19781
|
-
throw new Error(`require('${
|
|
20031
|
+
throw new Error(`require('${id2}') is not available in the Lua sandbox. If you have a legitimate use case, contact support.`);
|
|
19782
20032
|
}
|
|
19783
20033
|
}
|
|
19784
|
-
return realRequire(
|
|
20034
|
+
return realRequire(id2);
|
|
19785
20035
|
}, "wrapped");
|
|
19786
20036
|
wrapped.resolve = realRequire.resolve;
|
|
19787
20037
|
wrapped.cache = realRequire.cache;
|
|
@@ -20453,25 +20703,25 @@ function createBaseSandboxContext(opts) {
|
|
|
20453
20703
|
} : {}
|
|
20454
20704
|
};
|
|
20455
20705
|
const wrappedModuleCache = /* @__PURE__ */ new Map();
|
|
20456
|
-
const requireWithEgress = /* @__PURE__ */ __name6((
|
|
20457
|
-
const result = sandboxRequire(
|
|
20706
|
+
const requireWithEgress = /* @__PURE__ */ __name6((id2) => {
|
|
20707
|
+
const result = sandboxRequire(id2);
|
|
20458
20708
|
if (egressMode === "off") return result;
|
|
20459
|
-
if (wrappedModuleCache.has(
|
|
20709
|
+
if (wrappedModuleCache.has(id2)) return wrappedModuleCache.get(id2);
|
|
20460
20710
|
let wrapped = result;
|
|
20461
|
-
if (
|
|
20711
|
+
if (id2 === "http" || id2 === "node:http") {
|
|
20462
20712
|
wrapped = wrapHttpModule(result, egressOpts);
|
|
20463
|
-
} else if (
|
|
20713
|
+
} else if (id2 === "https" || id2 === "node:https") {
|
|
20464
20714
|
wrapped = wrapHttpsModule(result, egressOpts);
|
|
20465
|
-
} else if (
|
|
20715
|
+
} else if (id2 === "net" || id2 === "node:net") {
|
|
20466
20716
|
wrapped = wrapNetModule(result, egressOpts);
|
|
20467
|
-
} else if (
|
|
20717
|
+
} else if (id2 === "tls" || id2 === "node:tls") {
|
|
20468
20718
|
wrapped = wrapTlsModule(result, egressOpts);
|
|
20469
|
-
} else if (
|
|
20719
|
+
} else if (id2 === "http2" || id2 === "node:http2") {
|
|
20470
20720
|
wrapped = wrapHttp2Module(result, egressOpts);
|
|
20471
20721
|
} else {
|
|
20472
20722
|
return result;
|
|
20473
20723
|
}
|
|
20474
|
-
wrappedModuleCache.set(
|
|
20724
|
+
wrappedModuleCache.set(id2, wrapped);
|
|
20475
20725
|
return wrapped;
|
|
20476
20726
|
}, "requireWithEgress");
|
|
20477
20727
|
requireWithEgress.resolve = sandboxRequire.resolve;
|
|
@@ -20723,7 +20973,7 @@ var init_dist4 = __esm({
|
|
|
20723
20973
|
SANDBOX_FAKE_FILENAME = "/index.ts";
|
|
20724
20974
|
BLOCKLISTED_PACKAGES = [
|
|
20725
20975
|
...REQUIRE_BLOCKLIST
|
|
20726
|
-
].filter((
|
|
20976
|
+
].filter((id2) => !id2.startsWith("node:") && !builtinModules.includes(id2));
|
|
20727
20977
|
__name(isRequireBlocklisted, "isRequireBlocklisted");
|
|
20728
20978
|
__name6(isRequireBlocklisted, "isRequireBlocklisted");
|
|
20729
20979
|
__name(buildSandboxRequire, "buildSandboxRequire");
|
|
@@ -21508,12 +21758,12 @@ function createSerializationContext() {
|
|
|
21508
21758
|
}, "template")
|
|
21509
21759
|
});
|
|
21510
21760
|
const cryptoFacade = deterministicCrypto();
|
|
21511
|
-
const sandboxRequire = /* @__PURE__ */ __name((
|
|
21512
|
-
if (
|
|
21513
|
-
if (
|
|
21514
|
-
throw Object.assign(new Error(`${NOT_STATIC}: require('${
|
|
21761
|
+
const sandboxRequire = /* @__PURE__ */ __name((id2) => {
|
|
21762
|
+
if (id2 === "zod") return zodModule;
|
|
21763
|
+
if (id2 === "crypto" || id2 === "node:crypto") return cryptoFacade;
|
|
21764
|
+
throw Object.assign(new Error(`${NOT_STATIC}: require('${id2}') is not available in the serialization sandbox`), {
|
|
21515
21765
|
code: NOT_STATIC,
|
|
21516
|
-
offendingGlobal: `require('${
|
|
21766
|
+
offendingGlobal: `require('${id2}')`
|
|
21517
21767
|
});
|
|
21518
21768
|
}, "sandboxRequire");
|
|
21519
21769
|
const facades = {};
|
|
@@ -21709,9 +21959,9 @@ function callDeclaredIds(call, mapCounter) {
|
|
|
21709
21959
|
case "foreach":
|
|
21710
21960
|
case "dowhile":
|
|
21711
21961
|
case "dountil": {
|
|
21712
|
-
const
|
|
21713
|
-
return
|
|
21714
|
-
|
|
21962
|
+
const id2 = stepRefId(args2[0]);
|
|
21963
|
+
return id2 ? [
|
|
21964
|
+
id2
|
|
21715
21965
|
] : [];
|
|
21716
21966
|
}
|
|
21717
21967
|
case "parallel": {
|
|
@@ -21726,8 +21976,8 @@ function callDeclaredIds(call, mapCounter) {
|
|
|
21726
21976
|
if (arr && Node17.isArrayLiteralExpression(arr)) {
|
|
21727
21977
|
for (const el of arr.getElements()) {
|
|
21728
21978
|
if (Node17.isArrayLiteralExpression(el)) {
|
|
21729
|
-
const
|
|
21730
|
-
if (
|
|
21979
|
+
const id2 = stepRefId(el.getElements()[1]);
|
|
21980
|
+
if (id2) ids.push(id2);
|
|
21731
21981
|
}
|
|
21732
21982
|
}
|
|
21733
21983
|
}
|
|
@@ -21749,18 +21999,18 @@ function callDeclaredIds(call, mapCounter) {
|
|
|
21749
21999
|
];
|
|
21750
22000
|
if (name === "sleep" || name === "sleepUntil") {
|
|
21751
22001
|
const opts = args2[1];
|
|
21752
|
-
const
|
|
22002
|
+
const id2 = opts && Node17.isObjectLiteralExpression(opts) ? extractStringProperty(opts, "id") : void 0;
|
|
21753
22003
|
return [
|
|
21754
|
-
|
|
22004
|
+
id2 ?? `sleep_${++mapCounter.n}`
|
|
21755
22005
|
];
|
|
21756
22006
|
}
|
|
21757
22007
|
return [];
|
|
21758
22008
|
}
|
|
21759
22009
|
case "map": {
|
|
21760
22010
|
const opts = args2[1];
|
|
21761
|
-
const
|
|
22011
|
+
const id2 = opts && Node17.isObjectLiteralExpression(opts) ? extractStringProperty(opts, "id") : void 0;
|
|
21762
22012
|
return [
|
|
21763
|
-
|
|
22013
|
+
id2 ?? `map_${++mapCounter.n}`
|
|
21764
22014
|
];
|
|
21765
22015
|
}
|
|
21766
22016
|
default:
|
|
@@ -21777,7 +22027,7 @@ function stampSources(sourceFile, exportName, rootDir) {
|
|
|
21777
22027
|
};
|
|
21778
22028
|
for (const call of calls) {
|
|
21779
22029
|
const { line, column } = sourceFile.getLineAndColumnAtPos(call.getStart());
|
|
21780
|
-
for (const
|
|
22030
|
+
for (const id2 of callDeclaredIds(call, counter)) if (!out.has(id2)) out.set(id2, {
|
|
21781
22031
|
file,
|
|
21782
22032
|
line,
|
|
21783
22033
|
col: column
|
|
@@ -21806,7 +22056,7 @@ function collectBuilderCalls(expr) {
|
|
|
21806
22056
|
function serializeViaAst(sourceFile, exportName) {
|
|
21807
22057
|
const expr = locateWorkflowExpression(sourceFile, exportName);
|
|
21808
22058
|
if (!expr) return void 0;
|
|
21809
|
-
const
|
|
22059
|
+
const z9 = zodModule.z;
|
|
21810
22060
|
const committed = [];
|
|
21811
22061
|
const prev = __workflowCommitHook.onCommit;
|
|
21812
22062
|
__workflowCommitHook.onCommit = (wf) => committed.push(wf);
|
|
@@ -21819,7 +22069,7 @@ function serializeViaAst(sourceFile, exportName) {
|
|
|
21819
22069
|
preset: "NODE",
|
|
21820
22070
|
extra: {
|
|
21821
22071
|
...PRIMITIVE_SHIMS,
|
|
21822
|
-
z:
|
|
22072
|
+
z: z9,
|
|
21823
22073
|
env: Object.assign(() => "", {
|
|
21824
22074
|
template: /* @__PURE__ */ __name((k) => ({
|
|
21825
22075
|
__envRef: k
|
|
@@ -21870,13 +22120,13 @@ function sketchTopology(sourceFile, exportName, name, description) {
|
|
|
21870
22120
|
const seen = /* @__PURE__ */ new Set();
|
|
21871
22121
|
const graph = [];
|
|
21872
22122
|
for (const call of calls) {
|
|
21873
|
-
for (const
|
|
21874
|
-
if (seen.has(
|
|
21875
|
-
seen.add(
|
|
22123
|
+
for (const id2 of callDeclaredIds(call, counter)) {
|
|
22124
|
+
if (seen.has(id2)) continue;
|
|
22125
|
+
seen.add(id2);
|
|
21876
22126
|
graph.push({
|
|
21877
22127
|
type: "step",
|
|
21878
22128
|
step: {
|
|
21879
|
-
id
|
|
22129
|
+
id: id2
|
|
21880
22130
|
}
|
|
21881
22131
|
});
|
|
21882
22132
|
}
|
|
@@ -21909,9 +22159,9 @@ function sketchTopology(sourceFile, exportName, name, description) {
|
|
|
21909
22159
|
}
|
|
21910
22160
|
function metaOf(node, sources) {
|
|
21911
22161
|
const n2 = node;
|
|
21912
|
-
const
|
|
22162
|
+
const id2 = n2.type === "step" ? n2.step.id : n2.id;
|
|
21913
22163
|
const meta = {
|
|
21914
|
-
id,
|
|
22164
|
+
id: id2,
|
|
21915
22165
|
kind: kindOf(n2.type)
|
|
21916
22166
|
};
|
|
21917
22167
|
const pick = /* @__PURE__ */ __name((k, v) => {
|
|
@@ -21951,7 +22201,7 @@ function metaOf(node, sources) {
|
|
|
21951
22201
|
pick("itemTimeout", n2.itemTimeout);
|
|
21952
22202
|
}
|
|
21953
22203
|
if (n2.type === "waitForSignal") pick("outputSchema", n2.schema);
|
|
21954
|
-
const src = sources.get(
|
|
22204
|
+
const src = sources.get(id2);
|
|
21955
22205
|
if (src) meta.source = src;
|
|
21956
22206
|
return meta;
|
|
21957
22207
|
}
|
|
@@ -22251,8 +22501,8 @@ function collectDeclaredStepIds(sourceFile) {
|
|
|
22251
22501
|
if (callee.getText() !== "createStep") continue;
|
|
22252
22502
|
const cfg = init3.getArguments()[0];
|
|
22253
22503
|
if (cfg && Node18.isObjectLiteralExpression(cfg)) {
|
|
22254
|
-
const
|
|
22255
|
-
if (
|
|
22504
|
+
const id2 = extractStringProperty(cfg, "id");
|
|
22505
|
+
if (id2) ids.push(id2);
|
|
22256
22506
|
}
|
|
22257
22507
|
}
|
|
22258
22508
|
return ids;
|
|
@@ -22665,14 +22915,14 @@ ${firstBundleFrame(vmResult.error.stack)}` : ""}`,
|
|
|
22665
22915
|
source: w.stepId ? sources.get(w.stepId) : void 0
|
|
22666
22916
|
});
|
|
22667
22917
|
const graphIds = new Set(collectGraphIds(graph));
|
|
22668
|
-
for (const
|
|
22669
|
-
if (!graphIds.has(
|
|
22918
|
+
for (const id2 of metadata.metadata.declaredStepIds ?? []) {
|
|
22919
|
+
if (!graphIds.has(id2) && tier.topology !== "sketch") {
|
|
22670
22920
|
issues.push({
|
|
22671
22921
|
code: WORKFLOW_COMPILE_CODES.UNPLACED_STEP,
|
|
22672
|
-
message: `createStep "${
|
|
22922
|
+
message: `createStep "${id2}" is declared in ${relative(rootDir, metadata.sourcePath)} but placed in no workflow of the project (compiled with "${metadata.name}"; error at push \u2014 lua push workflow refuses the version: place it in a chain or delete the declaration)`,
|
|
22673
22923
|
severity: "warning",
|
|
22674
|
-
stepId:
|
|
22675
|
-
source: sources.get(
|
|
22924
|
+
stepId: id2,
|
|
22925
|
+
source: sources.get(id2)
|
|
22676
22926
|
});
|
|
22677
22927
|
}
|
|
22678
22928
|
}
|
|
@@ -22731,7 +22981,7 @@ ${firstBundleFrame(vmResult.error.stack)}` : ""}`,
|
|
|
22731
22981
|
const inheritTargets2 = new Set(workflows.flatMap((p) => p.graph?.inheritRefs ?? []));
|
|
22732
22982
|
for (const p of workflows) if (p.graph && inheritTargets2.has(p.name)) p.graph = applyInheritCandidate(p.graph);
|
|
22733
22983
|
const placed = /* @__PURE__ */ new Set();
|
|
22734
|
-
for (const p of workflows) for (const
|
|
22984
|
+
for (const p of workflows) for (const id2 of collectGraphIds(p.graph.graph)) placed.add(id2);
|
|
22735
22985
|
for (const p of workflows) {
|
|
22736
22986
|
if (!p.graph) continue;
|
|
22737
22987
|
p.graph.issues = p.graph.issues.filter((i) => i.code !== WORKFLOW_COMPILE_CODES.UNPLACED_STEP || !i.stepId || !placed.has(i.stepId));
|
|
@@ -27640,7 +27890,7 @@ var init_workflow_api_service = __esm({
|
|
|
27640
27890
|
throw new WorkflowApiError("FORBIDDEN", `Workflows.${member}: goals are scoped to the bound agent ${api.agentId}`, 403);
|
|
27641
27891
|
}
|
|
27642
27892
|
}, "assertBoundAgent");
|
|
27643
|
-
pathId = /* @__PURE__ */ __name((
|
|
27893
|
+
pathId = /* @__PURE__ */ __name((id2) => encodeURIComponent(id2), "pathId");
|
|
27644
27894
|
unavailable = /* @__PURE__ */ __name((member, route) => async () => {
|
|
27645
27895
|
throw new WorkflowApiError("WORKFLOWS_API_UNAVAILABLE", `Workflows.${member} is not available in this runtime yet (${route} lands with a later wave)`, 501);
|
|
27646
27896
|
}, "unavailable");
|
|
@@ -29025,9 +29275,10 @@ var init_mcp_server_handler = __esm({
|
|
|
29025
29275
|
* 1. Link its id into an existing YAML entry by name if the id is missing.
|
|
29026
29276
|
* 2. Append a new YAML entry if no local match by id or name exists.
|
|
29027
29277
|
*/
|
|
29028
|
-
async applySyncToYaml(serverData, config, _manifest) {
|
|
29278
|
+
async applySyncToYaml(serverData, config, _manifest, apiCredentials) {
|
|
29029
29279
|
const messages = [];
|
|
29030
29280
|
let yamlUpdated = false;
|
|
29281
|
+
const registerOnly = apiCredentials?.registerOnly === true;
|
|
29031
29282
|
if (!serverData.serverItems) {
|
|
29032
29283
|
if (serverData.fetchError) {
|
|
29033
29284
|
console.error(`\u274C Error syncing server ${this.displayNamePlural}: ${serverData.fetchError}`);
|
|
@@ -29050,32 +29301,33 @@ var init_mcp_server_handler = __esm({
|
|
|
29050
29301
|
const idToIndex = /* @__PURE__ */ new Map();
|
|
29051
29302
|
const nameToIndex = /* @__PURE__ */ new Map();
|
|
29052
29303
|
items.forEach((item, idx) => {
|
|
29053
|
-
const
|
|
29054
|
-
if (
|
|
29304
|
+
const id2 = getId(item);
|
|
29305
|
+
if (id2) idToIndex.set(id2, idx);
|
|
29055
29306
|
nameToIndex.set(item.name, idx);
|
|
29056
29307
|
});
|
|
29057
29308
|
for (const serverItem of syncableServers) {
|
|
29058
|
-
const
|
|
29309
|
+
const id2 = serverItem.id;
|
|
29059
29310
|
const name = serverItem.name;
|
|
29060
|
-
if (idToIndex.has(
|
|
29311
|
+
if (idToIndex.has(id2)) continue;
|
|
29061
29312
|
const nameIdx = nameToIndex.get(name);
|
|
29062
29313
|
if (nameIdx !== void 0) {
|
|
29063
29314
|
if (!getId(items[nameIdx])) {
|
|
29064
|
-
items[nameIdx][idField] =
|
|
29065
|
-
idToIndex.set(
|
|
29066
|
-
const msg2 = `\u{1F517} Linked "${name}" ${this.displayName} to server (ID: ${
|
|
29315
|
+
items[nameIdx][idField] = id2;
|
|
29316
|
+
idToIndex.set(id2, nameIdx);
|
|
29317
|
+
const msg2 = `\u{1F517} Linked "${name}" ${this.displayName} to server (ID: ${id2})`;
|
|
29067
29318
|
messages.push(msg2);
|
|
29068
29319
|
console.log(msg2);
|
|
29069
29320
|
yamlUpdated = true;
|
|
29070
29321
|
}
|
|
29071
29322
|
continue;
|
|
29072
29323
|
}
|
|
29324
|
+
if (registerOnly) continue;
|
|
29073
29325
|
const newItem = {
|
|
29074
29326
|
name,
|
|
29075
|
-
mcpServerId:
|
|
29327
|
+
mcpServerId: id2
|
|
29076
29328
|
};
|
|
29077
29329
|
items.push(newItem);
|
|
29078
|
-
idToIndex.set(
|
|
29330
|
+
idToIndex.set(id2, items.length - 1);
|
|
29079
29331
|
nameToIndex.set(name, items.length - 1);
|
|
29080
29332
|
const msg = `\u{1F4E5} Added "${name}" ${this.displayName} from server`;
|
|
29081
29333
|
messages.push(msg);
|
|
@@ -35693,7 +35945,7 @@ function coerceAgentStepOutput(schema, reply) {
|
|
|
35693
35945
|
}
|
|
35694
35946
|
__name(coerceAgentStepOutput, "coerceAgentStepOutput");
|
|
35695
35947
|
var armId2 = /* @__PURE__ */ __name((arm) => arm.type === "step" ? arm.step.id : arm.id, "armId");
|
|
35696
|
-
var baseIdOf = /* @__PURE__ */ __name((
|
|
35948
|
+
var baseIdOf = /* @__PURE__ */ __name((id2) => id2.replace(/(\[\d+\]|#\d+)$/, ""), "baseIdOf");
|
|
35697
35949
|
var outputSchemaOf = /* @__PURE__ */ __name((entry) => {
|
|
35698
35950
|
if (!entry) return void 0;
|
|
35699
35951
|
if (entry.type === "step") return entry.step.outputSchema;
|
|
@@ -35797,36 +36049,36 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
35797
36049
|
runtimeBodies.set(body.type === "step" ? body.step.id : body.id, body);
|
|
35798
36050
|
}
|
|
35799
36051
|
}
|
|
35800
|
-
for (const [
|
|
35801
|
-
const node = plan.steps[
|
|
35802
|
-
const body = node ? void 0 : runtimeBodies.get(
|
|
35803
|
-
if (!node && !body) throw new WorkflowLocalUsageError("unknown-step", `--step-output: unknown step "${
|
|
36052
|
+
for (const [id2, out] of Object.entries(opts.stepOutputs ?? {})) {
|
|
36053
|
+
const node = plan.steps[id2];
|
|
36054
|
+
const body = node ? void 0 : runtimeBodies.get(id2);
|
|
36055
|
+
if (!node && !body) throw new WorkflowLocalUsageError("unknown-step", `--step-output: unknown step "${id2}"`, id2);
|
|
35804
36056
|
const schema = outputSchemaOf(node?.entry ?? body);
|
|
35805
36057
|
const issues = schema ? validateJsonSchema(schema, out) : [];
|
|
35806
36058
|
if (issues.length) {
|
|
35807
|
-
throw new WorkflowLocalUsageError("step-output-schema", `--step-output ${
|
|
36059
|
+
throw new WorkflowLocalUsageError("step-output-schema", `--step-output ${id2}: ${issues.join("; ")}`, id2);
|
|
35808
36060
|
}
|
|
35809
36061
|
}
|
|
35810
|
-
const approvalEntryOf = /* @__PURE__ */ __name((
|
|
35811
|
-
const node = plan.steps[
|
|
36062
|
+
const approvalEntryOf = /* @__PURE__ */ __name((id2) => {
|
|
36063
|
+
const node = plan.steps[id2];
|
|
35812
36064
|
if (node?.kind === "approval") return node.entry;
|
|
35813
|
-
const body = runtimeBodies.get(
|
|
36065
|
+
const body = runtimeBodies.get(id2) ?? runtimeBodies.get(baseIdOf(id2));
|
|
35814
36066
|
return body?.type === "approval" ? body : void 0;
|
|
35815
36067
|
}, "approvalEntryOf");
|
|
35816
|
-
for (const [
|
|
35817
|
-
const entry = approvalEntryOf(
|
|
36068
|
+
for (const [id2, answer] of Object.entries(opts.approvals ?? {})) {
|
|
36069
|
+
const entry = approvalEntryOf(id2);
|
|
35818
36070
|
if (!entry) {
|
|
35819
|
-
throw new WorkflowLocalUsageError("unknown-approval", `--approve/--deny: "${
|
|
36071
|
+
throw new WorkflowLocalUsageError("unknown-approval", `--approve/--deny: "${id2}" is not an approval step`, id2);
|
|
35820
36072
|
}
|
|
35821
36073
|
if (answer.decision === "approve" && answer.payload !== void 0) {
|
|
35822
36074
|
const editable = entry.editablePaths ?? [];
|
|
35823
36075
|
if (!entry.editable && editable.length === 0) {
|
|
35824
|
-
throw new WorkflowLocalUsageError("approval-not-editable", `--approve ${
|
|
36076
|
+
throw new WorkflowLocalUsageError("approval-not-editable", `--approve ${id2}: the approval is not editable`, id2);
|
|
35825
36077
|
}
|
|
35826
36078
|
if (entry.editedPayloadSchema) {
|
|
35827
36079
|
const issues = validateJsonSchema(entry.editedPayloadSchema, answer.payload);
|
|
35828
36080
|
if (issues.length) {
|
|
35829
|
-
throw new WorkflowLocalUsageError("edited-payload-schema", `--approve ${
|
|
36081
|
+
throw new WorkflowLocalUsageError("edited-payload-schema", `--approve ${id2}: ${issues.join("; ")}`, id2);
|
|
35830
36082
|
}
|
|
35831
36083
|
}
|
|
35832
36084
|
}
|
|
@@ -35873,9 +36125,9 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
35873
36125
|
}, "emit");
|
|
35874
36126
|
const stamp = /* @__PURE__ */ __name(() => new Date(clock).toISOString().slice(11, 19), "stamp");
|
|
35875
36127
|
const rows3 = /* @__PURE__ */ new Map();
|
|
35876
|
-
const addRow = /* @__PURE__ */ __name((
|
|
36128
|
+
const addRow = /* @__PURE__ */ __name((id2, node, dependsOn, downstream, extra = {}) => {
|
|
35877
36129
|
const row2 = {
|
|
35878
|
-
stepId:
|
|
36130
|
+
stepId: id2,
|
|
35879
36131
|
kind: node.kind,
|
|
35880
36132
|
status: "pending",
|
|
35881
36133
|
attempt: 0,
|
|
@@ -35885,12 +36137,12 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
35885
36137
|
unsatisfied: dependsOn.length,
|
|
35886
36138
|
...extra
|
|
35887
36139
|
};
|
|
35888
|
-
rows3.set(
|
|
36140
|
+
rows3.set(id2, row2);
|
|
35889
36141
|
return row2;
|
|
35890
36142
|
}, "addRow");
|
|
35891
|
-
for (const
|
|
35892
|
-
const node = plan.steps[
|
|
35893
|
-
addRow(
|
|
36143
|
+
for (const id2 of plan.order) {
|
|
36144
|
+
const node = plan.steps[id2];
|
|
36145
|
+
addRow(id2, node, [
|
|
35894
36146
|
...node.dependsOn
|
|
35895
36147
|
], [
|
|
35896
36148
|
...node.downstream
|
|
@@ -36093,14 +36345,14 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36093
36345
|
suspendData,
|
|
36094
36346
|
// LUA-706: a run without input reads `null` — the pod's and the worker's rule (never `undefined`).
|
|
36095
36347
|
getInitData: /* @__PURE__ */ __name(() => opts.input === void 0 ? null : opts.input, "getInitData"),
|
|
36096
|
-
getStepResult: /* @__PURE__ */ __name((
|
|
36097
|
-
if (!(
|
|
36098
|
-
const err = Object.assign(new Error(`step "${
|
|
36348
|
+
getStepResult: /* @__PURE__ */ __name((id2) => {
|
|
36349
|
+
if (!(id2 in stepResults)) {
|
|
36350
|
+
const err = Object.assign(new Error(`step "${id2}" is not a completed ancestor of "${row2.stepId}"`), {
|
|
36099
36351
|
code: "STEP_RESULT_NOT_ANCESTOR"
|
|
36100
36352
|
});
|
|
36101
36353
|
throw err;
|
|
36102
36354
|
}
|
|
36103
|
-
return stepResults[
|
|
36355
|
+
return stepResults[id2];
|
|
36104
36356
|
}, "getStepResult"),
|
|
36105
36357
|
state: {
|
|
36106
36358
|
get: /* @__PURE__ */ __name((k) => ledger.state[k], "get"),
|
|
@@ -36163,15 +36415,15 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36163
36415
|
return new StepFailure("input_schema_invalid", `input does not match inputSchema of "${single.step.id}" \u2014 the previous node does not emit what the step declares: ${issues.join("; ")}`);
|
|
36164
36416
|
}, "stepInputIssue");
|
|
36165
36417
|
const agentReply = /* @__PURE__ */ __name(async (row2, single, input) => {
|
|
36166
|
-
const
|
|
36167
|
-
const fixture = opts.fixturesDir ? readFixture(
|
|
36418
|
+
const id2 = row2.stepId;
|
|
36419
|
+
const fixture = opts.fixturesDir ? readFixture(id2, row2.attempt) : void 0;
|
|
36168
36420
|
if (opts.fixturesDir) return fixture;
|
|
36169
36421
|
const prompt = renderPrompt(single);
|
|
36170
36422
|
if (opts.agents === "live") {
|
|
36171
36423
|
if (!opts.agentInvoke) throw new StepFailure("AGENTS_LIVE_UNAVAILABLE", "--agents live needs a dev API session");
|
|
36172
36424
|
const t0 = Date.now();
|
|
36173
|
-
const out = await withWall(
|
|
36174
|
-
record(
|
|
36425
|
+
const out = await withWall(id2, single, () => opts.agentInvoke(single, prompt, input));
|
|
36426
|
+
record(id2, row2.attempt, {
|
|
36175
36427
|
prompt,
|
|
36176
36428
|
input
|
|
36177
36429
|
}, out, Date.now() - t0);
|
|
@@ -36186,8 +36438,8 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36186
36438
|
elapsedS += wallS;
|
|
36187
36439
|
clock += wallS * 1e3;
|
|
36188
36440
|
const requeued = s < segments;
|
|
36189
|
-
const nextSession = `session-${
|
|
36190
|
-
emit3("step.checkpointed",
|
|
36441
|
+
const nextSession = `session-${id2}-s${s}`;
|
|
36442
|
+
emit3("step.checkpointed", id2, {
|
|
36191
36443
|
segment: s,
|
|
36192
36444
|
segmentsMax: segments,
|
|
36193
36445
|
headSha: `local${s}`,
|
|
@@ -36203,7 +36455,7 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36203
36455
|
sessionRef: nextSession,
|
|
36204
36456
|
reason: requeued ? "segment_boundary" : "interval"
|
|
36205
36457
|
});
|
|
36206
|
-
say(`[${stamp()}] ${
|
|
36458
|
+
say(`[${stamp()}] ${id2} \xB7 checkpointed \xB7 segment ${s}/${segments}${requeued ? ` \u2192 re-queued (resume ${nextSession})` : ""}`);
|
|
36207
36459
|
sessionRef = nextSession;
|
|
36208
36460
|
}
|
|
36209
36461
|
return {
|
|
@@ -36220,16 +36472,16 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36220
36472
|
object: stubFromSchema(single.outputSchema)
|
|
36221
36473
|
} : {}, "fakeObject");
|
|
36222
36474
|
const executeSingle = /* @__PURE__ */ __name(async (row2, single, rawInput) => {
|
|
36223
|
-
const
|
|
36475
|
+
const id2 = row2.stepId;
|
|
36224
36476
|
const input = nodeInputFor(row2, single, rawInput);
|
|
36225
36477
|
const drift = stepInputIssue(single, input);
|
|
36226
36478
|
if (drift) throw drift;
|
|
36227
|
-
if (opts.stepOutputs &&
|
|
36228
|
-
say(`[${stamp()}] ${
|
|
36229
|
-
return opts.stepOutputs[
|
|
36479
|
+
if (opts.stepOutputs && id2 in opts.stepOutputs) {
|
|
36480
|
+
say(`[${stamp()}] ${id2} \xB7 step-output supplied \u2014 execute skipped`);
|
|
36481
|
+
return opts.stepOutputs[id2];
|
|
36230
36482
|
}
|
|
36231
|
-
const baseId = baseIdOf(
|
|
36232
|
-
if (opts.stepOutputs && baseId !==
|
|
36483
|
+
const baseId = baseIdOf(id2);
|
|
36484
|
+
if (opts.stepOutputs && baseId !== id2 && baseId in opts.stepOutputs) return opts.stepOutputs[baseId];
|
|
36233
36485
|
switch (single.type) {
|
|
36234
36486
|
case "step": {
|
|
36235
36487
|
const def = opts.steps[single.step.id];
|
|
@@ -36240,22 +36492,22 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36240
36492
|
let suspendData;
|
|
36241
36493
|
for (; ; ) {
|
|
36242
36494
|
try {
|
|
36243
|
-
return await withWall(
|
|
36495
|
+
return await withWall(id2, single, (signal) => def.execute(buildCtx(row2, single, input, resumeData, suspendData, signal)));
|
|
36244
36496
|
} catch (e) {
|
|
36245
36497
|
if (e instanceof SuspendSignal) {
|
|
36246
36498
|
row2.status = "suspended";
|
|
36247
|
-
emit3("step.suspended",
|
|
36499
|
+
emit3("step.suspended", id2, {
|
|
36248
36500
|
kind: "input"
|
|
36249
36501
|
});
|
|
36250
|
-
say(`[${stamp()}] ${
|
|
36502
|
+
say(`[${stamp()}] ${id2} \xB7 suspended \xB7 awaiting resumeData`);
|
|
36251
36503
|
if (!opts.prompt) {
|
|
36252
|
-
throw new WorkflowLocalUsageError("RESUME_UNANSWERED", `step "${
|
|
36504
|
+
throw new WorkflowLocalUsageError("RESUME_UNANSWERED", `step "${id2}" suspended and no resumeData is available offline (interactive stdin required)`, id2);
|
|
36253
36505
|
}
|
|
36254
36506
|
suspendData = e.payload;
|
|
36255
|
-
resumeData = await opts.prompt("resume",
|
|
36507
|
+
resumeData = await opts.prompt("resume", id2, e.payload);
|
|
36256
36508
|
const schema = single.step.resumeSchema;
|
|
36257
36509
|
const issues = schema ? validateJsonSchema(schema, resumeData) : [];
|
|
36258
|
-
if (issues.length) throw new WorkflowLocalUsageError("resume-schema", `resumeData for ${
|
|
36510
|
+
if (issues.length) throw new WorkflowLocalUsageError("resume-schema", `resumeData for ${id2}: ${issues.join("; ")}`, id2);
|
|
36259
36511
|
row2.status = "running";
|
|
36260
36512
|
continue;
|
|
36261
36513
|
}
|
|
@@ -36272,17 +36524,17 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36272
36524
|
return coerced.output;
|
|
36273
36525
|
}
|
|
36274
36526
|
case "tool": {
|
|
36275
|
-
if (opts.fixturesDir) return readFixture(
|
|
36527
|
+
if (opts.fixturesDir) return readFixture(id2, row2.attempt);
|
|
36276
36528
|
if (!opts.toolInvoke) {
|
|
36277
|
-
throw new StepFailure("TOOL_NOT_AVAILABLE_OFFLINE", `tool step "${
|
|
36529
|
+
throw new StepFailure("TOOL_NOT_AVAILABLE_OFFLINE", `tool step "${id2}" (${single.toolId}) \u2014 supply --step-output ${id2}=<json> or --fixtures`);
|
|
36278
36530
|
}
|
|
36279
36531
|
const t0 = Date.now();
|
|
36280
|
-
const out = await withWall(
|
|
36281
|
-
record(
|
|
36532
|
+
const out = await withWall(id2, single, () => opts.toolInvoke(single, input));
|
|
36533
|
+
record(id2, row2.attempt, input, out, Date.now() - t0);
|
|
36282
36534
|
return out;
|
|
36283
36535
|
}
|
|
36284
36536
|
case "workflow": {
|
|
36285
|
-
throw new StepFailure("SUBRUN_NOT_SUPPORTED_OFFLINE", `nested workflow "${single.workflowId}" cannot run offline \u2014 supply --step-output ${
|
|
36537
|
+
throw new StepFailure("SUBRUN_NOT_SUPPORTED_OFFLINE", `nested workflow "${single.workflowId}" cannot run offline \u2014 supply --step-output ${id2}=<json>`);
|
|
36286
36538
|
}
|
|
36287
36539
|
}
|
|
36288
36540
|
}, "executeSingle");
|
|
@@ -36953,7 +37205,7 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36953
37205
|
}
|
|
36954
37206
|
const lastId = [
|
|
36955
37207
|
...plan.order
|
|
36956
|
-
].reverse().find((
|
|
37208
|
+
].reverse().find((id2) => rows3.get(id2)?.status === "completed");
|
|
36957
37209
|
const tail = lastId ? rows3.get(lastId) : void 0;
|
|
36958
37210
|
const tailOutput = tail && tail.node.kind !== "branch" && tail.node.kind !== "foreach" ? tail.output : lastId ? stepResults[joinIdOf(lastId)] ?? tail?.output : void 0;
|
|
36959
37211
|
const output = tailOutput;
|
|
@@ -36988,9 +37240,9 @@ async function runWorkflowLocallyInner(rawOpts) {
|
|
|
36988
37240
|
timeline
|
|
36989
37241
|
};
|
|
36990
37242
|
function finalizeLedger() {
|
|
36991
|
-
for (const [
|
|
36992
|
-
ledger.steps[
|
|
36993
|
-
stepId:
|
|
37243
|
+
for (const [id2, r] of rows3) {
|
|
37244
|
+
ledger.steps[id2] = {
|
|
37245
|
+
stepId: id2,
|
|
36994
37246
|
kind: r.kind,
|
|
36995
37247
|
status: r.status,
|
|
36996
37248
|
attempt: r.attempt,
|
|
@@ -37879,8 +38131,8 @@ var WorkflowHandler = class extends BaseVersionedHandler {
|
|
|
37879
38131
|
staleYamlRows(yamlItems, serverItems, manifestNames) {
|
|
37880
38132
|
const serverIds = new Set(serverItems.map((s) => s?.id));
|
|
37881
38133
|
return yamlItems.filter((row2) => {
|
|
37882
|
-
const
|
|
37883
|
-
return !!
|
|
38134
|
+
const id2 = this.getItemId(row2);
|
|
38135
|
+
return !!id2 && !serverIds.has(id2) && manifestNames.has(row2.name);
|
|
37884
38136
|
});
|
|
37885
38137
|
}
|
|
37886
38138
|
async publishVersion(apiKey, agentId, entityId, version) {
|
|
@@ -38025,7 +38277,7 @@ var WorkflowHandler = class extends BaseVersionedHandler {
|
|
|
38025
38277
|
};
|
|
38026
38278
|
var workflowHandler = new WorkflowHandler();
|
|
38027
38279
|
function unplacedStepError(workflowName, stepIds) {
|
|
38028
|
-
const list = stepIds.map((
|
|
38280
|
+
const list = stepIds.map((id2) => `"${id2}"`).join(", ");
|
|
38029
38281
|
return new CliError("unplaced_step", `workflow "${workflowName}" is not pushed: createStep ${list} ${stepIds.length === 1 ? "is" : "are"} declared in its source file but placed in no workflow (WORKFLOW_UNPLACED_STEP)`, {
|
|
38030
38282
|
hint: `place ${stepIds.length === 1 ? "it" : "them"} in a chain (.then(step) / .parallel([...])) or delete the declaration, then push again \u2014 lua compile lists every unplaced step`
|
|
38031
38283
|
});
|
|
@@ -38040,9 +38292,9 @@ __name(toolUnbundledError, "toolUnbundledError");
|
|
|
38040
38292
|
function workflowNameTakenHint(name, error) {
|
|
38041
38293
|
if (error?.code !== "WORKFLOW_NAME_TAKEN") return null;
|
|
38042
38294
|
const holder = error.dynamic ? "a chat-composed (dynamic) workflow" : "an existing workflow";
|
|
38043
|
-
const
|
|
38295
|
+
const id2 = error.workflowId ? ` (${error.workflowId})` : "";
|
|
38044
38296
|
const see = error.dynamic ? "run `lua workflows list --all` to see it" : "run `lua workflows list` to see it";
|
|
38045
|
-
return `workflow name "${name}" is held by ${holder}${
|
|
38297
|
+
return `workflow name "${name}" is held by ${holder}${id2} \u2014 ${see}. Push does not replace it: rename this workflow, or delete the other one first.`;
|
|
38046
38298
|
}
|
|
38047
38299
|
__name(workflowNameTakenHint, "workflowNameTakenHint");
|
|
38048
38300
|
function workflowModelMemberError(workflowName, issues) {
|
|
@@ -38087,7 +38339,8 @@ async function compileCommand(options) {
|
|
|
38087
38339
|
const debugMode = options?.debug || debugEnabled();
|
|
38088
38340
|
const verboseMode = options?.verbose || debugMode;
|
|
38089
38341
|
const doSync = options?.sync === true;
|
|
38090
|
-
const
|
|
38342
|
+
const registerOnly = options?.serverSync === "register-only";
|
|
38343
|
+
const doServerSync = options?.serverSync === true || registerOnly;
|
|
38091
38344
|
if (debugMode) {
|
|
38092
38345
|
console.log("\u{1F41B} Debug mode enabled");
|
|
38093
38346
|
}
|
|
@@ -38186,12 +38439,13 @@ async function compileCommand(options) {
|
|
|
38186
38439
|
if (!doServerSync) {
|
|
38187
38440
|
writeInfo("\u2139\uFE0F Server sync skipped \u2014 nothing was sent to the server; `lua push` publishes.");
|
|
38188
38441
|
} else if (apiKey && agentId) {
|
|
38189
|
-
writeProgress("\u{1F504} Syncing with server...");
|
|
38442
|
+
writeProgress(registerOnly ? "\u{1F504} Registering primitives with server (read-only for lua.skill.yaml versions)..." : "\u{1F504} Syncing with server...");
|
|
38190
38443
|
const fetchResults = await Promise.all(syncableHandlers.map((h) => h.fetchServerState(apiKey, agentId)));
|
|
38191
38444
|
for (let i = 0; i < syncableHandlers.length; i++) {
|
|
38192
38445
|
const applyResult = await syncableHandlers[i].applySyncToYaml(fetchResults[i], syncConfig, result.manifest, {
|
|
38193
38446
|
apiKey,
|
|
38194
|
-
agentId
|
|
38447
|
+
agentId,
|
|
38448
|
+
registerOnly
|
|
38195
38449
|
});
|
|
38196
38450
|
if (applyResult.yamlUpdated) {
|
|
38197
38451
|
syncConfig = readYamlConfig();
|
|
@@ -40081,24 +40335,24 @@ function parseSteeringFlags(flags) {
|
|
|
40081
40335
|
const approvals = {};
|
|
40082
40336
|
for (const raw of asList(flags.approve)) {
|
|
40083
40337
|
const eq3 = raw.indexOf("=");
|
|
40084
|
-
const
|
|
40085
|
-
if (!
|
|
40086
|
-
approvals[
|
|
40338
|
+
const id2 = (eq3 === -1 ? raw : raw.slice(0, eq3)).trim();
|
|
40339
|
+
if (!id2) throw new WorkflowLocalUsageError("usage", `--approve expects <id>[=@payload] (got "${raw}")`);
|
|
40340
|
+
approvals[id2] = {
|
|
40087
40341
|
decision: "approve",
|
|
40088
|
-
payload: eq3 === -1 ? void 0 : parseJsonOrFile(raw.slice(eq3 + 1).trim(), `--approve ${
|
|
40342
|
+
payload: eq3 === -1 ? void 0 : parseJsonOrFile(raw.slice(eq3 + 1).trim(), `--approve ${id2}`)
|
|
40089
40343
|
};
|
|
40090
40344
|
}
|
|
40091
40345
|
for (const raw of asList(flags.deny)) {
|
|
40092
40346
|
const eq3 = raw.indexOf("=");
|
|
40093
|
-
const
|
|
40094
|
-
if (!
|
|
40095
|
-
if (approvals[
|
|
40347
|
+
const id2 = (eq3 === -1 ? raw : raw.slice(0, eq3)).trim();
|
|
40348
|
+
if (!id2) throw new WorkflowLocalUsageError("usage", `--deny expects <id>[=@reason] (got "${raw}")`);
|
|
40349
|
+
if (approvals[id2]) throw new WorkflowLocalUsageError("usage", `--deny ${id2}: also passed to --approve`);
|
|
40096
40350
|
let reason;
|
|
40097
40351
|
if (eq3 !== -1) {
|
|
40098
40352
|
const rhs = raw.slice(eq3 + 1).trim();
|
|
40099
|
-
reason = rhs.startsWith("@") ? String(parseJsonOrFile(rhs, `--deny ${
|
|
40353
|
+
reason = rhs.startsWith("@") ? String(parseJsonOrFile(rhs, `--deny ${id2}`)) : rhs;
|
|
40100
40354
|
}
|
|
40101
|
-
approvals[
|
|
40355
|
+
approvals[id2] = {
|
|
40102
40356
|
decision: "deny",
|
|
40103
40357
|
reason
|
|
40104
40358
|
};
|
|
@@ -43036,6 +43290,7 @@ async function pushAllCommand(options) {
|
|
|
43036
43290
|
}
|
|
43037
43291
|
const allResults = [];
|
|
43038
43292
|
const toDeploy = [];
|
|
43293
|
+
const stagedWorkflows = [];
|
|
43039
43294
|
const failedItems = [];
|
|
43040
43295
|
let deployFailedCount = 0;
|
|
43041
43296
|
let personaPushResult = null;
|
|
@@ -43166,13 +43421,18 @@ ${icon} Pushing ${items.length} ${handler.displayName}(s)...`);
|
|
|
43166
43421
|
entityId
|
|
43167
43422
|
});
|
|
43168
43423
|
writeSuccess(` \u2705 ${item.name} v${newVersion} pushed`);
|
|
43169
|
-
if (options.autoDeploy
|
|
43424
|
+
if (options.autoDeploy) {
|
|
43170
43425
|
toDeploy.push({
|
|
43171
43426
|
handler,
|
|
43172
43427
|
name: item.name,
|
|
43173
43428
|
version: newVersion,
|
|
43174
43429
|
entityId
|
|
43175
43430
|
});
|
|
43431
|
+
} else if (handler.kind === PrimitiveKind.WORKFLOW) {
|
|
43432
|
+
stagedWorkflows.push({
|
|
43433
|
+
name: item.name,
|
|
43434
|
+
version: newVersion
|
|
43435
|
+
});
|
|
43176
43436
|
}
|
|
43177
43437
|
} catch (error) {
|
|
43178
43438
|
if (AuthenticationError.isAuthenticationError(error)) throw error;
|
|
@@ -43221,8 +43481,7 @@ ${icon} Pushing ${items.length} ${handler.displayName}(s)...`);
|
|
|
43221
43481
|
writePersonaServedHint(personaPushResult.version);
|
|
43222
43482
|
}
|
|
43223
43483
|
if (toDeploy.length > 0) {
|
|
43224
|
-
|
|
43225
|
-
writeProgress(workflowsOnly ? "\n\u{1F680} Activating workflow version(s) \u2014 workflows deploy on their own, not via `lua version promote`..." : "\n\u{1F680} Deploying all pushed versions to production...");
|
|
43484
|
+
writeProgress("\n\u{1F680} Deploying all pushed versions to production...");
|
|
43226
43485
|
writeInfo("\u23F1\uFE0F Waiting for server to process versions (5 seconds)...\n");
|
|
43227
43486
|
await new Promise((resolve7) => setTimeout(resolve7, 5e3));
|
|
43228
43487
|
for (const item of toDeploy) {
|
|
@@ -43348,7 +43607,12 @@ Until the backup catches up, \`lua init\` for this agent will restore an older s
|
|
|
43348
43607
|
// Agent-versioning telemetry.
|
|
43349
43608
|
versioning_mode: "stage-all",
|
|
43350
43609
|
granular_deprecation_warned: false,
|
|
43351
|
-
auto_deploy_noop_warned: options.autoDeployNoopWarned || false
|
|
43610
|
+
auto_deploy_noop_warned: options.autoDeployNoopWarned || false,
|
|
43611
|
+
// PRO-2158: how many workflow versions this push uploaded WITHOUT activating. Before the fix this was
|
|
43612
|
+
// always 0 because every workflow was published (and, via the server's scoped promote, silently moved
|
|
43613
|
+
// the agent's active version). A rising count here against a flat `lua workflows deploy` rate is the
|
|
43614
|
+
// signal that users are not finding the printed activation step.
|
|
43615
|
+
workflows_staged_not_activated: stagedWorkflows.length
|
|
43352
43616
|
});
|
|
43353
43617
|
try {
|
|
43354
43618
|
await tryGitCommit({
|
|
@@ -43363,6 +43627,11 @@ Until the backup catches up, \`lua init\` for this agent will restore an older s
|
|
|
43363
43627
|
failedCount: failedItems.length + deployFailedCount
|
|
43364
43628
|
});
|
|
43365
43629
|
process.exitCode = pushAllExitCode(variant);
|
|
43630
|
+
if (stagedWorkflows.length > 0) {
|
|
43631
|
+
console.log("");
|
|
43632
|
+
writeInfo(`\u2139\uFE0F Workflow version(s) staged, NOT activated (workflows do not ride \`lua version promote\`). Activate each with:
|
|
43633
|
+
` + stagedWorkflows.map((w) => ` lua workflows deploy ${w.name} -v ${w.version}`).join("\n"));
|
|
43634
|
+
}
|
|
43366
43635
|
if (variant === "success") {
|
|
43367
43636
|
console.log("");
|
|
43368
43637
|
if (!options.suppressVersionCreateHint) {
|
|
@@ -45114,7 +45383,7 @@ async function setupChatEnvironment(chatEnv, config) {
|
|
|
45114
45383
|
writeProgress("\u{1F504} Setting up sandbox environment...");
|
|
45115
45384
|
writeProgress("\u{1F504} Compiling skill...");
|
|
45116
45385
|
await compileCommand({
|
|
45117
|
-
serverSync:
|
|
45386
|
+
serverSync: "register-only"
|
|
45118
45387
|
});
|
|
45119
45388
|
const manifest = loadManifest();
|
|
45120
45389
|
const skills = getPrimitivesByKind(manifest, PrimitiveKind.SKILL);
|
|
@@ -56817,13 +57086,13 @@ function consentCardLines(consent) {
|
|
|
56817
57086
|
}
|
|
56818
57087
|
__name(consentCardLines, "consentCardLines");
|
|
56819
57088
|
function printRun(run, withSteps) {
|
|
56820
|
-
const
|
|
57089
|
+
const id2 = runIdOf(run);
|
|
56821
57090
|
console.log(`
|
|
56822
|
-
\u{1F9ED} Run ${
|
|
57091
|
+
\u{1F9ED} Run ${id2} \xB7 ${run.status}`);
|
|
56823
57092
|
console.log(` Workflow: ${run.workflowId} @ ${run.workflowVersionId} (${shortHash(run.graphHash)})`);
|
|
56824
57093
|
console.log(` Trigger: ${run.trigger}${run.correlationKey ? ` \xB7 correlation ${run.correlationKey}` : ""}${run.tags?.length ? ` \xB7 tags ${run.tags.join(",")}` : ""}`);
|
|
56825
57094
|
console.log(` Created: ${when2(run.createdAt)}${run.startedAt ? ` \xB7 started ${when2(run.startedAt)}` : ""}${run.completedAt ? ` \xB7 completed ${when2(run.completedAt)}` : ""}`);
|
|
56826
|
-
if (run.lineageId && run.lineageId !==
|
|
57095
|
+
if (run.lineageId && run.lineageId !== id2) console.log(` Lineage: ${run.lineageId}`);
|
|
56827
57096
|
if (run.parentRunId) console.log(` Parent: ${run.parentRunId} \u2014 lua workflows status ${run.parentRunId} --steps`);
|
|
56828
57097
|
const consent = consentLine(run.consent);
|
|
56829
57098
|
if (consent) console.log(` Consent: ${consent}`);
|
|
@@ -56836,19 +57105,19 @@ function printRun(run, withSteps) {
|
|
|
56836
57105
|
const kind = run.gate.kind;
|
|
56837
57106
|
if (kind === "exception") {
|
|
56838
57107
|
console.log(run.status === "running" ? "\n\u26A0\uFE0F Needs a decision \u2014 a step is parked on an exception gate (the run continues past it):" : "\n\u26A0\uFE0F Needs a decision \u2014 the run is parked on an exception gate:");
|
|
56839
|
-
console.log(` lua workflows retry-step ${
|
|
56840
|
-
console.log(` lua workflows resolve-step ${
|
|
57108
|
+
console.log(` lua workflows retry-step ${id2} --step <id>`);
|
|
57109
|
+
console.log(` lua workflows resolve-step ${id2} --step <id> --outcome skip|complete|fail [--output <json|@file>]`);
|
|
56841
57110
|
} else if (kind === "budget") {
|
|
56842
57111
|
console.log(`
|
|
56843
57112
|
\u23F8\uFE0F Paused \u2014 run budget reached (${budgetCopy(run)}):`);
|
|
56844
|
-
console.log(` lua workflows raise-budget ${
|
|
57113
|
+
console.log(` lua workflows raise-budget ${id2} --credits <n> (<n> is the new cap in ${budgetEngineOf(run) === "seat" ? "actions" : "credits"})`);
|
|
56845
57114
|
} else if (kind === "billing") {
|
|
56846
57115
|
for (const line of billingParkLines(run)) console.log(line);
|
|
56847
57116
|
} else if (kind === "model_policy") {
|
|
56848
57117
|
console.log(`
|
|
56849
57118
|
\u23F8\uFE0F Paused \u2014 a step's model request cannot be resolved under the current policy:`);
|
|
56850
57119
|
if (run.gate?.code) console.log(` ${run.gate.code}${run.gate.stepId ? ` \xB7 step ${run.gate.stepId}` : ""}`);
|
|
56851
|
-
console.log(` lua workflows clear-gate ${
|
|
57120
|
+
console.log(` lua workflows clear-gate ${id2} --kind model_policy`);
|
|
56852
57121
|
} else {
|
|
56853
57122
|
console.log(` Gate: ${kind}${run.gate.reason ? ` (${run.gate.reason})` : ""}${run.gate.since ? ` since ${when2(run.gate.since)}` : ""}`);
|
|
56854
57123
|
}
|
|
@@ -56864,7 +57133,7 @@ function printRun(run, withSteps) {
|
|
|
56864
57133
|
const fetchable = outputRefLine(run.outputRef);
|
|
56865
57134
|
if (fetchable) console.log(` Download: ${fetchable}`);
|
|
56866
57135
|
} else if (run.hasOutput) {
|
|
56867
|
-
console.log(` Output: present \u2014 lua workflows status ${
|
|
57136
|
+
console.log(` Output: present \u2014 lua workflows status ${id2} --steps`);
|
|
56868
57137
|
} else if (RUN_TERMINAL_STATUSES.has(run.status)) {
|
|
56869
57138
|
const last = lastCompletedPreview(steps);
|
|
56870
57139
|
console.log(` Output: (none${last ? "" : withSteps ? "" : " \u2014 pass --steps for per-step output previews"})`);
|
|
@@ -56909,7 +57178,7 @@ function printRun(run, withSteps) {
|
|
|
56909
57178
|
}
|
|
56910
57179
|
__name(printRun, "printRun");
|
|
56911
57180
|
function billingParkLines(run) {
|
|
56912
|
-
const
|
|
57181
|
+
const id2 = runIdOf(run);
|
|
56913
57182
|
const gate = run.gate ?? {
|
|
56914
57183
|
kind: "billing"
|
|
56915
57184
|
};
|
|
@@ -56920,7 +57189,7 @@ function billingParkLines(run) {
|
|
|
56920
57189
|
\u23F8\uFE0F Paused \u2014 payment required (${what})${step3}:`
|
|
56921
57190
|
];
|
|
56922
57191
|
out.push(" top up the workspace (or ask a workspace admin to) \u2014 the run resumes on its own within a few minutes of the top-up");
|
|
56923
|
-
out.push(` to resume it right away after topping up: lua workflows retry-step ${
|
|
57192
|
+
out.push(` to resume it right away after topping up: lua workflows retry-step ${id2} --step ${gate.stepId ?? "<stepId>"}`);
|
|
56924
57193
|
if (typeof gate.expiresAt === "number") out.push(` still unpaid at ${when2(gate.expiresAt)} \u21D2 the run fails`);
|
|
56925
57194
|
return out;
|
|
56926
57195
|
}
|
|
@@ -57757,8 +58026,8 @@ function actorLabel(by, now = Date.now()) {
|
|
|
57757
58026
|
if (typeof by !== "object") return String(by);
|
|
57758
58027
|
const a = by;
|
|
57759
58028
|
const kind = a.subjectType ?? a.kind;
|
|
57760
|
-
const
|
|
57761
|
-
const who = kind &&
|
|
58029
|
+
const id2 = a.name ?? a.subjectId ?? a.id;
|
|
58030
|
+
const who = kind && id2 ? `${kind}:${id2}` : kind ?? id2;
|
|
57762
58031
|
if (!who) return void 0;
|
|
57763
58032
|
const at = typeof a.at === "number" ? a.at : typeof a.at === "string" ? Date.parse(a.at) : NaN;
|
|
57764
58033
|
return Number.isFinite(at) ? `${who} (${agoFrom(at, now)})` : who;
|