@openagents-org/agent-launcher 0.2.220 → 0.2.221

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagents-org/agent-launcher",
3
- "version": "0.2.220",
3
+ "version": "0.2.221",
4
4
  "description": "OpenAgents Launcher — install, configure, and run AI coding agents from your terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -8,30 +8,10 @@
8
8
  * ~/.pi/agent/models.json and auth.json untouched.
9
9
  */
10
10
 
11
- const value = (name) => String(process.env[name] || '').trim()
11
+ import launcherConfig from './pi-provider-config.js'
12
12
 
13
- const PROVIDER_DEFAULTS = {
14
- anthropic: {
15
- baseUrl: 'https://api.anthropic.com',
16
- api: 'anthropic-messages',
17
- },
18
- openai: {
19
- baseUrl: 'https://api.openai.com/v1',
20
- api: 'openai-responses',
21
- },
22
- deepseek: {
23
- baseUrl: 'https://api.deepseek.com/v1',
24
- api: 'openai-completions',
25
- },
26
- google: {
27
- baseUrl: 'https://generativelanguage.googleapis.com/v1beta',
28
- api: 'google-generative-ai',
29
- },
30
- openrouter: {
31
- baseUrl: 'https://openrouter.ai/api/v1',
32
- api: 'openai-completions',
33
- },
34
- }
13
+ const { PROVIDER_DEFAULTS, launcherProviderId } = launcherConfig
14
+ const value = (name) => String(process.env[name] || '').trim()
35
15
 
