lua-cli 3.32.4 → 3.32.5

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.
@@ -1248,6 +1248,7 @@ var DeviceBindingSchema = z2.object({
1248
1248
  }
1249
1249
  });
1250
1250
  var IdSchema = z2.string().min(1).max(256);
1251
+ var SESSION_AUTH_TIME_MAX_S = 4102444800;
1251
1252
  var PrincipalDescriptorSchema = z2.object({
1252
1253
  subjectType: SubjectTypeSchema,
1253
1254
  subjectId: IdSchema
@@ -1296,7 +1297,8 @@ var GeneralPrincipalContextSchema = z2.object({
1296
1297
  owner: PrincipalOwnerSchema.optional(),
1297
1298
  compatibility: z2.object({
1298
1299
  mode: z2.literal("legacy-owner-delegation")
1299
- }).strict().optional()
1300
+ }).strict().optional(),
1301
+ authTime: z2.number().int().nonnegative().max(SESSION_AUTH_TIME_MAX_S).optional()
1300
1302
  }).strict();
1301
1303
  var DeviceCredentialPrincipalContextSchema = z2.object({
1302
1304
  version: z2.literal(1),
@@ -1362,6 +1364,13 @@ function hasDeviceCredentialType(value3) {
1362
1364
  }
1363
1365
  __name(hasDeviceCredentialType, "hasDeviceCredentialType");
1364
1366
  __name2(hasDeviceCredentialType, "hasDeviceCredentialType");
1367
+ function sessionAuthTime(context) {
1368
+ if (!context || context.credential.type !== "firstPartySession") return void 0;
1369
+ const authTime = context.authTime;
1370
+ return typeof authTime === "number" && Number.isInteger(authTime) && authTime >= 0 && authTime <= SESSION_AUTH_TIME_MAX_S ? authTime : void 0;
1371
+ }
1372
+ __name(sessionAuthTime, "sessionAuthTime");
1373
+ __name2(sessionAuthTime, "sessionAuthTime");
1365
1374
  function isTypedApiKeyPrincipal(context) {
1366
1375
  return context?.subject.subjectType === "apiKey" && context.credential.type === "apiKey" && !context.compatibility;
1367
1376
  }
@@ -1764,6 +1773,47 @@ function scheduledWorkflowRunId(jobId, scheduledTime) {
1764
1773
  }
1765
1774
  __name(scheduledWorkflowRunId, "scheduledWorkflowRunId");
1766
1775
  __name2(scheduledWorkflowRunId, "scheduledWorkflowRunId");
1776
+ var WORKFLOW_SCHEDULE_KEY_MAX = 128;
1777
+ function renderWorkflowScheduleKeyTemplate(template3, ctx) {
1778
+ if (!template3) return void 0;
1779
+ const read = /* @__PURE__ */ __name2((path) => path.split(".").reduce((o, k) => o && typeof o === "object" ? o[k] : void 0, ctx.input), "read");
1780
+ let unresolved = false;
1781
+ const out = template3.replace(/\$\{\s*([a-zA-Z0-9_.]+)\s*\}/g, (_m, expr) => {
1782
+ let v = "";
1783
+ if (expr === "scheduledTime") v = ctx.scheduledTime ?? "";
1784
+ else if (expr.startsWith("input.")) v = read(expr.slice("input.".length));
1785
+ const s = v === void 0 || v === null ? "" : String(v);
1786
+ if (s === "") unresolved = true;
1787
+ return s;
1788
+ });
1789
+ if (unresolved) return void 0;
1790
+ const key = out.slice(0, WORKFLOW_SCHEDULE_KEY_MAX);
1791
+ return key && /^[A-Za-z0-9:_\-.\/]+$/.test(key) ? key : void 0;
1792
+ }
1793
+ __name(renderWorkflowScheduleKeyTemplate, "renderWorkflowScheduleKeyTemplate");
1794
+ __name2(renderWorkflowScheduleKeyTemplate, "renderWorkflowScheduleKeyTemplate");
1795
+ var WORKFLOW_SCHEDULE_IDEMPOTENCY_KEY_PREFIX = "sched:";
1796
+ function scheduledWorkflowIdempotencyKey(jobId, rendered) {
1797
+ const head = `${WORKFLOW_SCHEDULE_IDEMPOTENCY_KEY_PREFIX}${jobId}:`;
1798
+ if (head.length + rendered.length <= WORKFLOW_SCHEDULE_KEY_MAX) return `${head}${rendered}`;
1799
+ const digest = stableKeyDigest(rendered);
1800
+ const room = WORKFLOW_SCHEDULE_KEY_MAX - head.length - digest.length - 1;
1801
+ return `${head}${rendered.slice(0, Math.max(0, room))}~${digest}`;
1802
+ }
1803
+ __name(scheduledWorkflowIdempotencyKey, "scheduledWorkflowIdempotencyKey");
1804
+ __name2(scheduledWorkflowIdempotencyKey, "scheduledWorkflowIdempotencyKey");
1805
+ function stableKeyDigest(s) {
1806
+ let a = 2166136261;
1807
+ let b = 84696351;
1808
+ for (let i = 0; i < s.length; i++) {
1809
+ const c = s.charCodeAt(i);
1810
+ a = Math.imul(a ^ c, 16777619);
1811
+ b = Math.imul(b ^ c, 16777619) ^ b >>> 13;
1812
+ }
1813
+ return (a >>> 0).toString(16).padStart(8, "0") + (b >>> 0).toString(16).padStart(8, "0");
1814
+ }
1815
+ __name(stableKeyDigest, "stableKeyDigest");
1816
+ __name2(stableKeyDigest, "stableKeyDigest");
1767
1817
  var WORKFLOW_OPERATION_ID_PREFIX = "wf:";
1768
1818
  function workflowOperationId(runId, stepId, billingEpoch) {
1769
1819
  return `${WORKFLOW_OPERATION_ID_PREFIX}${runId}:${stepId}:${billingEpoch}`;
@@ -2512,6 +2562,75 @@ function extractSingleJsonValue(text) {
2512
2562
  }
2513
2563
  __name(extractSingleJsonValue, "extractSingleJsonValue");
2514
2564
  __name2(extractSingleJsonValue, "extractSingleJsonValue");
2565
+ var DEFAULT_ON_AGENT_FEATURES = [
2566
+ "workflows",
2567
+ "workflowCompose",
2568
+ "observationalMemory"
2569
+ ];
2570
+ function agentFeatureCatalogDefault(featureName) {
2571
+ return DEFAULT_ON_AGENT_FEATURES.includes(featureName);
2572
+ }
2573
+ __name(agentFeatureCatalogDefault, "agentFeatureCatalogDefault");
2574
+ __name2(agentFeatureCatalogDefault, "agentFeatureCatalogDefault");
2575
+ function hasExplicitFeatureActive(row) {
2576
+ return typeof row?.active === "boolean";
2577
+ }
2578
+ __name(hasExplicitFeatureActive, "hasExplicitFeatureActive");
2579
+ __name2(hasExplicitFeatureActive, "hasExplicitFeatureActive");
2580
+ function effectiveFeatureActive(row, catalogDefault) {
2581
+ return hasExplicitFeatureActive(row) ? row.active : catalogDefault;
2582
+ }
2583
+ __name(effectiveFeatureActive, "effectiveFeatureActive");
2584
+ __name2(effectiveFeatureActive, "effectiveFeatureActive");
2585
+ function resolveEffectiveFeature(row, catalogDefault) {
2586
+ return hasExplicitFeatureActive(row) ? {
2587
+ active: row.active,
2588
+ source: "agent",
2589
+ default: catalogDefault
2590
+ } : {
2591
+ active: catalogDefault,
2592
+ source: "default",
2593
+ default: catalogDefault
2594
+ };
2595
+ }
2596
+ __name(resolveEffectiveFeature, "resolveEffectiveFeature");
2597
+ __name2(resolveEffectiveFeature, "resolveEffectiveFeature");
2598
+ function isFeatureRow(value3) {
2599
+ return typeof value3 === "object" && value3 !== null;
2600
+ }
2601
+ __name(isFeatureRow, "isFeatureRow");
2602
+ __name2(isFeatureRow, "isFeatureRow");
2603
+ function effectiveAgentFeatureRows(base, override) {
2604
+ const merged = /* @__PURE__ */ new Map();
2605
+ for (const [name, row] of Object.entries(base ?? {})) {
2606
+ if (isFeatureRow(row)) merged.set(name, {
2607
+ row,
2608
+ origin: "baseAgent"
2609
+ });
2610
+ }
2611
+ for (const [name, row] of Object.entries(override ?? {})) {
2612
+ if (isFeatureRow(row)) merged.set(name, {
2613
+ row,
2614
+ origin: "subAgent"
2615
+ });
2616
+ }
2617
+ return {
2618
+ rows: Object.fromEntries([
2619
+ ...merged
2620
+ ].map(([name, e]) => [
2621
+ name,
2622
+ e.row
2623
+ ])),
2624
+ origins: Object.fromEntries([
2625
+ ...merged
2626
+ ].map(([name, e]) => [
2627
+ name,
2628
+ e.origin
2629
+ ]))
2630
+ };
2631
+ }
2632
+ __name(effectiveAgentFeatureRows, "effectiveAgentFeatureRows");
2633
+ __name2(effectiveAgentFeatureRows, "effectiveAgentFeatureRows");
2515
2634
 
2516
2635
  // ../workflow-graph/dist/index.mjs
2517
2636
  import { createHash } from "crypto";
@@ -3416,7 +3535,7 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
3416
3535
  const id = singleId(node);
3417
3536
  const unknown = unknownWorkflowRetryMembers(r);
3418
3537
  if (unknown.length) err("invalid-envelope", workflowRetryUnknownMembersMessage(unknown), `${path}.retry`, id);
3419
- if (r.maxAttempts !== void 0 && !isWithinWorkflowRetryAttempts(r.maxAttempts)) {
3538
+ if (!isWithinWorkflowRetryAttempts(r.maxAttempts)) {
3420
3539
  const over = typeof r.maxAttempts === "number" && r.maxAttempts > WORKFLOW_RETRY_MAX_ATTEMPTS;
3421
3540
  err(over ? "cap-exceeded" : "invalid-envelope", workflowRetryMaxAttemptsMessage(r.maxAttempts), `${path}.retry.maxAttempts`, id);
3422
3541
  }
@@ -5218,6 +5337,7 @@ __name3(runErrorIssues, "runErrorIssues");
5218
5337
  function runNextAction(run) {
5219
5338
  if (isTerminalRunStatus(run.status)) return "none";
5220
5339
  if (run.status === "suspended" && run.gate?.kind === "budget") return "raise_budget";
5340
+ if (run.status === "suspended" && run.gate?.kind === "billing") return "top_up";
5221
5341
  if (!run.cancel?.requestedAt) return "none";
5222
5342
  const forceAt = run.cancel.forceAfter ?? run.cancel.requestedAt + FORCE_CANCEL_STALE_MS;
5223
5343
  return Date.now() >= forceAt ? "force" : "cancel_again";
@@ -5254,6 +5374,16 @@ function runCountsFromStepStatuses(statuses) {
5254
5374
  }
5255
5375
  __name(runCountsFromStepStatuses, "runCountsFromStepStatuses");
5256
5376
  __name3(runCountsFromStepStatuses, "runCountsFromStepStatuses");
5377
+ function isBillingHeldStep(row) {
5378
+ return row.status === "ready" && row.billingHold === true;
5379
+ }
5380
+ __name(isBillingHeldStep, "isBillingHeldStep");
5381
+ __name3(isBillingHeldStep, "isBillingHeldStep");
5382
+ function stepEffectiveStatus(row) {
5383
+ return isBillingHeldStep(row) ? "suspended" : row.status;
5384
+ }
5385
+ __name(stepEffectiveStatus, "stepEffectiveStatus");
5386
+ __name3(stepEffectiveStatus, "stepEffectiveStatus");
5257
5387
  var n = /* @__PURE__ */ __name3((v) => typeof v === "number" && Number.isFinite(v) ? v : 0, "n");
5258
5388
  function runCounts(counts) {
5259
5389
  const c = counts ?? {};
@@ -6532,7 +6662,7 @@ var assertPredicate = /* @__PURE__ */ __name((p, where) => {
6532
6662
  }, "assertPredicate");
6533
6663
  var assertRetry = /* @__PURE__ */ __name((r, id) => {
6534
6664
  if (!r) return;
6535
- if (r.maxAttempts !== void 0 && !isWithinWorkflowRetryAttempts(r.maxAttempts)) {
6665
+ if (!isWithinWorkflowRetryAttempts(r.maxAttempts)) {
6536
6666
  const over = typeof r.maxAttempts === "number" && r.maxAttempts > WORKFLOW_RETRY_MAX_ATTEMPTS;
6537
6667
  throw new LuaWorkflowBuildError(over ? "cap-exceeded" : "invalid-envelope", `"${id}": ${workflowRetryMaxAttemptsMessage(r.maxAttempts)}`);
6538
6668
  }