pairit 0.1.4 → 0.1.6

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.
Files changed (3) hide show
  1. package/README.md +34 -6
  2. package/dist/index.js +9 -447
  3. package/package.json +1 -2
package/README.md CHANGED
@@ -5,10 +5,10 @@ A lightweight command line utility for working with Pairit experiment configurat
5
5
  - `login` — authenticate with Google OAuth (required for all hosted commands)
6
6
  - `config lint` — run minimal validation (schema_version, initialPageId, pages)
7
7
  - `config compile` — normalize a YAML config and emit sibling canonical JSON
8
- - `config upload` — compile and upload a config through the manager service
8
+ - `config upload` — compile and upload a config through the manager service, optionally with per-experiment LLM provider keys
9
9
  - `config list` — list configs stored via the manager service
10
10
  - `config delete` — delete a stored config
11
- - `media upload` — upload a binary asset to Cloud Storage via the manager service (uploads are public unless `--private` is passed; the backend selects the bucket unless you override with `--bucket`)
11
+ - `media upload` — upload a binary asset to Cloud Storage via the manager service (uploads are public unless `--private` is passed; public uploads return a stable asset URL when the backend supports it)
12
12
  - `media list` — list media objects in Cloud Storage
13
13
  - `media delete` — delete a media object from Cloud Storage
14
14
  - `data export` — export sessions, events, and chat messages for a config as CSV/JSON/JSONL
@@ -42,8 +42,9 @@ pairit login # Authenticate (required firs
42
42
 
43
43
  pairit config lint path/to/config.yaml
44
44
  pairit config compile path/to/config.yaml
45
- pairit config upload configs/simple-survey-basic.yaml --owner you@example.com
46
- pairit config list --owner you@example.com
45
+ pairit config upload configs/simple-survey-basic.yaml --config-id simple-survey-basic
46
+ pairit config upload configs/agent-study.yaml --config-id agent-study --openai-api-key sk-...
47
+ pairit config list
47
48
  pairit config delete 2f3c4d5e...
48
49
 
49
50
  pairit media upload assets/video.mp4 --content-type video/mp4
@@ -64,7 +65,8 @@ Add `--private` if you need to keep an object private. Use `--bucket <name>` onl
64
65
  # Point to local manager server (default is http://localhost:3002)
65
66
  export PAIRIT_API_URL=http://localhost:3002
66
67
 
67
- bun run apps/manager/cli/src/index.ts config upload configs/simple-survey-basic.yaml --owner you@example.com
68
+ bun run apps/manager/cli/src/index.ts config upload configs/simple-survey-basic.yaml --config-id simple-survey-basic
69
+ bun run apps/manager/cli/src/index.ts config upload configs/agent-study.yaml --config-id agent-study --openai-api-key sk-...
68
70
  bun run apps/manager/cli/src/index.ts config list
69
71
  bun run apps/manager/cli/src/index.ts config delete 2f3c4d5e... --force
70
72
 
@@ -75,12 +77,38 @@ bun run apps/manager/cli/src/index.ts media delete onboarding/logo.png --force
75
77
 
76
78
  `config compile` writes `configs/simple-survey-basic.json` next to the source YAML. `config upload` defaults the config id to a 16-character base64url string derived from the SHA-256 hash of the compiled JSON (unless `--config-id` overrides it).
77
79
 
80
+ ## Per-experiment LLM credentials
81
+
82
+ If your config uses AI agents, attach provider credentials when uploading:
83
+
84
+ ```bash
85
+ pairit config upload path/to/config.yaml --config-id my-exp --openai-api-key sk-...
86
+ pairit config upload path/to/config.yaml --config-id my-exp --anthropic-api-key sk-ant-...
87
+ ```
88
+
89
+ Notes:
90
+ - Keys are stored per config, encrypted at rest by the manager server.
91
+ - Re-uploading the same `configId` without a new key keeps the previously stored key for that config.
92
+ - That means billing continues on the experimenter's previously uploaded key, not on a shared platform key.
93
+ - If an agent uses `gpt-*` and the config has no OpenAI key, the run fails.
94
+ - If an agent uses `claude*` and the config has no Anthropic key, the run fails.
95
+ - There is no global platform-key fallback for experiment agent execution.
96
+
78
97
  `data export` creates three files in the output directory:
79
98
  - `{configId}-sessions.{format}` — session ID, user_state fields (flattened), timestamps, status
80
99
  - `{configId}-events.{format}` — session ID, event type, component info, payload, timestamps
81
100
  - `{configId}-chat-messages.{format}` — group ID, session ID, sender, content, timestamps
82
101
 
83
- All hosted commands require the manager service to be reachable (Cloud Run deployment or local server). Set `PAIRIT_API_URL` to point to the desired target. When unset, the CLI defaults to `http://localhost:3002`.
102
+ All hosted commands require the manager service to be reachable (Cloud Run deployment or local server). By default the CLI talks to the deployed manager. Override via shell environment variables when needed:
103
+
104
+ - `PAIRIT_API_URL` — manager base URL (e.g. `http://localhost:3002` for local dev)
105
+ - `PAIRIT_LAB_URL` — lab base URL used to print the survey link after `config upload`
106
+ - `PAIRIT_CREDENTIALS_BACKEND` — `keychain` (default when available) or `file`
107
+ - `PAIRIT_MAX_INLINE_MEDIA_BYTES` — switch to signed-URL upload above this size (default 5 MiB)
108
+
109
+ ```bash
110
+ PAIRIT_API_URL=http://localhost:3002 pairit config list
111
+ ```
84
112
 
85
113
  ## Development
86
114
 