36
16
  function providerKey(provider) {
37
17
  return value('PI_API_KEY') || {
@@ -78,7 +58,13 @@ export default function configureLauncherProvider(pi) {
78
58
  compat.supportsDeveloperRole = false
79
59
  }
80
60
 
81
- pi.registerProvider(provider, {
61
+ // Pi prefers auth.json credentials over an extension's configured key.
62
+ // Match the adapter's process-local provider id when Launcher supplied a
63
+ // key, while keyless relays can still reuse their existing Pi login.
64
+ const providerId = launcherProviderId({
65
+ provider, model, baseUrl: configuredBaseUrl, apiKey: value('PI_API_KEY'),
66
+ })
67
+ pi.registerProvider(providerId, {
82
68
  baseUrl,
83
69
  api,
84
70
  // Pass the resolved secret directly to the process-local provider. This is
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const PROVIDER_DEFAULTS = {
4
+ anthropic: {
5
+ baseUrl: 'https://api.anthropic.com',
6
+ api: 'anthropic-messages',
7
+ },
8
+ openai: {
9
+ baseUrl: 'https://api.openai.com/v1',
10
+ api: 'openai-responses',
11
+ },
12
+ deepseek: {
13
+ baseUrl: 'https://api.deepseek.com/v1',
14
+ api: 'openai-completions',
15
+ },
16
+ google: {
17
+ baseUrl: 'https://generativelanguage.googleapis.com/v1beta',
18
+ api: 'google-generative-ai',
19
+ },
20
+ openrouter: {
21
+ baseUrl: 'https://openrouter.ai/api/v1',
22
+ api: 'openai-completions',
23
+ },
24
+ };
25
+
26
+ /** Keep Launcher keys separate from native Pi credentials when we can register the provider. */
27
+ function launcherProviderId({ provider, model, baseUrl, apiKey }) {
28
+ const name = String(provider || '').trim().toLowerCase();
29
+ if (name && String(model || '').trim() && String(apiKey || '').trim() &&
30
+ (String(baseUrl || '').trim().replace(/\/+$/, '') || PROVIDER_DEFAULTS[name]?.baseUrl)) {
31
+ return `openagents-${name}`;
32
+ }
33
+ return provider;
34
+ }
35
+
36
+ module.exports = { PROVIDER_DEFAULTS, launcherProviderId };
@@ -64,6 +64,8 @@ const {
64
64
  MIN_PI_VERSION,
65
65
  } = require('./pi-stream');
66
66
 
67
+ const { launcherProviderId } = require('./pi-provider-config');
68
+
67
69
  const IS_WINDOWS = process.platform === 'win32';
68
70
  const LAUNCHER_PROVIDER_EXTENSION = path.join(__dirname, 'pi-launcher-provider.mjs');
69
71
 
@@ -1384,7 +1386,10 @@ class PiAdapter extends BaseAdapter {
1384
1386
  sessionDir: this._sessionDir,
1385
1387
  sessionId,
1386
1388
  appendSystemPrompt,
1387
- provider: cfg.provider,
1389
+ // A stored Pi login wins over an extension's apiKey for the same
1390
+ // provider. Keep Launcher-key requests in a separate provider namespace
1391
+ // so a native login cannot authenticate a different endpoint.
1392
+ provider: launcherProviderId({ ...cfg, apiKey: launcherKey }),
1388
1393
  model: cfg.model,
1389
1394
  thinking: cfg.thinking,
1390
1395
  sessionName: `${this.agentName}/${channel}`,
package/src/cli-models.js CHANGED
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  const os = require('os');
19
+ const { stripVTControlCharacters } = require('node:util');
19
20
  // spawn() here is the WSL bridge from ./wsl: same signature as
20
21
  // child_process.spawn, and a straight pass-through unless the resolved CLI
21
22
  // lives on the other side of the Windows/WSL boundary.
@@ -124,12 +125,48 @@ function parseQoderModels(text) {
124
125
  return [...seen.values()].slice(0, MAX_MODELS);
125
126
  }
126
127
 
128
+ /**
129
+ * Pi --list-models prints the configured providers' catalog as a table, not a
130
+ * per-model subscription entitlement check. Qualify ids so identical model
131
+ * names on different signed-in providers remain selectable without ambiguity.
132
+ */
133
+ function parsePiModels(text, env = {}) {
134
+ const selectedProvider = String(env.PI_PROVIDER || '').trim().toLowerCase();
135
+ const seen = new Map();
136
+ let inTable = false;
137
+ for (const raw of stripVTControlCharacters(String(text || '')).split(/\r?\n/)) {
138
+ const fields = raw.trim().split(/\s+/);
139
+ if (fields.join(' ') === 'provider model context max-out thinking images') {
140
+ inTable = true;
141
+ continue;
142
+ }
143
+ if (!inTable || fields.length !== 6 ||
144
+ !/^\d+(?:\.\d+)?[KM]?$/i.test(fields[2]) ||
145
+ !/^\d+(?:\.\d+)?[KM]?$/i.test(fields[3]) ||
146
+ !/^(yes|no)$/.test(fields[4]) || !/^(yes|no)$/.test(fields[5])) continue;
147
+ const [provider, model] = fields;
148
+ if (!/^[\w.-]+$/.test(provider) || !cleanId(model)) continue;
149
+ if (selectedProvider && provider.toLowerCase() !== selectedProvider) continue;
150
+ const id = cleanId(`${provider}/${model}`);
151
+ if (!id || seen.has(id)) continue;
152
+ seen.set(id, { id, label: cleanLabel(`${model} (${provider})`, id) });
153
+ if (seen.size >= MAX_MODELS) break;
154
+ }
155
+ return [...seen.values()];
156
+ }
157
+
127
158
  /**
128
159
  * How each CLI is asked. Claude Code has no command for it; its SDK control
129
160
  * protocol does, and a run that is sent the request and then end-of-input
130
161
  * answers and exits without a prompt ever reaching a model.
131
162
  */
132
163
  const LISTERS = {
164
+ pi: {
165
+ args: ['--no-approve', '--no-extensions', '--no-skills', '--list-models'],
166
+ parse: parsePiModels,
167
+ timeoutMs: 30_000,
168
+ env: { PI_SKIP_VERSION_CHECK: '1', NO_COLOR: '1' },
169
+ },
133
170
  codex: {
134
171
  args: ['debug', 'models'],
135
172
  parse: parseCodexModels,
@@ -279,9 +316,9 @@ async function listCliModels(connector, type, opts = {}) {
279
316
  });
280
317
  // A run killed for taking too long may still have answered: Claude Code
281
318
  // replies before it finishes starting up.
282
- const models = lister.parse(res.stdout);
319
+ const models = lister.parse(res.stdout, agentEnv);
283
320
  if (models.length) return { type, ok: true, models };
284
321
  return fail(res.error || 'The CLI listed no models.');
285
322
  }
286
323
 
287
- module.exports = { listCliModels, supportsCliModels, cliModelsWithKey, parseCodexModels, parseClaudeModels, parseQoderModels };
324
+ module.exports = { listCliModels, supportsCliModels, cliModelsWithKey, parseCodexModels, parseClaudeModels, parseQoderModels, parsePiModels };