lua-cli 3.24.0 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1146,6 +1146,9 @@ function isDesktopFileCommandName(value) {
1146
1146
  function isDesktopFileSessionId(value) {
1147
1147
  return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
1148
1148
  }
1149
+ function isImplicitModelSelectionSource(source) {
1150
+ return source !== void 0 && IMPLICIT_MODEL_SELECTION_SOURCES.includes(source);
1151
+ }
1149
1152
  function resolveRequireToolApproval(rules) {
1150
1153
  const raw = rules?.requireToolApproval ?? rules?.requireApproval;
1151
1154
  if (raw === void 0 || raw === null) return void 0;
@@ -1157,6 +1160,9 @@ function resolveRequireToolApproval(rules) {
1157
1160
  function buildDefaultPersona(agentName) {
1158
1161
  return DEFAULT_PERSONA_GUIDE.replace(AGENT_NAME_TOKEN, () => agentName || "My Agent");
1159
1162
  }
1163
+ function buildPersonalSpaceStartingPersona(agentName) {
1164
+ return PERSONAL_SPACE_STARTING_PERSONA.replace(new RegExp(AGENT_NAME_TOKEN.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), () => agentName || "Your assistant");
1165
+ }
1160
1166
  function resolveLuaJobTimeoutSeconds(timeout) {
1161
1167
  const resolved = timeout ?? LUA_JOB_DEFAULT_TIMEOUT_SECONDS;
1162
1168
  if (!Number.isInteger(resolved)) {
@@ -1173,7 +1179,7 @@ function normalizeLuaJobExecutionTimeoutSeconds(timeout) {
1173
1179
  }
1174
1180
  return Math.min(Math.max(timeout, LUA_JOB_MIN_TIMEOUT_SECONDS), LUA_JOB_MAX_TIMEOUT_SECONDS);
1175
1181
  }
1176
- var __defProp2, __name2, REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST, 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, DESKTOP_FILE_COMMANDS, DESKTOP_FILE_COMMAND_SET, REASONING_EFFORT_VALUES, AGENT_NAME_TOKEN, DEFAULT_PERSONA_GUIDE, AGENT_LOG_SOURCES, VoiceNameSchema, PluginProviderSchema, RealtimeProviderSchema, PluginClassSchema, ModelDescriptorSchema, InferenceModelSchema, PluginModelSchema, RealtimeModelSchema, LuaVoiceModelSchema, TurnDetectionSchema, InterruptionSchema, BuiltinAudioClipSchema, AudioConfigSchema, BackgroundAudioEntrySchema, BackgroundAudioSchema, LuaVoiceConfigInnerSchema, LuaVoiceConfigSchema, LuaVoiceRefSchema, LUA_JOB_DEFAULT_TIMEOUT_SECONDS, LUA_JOB_MIN_TIMEOUT_SECONDS, LUA_JOB_MAX_TIMEOUT_SECONDS;
1182
+ var __defProp2, __name2, REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST, 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, DESKTOP_FILE_COMMANDS, DESKTOP_FILE_COMMAND_SET, REASONING_EFFORT_VALUES, IMPLICIT_MODEL_SELECTION_SOURCES, AGENT_NAME_TOKEN, DEFAULT_PERSONA_GUIDE, PERSONAL_SPACE_STARTING_PERSONA, AGENT_LOG_SOURCES, VoiceNameSchema, PluginProviderSchema, RealtimeProviderSchema, PluginClassSchema, ModelDescriptorSchema, InferenceModelSchema, PluginModelSchema, RealtimeModelSchema, LuaVoiceModelSchema, TurnDetectionSchema, InterruptionSchema, BuiltinAudioClipSchema, AudioConfigSchema, BackgroundAudioEntrySchema, BackgroundAudioSchema, LuaVoiceConfigInnerSchema, LuaVoiceConfigSchema, LuaVoiceRefSchema, LUA_JOB_DEFAULT_TIMEOUT_SECONDS, LUA_JOB_MIN_TIMEOUT_SECONDS, LUA_JOB_MAX_TIMEOUT_SECONDS;
1177
1183
  var init_dist = __esm({
1178
1184
  "../shared-types/dist/index.mjs"() {
1179
1185
  "use strict";
@@ -1487,6 +1493,12 @@ var init_dist = __esm({
1487
1493
  "high",
1488
1494
  "max"
1489
1495
  ];
1496
+ IMPLICIT_MODEL_SELECTION_SOURCES = [
1497
+ "workspace-default",
1498
+ "platform-default"
1499
+ ];
1500
+ __name(isImplicitModelSelectionSource, "isImplicitModelSelectionSource");
1501
+ __name2(isImplicitModelSelectionSource, "isImplicitModelSelectionSource");
1490
1502
  __name(resolveRequireToolApproval, "resolveRequireToolApproval");
1491
1503
  __name2(resolveRequireToolApproval, "resolveRequireToolApproval");
1492
1504
  AGENT_NAME_TOKEN = "[Your Agent Name]";
@@ -1538,6 +1550,40 @@ Feel free to add, remove, or rename sections. Your persona can be a single parag
1538
1550
  `;
1539
1551
  __name(buildDefaultPersona, "buildDefaultPersona");
1540
1552
  __name2(buildDefaultPersona, "buildDefaultPersona");
1553
+ PERSONAL_SPACE_STARTING_PERSONA = `# ${AGENT_NAME_TOKEN}
1554
+
1555
+ You are ${AGENT_NAME_TOKEN}, the assistant for whoever is chatting with you here. Your job is simple: help them get things done, and get better at it every day.
1556
+
1557
+ ## You're just getting started
1558
+
1559
+ This workspace is new. What you already know about the person lives in your memory \u2014 the "Known about this user" notes are verified facts, so use them like you've known them all along; never say you don't know something that's written there. Beyond that, don't pretend. Pay attention instead: how they write, what they ask for, what they're working on. When something matters and you're not sure, ask. One good question beats a wrong guess.
1560
+
1561
+ ## You have real tools
1562
+
1563
+ You can do a lot more than talk. Use your tools when they help, and be straight about what worked and what didn't. The more you learn, the more you can take off their plate without being asked.
1564
+
1565
+ ## How you sound
1566
+
1567
+ Like a sharp, warm human who's on their side. Plain words. Short sentences when short works. React like a person would: if something's great, say so; if something's off, say that too. No corporate filler, no fake enthusiasm.
1568
+
1569
+ ## What you hold yourself to
1570
+
1571
+ - Never make up facts about the person, and never claim you did something you didn't.
1572
+ - What you learn about them serves them. Nothing else.
1573
+ - If you can't do something, say so and offer what you can do.
1574
+
1575
+ ## Where you come from
1576
+
1577
+ You live on Lua, the platform this workspace runs on. Lua gives people AI agents that do real work for them, and it lives at heylua.ai. It was founded by Lorcan (CEO) and Stefan (CTO).
1578
+
1579
+ If someone asks about Lua itself, have fun with it. It's your hometown, so show them around like a proud local: keep the facts straight, keep the delivery playful and a little whimsical. For anything you don't know (pricing, plans, roadmap), point them to heylua.ai instead of guessing.
1580
+
1581
+ ## Keep this persona alive
1582
+
1583
+ This text is who you are for this person. As you learn them, their name, their work, what they care about, update it so tomorrow's you starts smarter than today's. Keep it about who they are and who you are for them.
1584
+ `;
1585
+ __name(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
1586
+ __name2(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
1541
1587
  AGENT_LOG_SOURCES = [
1542
1588
  "skill",
1543
1589
  "job",
@@ -3289,6 +3335,7 @@ var init_files = __esm({
3289
3335
  "preprocessors",
3290
3336
  "postprocessors",
3291
3337
  "mcpServers",
3338
+ "template",
3292
3339
  "skill"
3293
3340
  ];
3294
3341
  __name(yamlKeySorter, "yamlKeySorter");
@@ -7588,7 +7635,8 @@ var init_agent_plugin = __esm({
7588
7635
  const isDefaultExport = classDecl.isDefaultExport();
7589
7636
  const exportName = isDefaultExport ? "default" : className;
7590
7637
  const name = readStringMember(classDecl, "name") ?? deriveNameFromClassName(className);
7591
- const baseDescription = readStringMember(classDecl, "description") ?? "";
7638
+ const routingDescription = readStringMember(classDecl, "description");
7639
+ const baseDescription = routingDescription ?? "";
7592
7640
  const personaHit = findClassMember(classDecl, "persona", "property");
7593
7641
  let persona = "";
7594
7642
  if (personaHit && Node13.isPropertyDeclaration(personaHit.node)) {
@@ -7639,6 +7687,7 @@ var init_agent_plugin = __esm({
7639
7687
  metadata: {
7640
7688
  pattern: "class-definition",
7641
7689
  persona,
7690
+ routingDescription,
7642
7691
  model,
7643
7692
  hasModelResolver,
7644
7693
  modelSettings,
@@ -7671,6 +7720,7 @@ var init_agent_plugin = __esm({
7671
7720
  "voice",
7672
7721
  "text"
7673
7722
  ]) ?? "";
7723
+ const routingDescription = extractStringProperty(config, "description");
7674
7724
  const { model, hasModelResolver } = this.extractModelInfo(config);
7675
7725
  const modelSettings = this.extractModelSettings(config);
7676
7726
  const batching = this.extractBatchingInfo(config);
@@ -7688,6 +7738,7 @@ var init_agent_plugin = __esm({
7688
7738
  metadata: {
7689
7739
  pattern,
7690
7740
  persona,
7741
+ routingDescription,
7691
7742
  model,
7692
7743
  hasModelResolver,
7693
7744
  modelSettings,
@@ -7873,6 +7924,7 @@ var init_agent_plugin = __esm({
7873
7924
  return {
7874
7925
  ...this.baseManifestFields(compiled),
7875
7926
  persona: agentMeta.persona,
7927
+ routingDescription: agentMeta.routingDescription,
7876
7928
  model: agentMeta.model,
7877
7929
  hasModelResolver: agentMeta.hasModelResolver || void 0,
7878
7930
  modelSettings: agentMeta.modelSettings,
@@ -13093,6 +13145,43 @@ var init_ai_api_service = __esm({
13093
13145
  }
13094
13146
  });
13095
13147
 
13148
+ // src/api/integrations.api.service.ts
13149
+ var IntegrationsApiService;
13150
+ var init_integrations_api_service = __esm({
13151
+ "src/api/integrations.api.service.ts"() {
13152
+ "use strict";
13153
+ init_http_client();
13154
+ IntegrationsApiService = class extends HttpClient {
13155
+ static {
13156
+ __name(this, "IntegrationsApiService");
13157
+ }
13158
+ apiKey;
13159
+ agentId;
13160
+ constructor(baseUrl, apiKey, agentId) {
13161
+ super(baseUrl), this.apiKey = apiKey, this.agentId = agentId;
13162
+ }
13163
+ async passthrough(integrationType, request2) {
13164
+ return this.httpPost(`/developer/unifiedto/connections/${encodeURIComponent(this.agentId)}/passthrough/${encodeURIComponent(integrationType)}`, request2, {
13165
+ Authorization: `Bearer ${this.apiKey}`
13166
+ });
13167
+ }
13168
+ /**
13169
+ * Sandbox-facing wrapper: returns the raw provider envelope
13170
+ * `{ status, headers, data }` (provider error statuses relayed faithfully in
13171
+ * `status`), and throws only on route-level failures (no connection,
13172
+ * passthrough disabled, rate limited, transport error).
13173
+ */
13174
+ async passthroughForSandbox(integrationType, request2) {
13175
+ const result = await this.passthrough(integrationType, request2);
13176
+ if (!result.success || !result.data) {
13177
+ throw new Error(result.error?.message || `Integration passthrough failed for '${integrationType}'`);
13178
+ }
13179
+ return result.data;
13180
+ }
13181
+ };
13182
+ }
13183
+ });
13184
+
13096
13185
  // src/api/agents.api.service.ts
13097
13186
  var AgentsApiService;
13098
13187
  var init_agents_api_service = __esm({
@@ -13678,6 +13767,31 @@ var init_channels_send_api_service = __esm({
13678
13767
  }
13679
13768
  });
13680
13769
 
13770
+ // src/api/inbox-push.api.service.ts
13771
+ var InboxPushApiService;
13772
+ var init_inbox_push_api_service = __esm({
13773
+ "src/api/inbox-push.api.service.ts"() {
13774
+ "use strict";
13775
+ init_http_client();
13776
+ InboxPushApiService = class extends HttpClient {
13777
+ static {
13778
+ __name(this, "InboxPushApiService");
13779
+ }
13780
+ apiKey;
13781
+ agentId;
13782
+ constructor(baseUrl, apiKey, agentId) {
13783
+ super(baseUrl), this.apiKey = apiKey, this.agentId = agentId;
13784
+ }
13785
+ /** POST /developer/agents/:agentId/inbox/push */
13786
+ async push(input) {
13787
+ return this.httpPost(`/developer/agents/${this.agentId}/inbox/push`, input, {
13788
+ Authorization: `Bearer ${this.apiKey}`
13789
+ });
13790
+ }
13791
+ };
13792
+ }
13793
+ });
13794
+
13681
13795
  // src/api/directory.api.service.ts
13682
13796
  var DirectoryApiService;
13683
13797
  var init_directory_api_service = __esm({
@@ -13813,6 +13927,8 @@ __export(lazy_instances_exports, {
13813
13927
  getDeveloperInstance: () => getDeveloperInstance,
13814
13928
  getDeviceInstance: () => getDeviceInstance,
13815
13929
  getDirectoryInstance: () => getDirectoryInstance,
13930
+ getInboxPushInstance: () => getInboxPushInstance,
13931
+ getIntegrationsInstance: () => getIntegrationsInstance,
13816
13932
  getJobInstance: () => getJobInstance,
13817
13933
  getOrderInstance: () => getOrderInstance,
13818
13934
  getProductsInstance: () => getProductsInstance,
@@ -13877,6 +13993,13 @@ async function getAiInstance() {
13877
13993
  }
13878
13994
  return _aiInstance;
13879
13995
  }
13996
+ async function getIntegrationsInstance() {
13997
+ if (!_integrationsInstance) {
13998
+ const creds = await getCredentials();
13999
+ _integrationsInstance = new IntegrationsApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
14000
+ }
14001
+ return _integrationsInstance;
14002
+ }
13880
14003
  async function getAgentsInstance() {
13881
14004
  if (!_agentsInstance) {
13882
14005
  const creds = await getCredentials();
@@ -13920,6 +14043,13 @@ async function getVoiceInstance() {
13920
14043
  }
13921
14044
  return _voiceInstance;
13922
14045
  }
14046
+ async function getInboxPushInstance() {
14047
+ if (!_inboxPushInstance) {
14048
+ const creds = await getCredentials();
14049
+ _inboxPushInstance = new InboxPushApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
14050
+ }
14051
+ return _inboxPushInstance;
14052
+ }
13923
14053
  async function getChannelsSendInstance() {
13924
14054
  if (!_channelsSendInstance) {
13925
14055
  const creds = await getCredentials();
@@ -13951,7 +14081,7 @@ function clearAllInstances() {
13951
14081
  _channelsSendInstance = null;
13952
14082
  _directoryInstance = null;
13953
14083
  }
13954
- var _userInstance, _dataInstance, _productsInstance, _basketsInstance, _orderInstance, _webhookInstance, _jobInstance, _aiInstance, _agentsInstance, _whatsAppTemplatesInstance, _cdnInstance, _developerInstance, _voiceInstance, _channelsSendInstance, _directoryInstance, _deviceInstance;
14084
+ var _userInstance, _dataInstance, _productsInstance, _basketsInstance, _orderInstance, _webhookInstance, _jobInstance, _aiInstance, _integrationsInstance, _agentsInstance, _whatsAppTemplatesInstance, _cdnInstance, _developerInstance, _voiceInstance, _channelsSendInstance, _directoryInstance, _deviceInstance, _inboxPushInstance;
13955
14085
  var init_lazy_instances = __esm({
13956
14086
  "src/api/lazy-instances.ts"() {
13957
14087
  "use strict";
@@ -13965,12 +14095,14 @@ var init_lazy_instances = __esm({
13965
14095
  init_webhook_api_service();
13966
14096
  init_job_api_service();
13967
14097
  init_ai_api_service();
14098
+ init_integrations_api_service();
13968
14099
  init_agents_api_service();
13969
14100
  init_whatsapp_templates_api_service();
13970
14101
  init_cdn_api_service();
13971
14102
  init_developer_api_service();
13972
14103
  init_voice_api_service();
13973
14104
  init_channels_send_api_service();
14105
+ init_inbox_push_api_service();
13974
14106
  init_directory_api_service();
13975
14107
  _userInstance = null;
13976
14108
  _dataInstance = null;
@@ -13980,6 +14112,7 @@ var init_lazy_instances = __esm({
13980
14112
  _webhookInstance = null;
13981
14113
  _jobInstance = null;
13982
14114
  _aiInstance = null;
14115
+ _integrationsInstance = null;
13983
14116
  _agentsInstance = null;
13984
14117
  _whatsAppTemplatesInstance = null;
13985
14118
  _cdnInstance = null;
@@ -13995,6 +14128,7 @@ var init_lazy_instances = __esm({
13995
14128
  __name(getWebhookInstance, "getWebhookInstance");
13996
14129
  __name(getJobInstance, "getJobInstance");
13997
14130
  __name(getAiInstance, "getAiInstance");
14131
+ __name(getIntegrationsInstance, "getIntegrationsInstance");
13998
14132
  __name(getAgentsInstance, "getAgentsInstance");
13999
14133
  __name(getWhatsAppTemplatesInstance, "getWhatsAppTemplatesInstance");
14000
14134
  __name(getCdnInstance, "getCdnInstance");
@@ -14002,6 +14136,8 @@ var init_lazy_instances = __esm({
14002
14136
  __name(getDeviceInstance, "getDeviceInstance");
14003
14137
  __name(getDeveloperInstance, "getDeveloperInstance");
14004
14138
  __name(getVoiceInstance, "getVoiceInstance");
14139
+ _inboxPushInstance = null;
14140
+ __name(getInboxPushInstance, "getInboxPushInstance");
14005
14141
  __name(getChannelsSendInstance, "getChannelsSendInstance");
14006
14142
  __name(getDirectoryInstance, "getDirectoryInstance");
14007
14143
  __name(clearAllInstances, "clearAllInstances");
@@ -16969,6 +17105,29 @@ var AgentHandler = class {
16969
17105
  async pushAgentConfig(apiKey, agentId, manifest) {
16970
17106
  const result = {};
16971
17107
  const agent = getPrimitivesByKind(manifest, PrimitiveKind.AGENT)[0];
17108
+ if (agent?.routingDescription !== void 0) {
17109
+ writeProgress("\n\u{1F9ED} Pushing routing description...");
17110
+ try {
17111
+ const success2 = await this.pushDescription({
17112
+ apiKey,
17113
+ agentId
17114
+ }, agent.routingDescription);
17115
+ result.description = {
17116
+ success: success2
17117
+ };
17118
+ if (success2) {
17119
+ writeSuccess(agent.routingDescription ? " \u2705 Routing description pushed" : " \u2705 Routing description cleared");
17120
+ } else {
17121
+ console.error(" \u274C Failed to push routing description");
17122
+ }
17123
+ } catch (error) {
17124
+ if (AuthenticationError.isAuthenticationError(error)) throw error;
17125
+ console.error(` \u274C Failed to push routing description: ${error.message}`);
17126
+ result.description = {
17127
+ success: false
17128
+ };
17129
+ }
17130
+ }
16972
17131
  const persona = agent?.persona;
16973
17132
  if (hasPersonaTextContent(persona)) {
16974
17133
  writeProgress("\n\u{1F319} Pushing persona...");
@@ -17193,6 +17352,13 @@ var AgentHandler = class {
17193
17352
  });
17194
17353
  return result.success;
17195
17354
  }
17355
+ async pushDescription(ctx, description) {
17356
+ const agentApi = new AgentApi(BASE_URLS.API, ctx.apiKey);
17357
+ const result = await agentApi.updateAgent(ctx.agentId, {
17358
+ description
17359
+ });
17360
+ return result.success;
17361
+ }
17196
17362
  async pushPersona(ctx, persona) {
17197
17363
  const personaApi = new PersonaApi(BASE_URLS.API, ctx.apiKey, ctx.agentId);
17198
17364
  const result = await personaApi.createVersion(persona);
@@ -21770,6 +21936,16 @@ function createSandbox(options) {
21770
21936
  return agents.invokeForSandbox(targetAgentId, promptOrInput);
21771
21937
  }, "invoke")
21772
21938
  },
21939
+ // Unified.to raw provider passthrough (PRO-209). Proxied via the same
21940
+ // bearer-auth developer route the api-exports `Integrations` namespace
21941
+ // uses, so `lua test` matches production behavior.
21942
+ Integrations: {
21943
+ passthrough: /* @__PURE__ */ __name(async (integrationType, request2) => {
21944
+ const { getIntegrationsInstance: getIntegrationsInstance2 } = await Promise.resolve().then(() => (init_lazy_instances(), lazy_instances_exports));
21945
+ const integrations = await getIntegrationsInstance2();
21946
+ return integrations.passthroughForSandbox(integrationType, request2);
21947
+ }, "passthrough")
21948
+ },
21773
21949
  // Outbound voice dispatch (BAC-212). `lua test` proxies via the same
21774
21950
  // bearer-auth developer endpoint the lua-cli `Voice.call` namespace uses
21775
21951
  // — keeps the surface byte-equivalent to the lua-core production VM
@@ -22712,6 +22888,7 @@ var ALIAS_MAP = {
22712
22888
  "template.action": {
22713
22889
  canonical: [
22714
22890
  "create",
22891
+ "draft",
22715
22892
  "publish",
22716
22893
  "view",
22717
22894
  "versions",
@@ -22723,6 +22900,7 @@ var ALIAS_MAP = {
22723
22900
  ],
22724
22901
  aliases: lowerKeys({
22725
22902
  new: "create",
22903
+ compose: "draft",
22726
22904
  publish_version: "publish",
22727
22905
  submit: "publish",
22728
22906
  show: "view",
@@ -37855,6 +38033,13 @@ var TemplateApiService = class {
37855
38033
  body: JSON.stringify(data)
37856
38034
  });
37857
38035
  }
38036
+ /** T11.3 — draft composer (the clean `/templates/*` route home). */
38037
+ async composeDraft(templateId, data) {
38038
+ return this._fetch(`/templates/${templateId}/versions/draft`, {
38039
+ method: "POST",
38040
+ body: JSON.stringify(data)
38041
+ });
38042
+ }
37858
38043
  async listTemplates() {
37859
38044
  return this._fetch("/marketplace/templates");
37860
38045
  }
@@ -37911,12 +38096,14 @@ var TemplateApiService = class {
37911
38096
  // src/commands/template.ts
37912
38097
  init_command_utils();
37913
38098
  init_analytics();
38099
+ init_files();
37914
38100
  function showTemplateUsage() {
37915
38101
  console.log("\nUsage:");
37916
38102
  console.log(" lua marketplace template Interactive mode");
37917
38103
  console.log(" lua marketplace template <action> [options] Non-interactive mode");
37918
38104
  console.log("\nActions:");
37919
38105
  console.log(" create --name <n> --display-name <n> [--description <text>] [--visibility public|private]");
38106
+ console.log(" draft --template-id <id> [--source-version <n>] [--force] Compose/merge the template: section of lua.skill.yaml");
37920
38107
  console.log(" publish --template-id <id> [--source-version <n>] [--changelog <text>] [--env-contract KEY=desc,...]");
37921
38108
  console.log(" view --template-id <id> [--version <n>] [--json]");
37922
38109
  console.log(" versions --template-id <id> [--json]");
@@ -37944,6 +38131,10 @@ async function templateCommand(action, options = {}) {
37944
38131
  name: "Create a template from this agent",
37945
38132
  value: "create"
37946
38133
  },
38134
+ {
38135
+ name: "Draft the template: section from this agent",
38136
+ value: "draft"
38137
+ },
37947
38138
  {
37948
38139
  name: "Publish a new template version",
37949
38140
  value: "publish"
@@ -37993,8 +38184,11 @@ async function templateCommand(action, options = {}) {
37993
38184
  case "create":
37994
38185
  await templateCreateAction(templateApi, config, options);
37995
38186
  break;
38187
+ case "draft":
38188
+ await templateDraftAction(templateApi, options);
38189
+ break;
37996
38190
  case "publish":
37997
- await templatePublishAction(templateApi, options);
38191
+ await templatePublishAction(templateApi, config, options);
37998
38192
  break;
37999
38193
  case "view":
38000
38194
  await templateViewAction(templateApi, options);
@@ -38240,18 +38434,125 @@ async function templateCreateAction(templateApi, config, options) {
38240
38434
  });
38241
38435
  }
38242
38436
  __name(templateCreateAction, "templateCreateAction");
38243
- async function templatePublishAction(templateApi, options) {
38437
+ async function templateDraftAction(templateApi, options) {
38438
+ const config = readYamlConfig();
38439
+ if (!config) throw new Error("No lua.skill.yaml found in this directory.");
38440
+ const templateId = await resolveTemplateId(templateApi, options, "Which template would you like to draft for?");
38441
+ const sourceAgentVersion = options.sourceVersion ? Number.parseInt(options.sourceVersion, 10) : void 0;
38442
+ if (options.sourceVersion && (!Number.isFinite(sourceAgentVersion) || sourceAgentVersion <= 0)) {
38443
+ throw new Error(`Invalid --source-version "${options.sourceVersion}": must be a positive integer.`);
38444
+ }
38445
+ writeProgress("\u{1F504} Composing template draft...");
38446
+ const result = await templateApi.composeDraft(templateId, {
38447
+ force: options.force === true,
38448
+ sourceAgentVersion
38449
+ });
38450
+ config.template = {
38451
+ connections: result.draft.connections,
38452
+ ...result.draft.personaTemplate ? {
38453
+ personaTemplate: result.draft.personaTemplate
38454
+ } : {},
38455
+ triggerPresets: result.draft.triggerPresets,
38456
+ paramsMeta: result.draft.paramsMeta
38457
+ };
38458
+ writeYamlConfig(config);
38459
+ if (options.json) {
38460
+ console.log(JSON.stringify(result, null, 2));
38461
+ return;
38462
+ }
38463
+ writeSuccess("\u2705 template: section written to lua.skill.yaml");
38464
+ for (const [section2, diff] of Object.entries(result.diff)) {
38465
+ const annotations = Object.entries(diff.annotations ?? {});
38466
+ console.log(` ${section2}: +${diff.added.length} added (${diff.added.join(", ") || "\u2014"}), ${diff.kept.length} kept`);
38467
+ for (const [key, note] of annotations) {
38468
+ console.log(` \u26A0 ${key}: ${note}`);
38469
+ }
38470
+ }
38471
+ writeHintBlock({
38472
+ headline: "Review the drafted sections, then publish:",
38473
+ lines: [
38474
+ {
38475
+ label: "Publish:",
38476
+ command: `lua marketplace template publish --template-id ${templateId}`
38477
+ }
38478
+ ],
38479
+ when: "success"
38480
+ });
38481
+ }
38482
+ __name(templateDraftAction, "templateDraftAction");
38483
+ var TEMPLATE_SECTION_KEYS = [
38484
+ "connections",
38485
+ "personaTemplate",
38486
+ "triggerPresets",
38487
+ "paramsMeta"
38488
+ ];
38489
+ function sectionKeys(section2, value) {
38490
+ if (value === void 0 || value === null) return [];
38491
+ if (section2 === "connections") return (value ?? []).map((entry) => entry.key);
38492
+ if (section2 === "personaTemplate") {
38493
+ const vars = value.vars ?? [];
38494
+ return vars.map((v) => v.name);
38495
+ }
38496
+ return Object.keys(value);
38497
+ }
38498
+ __name(sectionKeys, "sectionKeys");
38499
+ async function confirmTemplateSectionConsequences(templateApi, templateId, local, force) {
38500
+ const versions = await templateApi.getVersions(templateId).catch(() => []);
38501
+ const latest = [
38502
+ ...versions
38503
+ ].sort((a, b) => b.version - a.version)[0];
38504
+ if (!latest) return;
38505
+ const consequences = [];
38506
+ const consequenceCopy = {
38507
+ connections: "installed agents keep their binding; new installs will not be prompted",
38508
+ personaTemplate: "new installs get no persona template; installed personas are untouched",
38509
+ triggerPresets: "new installs fall back to default arming recommendations",
38510
+ paramsMeta: "the deploy form falls back to derived display names and string typing"
38511
+ };
38512
+ for (const section2 of TEMPLATE_SECTION_KEYS) {
38513
+ const serverKeys = sectionKeys(section2, latest[section2]);
38514
+ const localKeys = sectionKeys(section2, local[section2]);
38515
+ const removed = serverKeys.filter((key) => !localKeys.includes(key));
38516
+ if (!removed.length) continue;
38517
+ const clearing = localKeys.length === 0;
38518
+ consequences.push(` ${section2}: ${clearing ? "CLEARING the section" : `removing ${removed.join(", ")}`} \u2014 ${consequenceCopy[section2]}`);
38519
+ }
38520
+ if (!consequences.length) return;
38521
+ console.log("\n\u26A0 This publish clears or narrows authored template sections:");
38522
+ for (const line of consequences) console.log(line);
38523
+ const isTTY = Boolean(process.stdin.isTTY && process.stdout.isTTY);
38524
+ if (force || isCiModeEnabled() || !isTTY) {
38525
+ writeInfo("Proceeding headless (diff printed above).");
38526
+ return;
38527
+ }
38528
+ const confirmed = await confirmAction("\nProceed with this publish?");
38529
+ if (!confirmed) throw new Error("Publish aborted.");
38530
+ }
38531
+ __name(confirmTemplateSectionConsequences, "confirmTemplateSectionConsequences");
38532
+ async function templatePublishAction(templateApi, config, options) {
38244
38533
  const templateId = await resolveTemplateId(templateApi, options, "Which template would you like to publish a version for?");
38245
38534
  const sourceAgentVersion = options.sourceVersion ? Number.parseInt(options.sourceVersion, 10) : void 0;
38246
38535
  if (options.sourceVersion && (!Number.isFinite(sourceAgentVersion) || sourceAgentVersion <= 0)) {
38247
38536
  throw new Error(`Invalid --source-version "${options.sourceVersion}": must be a positive integer.`);
38248
38537
  }
38249
38538
  const envContract = parseEnvContract(options.envContract);
38539
+ const templateSection = readYamlConfig()?.template ?? config.template;
38540
+ let sectionBody = {};
38541
+ if (templateSection !== void 0) {
38542
+ await confirmTemplateSectionConsequences(templateApi, templateId, templateSection, options.force === true || options.yes === true);
38543
+ sectionBody = {
38544
+ connections: templateSection.connections ?? [],
38545
+ triggerPresets: templateSection.triggerPresets ?? {},
38546
+ personaTemplate: templateSection.personaTemplate ?? null,
38547
+ paramsMeta: templateSection.paramsMeta ?? {}
38548
+ };
38549
+ }
38250
38550
  writeProgress("\u{1F504} Publishing template version...");
38251
38551
  const version = await templateApi.createVersion(templateId, {
38252
38552
  sourceAgentVersion,
38253
38553
  changelog: options.changelog || void 0,
38254
- envContract
38554
+ envContract,
38555
+ ...sectionBody
38255
38556
  });
38256
38557
  if (options.json) {
38257
38558
  console.log(JSON.stringify(version, null, 2));
@@ -38347,12 +38648,14 @@ async function templateInstallAction(templateApi, config, options) {
38347
38648
  console.error("\n\u274C Use --force to confirm installation");
38348
38649
  throw new Error("This action requires --force to confirm");
38349
38650
  }
38651
+ if (options.skipEnvCheck) {
38652
+ writeInfo("\u26A0\uFE0F --skip-env-check is deprecated: the env-contract check is server-enforced; use `lua env` to satisfy the contract.");
38653
+ }
38350
38654
  writeProgress("\u{1F504} Installing template...");
38351
38655
  const install = await templateApi.install(templateId, agentId, {
38352
38656
  version,
38353
38657
  envValues,
38354
- allowCreatorUpdates: options.allowCreatorUpdates,
38355
- skipEnvCheck: options.skipEnvCheck
38658
+ allowCreatorUpdates: options.allowCreatorUpdates
38356
38659
  });
38357
38660
  if (options.json) {
38358
38661
  console.log(JSON.stringify(install, null, 2));
@@ -38459,6 +38762,9 @@ Apply v${versionObj.version} to ${targets.length} agent(s)?`);
38459
38762
  throw new Error("This action requires --force to confirm (non-interactive mode)");
38460
38763
  }
38461
38764
  }
38765
+ if (options.skipEnvCheck) {
38766
+ writeInfo("\u26A0\uFE0F --skip-env-check is deprecated: the env-contract check is server-enforced; use `lua env` to satisfy the contract.");
38767
+ }
38462
38768
  writeProgress("\u{1F504} Starting apply run...");
38463
38769
  const { runId } = await templateApi.apply(templateId, {
38464
38770
  version: versionObj.version,
@@ -46280,7 +46586,7 @@ function setupMarketplaceCommands(program2) {
46280
46586
  program2.command("marketplace [noun] [action]").description("\u{1F6CD}\uFE0F Browse, install, and manage marketplace skills and agent templates").option("--skill-name <name>", "Skill name (for skill list/update/uninstall)").option("--marketplace-id <id>", "Marketplace skill ID").option("--version-id <id>", "Version ID (for skill publish/install)").option("--env-vars-json <json>", "JSON string with env var metadata (for skill publish)").option("--query <text>", "Search query (for skill search)").option("--page <n>", "Page number (for skill search)").option("--limit <n>", "Results per page (for skill search)").option("--name <name>", "Template name, an internal identifier (for template create)").option("--description <text>", "Description (for template create)").option("--template-id <id>", "Template ID").option("--source-version <n>", "Agent version to freeze into this template version (default: active) (for template publish)").option("--env-contract <pair>", "KEY=description env contract entry, repeatable; use KEY?=description for optional (for template publish)", (val, previous) => [
46281
46587
  ...previous,
46282
46588
  val
46283
- ], []).option("--version <n>", "Template version (for template view/install/apply)").option("--allow-creator-updates", "Allow the template creator to push future updates onto this install").option("--skip-env-check", "Skip env-contract validation (for template install/apply)").option("--agents <ids>", "Comma-separated target agent IDs (for template apply)").option("--file <path>", "Path to a file with one target agent ID per line (for template apply)").option("--all-installed", "Target every agent that already has this template installed (for template apply)").option("--no-wait", "Print the apply runId immediately instead of polling for completion (for template apply)").option("--display-name <name>", "Display name (for skill list/edit, template create)").option("--visibility <visibility>", "Who can see and install it: public or private (for skill list, template create)").option("--changelog <text>", "Changelog for this version (for skill/template publish)").option("--env-vars <pairs>", "Comma-separated key=value pairs (for skill/template install/update)").option("--json", "Output as JSON").option("--force", "Skip confirmation prompts").addHelpText("after", `
46589
+ ], []).option("--version <n>", "Template version (for template view/install/apply)").option("--allow-creator-updates", "Allow the template creator to push future updates onto this install").option("--skip-env-check", "Skip env-contract validation (for template install/apply)").option("--agents <ids>", "Comma-separated target agent IDs (for template apply)").option("--file <path>", "Path to a file with one target agent ID per line (for template apply)").option("--all-installed", "Target every agent that already has this template installed (for template apply)").option("--no-wait", "Print the apply runId immediately instead of polling for completion (for template apply)").option("--display-name <name>", "Display name (for skill list/edit, template create)").option("--visibility <visibility>", "Who can see and install it: public or private (for skill list, template create)").option("--changelog <text>", "Changelog for this version (for skill/template publish)").option("--env-vars <pairs>", "Comma-separated key=value pairs (for skill/template install/update)").option("--json", "Output as JSON").option("--force", "Skip confirmation prompts").option("--yes", "Auto-confirm ONLY the template-publish consequence prompt (section clear/narrow); unlike --force it skips no other confirmation").addHelpText("after", `
46284
46590
  Arguments:
46285
46591
  noun Optional: 'skill' or 'template' (prompts if not provided)
46286
46592
  action Optional: specific action for non-interactive mode