larkway 0.3.7 → 0.3.8

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/main.js CHANGED
@@ -111527,20 +111527,6 @@ var ChatEntry = external_exports.object({
111527
111527
  purpose: external_exports.enum(["production", "test", "staging"]).default("production"),
111528
111528
  description: external_exports.string().optional()
111529
111529
  });
111530
- var CentralConfig = external_exports.object({
111531
- /**
111532
- * Git URL or local path of the central config repo (where `bots/` lives).
111533
- * e.g. "git@gitlab.company.com:ops/larkway-bots.git" or a bare repo path.
111534
- */
111535
- repo: external_exports.string().min(1, "centralConfig.repo is required (git url or path)"),
111536
- /** Branch to track on the central repo. @default "main" */
111537
- branch: external_exports.string().min(1).default("main"),
111538
- /**
111539
- * Path INSIDE the central repo that holds the bot files (<id>.yaml +
111540
- * <id>.memory.md). @default "bots"
111541
- */
111542
- path: external_exports.string().min(1).default("bots")
111543
- });
111544
111530
  var ConfigJson = external_exports.object({
111545
111531
  conventions: ConventionsConfig,
111546
111532
  permissions: PermissionsConfig,
@@ -111548,12 +111534,7 @@ var ConfigJson = external_exports.object({
111548
111534
  * List of allowed chats with labels. If empty/missing, bridge falls back
111549
111535
  * to the legacy `LARK_ALLOWED_CHAT_IDS` env var (deprecated).
111550
111536
  */
111551
- chats: external_exports.array(ChatEntry).default([]),
111552
- /**
111553
- * Central config repo (V2.2 §7 A.2). Optional — when present, `larkway sync`
111554
- * pulls bots/ from it. Absent = local self-management.
111555
- */
111556
- centralConfig: CentralConfig.optional()
111537
+ chats: external_exports.array(ChatEntry).default([])
111557
111538
  });
111558
111539
  var DEFAULT_CONFIG_PATH = path2.join(larkwayHome(), "config.json");
111559
111540
  function getLanIp() {
@@ -111577,8 +111558,7 @@ function defaultConfigJson() {
111577
111558
  portRangeEnd: 3050
111578
111559
  },
111579
111560
  permissions: { allowExtra: [] },
111580
- chats: [],
111581
- centralConfig: void 0
111561
+ chats: []
111582
111562
  };
111583
111563
  }
111584
111564
  async function loadConfigJson(configPath = DEFAULT_CONFIG_PATH) {
@@ -113555,7 +113535,7 @@ function renderPrompt(input) {
113555
113535
  ` lark-cli docs +get <doc-url>${profileFlag}`,
113556
113536
  "- \u53D6\u672C\u6761\u6D88\u606F\u7684\u9644\u4EF6/\u5185\u8054\u56FE(post \u5185\u8054\u56FE\u4E0D\u5728\u4E0A\u9762 attachments/images \u91CC)\u3001\u62C9\u8BDD\u9898\u5386\u53F2:",
113557
113537
  attachmentHelpLine,
113558
- "- glab / git / gitlab API",
113538
+ "- glab / gh / git API",
113559
113539
  "- pnpm / npm",
113560
113540
  "",
113561
113541
  "**\u91CD\u8981**:`thread_id` \u5C31\u662F\u8BDD\u9898\u9996\u697C\u7684 message_id\u3002\u5982\u679C\u5F53\u524D\u6D88\u606F attachments/feishu_doc_links \u4E3A\u7A7A,\u8BF4\u660E\u8FD0\u8425\u628A\u7D20\u6750\u653E\u5728\u9996\u697C,**\u5148\u62C9\u9996\u697C\u770B\u8FD0\u8425\u539F\u59CB\u9700\u6C42**,\u518D\u51B3\u5B9A\u4E0B\u4E00\u6B65\u3002",
@@ -113850,7 +113830,7 @@ function renderPermissionsRequest(input) {
113850
113830
  "## Repo Pointers",
113851
113831
  "",
113852
113832
  ...repoLines,
113853
- input.bot.gitlab_token_env ? `- GitLab token env name available after human setup: ${input.bot.gitlab_token_env}` : "- GitLab token env name: pending human confirmation",
113833
+ input.bot.gitlab_token_env ? `- Git token env name available after human setup: ${input.bot.gitlab_token_env}` : "- Git token env name: pending human confirmation",
113854
113834
  "",
113855
113835
  "## Human Gate",
113856
113836
  "",
@@ -113876,11 +113856,11 @@ function defaultWorkspacePermissionItems(input) {
113876
113856
  }
113877
113857
  if (input.repos && input.repos.length > 0) {
113878
113858
  for (const repo of input.repos) {
113879
- capabilities.push(`GitLab repo pointer: ${repo.slug} (${repo.branch ?? "master"})`);
113859
+ capabilities.push(`Git repo pointer: ${repo.slug} (${repo.branch ?? "master"})`);
113880
113860
  }
113881
113861
  }
113882
113862
  if (input.bot.gitlab_token_env) {
113883
- capabilities.push(`GitLab token env name: ${input.bot.gitlab_token_env}`);
113863
+ capabilities.push(`Git token env name: ${input.bot.gitlab_token_env}`);
113884
113864
  }
113885
113865
  capabilities.push("Local shell inside the Agent Workspace for task execution and verification");
113886
113866
  return permissionItemsFromCapabilities(capabilities);
@@ -113936,10 +113916,10 @@ function renderDefaultPermissionGrantLines(input) {
113936
113916
  lines.push(`- type=read Feishu chat allowlist: ${chats.join(", ")} source=saved-agent-config`);
113937
113917
  }
113938
113918
  for (const repo of input.repos ?? []) {
113939
- lines.push(`- type=read GitLab repo pointer: ${repo.slug} (${repo.branch ?? "master"}) source=saved-agent-config`);
113919
+ lines.push(`- type=read Git repo pointer: ${repo.slug} (${repo.branch ?? "master"}) source=saved-agent-config`);
113940
113920
  }
113941
113921
  if (input.bot.gitlab_token_env) {
113942
- lines.push(`- type=write GitLab write/MR env=${input.bot.gitlab_token_env} source=saved-agent-config`);
113922
+ lines.push(`- type=write Git write/MR env=${input.bot.gitlab_token_env} source=saved-agent-config`);
113943
113923
  }
113944
113924
  const humanGates = input.humanGates && input.humanGates.length > 0 ? input.humanGates : ["Deploy/restart and production-impact actions require explicit human confirmation."];
113945
113925
  for (const gate of humanGates) {
@@ -114596,7 +114576,7 @@ var BridgeHandler = class {
114596
114576
  bot: {
114597
114577
  name: this.deps.botConfig?.name ?? "Larkway Agent",
114598
114578
  description: this.deps.botConfig?.description ?? "Local agent served through Larkway.",
114599
- gitlab_token_env: this.deps.botConfig?.gitlab_token_env
114579
+ gitlab_token_env: this.deps.botConfig?.git_token_env ?? this.deps.botConfig?.gitlab_token_env
114600
114580
  },
114601
114581
  agentMemory: this.deps.agentMemory,
114602
114582
  repos: [
@@ -117977,13 +117957,23 @@ var BotConfigSchema = external_exports.object({
117977
117957
  */
117978
117958
  lark_cli_profile: external_exports.string().min(1).optional(),
117979
117959
  /**
117980
- * Env-var *name* (not value) that holds this bot's GitLab PAT.
117960
+ * Env-var *name* (not value) that holds this bot's Git PAT.
117981
117961
  * Read from process.env at startup and injected as GITLAB_TOKEN into the
117982
- * claude subprocess env, so MRs/git ops use the bot's own GitLab account.
117983
- * When absent, the claude subprocess inherits process.env.GITLAB_TOKEN
117962
+ * agent subprocess env, so MRs/git ops use the bot's own account.
117963
+ * When absent, the subprocess inherits process.env.GITLAB_TOKEN
117984
117964
  * (V1 single-bot behavior — one global token).
117965
+ *
117966
+ * Preferred field name; `gitlab_token_env` below is the backward-compat alias.
117967
+ */
117968
+ git_token_env: external_exports.string().min(1).optional(),
117969
+ // preferred: generic git PAT env-var name
117970
+ /**
117971
+ * @deprecated Backward-compat alias for `git_token_env`. If both are present,
117972
+ * main.ts prefers `git_token_env`. Old bot yamls with this field continue to
117973
+ * work without changes.
117985
117974
  */
117986
117975
  gitlab_token_env: external_exports.string().min(1).optional(),
117976
+ // compat alias (legacy)
117987
117977
  /**
117988
117978
  * L2 Agent Memory (职能定义) — filename relative to the bots/ directory,
117989
117979
  * pointing at this bot's `*.memory.md`. Loaded at startup and injected into
@@ -119057,17 +119047,18 @@ async function runV2Mode({
119057
119047
  continue;
119058
119048
  }
119059
119049
  if (bot.runtime === "agent_workspace") {
119060
- if (bot.repos.length > 0 && !bot.gitlab_token_env) {
119050
+ const _agentTokenEnvName = bot.git_token_env ?? bot.gitlab_token_env;
119051
+ if (bot.repos.length > 0 && !_agentTokenEnvName) {
119061
119052
  console.error(
119062
- `[larkway] SKIPPING bot "${bot.id}": runtime=agent_workspace has repo pointers but no gitlab_token_env. v0.3 workspace repo bots must reference an explicit per-agent token env name; they do not inherit global GITLAB_TOKEN.`
119053
+ `[larkway] SKIPPING bot "${bot.id}": runtime=agent_workspace has repo pointers but no git_token_env (or gitlab_token_env). v0.3 workspace repo bots must reference an explicit per-agent token env name; they do not inherit global GITLAB_TOKEN.`
119063
119054
  );
119064
119055
  continue;
119065
119056
  }
119066
- if (bot.gitlab_token_env) {
119067
- const gitlabToken = process.env[bot.gitlab_token_env];
119068
- if (gitlabToken == null || gitlabToken === "") {
119057
+ if (_agentTokenEnvName) {
119058
+ const agentToken = process.env[_agentTokenEnvName];
119059
+ if (agentToken == null || agentToken === "") {
119069
119060
  console.error(
119070
- `[larkway] SKIPPING bot "${bot.id}": runtime=agent_workspace declares gitlab_token_env="${bot.gitlab_token_env}", but that env var is unset/empty. Set the real token in ~/.larkway/.env; v0.3 workspace bots do not fall back to global GITLAB_TOKEN.`
119061
+ `[larkway] SKIPPING bot "${bot.id}": runtime=agent_workspace declares token env "${_agentTokenEnvName}", but that env var is unset/empty. Set the real token in ~/.larkway/.env; v0.3 workspace bots do not fall back to global GITLAB_TOKEN.`
119071
119062
  );
119072
119063
  continue;
119073
119064
  }
@@ -119096,10 +119087,11 @@ async function runV2Mode({
119096
119087
  const instances = [];
119097
119088
  for (const bot of healthyBots) {
119098
119089
  const appSecret = process.env[bot.app_secret_env];
119099
- const gitlabToken = bot.gitlab_token_env != null ? process.env[bot.gitlab_token_env] : void 0;
119100
- if (bot.gitlab_token_env != null && (gitlabToken == null || gitlabToken === "")) {
119090
+ const tokenEnvName = bot.git_token_env ?? bot.gitlab_token_env;
119091
+ const gitlabToken = tokenEnvName != null ? process.env[tokenEnvName] : void 0;
119092
+ if (tokenEnvName != null && (gitlabToken == null || gitlabToken === "")) {
119101
119093
  console.warn(
119102
- `[larkway] bot "${bot.id}" declares gitlab_token_env="${bot.gitlab_token_env}" but that env var is unset/empty \u2014 falling back to global GITLAB_TOKEN.`
119094
+ `[larkway] bot "${bot.id}" declares token env "${tokenEnvName}" but that env var is unset/empty \u2014 falling back to global GITLAB_TOKEN.`
119103
119095
  );
119104
119096
  }
119105
119097
  const larkCliProfile = deriveLarkCliProfile(bot.lark_cli_profile, bot.app_id);
@@ -119168,7 +119160,7 @@ async function runV2Mode({
119168
119160
  portRangeStart: configJson.conventions.portRangeStart,
119169
119161
  portRangeEnd: configJson.conventions.portRangeEnd,
119170
119162
  readOnly: bot.read_only,
119171
- gitlabTokenEnvName: bot.gitlab_token_env
119163
+ gitlabTokenEnvName: tokenEnvName
119172
119164
  };
119173
119165
  const effectiveGitlabToken = bot.runtime === "agent_workspace" ? gitlabToken ?? "" : gitlabToken;
119174
119166
  const resolvedPeers = bot.peers.flatMap((peerId) => {
@@ -119191,6 +119183,7 @@ async function runV2Mode({
119191
119183
  git_identity: bot.git_identity,
119192
119184
  backend: bot.backend,
119193
119185
  runtime: bot.runtime,
119186
+ git_token_env: bot.git_token_env,
119194
119187
  gitlab_token_env: bot.gitlab_token_env
119195
119188
  },
119196
119189
  gitlabToken: effectiveGitlabToken,