larkin 0.4.26 → 0.4.27

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.
@@ -42,8 +42,10 @@ exports.resolveRuntimeExecutable = resolveRuntimeExecutable;
42
42
  exports.classifyRuntimePrerequisite = classifyRuntimePrerequisite;
43
43
  exports.probeNativeRuntimeReadiness = probeNativeRuntimeReadiness;
44
44
  const node_fs_1 = __importDefault(require("node:fs"));
45
+ const node_os_1 = __importDefault(require("node:os"));
45
46
  const node_path_1 = __importDefault(require("node:path"));
46
47
  const node_child_process_1 = require("node:child_process");
48
+ const root_layout_js_1 = require("../platform/root-layout.cjs");
47
49
  const builtin_pi_assets_js_1 = require("./builtin-pi-assets.cjs");
48
50
  const pi_provider_config_js_1 = require("./pi-provider-config.cjs");
49
51
  const process_boundary_trace_js_1 = require("../platform/process-boundary-trace.cjs");
@@ -162,11 +164,27 @@ async function probeNativeRuntimeReadiness(options) {
162
164
  ? "Install Pi and ensure `pi` is on PATH, or set LARKIN_PI_COMMAND."
163
165
  : `Install ${options.runtime} and ensure it is on PATH.`,
164
166
  };
167
+ const piAgentId = options.agentId;
168
+ if (options.runtime === "pi" && !piAgentId) {
169
+ return {
170
+ runtime: "pi",
171
+ state: "unavailable",
172
+ executable,
173
+ reason: "Pi catalog readiness requires Agent ID",
174
+ nextAction: "Retry setup or start so Larkin can probe the Agent-owned Pi provider directory.",
175
+ };
176
+ }
165
177
  const version = executableVersion(executable, env, options.commandArgs);
166
178
  try {
167
179
  if (options.runtime === "pi") {
168
180
  const { discoverPiModelCatalog } = await Promise.resolve().then(() => __importStar(require("./pi-model-catalog.cjs")));
169
- await discoverPiModelCatalog({ cwd: options.cwd, command: executable, commandArgs: options.commandArgs, env });
181
+ await discoverPiModelCatalog({
182
+ cwd: options.cwd,
183
+ command: executable,
184
+ commandArgs: options.commandArgs,
185
+ env,
186
+ agentDir: (0, pi_provider_config_js_1.ownedPiCatalogAgentDir)((0, root_layout_js_1.resolveConfigDir)(env, node_os_1.default.homedir()), piAgentId),
187
+ });
170
188
  }
171
189
  else if (options.runtime === "codex") {
172
190
  const { discoverCodexModelCatalog } = await Promise.resolve().then(() => __importStar(require("./codex-model-catalog.cjs")));
@@ -1,8 +1,10 @@
1
1
  import fs from "node:fs";
2
+ import os from "node:os";
2
3
  import path from "node:path";
3
4
  import { spawnSync } from "node:child_process";
5
+ import { resolveConfigDir as resolveRootConfigDir } from "../platform/root-layout.mjs";
4
6
  import { applyPiPackageDirForChild, piChildDistributionFromOverrides } from "./builtin-pi-assets.mjs";
5
- import { assertBuiltinPiAgentDirectory, BUNDLED_PI_VERSION, piAgentDirectory } from "./pi-provider-config.mjs";
7
+ import { assertBuiltinPiAgentDirectory, BUNDLED_PI_VERSION, ownedPiCatalogAgentDir, piAgentDirectory } from "./pi-provider-config.mjs";
6
8
  import { traceProcessBoundary } from "../platform/process-boundary-trace.mjs";
7
9
  function safeProviderLabel(value) {
8
10
  const provider = typeof value === "string" ? value.trim() : "";
@@ -118,11 +120,27 @@ export async function probeNativeRuntimeReadiness(options) {
118
120
  ? "Install Pi and ensure `pi` is on PATH, or set LARKIN_PI_COMMAND."
119
121
  : `Install ${options.runtime} and ensure it is on PATH.`,
120
122
  };
123
+ const piAgentId = options.agentId;
124
+ if (options.runtime === "pi" && !piAgentId) {
125
+ return {
126
+ runtime: "pi",
127
+ state: "unavailable",
128
+ executable,
129
+ reason: "Pi catalog readiness requires Agent ID",
130
+ nextAction: "Retry setup or start so Larkin can probe the Agent-owned Pi provider directory.",
131
+ };
132
+ }
121
133
  const version = executableVersion(executable, env, options.commandArgs);
122
134
  try {
123
135
  if (options.runtime === "pi") {
124
136
  const { discoverPiModelCatalog } = await import("./pi-model-catalog.mjs");
125
- await discoverPiModelCatalog({ cwd: options.cwd, command: executable, commandArgs: options.commandArgs, env });
137
+ await discoverPiModelCatalog({
138
+ cwd: options.cwd,
139
+ command: executable,
140
+ commandArgs: options.commandArgs,
141
+ env,
142
+ agentDir: ownedPiCatalogAgentDir(resolveRootConfigDir(env, os.homedir()), piAgentId),
143
+ });
126
144
  }
127
145
  else if (options.runtime === "codex") {
128
146
  const { discoverCodexModelCatalog } = await import("./codex-model-catalog.mjs");
@@ -666,7 +666,8 @@ Lark 必须用 --tenant lark:授权二维码是官方 /page/cli(begin 仍走
666
666
  const choice = injectedAgentChoice
667
667
  ? requested
668
668
  : await recoverUnavailableExternalPi(requested, questioner, () => probeNativeRuntimeReadiness({
669
- runtime: "pi", agentId: id, cwd: path.join(CFG_DIR, "agents", id), env: process.env,
669
+ runtime: "pi", agentId: id, cwd: path.join(CFG_DIR, "agents", id),
670
+ env: { ...process.env, LARKIN_CONFIG_DIR: CFG_DIR, LARKIN_PI_DISTRIBUTION: "external" },
670
671
  }), (message) => say(`! ${message}`), authServices);
671
672
  if (choice) {
672
673
  let serializedChoice = choice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "larkin",
3
- "version": "0.4.26",
3
+ "version": "0.4.27",
4
4
  "private": false,
5
5
  "larkinPackageRole": "npm-published",
6
6
  "files": [