package/dist/index.js CHANGED
@@ -29,450 +29,6 @@ var __export = (target, all) => {
29
29
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
30
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
31
 
32
- // ../../../node_modules/.bun/dotenv@17.2.3/node_modules/dotenv/package.json
33
- var require_package = __commonJS((exports, module) => {
34
- module.exports = {
35
- name: "dotenv",
36
- version: "17.2.3",
37
- description: "Loads environment variables from .env file",
38
- main: "lib/main.js",
39
- types: "lib/main.d.ts",
40
- exports: {
41
- ".": {
42
- types: "./lib/main.d.ts",
43
- require: "./lib/main.js",
44
- default: "./lib/main.js"
45
- },
46
- "./config": "./config.js",
47
- "./config.js": "./config.js",
48
- "./lib/env-options": "./lib/env-options.js",
49
- "./lib/env-options.js": "./lib/env-options.js",
50
- "./lib/cli-options": "./lib/cli-options.js",
51
- "./lib/cli-options.js": "./lib/cli-options.js",
52
- "./package.json": "./package.json"
53
- },
54
- scripts: {
55
- "dts-check": "tsc --project tests/types/tsconfig.json",
56
- lint: "standard",
57
- pretest: "npm run lint && npm run dts-check",
58
- test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
59
- "test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
60
- prerelease: "npm test",
61
- release: "standard-version"
62
- },
63
- repository: {
64
- type: "git",
65
- url: "git://github.com/motdotla/dotenv.git"
66
- },
67
- homepage: "https://github.com/motdotla/dotenv#readme",
68
- funding: "https://dotenvx.com",
69
- keywords: [
70
- "dotenv",
71
- "env",
72
- ".env",
73
- "environment",
74
- "variables",
75
- "config",
76
- "settings"
77
- ],
78
- readmeFilename: "README.md",
79
- license: "BSD-2-Clause",
80
- devDependencies: {
81
- "@types/node": "^18.11.3",
82
- decache: "^4.6.2",
83
- sinon: "^14.0.1",
84
- standard: "^17.0.0",
85
- "standard-version": "^9.5.0",
86
- tap: "^19.2.0",
87
- typescript: "^4.8.4"
88
- },
89
- engines: {
90
- node: ">=12"
91
- },
92
- browser: {
93
- fs: false
94
- }
95
- };
96
- });
97
-
98
- // ../../../node_modules/.bun/dotenv@17.2.3/node_modules/dotenv/lib/main.js
99
- var require_main = __commonJS((exports, module) => {
100
- var fs = __require("fs");
101
- var path = __require("path");
102
- var os = __require("os");
103
- var crypto = __require("crypto");
104
- var packageJson = require_package();
105
- var version = packageJson.version;
106
- var TIPS = [
107
- "\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
108
- "\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
109
- "\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
110
- "\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops",
111
- "\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops",
112
- "\uD83D\uDDC2️ backup and recover secrets: https://dotenvx.com/ops",
113
- "✅ audit secrets and track compliance: https://dotenvx.com/ops",
114
- "\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops",
115
- "\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops",
116
- "\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
117
- "⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
118
- "⚙️ enable debug logging with { debug: true }",
119
- "⚙️ override existing env vars with { override: true }",
120
- "⚙️ suppress all logs with { quiet: true }",
121
- "⚙️ write to custom object with { processEnv: myObject }",
122
- "⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
123
- ];
124
- function _getRandomTip() {
125
- return TIPS[Math.floor(Math.random() * TIPS.length)];
126
- }
127
- function parseBoolean(value) {
128
- if (typeof value === "string") {
129
- return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
130
- }
131
- return Boolean(value);
132
- }
133
- function supportsAnsi() {
134
- return process.stdout.isTTY;
135
- }
136
- function dim(text) {
137
- return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
138
- }
139
- var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
140
- function parse(src) {
141
- const obj = {};
142
- let lines = src.toString();
143
- lines = lines.replace(/\r\n?/mg, `
144
- `);
145
- let match;
146
- while ((match = LINE.exec(lines)) != null) {
147
- const key = match[1];
148
- let value = match[2] || "";
149
- value = value.trim();
150
- const maybeQuote = value[0];
151
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
152
- if (maybeQuote === '"') {
153
- value = value.replace(/\\n/g, `
154
- `);
155
- value = value.replace(/\\r/g, "\r");
156
- }
157
- obj[key] = value;
158
- }
159
- return obj;
160
- }
161
- function _parseVault(options) {
162
- options = options || {};
163
- const vaultPath = _vaultPath(options);
164
- options.path = vaultPath;
165
- const result = DotenvModule.configDotenv(options);
166
- if (!result.parsed) {
167
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
168
- err.code = "MISSING_DATA";
169
- throw err;
170
- }
171
- const keys = _dotenvKey(options).split(",");
172
- const length = keys.length;
173
- let decrypted;
174
- for (let i = 0;i < length; i++) {
175
- try {
176
- const key = keys[i].trim();
177
- const attrs = _instructions(result, key);
178
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
179
- break;
180
- } catch (error) {
181
- if (i + 1 >= length) {
182
- throw error;
183
- }
184
- }
185
- }
186
- return DotenvModule.parse(decrypted);
187
- }
188
- function _warn(message) {
189
- console.error(`[dotenv@${version}][WARN] ${message}`);
190
- }
191
- function _debug(message) {
192
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
193
- }
194
- function _log(message) {
195
- console.log(`[dotenv@${version}] ${message}`);
196
- }
197
- function _dotenvKey(options) {
198
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
199
- return options.DOTENV_KEY;
200
- }
201
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
202
- return process.env.DOTENV_KEY;
203
- }
204
- return "";
205
- }
206
- function _instructions(result, dotenvKey) {
207
- let uri;
208
- try {
209
- uri = new URL(dotenvKey);
210
- } catch (error) {
211
- if (error.code === "ERR_INVALID_URL") {
212
- const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
213
- err.code = "INVALID_DOTENV_KEY";
214
- throw err;
215
- }
216
- throw error;
217
- }
218
- const key = uri.password;
219
- if (!key) {
220
- const err = new Error("INVALID_DOTENV_KEY: Missing key part");
221
- err.code = "INVALID_DOTENV_KEY";
222
- throw err;
223
- }
224
- const environment = uri.searchParams.get("environment");
225
- if (!environment) {
226
- const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
227
- err.code = "INVALID_DOTENV_KEY";
228
- throw err;
229
- }
230
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
231
- const ciphertext = result.parsed[environmentKey];
232
- if (!ciphertext) {
233
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
234
- err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
235
- throw err;
236
- }
237
- return { ciphertext, key };
238
- }
239
- function _vaultPath(options) {
240
- let possibleVaultPath = null;
241
- if (options && options.path && options.path.length > 0) {
242
- if (Array.isArray(options.path)) {
243
- for (const filepath of options.path) {
244
- if (fs.existsSync(filepath)) {
245
- possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
246
- }
247
- }
248
- } else {
249
- possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
250
- }
251
- } else {
252
- possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
253
- }
254
- if (fs.existsSync(possibleVaultPath)) {
255
- return possibleVaultPath;
256
- }
257
- return null;
258
- }
259
- function _resolveHome(envPath) {
260
- return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
261
- }
262
- function _configVault(options) {
263
- const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
264
- const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
265
- if (debug || !quiet) {
266
- _log("Loading env from encrypted .env.vault");
267
- }
268
- const parsed = DotenvModule._parseVault(options);
269
- let processEnv = process.env;
270
- if (options && options.processEnv != null) {
271
- processEnv = options.processEnv;
272
- }
273
- DotenvModule.populate(processEnv, parsed, options);
274
- return { parsed };
275
- }
276
- function configDotenv(options) {
277
- const dotenvPath = path.resolve(process.cwd(), ".env");
278
- let encoding = "utf8";
279
- let processEnv = process.env;
280
- if (options && options.processEnv != null) {
281
- processEnv = options.processEnv;
282
- }
283
- let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
284
- let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
285
- if (options && options.encoding) {
286
- encoding = options.encoding;
287
- } else {
288
- if (debug) {
289
- _debug("No encoding is specified. UTF-8 is used by default");
290
- }
291
- }
292
- let optionPaths = [dotenvPath];
293
- if (options && options.path) {
294
- if (!Array.isArray(options.path)) {
295
- optionPaths = [_resolveHome(options.path)];
296
- } else {
297
- optionPaths = [];
298
- for (const filepath of options.path) {
299
- optionPaths.push(_resolveHome(filepath));
300
- }
301
- }
302
- }
303
- let lastError;
304
- const parsedAll = {};
305
- for (const path2 of optionPaths) {
306
- try {
307
- const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
308
- DotenvModule.populate(parsedAll, parsed, options);
309
- } catch (e) {
310
- if (debug) {
311
- _debug(`Failed to load ${path2} ${e.message}`);
312
- }
313
- lastError = e;
314
- }
315
- }
316
- const populated = DotenvModule.populate(processEnv, parsedAll, options);
317
- debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
318
- quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
319
- if (debug || !quiet) {
320
- const keysCount = Object.keys(populated).length;
321
- const shortPaths = [];
322
- for (const filePath of optionPaths) {
323
- try {
324
- const relative = path.relative(process.cwd(), filePath);
325
- shortPaths.push(relative);
326
- } catch (e) {
327
- if (debug) {
328
- _debug(`Failed to load ${filePath} ${e.message}`);
329
- }
330
- lastError = e;
331
- }
332
- }
333
- _log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
334
- }
335
- if (lastError) {
336
- return { parsed: parsedAll, error: lastError };
337
- } else {
338
- return { parsed: parsedAll };
339
- }
340
- }
341
- function config(options) {
342
- if (_dotenvKey(options).length === 0) {
343
- return DotenvModule.configDotenv(options);
344
- }
345
- const vaultPath = _vaultPath(options);
346
- if (!vaultPath) {
347
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
348
- return DotenvModule.configDotenv(options);
349
- }
350
- return DotenvModule._configVault(options);
351
- }
352
- function decrypt(encrypted, keyStr) {
353
- const key = Buffer.from(keyStr.slice(-64), "hex");
354
- let ciphertext = Buffer.from(encrypted, "base64");
355
- const nonce = ciphertext.subarray(0, 12);
356
- const authTag = ciphertext.subarray(-16);
357
- ciphertext = ciphertext.subarray(12, -16);
358
- try {
359
- const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
360
- aesgcm.setAuthTag(authTag);
361
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
362
- } catch (error) {
363
- const isRange = error instanceof RangeError;
364
- const invalidKeyLength = error.message === "Invalid key length";
365
- const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
366
- if (isRange || invalidKeyLength) {
367
- const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
368
- err.code = "INVALID_DOTENV_KEY";
369
- throw err;
370
- } else if (decryptionFailed) {
371
- const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
372
- err.code = "DECRYPTION_FAILED";
373
- throw err;
374
- } else {
375
- throw error;
376
- }
377
- }
378
- }
379
- function populate(processEnv, parsed, options = {}) {
380
- const debug = Boolean(options && options.debug);
381
- const override = Boolean(options && options.override);
382
- const populated = {};
383
- if (typeof parsed !== "object") {
384
- const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
385
- err.code = "OBJECT_REQUIRED";
386
- throw err;
387
- }
388
- for (const key of Object.keys(parsed)) {
389
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
390
- if (override === true) {
391
- processEnv[key] = parsed[key];
392
- populated[key] = parsed[key];
393
- }
394
- if (debug) {
395
- if (override === true) {
396
- _debug(`"${key}" is already defined and WAS overwritten`);
397
- } else {
398
- _debug(`"${key}" is already defined and was NOT overwritten`);
399
- }
400
- }
401
- } else {
402
- processEnv[key] = parsed[key];
403
- populated[key] = parsed[key];
404
- }
405
- }
406
- return populated;
407
- }
408
- var DotenvModule = {
409
- configDotenv,
410
- _configVault,
411
- _parseVault,
412
- config,
413
- decrypt,
414
- parse,
415
- populate
416
- };
417
- exports.configDotenv = DotenvModule.configDotenv;
418
- exports._configVault = DotenvModule._configVault;
419
- exports._parseVault = DotenvModule._parseVault;
420
- exports.config = DotenvModule.config;
421
- exports.decrypt = DotenvModule.decrypt;
422
- exports.parse = DotenvModule.parse;
423
- exports.populate = DotenvModule.populate;
424
- module.exports = DotenvModule;
425
- });
426
-
427
- // ../../../node_modules/.bun/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js
428
- var require_env_options = __commonJS((exports, module) => {
429
- var options = {};
430
- if (process.env.DOTENV_CONFIG_ENCODING != null) {
431
- options.encoding = process.env.DOTENV_CONFIG_ENCODING;
432
- }
433
- if (process.env.DOTENV_CONFIG_PATH != null) {
434
- options.path = process.env.DOTENV_CONFIG_PATH;
435
- }
436
- if (process.env.DOTENV_CONFIG_QUIET != null) {
437
- options.quiet = process.env.DOTENV_CONFIG_QUIET;
438
- }
439
- if (process.env.DOTENV_CONFIG_DEBUG != null) {
440
- options.debug = process.env.DOTENV_CONFIG_DEBUG;
441
- }
442
- if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
443
- options.override = process.env.DOTENV_CONFIG_OVERRIDE;
444
- }
445
- if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
446
- options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
447
- }
448
- module.exports = options;
449
- });
450
-
451
- // ../../../node_modules/.bun/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js
452
- var require_cli_options = __commonJS((exports, module) => {
453
- var re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
454
- module.exports = function optionMatcher(args) {
455
- const options = args.reduce(function(acc, cur) {
456
- const matches = cur.match(re);
457
- if (matches) {
458
- acc[matches[1]] = matches[2];
459
- }
460
- return acc;
461
- }, {});
462
- if (!("quiet" in options)) {
463
- options.quiet = "true";
464
- }
465
- return options;
466
- };
467
- });
468
-
469
- // ../../../node_modules/.bun/dotenv@17.2.3/node_modules/dotenv/config.js
470
- var require_config = __commonJS(() => {
471
- (function() {
472
- require_main().config(Object.assign({}, require_env_options(), require_cli_options()(process.argv)));
473
- })();
474
- });
475
-
476
32
  // ../../../node_modules/.bun/commander@12.1.0/node_modules/commander/lib/error.js
