lua-cli 3.53.0 → 3.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,6 +64,25 @@ declare interface LuaTool<TInput extends ZodType = ZodType> {
64
64
  name: string;
65
65
  /** Description of what the tool does */
66
66
  description: string;
67
+ /**
68
+ * Optional text the chat shows to the user while this tool runs and after it
69
+ * finishes, instead of the tool's name. Either one text for both moments, or
70
+ * one for each:
71
+ *
72
+ * ```ts
73
+ * label = { running: 'Creating a ticket for {subject}', done: 'Created a ticket for {subject}' };
74
+ * label = 'Checked stock';
75
+ * ```
76
+ *
77
+ * `{argName}` is replaced with that argument's value from the call (string
78
+ * and number arguments only). Don't end the text with "…": the chat adds it
79
+ * while the tool runs. Each text is a string literal (or a const holding one)
80
+ * of at most 80 characters; `lua compile` ignores a computed label.
81
+ */
82
+ label?: string | {
83
+ running: string;
84
+ done: string;
85
+ };
67
86
  /** Zod schema for input validation */
68
87
  inputSchema: TInput;
69
88
  /**
@@ -276,6 +276,25 @@ declare interface LuaTool<TInput extends ZodType = ZodType> {
276
276
  name: string;
277
277
  /** Description of what the tool does */
278
278
  description: string;
279
+ /**
280
+ * Optional text the chat shows to the user while this tool runs and after it
281
+ * finishes, instead of the tool's name. Either one text for both moments, or
282
+ * one for each:
283
+ *
284
+ * ```ts
285
+ * label = { running: 'Creating a ticket for {subject}', done: 'Created a ticket for {subject}' };
286
+ * label = 'Checked stock';
287
+ * ```
288
+ *
289
+ * `{argName}` is replaced with that argument's value from the call (string
290
+ * and number arguments only). Don't end the text with "…": the chat adds it
291
+ * while the tool runs. Each text is a string literal (or a const holding one)
292
+ * of at most 80 characters; `lua compile` ignores a computed label.
293
+ */
294
+ label?: string | {
295
+ running: string;
296
+ done: string;
297
+ };
279
298
  /** Zod schema for input validation */
280
299
  inputSchema: TInput;
281
300
  /**
@@ -1026,6 +1026,8 @@ import { z as z3 } from "zod";
1026
1026
  import { z as z4 } from "zod";
1027
1027
  import { z as z5 } from "zod";
1028
1028
  import { z as z6 } from "zod";
1029
+ import { z as z7 } from "zod";
1030
+ import { z as z8 } from "zod";
1029
1031
  var __defProp4 = Object.defineProperty;
1030
1032
  var __name4 = /* @__PURE__ */ __name((target, value3) => __defProp4(target, "name", { value: value3, configurable: true }), "__name");
1031
1033
  var PLUMBING_THREAD_CHANNELS = [
@@ -5105,6 +5107,24 @@ function sanitizeProgressUpdateInput(input) {
5105
5107
  }
5106
5108
  __name(sanitizeProgressUpdateInput, "sanitizeProgressUpdateInput");
5107
5109
  __name4(sanitizeProgressUpdateInput, "sanitizeProgressUpdateInput");
5110
+ function agentIdentityError(code, message, statusCode) {
5111
+ return Object.assign(new Error(message), {
5112
+ name: "AgentIdentityError",
5113
+ code,
5114
+ ...typeof statusCode === "number" ? {
5115
+ statusCode
5116
+ } : {}
5117
+ });
5118
+ }
5119
+ __name(agentIdentityError, "agentIdentityError");
5120
+ __name4(agentIdentityError, "agentIdentityError");
5121
+ function readAgentIdentityAudience(input) {
5122
+ if (!input || typeof input !== "object" || Array.isArray(input)) return null;
5123
+ const audience = input.audience;
5124
+ return typeof audience === "string" && audience.length > 0 && audience.length <= 200 ? audience : null;
5125
+ }
5126
+ __name(readAgentIdentityAudience, "readAgentIdentityAudience");
5127
+ __name4(readAgentIdentityAudience, "readAgentIdentityAudience");
5108
5128
  function toEpochMs(value3) {
5109
5129
  if (value3 === null || value3 === void 0) return void 0;
5110
5130
  const ms = value3 instanceof Date ? value3.getTime() : typeof value3 === "number" ? value3 : Date.parse(value3);
@@ -6479,6 +6499,12 @@ function removeHiddenBlocks(input) {
6479
6499
  }
6480
6500
  __name(removeHiddenBlocks, "removeHiddenBlocks");
6481
6501
  __name4(removeHiddenBlocks, "removeHiddenBlocks");
6502
+ function stripBlocksKeepingEdges(input, names) {
6503
+ const stripped = stripBlocks(input, names);
6504
+ return stripped === input ? input : stripped.trim();
6505
+ }
6506
+ __name(stripBlocksKeepingEdges, "stripBlocksKeepingEdges");
6507
+ __name4(stripBlocksKeepingEdges, "stripBlocksKeepingEdges");
6482
6508
  function startsWithHiddenBlock(input) {
6483
6509
  const [first] = splitBlocks(input);
6484
6510
  return first?.type === "block" && first.name === "hide";
@@ -6570,8 +6596,10 @@ function transformChatHistoryContentParts(parts) {
6570
6596
  }
6571
6597
  if (part?.type !== "text" && part?.type !== "file") continue;
6572
6598
  if (part.type === "text" && typeof part.text === "string") {
6573
- const rawText = removeHiddenBlocks(part.text || "");
6574
- if (!rawText) continue;
6599
+ const rawText = stripBlocksKeepingEdges(part.text || "", [
6600
+ "hide"
6601
+ ]);
6602
+ if (!rawText.trim()) continue;
6575
6603
  const audioMatch = rawText.match(/::: audio\s*!\[(.*?)\]\((.*?)\)\s*:::/);
6576
6604
  const videoMatch = rawText.match(/::: video\s*!\[(.*?)\]\((.*?)\)\s*:::/);
6577
6605
  if (audioMatch) {
@@ -6588,7 +6616,9 @@ function transformChatHistoryContentParts(parts) {
6588
6616
  });
6589
6617
  } else {
6590
6618
  let text2 = rawText.replace(/\\\\\\n/g, "\n");
6591
- text2 = removeNavigateBlock(text2);
6619
+ text2 = stripBlocksKeepingEdges(text2, [
6620
+ "navigate"
6621
+ ]);
6592
6622
  content.push({
6593
6623
  type: "text",
6594
6624
  text: text2
@@ -6669,6 +6699,15 @@ function mergeRichPartMirrorMessages(messages, sameTurnGroup) {
6669
6699
  break;
6670
6700
  }
6671
6701
  if (folded) continue;
6702
+ const content = message.content.filter((part) => part.type !== "data-lua-tool-step");
6703
+ if (content.length === 0) continue;
6704
+ if (content.length !== message.content.length) {
6705
+ merged.push({
6706
+ ...message,
6707
+ content
6708
+ });
6709
+ continue;
6710
+ }
6672
6711
  }
6673
6712
  merged.push(message);
6674
6713
  }
@@ -11844,6 +11883,42 @@ __name(composeAgentPaneRuntimeContext, "composeAgentPaneRuntimeContext");
11844
11883
  __name4(composeAgentPaneRuntimeContext, "composeAgentPaneRuntimeContext");
11845
11884
  var WEB_APP_ENTRY_HTML_MAX_CHARS = 256 * 1024;
11846
11885
  var WEB_APP_MAX_ASSET_BYTES = 8 * 1024 * 1024;
11886
+ var WEB_APP_HEALTH_KEY_TTL_SECONDS = 15 * 60;
11887
+ var WEB_APP_HEALTH_MIN_FAILURES = 3;
11888
+ var WEB_APP_HEALTH_MIN_FAILURE_RATIO = 0.5;
11889
+ function webAppHealthMinute(atMs) {
11890
+ return Math.floor(atMs / 6e4);
11891
+ }
11892
+ __name(webAppHealthMinute, "webAppHealthMinute");
11893
+ __name4(webAppHealthMinute, "webAppHealthMinute");
11894
+ function webAppHealthKey(webAppId, minute) {
11895
+ return `webapp:health:${webAppId}:${minute}`;
11896
+ }
11897
+ __name(webAppHealthKey, "webAppHealthKey");
11898
+ __name4(webAppHealthKey, "webAppHealthKey");
11899
+ function webAppHealthVerdict(minutes) {
11900
+ let requests = 0;
11901
+ let failures = 0;
11902
+ let firstFailingMinute;
11903
+ for (const m of minutes) {
11904
+ const r = Math.max(0, m.requests || 0);
11905
+ const f = Math.max(0, Math.min(m.failures || 0, r));
11906
+ requests += r;
11907
+ failures += f;
11908
+ if (f > 0 && (firstFailingMinute === void 0 || m.minute < firstFailingMinute)) firstFailingMinute = m.minute;
11909
+ }
11910
+ if (failures >= WEB_APP_HEALTH_MIN_FAILURES && failures >= requests * WEB_APP_HEALTH_MIN_FAILURE_RATIO) {
11911
+ return {
11912
+ state: "needs_attention",
11913
+ since: new Date(firstFailingMinute * 6e4)
11914
+ };
11915
+ }
11916
+ return {
11917
+ state: "ok"
11918
+ };
11919
+ }
11920
+ __name(webAppHealthVerdict, "webAppHealthVerdict");
11921
+ __name4(webAppHealthVerdict, "webAppHealthVerdict");
11847
11922
  var EVIDENCE_SESSION_IDLE_MS = 30 * 6e4;
11848
11923
  var EVIDENCE_MIN_CONVERSATIONS = 20;
11849
11924
  var EVIDENCE_LOW_CONFIDENCE_N = 5;
@@ -13005,13 +13080,15 @@ function parseConnectionSendPolicy(value3) {
13005
13080
  __name(parseConnectionSendPolicy, "parseConnectionSendPolicy");
13006
13081
  __name4(parseConnectionSendPolicy, "parseConnectionSendPolicy");
13007
13082
  var BILLING_REJECTION_TEXT_CREDITS = "This agent has run out of credits. Please top up to continue chatting.";
13083
+ var BILLING_REJECTION_TEXT_OUT_OF_ACTIONS = "This workspace is out of actions. A workspace owner or billing admin can top up or upgrade the plan to continue.";
13008
13084
  var BILLING_REJECTION_TEXT_SEAT = "You don't have access to this agent in this workspace. Ask a workspace admin to add you.";
13009
13085
  var BILLING_REJECTION_TEXT_USER_QUOTA = "You've reached your monthly usage limit in this workspace. Ask a workspace admin to raise it.";
13010
13086
  function isPaymentRequiredChatErrorEnvelope(data) {
13011
13087
  if (!data || typeof data !== "object") return false;
13012
13088
  const d = data;
13013
13089
  if (d.type !== "error") return false;
13014
- return d.textDelta === BILLING_REJECTION_TEXT_CREDITS || d.textDelta === BILLING_REJECTION_TEXT_SEAT || d.textDelta === BILLING_REJECTION_TEXT_USER_QUOTA;
13090
+ if (d.code === "OUT_OF_ACTIONS") return true;
13091
+ return d.textDelta === BILLING_REJECTION_TEXT_CREDITS || d.textDelta === BILLING_REJECTION_TEXT_OUT_OF_ACTIONS || d.textDelta === BILLING_REJECTION_TEXT_SEAT || d.textDelta === BILLING_REJECTION_TEXT_USER_QUOTA;
13015
13092
  }
13016
13093
  __name(isPaymentRequiredChatErrorEnvelope, "isPaymentRequiredChatErrorEnvelope");
13017
13094
  __name4(isPaymentRequiredChatErrorEnvelope, "isPaymentRequiredChatErrorEnvelope");
@@ -13621,10 +13698,259 @@ function isSharedDataOwnerKey(agentId2) {
13621
13698
  }
13622
13699
  __name(isSharedDataOwnerKey, "isSharedDataOwnerKey");
13623
13700
  __name4(isSharedDataOwnerKey, "isSharedDataOwnerKey");
13701
+ var PLAN_KEYS = {
13702
+ agents: {
13703
+ kind: "limit",
13704
+ default: null,
13705
+ label: "Agents"
13706
+ },
13707
+ members: {
13708
+ kind: "limit",
13709
+ default: null,
13710
+ label: "Members"
13711
+ },
13712
+ rooms: {
13713
+ kind: "limit",
13714
+ default: null,
13715
+ label: "Rooms"
13716
+ },
13717
+ externalShares: {
13718
+ kind: "limit",
13719
+ default: null,
13720
+ label: "Shares outside the workspace"
13721
+ },
13722
+ viewsPerAgent: {
13723
+ kind: "limit",
13724
+ default: null,
13725
+ label: "Views per agent"
13726
+ },
13727
+ freeWorkspacesPerPerson: {
13728
+ kind: "limit",
13729
+ default: null,
13730
+ label: "Free workspaces per person"
13731
+ },
13732
+ shareOutsideWorkspace: {
13733
+ kind: "feature",
13734
+ default: true,
13735
+ label: "Share outside the workspace"
13736
+ },
13737
+ roomsEnabled: {
13738
+ kind: "feature",
13739
+ default: true,
13740
+ label: "Rooms with agents"
13741
+ },
13742
+ comments: {
13743
+ kind: "feature",
13744
+ default: true,
13745
+ label: "Comments"
13746
+ },
13747
+ snapshots: {
13748
+ kind: "feature",
13749
+ default: true,
13750
+ label: "Snapshots"
13751
+ },
13752
+ topUps: {
13753
+ kind: "feature",
13754
+ default: true,
13755
+ label: "Top-ups"
13756
+ },
13757
+ deployAgents: {
13758
+ kind: "feature",
13759
+ default: true,
13760
+ label: "Deploy agents to production"
13761
+ }
13762
+ };
13763
+ var PLAN_LIMIT_KEYS = Object.keys(PLAN_KEYS).filter((k) => PLAN_KEYS[k].kind === "limit");
13764
+ var PLAN_FEATURE_KEYS = Object.keys(PLAN_KEYS).filter((k) => PLAN_KEYS[k].kind === "feature");
13765
+ var BILLING_ENGINES = [
13766
+ "actions",
13767
+ "credits"
13768
+ ];
13769
+ var BILLING_VERSION_KINDS = [
13770
+ "catalog",
13771
+ "custom"
13772
+ ];
13773
+ var planKeyString = z7.string().regex(/^[a-z0-9][a-z0-9-]{0,47}$/, "lowercase letters, digits and dashes");
13774
+ var planPriceSchema = z7.object({
13775
+ amountUsd: z7.number().nonnegative(),
13776
+ interval: z7.enum([
13777
+ "month",
13778
+ "year"
13779
+ ]),
13780
+ per: z7.enum([
13781
+ "workspace",
13782
+ "seat"
13783
+ ])
13784
+ }).strict();
13785
+ var limitsShape = Object.fromEntries(PLAN_LIMIT_KEYS.map((k) => [
13786
+ k,
13787
+ z7.number().int().nonnegative().nullable().optional()
13788
+ ]));
13789
+ var featuresShape = Object.fromEntries(PLAN_FEATURE_KEYS.map((k) => [
13790
+ k,
13791
+ z7.boolean().optional()
13792
+ ]));
13793
+ var billingPlanSchema = z7.object({
13794
+ key: planKeyString,
13795
+ name: z7.string().min(1).max(80),
13796
+ /** Absent = a workspace plan. An agent-team plan prices a hired team; it sets no limits or features. */
13797
+ kind: z7.enum([
13798
+ "workspace",
13799
+ "agent-team"
13800
+ ]).optional(),
13801
+ tagline: z7.string().max(200).optional(),
13802
+ visible: z7.boolean(),
13803
+ order: z7.number().int(),
13804
+ price: planPriceSchema.nullable(),
13805
+ stripeProductId: z7.string().optional(),
13806
+ stripePriceId: z7.string().optional(),
13807
+ actionsPerPeriod: z7.number().int().nonnegative(),
13808
+ trialDays: z7.number().int().nonnegative().optional(),
13809
+ limits: z7.object(limitsShape).strict(),
13810
+ features: z7.object(featuresShape).strict(),
13811
+ invoice: z7.object({
13812
+ collectionMode: z7.enum([
13813
+ "card",
13814
+ "invoice"
13815
+ ]),
13816
+ dueDays: z7.number().int().nonnegative(),
13817
+ lines: z7.array(z7.object({
13818
+ description: z7.string().min(1),
13819
+ amountUsd: z7.number().nonnegative()
13820
+ }).strict())
13821
+ }).strict().optional()
13822
+ }).strict();
13823
+ var topUpPackSchema = z7.object({
13824
+ key: planKeyString,
13825
+ name: z7.string().min(1).max(80),
13826
+ priceUsd: z7.number().positive(),
13827
+ actions: z7.number().int().positive(),
13828
+ stripeProductId: z7.string().optional(),
13829
+ stripePriceId: z7.string().optional()
13830
+ }).strict();
13831
+ function resolvePlanEntitlements(plan) {
13832
+ const limits = {};
13833
+ for (const k of PLAN_LIMIT_KEYS) {
13834
+ const v = plan.limits[k];
13835
+ limits[k] = v === void 0 ? PLAN_KEYS[k].default : v;
13836
+ }
13837
+ const features = {};
13838
+ for (const k of PLAN_FEATURE_KEYS) {
13839
+ const v = plan.features[k];
13840
+ features[k] = v === void 0 ? PLAN_KEYS[k].default : v;
13841
+ }
13842
+ return {
13843
+ limits,
13844
+ features
13845
+ };
13846
+ }
13847
+ __name(resolvePlanEntitlements, "resolvePlanEntitlements");
13848
+ __name4(resolvePlanEntitlements, "resolvePlanEntitlements");
13849
+ var PLAN_REFUSAL_CODES = [
13850
+ "PLAN_LIMIT_REACHED",
13851
+ "PLAN_FEATURE_LOCKED",
13852
+ "OUT_OF_ACTIONS"
13853
+ ];
13854
+ function isPlanRefusal(body) {
13855
+ if (!body || typeof body !== "object") return false;
13856
+ const code = body.code;
13857
+ return typeof code === "string" && PLAN_REFUSAL_CODES.includes(code);
13858
+ }
13859
+ __name(isPlanRefusal, "isPlanRefusal");
13860
+ __name4(isPlanRefusal, "isPlanRefusal");
13861
+ var billingSignupConfigSchema = z7.object({
13862
+ enabled: z7.boolean(),
13863
+ defaultVersionKey: z7.string().min(1).nullable(),
13864
+ allowlistEmails: z7.array(z7.string().email().toLowerCase()).max(500),
13865
+ friendsPlan: z7.object({
13866
+ versionKey: z7.string().min(1),
13867
+ planKey: planKeyString
13868
+ }).strict().nullable()
13869
+ }).strict();
13870
+ var billingVersionDraftPatchSchema = z7.object({
13871
+ revision: z7.number().int().nonnegative().optional(),
13872
+ name: z7.string().min(1).max(80).optional(),
13873
+ kind: z7.enum(BILLING_VERSION_KINDS).optional(),
13874
+ engine: z7.enum(BILLING_ENGINES).optional(),
13875
+ defaultPlanKey: z7.string().optional(),
13876
+ plans: z7.array(billingPlanSchema).optional(),
13877
+ topUpPacks: z7.array(topUpPackSchema).optional(),
13878
+ forOrgIds: z7.array(z7.string().min(1)).optional(),
13879
+ legacyCheckout: z7.boolean().optional(),
13880
+ voiceAndDelegationAsActions: z7.boolean().optional(),
13881
+ notes: z7.string().max(2e3).optional()
13882
+ }).strict();
13883
+ var billingVersionDraftCreateSchema = billingVersionDraftPatchSchema.extend({
13884
+ key: z7.string().min(2),
13885
+ copyFrom: z7.string().optional()
13886
+ }).strict();
13887
+ var assignBillingPlanSchema = z7.object({
13888
+ versionKey: z7.string().min(1),
13889
+ planKey: z7.string().optional()
13890
+ }).strict();
13891
+ function planKeyList() {
13892
+ return Object.keys(PLAN_KEYS).map((key) => ({
13893
+ key,
13894
+ kind: PLAN_KEYS[key].kind,
13895
+ label: PLAN_KEYS[key].label,
13896
+ default: PLAN_KEYS[key].default
13897
+ }));
13898
+ }
13899
+ __name(planKeyList, "planKeyList");
13900
+ __name4(planKeyList, "planKeyList");
13901
+ function parseWith(schema, body) {
13902
+ const r = schema.safeParse(body);
13903
+ return r.success ? {
13904
+ ok: true,
13905
+ data: r.data
13906
+ } : {
13907
+ ok: false,
13908
+ problems: r.error.issues.map((i) => `${i.path.join(".")} ${i.message}`)
13909
+ };
13910
+ }
13911
+ __name(parseWith, "parseWith");
13912
+ __name4(parseWith, "parseWith");
13913
+ var billingActionRatesSchema = z7.object({
13914
+ voiceActionsPerMinute: z7.number().nonnegative()
13915
+ }).strict();
13916
+ var BILLING_MOVE_DEFAULT_NOTICE_DAYS = 90;
13917
+ var keyString = z8.string().regex(/^[a-z0-9][a-z0-9-]{1,63}$/, "lowercase letters, digits and dashes");
13918
+ var billingMoveDraftSchema = z8.object({
13919
+ key: keyString,
13920
+ name: z8.string().min(1).max(120),
13921
+ fromVersionKey: keyString,
13922
+ toVersionKey: keyString,
13923
+ /** Every plan of the source version → a plan of the target version. */
13924
+ planMap: z8.record(z8.string().min(1), z8.string().min(1)),
13925
+ noticeDays: z8.number().int().min(0).max(730).default(BILLING_MOVE_DEFAULT_NOTICE_DAYS),
13926
+ /** Absent ⇒ every org on the source version. */
13927
+ orgIds: z8.array(z8.string().min(1)).max(1e4).optional(),
13928
+ excludeOrgIds: z8.array(z8.string().min(1)).max(1e4).default([]),
13929
+ notes: z8.string().max(2e3).optional(),
13930
+ /** Actions per leftover credit when a credits version moves to an actions version; required then. */
13931
+ creditsToActionsRate: z8.number().positive().max(1e4).optional()
13932
+ }).strict().refine((m) => m.fromVersionKey !== m.toVersionKey, {
13933
+ message: "source and target version must differ"
13934
+ });
13935
+ var billingMoveOrgDateSchema = z8.object({
13936
+ effectiveAt: z8.coerce.date()
13937
+ }).strict();
13938
+ function parseWith2(schema, body) {
13939
+ const r = schema.safeParse(body);
13940
+ return r.success ? {
13941
+ ok: true,
13942
+ data: r.data
13943
+ } : {
13944
+ ok: false,
13945
+ problems: r.error.issues.map((i) => `${i.path.join(".")} ${i.message}`)
13946
+ };
13947
+ }
13948
+ __name(parseWith2, "parseWith2");
13949
+ __name4(parseWith2, "parseWith");
13624
13950
 
13625
13951
  // ../workflow-graph/dist/index.mjs
13626
13952
  import { createHash } from "crypto";
13627
- import { z as z7 } from "zod";
13953
+ import { z as z9 } from "zod";
13628
13954
  import { z as z22 } from "zod";
13629
13955
  import { createHash as createHash2 } from "crypto";
13630
13956
  var __defProp5 = Object.defineProperty;
@@ -13919,8 +14245,8 @@ var rows = /* @__PURE__ */ __name5((s, path, page) => ({
13919
14245
  var fromKnowledge = /* @__PURE__ */ __name5((k) => ({
13920
14246
  knowledge: k
13921
14247
  }), "fromKnowledge");
13922
- var SideEffectsSchema = z7.enum(WORKFLOW_SIDE_EFFECTS);
13923
- var JobResourcesSchema = z7.enum(WORKFLOW_JOB_RESOURCES);
14248
+ var SideEffectsSchema = z9.enum(WORKFLOW_SIDE_EFFECTS);
14249
+ var JobResourcesSchema = z9.enum(WORKFLOW_JOB_RESOURCES);
13924
14250
  var WORKFLOW_MODEL_TEMPLATE_ROOT = "initData";
13925
14251
  var WORKFLOW_MODEL_TEMPLATE_RE = /^\$\{\s*initData\.([A-Za-z0-9_.\-[\]]+)\s*(?:\|([^}]*))?\}$/;
13926
14252
  var PATH_SEGMENT_RE = /^[A-Za-z0-9_-]+(?:\[(?:0|[1-9]\d*)\])*$/;