477
33
  var require_error = __commonJS((exports) => {
478
34
  class CommanderError extends Error {
@@ -9899,7 +9455,6 @@ var init_open = __esm(() => {
9899
9455
  });
9900
9456
 
9901
9457
  // src/index.ts
9902
- var import_config = __toESM(require_config(), 1);
9903
9458
  import { createHash } from "node:crypto";
9904
9459
  import { mkdir as mkdir2, readFile as readFile2, stat, writeFile as writeFile2 } from "node:fs/promises";
9905
9460
  import path2 from "node:path";
@@ -10111,7 +9666,7 @@ async function loadKeytar() {
10111
9666
 
10112
9667
  // src/index.ts
10113
9668
  var program2 = new Command;
10114
- program2.name("pairit").description("CLI for Pairit experiment configs").version("0.1.3");
9669
+ program2.name("pairit").description("CLI for Pairit experiment configs").version("0.1.6");
10115
9670
  program2.command("login").description("Login to Pairit Manager").action(async () => {
10116
9671
  try {
10117
9672
  await login();
@@ -10146,7 +9701,7 @@ configCommand.command("compile").argument("<config>", "Path to YAML config").des
10146
9701
  process9.exitCode = 1;
10147
9702
  }
10148
9703
  });
10149
- configCommand.command("upload").argument("<config>", "Path to YAML config").option("--config-id <configId>", "Config id (defaults to hash)").option("--metadata <json>", "Optional metadata JSON string").description("Compile and upload config via Pairit Functions").action(async (configPath, options) => {
9704
+ configCommand.command("upload").argument("<config>", "Path to YAML config").option("--config-id <configId>", "Config id (defaults to hash)").option("--metadata <json>", "Optional metadata JSON string").option("--openai-api-key <key>", "OpenAI API key for this experiment").option("--anthropic-api-key <key>", "Anthropic API key for this experiment").description("Compile and upload config via Pairit Functions").action(async (configPath, options) => {
10150
9705
  try {
10151
9706
  const { payload, checksum } = await buildUploadPayload(configPath, options);
10152
9707
  const response = await callFunctions("/configs/upload", {
@@ -10357,12 +9912,19 @@ async function buildUploadPayload(configPath, options) {
10357
9912
  if (!metadata.originalFilename) {
10358
9913
  metadata.originalFilename = path2.basename(configPath);
10359
9914
  }
9915
+ const llmCredentials = {
9916
+ ...options.openaiApiKey && { openaiApiKey: options.openaiApiKey },
9917
+ ...options.anthropicApiKey && {
9918
+ anthropicApiKey: options.anthropicApiKey
9919
+ }
9920
+ };
10360
9921
  return {
10361
9922
  payload: {
10362
9923
  configId,
10363
9924
  checksum,
10364
9925
  metadata: metadata ?? null,
10365
9926
  config: parsed,
9927
+ ...Object.keys(llmCredentials).length > 0 && { llmCredentials },
10366
9928
  allowRetake,
10367
9929
  ...requireAuth !== undefined && { requireAuth }
10368
9930
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pairit",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "CLI for the Pairit behavioral science experiment platform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,7 +35,6 @@
35
35
  "@types/open": "^6.2.1",
36
36
  "better-auth": "^1.4.7",
37
37
  "commander": "^12.1.0",
38
- "dotenv": "^17.2.3",
39
38
  "open": "^11.0.0",
40
39
  "typescript": "^5.9.3",
41
40
  "yaml": "^2.6.0"