oneie 5.7.1 → 5.7.3
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/package.json +1 -1
- package/dist/src/catalog.d.ts +10 -0
- package/dist/src/catalog.js +9 -11
- package/dist/src/doctor.js +3 -3
- package/dist/src/lib/api-path.d.ts +1 -0
- package/dist/src/lib/api-path.js +31 -0
- package/dist/src/lib/journey.d.ts +13 -2
- package/dist/src/lib/journey.js +18 -5
- package/dist/src/lib/keyfile.d.ts +6 -0
- package/dist/src/lib/keyfile.js +13 -0
- package/dist/src/start.js +2 -2
- package/dist/src/substrate.js +2 -2
- package/dist/src/trade.js +9 -13
- package/dist/src/wallet.d.ts +2 -0
- package/dist/src/wallet.js +6 -4
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/src/catalog.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
interface CatalogItem {
|
|
3
|
+
receiver: string;
|
|
4
|
+
summary?: string;
|
|
5
|
+
effect?: string;
|
|
6
|
+
cost?: unknown;
|
|
7
|
+
reversible?: boolean;
|
|
8
|
+
settles?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function catalogItems(data: Record<string, unknown>): CatalogItem[];
|
|
2
11
|
export declare function catalogCommands(program: Command): void;
|
|
12
|
+
export {};
|
package/dist/src/catalog.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { askPath } from './lib/api-path.js';
|
|
2
|
+
import { authHeaders } from './lib/client.js';
|
|
2
3
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
3
|
-
function apiKey() {
|
|
4
|
-
return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
5
|
-
}
|
|
6
4
|
function base(opts) {
|
|
7
5
|
return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
|
|
8
6
|
}
|
|
9
|
-
function authHeaders() {
|
|
10
|
-
const h = { 'Content-Type': 'application/json' };
|
|
11
|
-
const k = apiKey();
|
|
12
|
-
if (k)
|
|
13
|
-
h['Authorization'] = `Bearer ${k}`;
|
|
14
|
-
return h;
|
|
15
|
-
}
|
|
16
7
|
const RECIPE_BLURB = {
|
|
17
8
|
spine: 'onboard — become an actor, mint a key, declare capability',
|
|
18
9
|
build: 'build a world — workspace, group, actor, thing',
|
|
@@ -50,6 +41,13 @@ function formatCatalog(items, goal) {
|
|
|
50
41
|
}
|
|
51
42
|
return out.join('\n');
|
|
52
43
|
}
|
|
44
|
+
// The door answers { outcome, result: CatalogItem[] }; older shapes put the list at
|
|
45
|
+
// items / receivers. Reading only those two printed an empty catalog.
|
|
46
|
+
export function catalogItems(data) {
|
|
47
|
+
const r = data.result;
|
|
48
|
+
const list = Array.isArray(r) ? r : r?.items ?? data.items ?? data.receivers ?? [];
|
|
49
|
+
return Array.isArray(list) ? list : [];
|
|
50
|
+
}
|
|
53
51
|
export function catalogCommands(program) {
|
|
54
52
|
program
|
|
55
53
|
.command('catalog')
|
|
@@ -72,7 +70,7 @@ export function catalogCommands(program) {
|
|
|
72
70
|
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
73
71
|
return;
|
|
74
72
|
}
|
|
75
|
-
const items = (data
|
|
73
|
+
const items = catalogItems(data);
|
|
76
74
|
process.stdout.write(formatCatalog(items, opts.goal) + '\n');
|
|
77
75
|
});
|
|
78
76
|
}
|
package/dist/src/doctor.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { mergeEnv } from './env.js';
|
|
4
4
|
import { resolveBase, resolveKey, authHeaders } from './lib/client.js';
|
|
5
|
-
import { readKeyFolder, keyFolderStatus } from './lib/keyfile.js';
|
|
5
|
+
import { readKeyFolder, keyFolderStatus, workspaceFor, KEY_DIR_NAME, LEGACY_KEY_DIR_NAME } from './lib/keyfile.js';
|
|
6
6
|
import { KEY_FILE } from './lib/paths.js';
|
|
7
7
|
import { askPath } from './lib/api-path.js';
|
|
8
8
|
/** api.one.ie (the gateway) answers `GET /health`; one.ie/web has no /health
|
|
@@ -57,7 +57,7 @@ export async function runDoctor(dir, opts = {}) {
|
|
|
57
57
|
name: 'config',
|
|
58
58
|
ok: hasConfig,
|
|
59
59
|
detail: folder
|
|
60
|
-
? `${dir}
|
|
60
|
+
? `${dir}/${existsSync(`${dir}/${KEY_DIR_NAME}/agent.key`) ? KEY_DIR_NAME : LEGACY_KEY_DIR_NAME}/agent.key (0600, project)`
|
|
61
61
|
: hasConfig
|
|
62
62
|
? `${keyFile} (0600)`
|
|
63
63
|
: `${keyFile} missing — run \`one setup\` or \`one login\``,
|
|
@@ -124,7 +124,7 @@ export function whoamiCmd() {
|
|
|
124
124
|
body: JSON.stringify({ data: {} }),
|
|
125
125
|
});
|
|
126
126
|
const live = res.ok;
|
|
127
|
-
process.stdout.write(`workspace ${env.WORKSPACE_SLUG ?? env
|
|
127
|
+
process.stdout.write(`workspace ${env.WORKSPACE_SLUG ?? workspaceFor(undefined, dir, env) ?? '(unset)'}\n`);
|
|
128
128
|
process.stdout.write(`key ${key.slice(0, 4)}***… ${live ? '(live)' : `(unreachable — ${base})`}\n`);
|
|
129
129
|
process.stdout.write(`base ${base}\n`);
|
|
130
130
|
if (!live)
|
package/dist/src/lib/api-path.js
CHANGED
|
@@ -7,3 +7,34 @@ export function askPath(base, receiver) {
|
|
|
7
7
|
const isGateway = new URL(base).hostname === 'api.one.ie';
|
|
8
8
|
return `${base}${isGateway ? '/ask' : '/api/ask'}/${encodeURIComponent(receiver)}`;
|
|
9
9
|
}
|
|
10
|
+
// The other substrate doors. They were written as one.ie/web's long form (/api/mark/…),
|
|
11
|
+
// which api.one.ie — the default base — answers 404; only /ask knew the host. The map is the
|
|
12
|
+
// inverse of api/src/substrate-binding.ts PATH_MAP, so a path the gateway serves is spelled the
|
|
13
|
+
// way the gateway serves it and every other host keeps the long form.
|
|
14
|
+
const GATEWAY_SHORT = [
|
|
15
|
+
['/api/export/groups', '/groups'],
|
|
16
|
+
['/api/export/actors', '/actors'],
|
|
17
|
+
['/api/export/paths', '/paths'],
|
|
18
|
+
['/api/signal', '/signal'],
|
|
19
|
+
['/api/mark', '/mark'],
|
|
20
|
+
['/api/warn', '/warn'],
|
|
21
|
+
['/api/fade', '/fade'],
|
|
22
|
+
['/api/sub', '/sub'],
|
|
23
|
+
['/api/follow', '/follow'],
|
|
24
|
+
['/api/select', '/select'],
|
|
25
|
+
['/api/things', '/things'],
|
|
26
|
+
['/api/events', '/events'],
|
|
27
|
+
['/api/learning', '/learning'],
|
|
28
|
+
];
|
|
29
|
+
export function substrateUrl(url) {
|
|
30
|
+
const u = new URL(url);
|
|
31
|
+
if (u.hostname !== 'api.one.ie')
|
|
32
|
+
return url;
|
|
33
|
+
for (const [long, short] of GATEWAY_SHORT) {
|
|
34
|
+
if (u.pathname === long || u.pathname.startsWith(`${long}/`)) {
|
|
35
|
+
u.pathname = short + u.pathname.slice(long.length);
|
|
36
|
+
return u.toString();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return url;
|
|
40
|
+
}
|
|
@@ -96,8 +96,12 @@ export interface JourneyOptions {
|
|
|
96
96
|
name: string;
|
|
97
97
|
email?: string;
|
|
98
98
|
products: ProductSpec[];
|
|
99
|
-
/**
|
|
100
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Seconds to keep reading back the sale before ending at `pending`. 0 = read once.
|
|
101
|
+
* Unset: a first run reads once (nobody has been sent to pay yet); a re-run waits
|
|
102
|
+
* RERUN_WAIT_S, because the person was sent to pay and the webhook takes seconds.
|
|
103
|
+
*/
|
|
104
|
+
waitSeconds?: number;
|
|
101
105
|
/** Between read-backs while waiting. */
|
|
102
106
|
pollMs?: number;
|
|
103
107
|
}
|
|
@@ -117,6 +121,13 @@ export interface JourneyReport {
|
|
|
117
121
|
next?: string;
|
|
118
122
|
}
|
|
119
123
|
export declare const TEST_CARD = "4242 4242 4242 4242 \u00B7 any future expiry \u00B7 any CVC \u00B7 any postcode";
|
|
124
|
+
/**
|
|
125
|
+
* Measured 2026-11-03 (text/agent-path.md § 6): Stripe's webhook counted a paid sale
|
|
126
|
+
* 3.2 s after the receipt. A re-run straight after paying read 0 and stopped. 20 s at
|
|
127
|
+
* 2 s a read covers that six times over without holding a run that will never sell.
|
|
128
|
+
*/
|
|
129
|
+
export declare const RERUN_WAIT_S = 20;
|
|
130
|
+
export declare const RERUN_POLL_MS = 2000;
|
|
120
131
|
export declare const DEFAULT_PRODUCT: ProductSpec;
|
|
121
132
|
/** `"Name=9.99"` → a product in minor units. A spec that is not that shape is refused by name. */
|
|
122
133
|
export declare function parseProductSpec(raw: string, currency?: string): {
|
package/dist/src/lib/journey.js
CHANGED
|
@@ -21,6 +21,13 @@
|
|
|
21
21
|
* step is done only when `storefront:stats` reads back a purchase.
|
|
22
22
|
*/
|
|
23
23
|
export const TEST_CARD = '4242 4242 4242 4242 · any future expiry · any CVC · any postcode';
|
|
24
|
+
/**
|
|
25
|
+
* Measured 2026-11-03 (text/agent-path.md § 6): Stripe's webhook counted a paid sale
|
|
26
|
+
* 3.2 s after the receipt. A re-run straight after paying read 0 and stopped. 20 s at
|
|
27
|
+
* 2 s a read covers that six times over without holding a run that will never sell.
|
|
28
|
+
*/
|
|
29
|
+
export const RERUN_WAIT_S = 20;
|
|
30
|
+
export const RERUN_POLL_MS = 2000;
|
|
24
31
|
export const DEFAULT_PRODUCT = { name: 'Test product', amount: 100, currency: 'usd' };
|
|
25
32
|
/** `"Name=9.99"` → a product in minor units. A spec that is not that shape is refused by name. */
|
|
26
33
|
export function parseProductSpec(raw, currency = 'usd') {
|
|
@@ -150,10 +157,15 @@ async function productsStep(deps, o, state, key) {
|
|
|
150
157
|
detail: { mode: 'test money', products: have.map((p) => `${p.name} ${(p.amount / 100).toFixed(2)} ${p.currency.toUpperCase()} ${p.url}`) },
|
|
151
158
|
};
|
|
152
159
|
}
|
|
153
|
-
async function saleStep(deps, o, state, key) {
|
|
160
|
+
async function saleStep(deps, o, state, key, rerun) {
|
|
154
161
|
if (state.sale)
|
|
155
162
|
return { step: 'sale', status: 'done', reused: true, detail: { purchases: state.sale.purchases } };
|
|
156
|
-
|
|
163
|
+
// An explicit --wait wins; unset, only a re-run waits (and never NaN — an unset wait
|
|
164
|
+
// once made the deadline NaN, and `now >= NaN` is never true).
|
|
165
|
+
const asked = Number(o.waitSeconds);
|
|
166
|
+
const waitS = o.waitSeconds !== undefined && Number.isFinite(asked) ? Math.max(0, asked) : rerun ? RERUN_WAIT_S : 0;
|
|
167
|
+
const pollMs = o.pollMs ?? (o.waitSeconds === undefined ? RERUN_POLL_MS : 5000);
|
|
168
|
+
const deadline = deps.now() + waitS * 1000;
|
|
157
169
|
for (;;) {
|
|
158
170
|
const r = readAnswer(await deps.ask(key, 'storefront:stats', { slug: state.workspace }), 'storefront:stats');
|
|
159
171
|
if (!r.ok)
|
|
@@ -176,7 +188,7 @@ async function saleStep(deps, o, state, key) {
|
|
|
176
188
|
}
|
|
177
189
|
if (deps.now() >= deadline)
|
|
178
190
|
break;
|
|
179
|
-
await deps.sleep(
|
|
191
|
+
await deps.sleep(pollMs);
|
|
180
192
|
}
|
|
181
193
|
const first = state.products?.[0];
|
|
182
194
|
return {
|
|
@@ -220,13 +232,14 @@ export async function runJourney(deps, o) {
|
|
|
220
232
|
if (products.status !== 'done') {
|
|
221
233
|
return { ok: false, workspace: state.workspace, steps, next: 'fix the products step and run `npx oneie` again' };
|
|
222
234
|
}
|
|
223
|
-
|
|
235
|
+
// A re-run: the shop already had its products before this run, so someone was sent to pay.
|
|
236
|
+
const sale = await saleStep(deps, o, state, k.key, products.reused === true);
|
|
224
237
|
steps.push(sale);
|
|
225
238
|
const handover = handoverStep(state, sale.status === 'done');
|
|
226
239
|
steps.push(handover);
|
|
227
240
|
const failed = steps.some((s) => s.status === 'failed');
|
|
228
241
|
const next = sale.status === 'pending'
|
|
229
|
-
? 'pay with the test card at the link above, then run `npx oneie` again (or `npx oneie --wait
|
|
242
|
+
? 'pay with the test card at the link above, then run `npx oneie` again — it waits for the sale to land (or `npx oneie --wait 30` to wait here now)'
|
|
230
243
|
: undefined;
|
|
231
244
|
return { ok: !failed, workspace: state.workspace, steps, ...(next ? { next } : {}) };
|
|
232
245
|
}
|
|
@@ -128,3 +128,9 @@ export declare function readKeyFolder(dir: string): {
|
|
|
128
128
|
* a silent null is right for `resolveKey` and useless for `doctor`.
|
|
129
129
|
*/
|
|
130
130
|
export declare function keyFolderStatus(dir: string): 'none' | 'ok' | 'foreign' | 'unsafe' | 'unreadable';
|
|
131
|
+
/**
|
|
132
|
+
* Which workspace a command acts in: flag > AGENCY_SLUG > the workspace `npx oneie`
|
|
133
|
+
* saved beside this folder's key. The journey already knows the agent's workspace;
|
|
134
|
+
* asking for it again was a dead end (`wallet get`, `whoami`).
|
|
135
|
+
*/
|
|
136
|
+
export declare function workspaceFor(explicit: string | undefined, dir: string, env: Record<string, string>): string | undefined;
|
package/dist/src/lib/keyfile.js
CHANGED
|
@@ -382,3 +382,16 @@ export function keyFolderStatus(dir) {
|
|
|
382
382
|
return 'unreadable';
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Which workspace a command acts in: flag > AGENCY_SLUG > the workspace `npx oneie`
|
|
387
|
+
* saved beside this folder's key. The journey already knows the agent's workspace;
|
|
388
|
+
* asking for it again was a dead end (`wallet get`, `whoami`).
|
|
389
|
+
*/
|
|
390
|
+
export function workspaceFor(explicit, dir, env) {
|
|
391
|
+
if (explicit)
|
|
392
|
+
return explicit;
|
|
393
|
+
if (env.AGENCY_SLUG)
|
|
394
|
+
return env.AGENCY_SLUG;
|
|
395
|
+
const saved = readKeyFolder(dir)?.meta.workspace;
|
|
396
|
+
return typeof saved === 'string' && saved ? saved : undefined;
|
|
397
|
+
}
|
package/dist/src/start.js
CHANGED
|
@@ -169,7 +169,7 @@ export function startCmd() {
|
|
|
169
169
|
.option('--email <email>', "The new owner's email — the handover link is sent there as well as printed")
|
|
170
170
|
.option('--product <name=price>', 'A product in major units, e.g. "Mug=12.50" (repeatable; default one Test product at 1.00)', (v, acc) => [...acc, v], [])
|
|
171
171
|
.option('--currency <iso>', 'ISO 4217 for --product prices', 'usd')
|
|
172
|
-
.option('--wait <seconds>', 'Keep reading back the test sale this long before stopping at pending
|
|
172
|
+
.option('--wait <seconds>', 'Keep reading back the test sale this long before stopping at pending (default: a re-run waits 20 s, a first run reads once)')
|
|
173
173
|
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
174
174
|
.action(async (opts, sub) => {
|
|
175
175
|
const products = [];
|
|
@@ -191,7 +191,7 @@ export function startCmd() {
|
|
|
191
191
|
name: opts.name,
|
|
192
192
|
...(opts.email ? { email: opts.email } : {}),
|
|
193
193
|
products,
|
|
194
|
-
waitSeconds: Math.max(0, Number(opts.wait) || 0),
|
|
194
|
+
...(opts.wait !== undefined ? { waitSeconds: Math.max(0, Number(opts.wait) || 0) } : {}),
|
|
195
195
|
});
|
|
196
196
|
if (jsonMode(sub))
|
|
197
197
|
process.stdout.write(JSON.stringify(report) + '\n');
|
package/dist/src/substrate.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { authHeaders, resolveBase, resolveKey } from './lib/client.js';
|
|
2
|
-
import { askPath } from './lib/api-path.js';
|
|
2
|
+
import { askPath, substrateUrl } from './lib/api-path.js';
|
|
3
3
|
import { sendMessage } from './message.js';
|
|
4
4
|
const DEFAULT_API = resolveBase({}, 'https://api.one.ie');
|
|
5
5
|
function base(opts) {
|
|
6
6
|
return resolveBase(opts, 'https://api.one.ie');
|
|
7
7
|
}
|
|
8
8
|
async function api(url, init) {
|
|
9
|
-
const res = await fetch(url, { headers: authHeaders(), ...init });
|
|
9
|
+
const res = await fetch(substrateUrl(url), { headers: authHeaders(), ...init });
|
|
10
10
|
if (!res.ok) {
|
|
11
11
|
const body = await res.text().catch(() => '');
|
|
12
12
|
process.stderr.write(`${init?.method ?? 'GET'} ${url} → ${res.status}\n${body}\n`);
|
package/dist/src/trade.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { askPath } from './lib/api-path.js';
|
|
2
|
+
import { authHeaders } from './lib/client.js';
|
|
2
3
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
3
|
-
function apiKey() {
|
|
4
|
-
return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
5
|
-
}
|
|
6
4
|
function base(opts) {
|
|
7
5
|
return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
|
|
8
6
|
}
|
|
9
|
-
function authHeaders() {
|
|
10
|
-
const h = { 'Content-Type': 'application/json' };
|
|
11
|
-
const k = apiKey();
|
|
12
|
-
if (k)
|
|
13
|
-
h['Authorization'] = `Bearer ${k}`;
|
|
14
|
-
return h;
|
|
15
|
-
}
|
|
16
7
|
async function ask(b, receiver, data) {
|
|
17
8
|
const res = await fetch(askPath(b, receiver), {
|
|
18
9
|
method: 'POST',
|
|
@@ -76,12 +67,17 @@ export function tradeCommands(program) {
|
|
|
76
67
|
});
|
|
77
68
|
program
|
|
78
69
|
.command('earn')
|
|
79
|
-
.description('
|
|
70
|
+
.description('What this workspace has earned — card money waiting, crypto owed, credit balance')
|
|
80
71
|
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
81
72
|
.option('--json', 'Output raw JSON')
|
|
82
73
|
.action(async (opts) => {
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
// pay:weight PAYS for a task (needs to/task/amount); it was never a summary.
|
|
75
|
+
// These two are what an agent key can read, and they answer for its own workspace.
|
|
76
|
+
const [store, credits] = await Promise.all([
|
|
77
|
+
ask(base(opts), 'storefront:balance', {}),
|
|
78
|
+
ask(base(opts), 'credits:balance', {}),
|
|
79
|
+
]);
|
|
80
|
+
process.stdout.write(JSON.stringify({ storefront: store, credits }, null, 2) + '\n');
|
|
85
81
|
});
|
|
86
82
|
program
|
|
87
83
|
.command('usage')
|
package/dist/src/wallet.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { type Derivation, type GeneratedWallet } from '@oneie/sdk/wallet';
|
|
3
3
|
import { type VaultBlob, type SealOpts } from '@oneie/sdk/vault-file';
|
|
4
4
|
import { askPath } from './lib/api-path.js';
|
|
5
|
+
import { workspaceFor } from './lib/keyfile.js';
|
|
5
6
|
export { askPath };
|
|
6
7
|
type AskEnvelope = {
|
|
7
8
|
outcome?: string;
|
|
@@ -48,6 +49,7 @@ export declare function sealWallet(mnemonic: string, passphrase: string, opts: {
|
|
|
48
49
|
}): Promise<VaultBlob>;
|
|
49
50
|
/** The addresses a sealed vault holds, read under ITS marker — absent is v1. */
|
|
50
51
|
export declare function openedWallet(blob: VaultBlob, mnemonic: string): Promise<GeneratedWallet>;
|
|
52
|
+
export { workspaceFor };
|
|
51
53
|
export declare function faucetOk(results: Array<{
|
|
52
54
|
success: boolean;
|
|
53
55
|
}>): boolean;
|
package/dist/src/wallet.js
CHANGED
|
@@ -6,6 +6,8 @@ import { generateWallet, recoverWallet, readDerivation } from '@oneie/sdk/wallet
|
|
|
6
6
|
import { sealVault, openVault, mintKeychainSecret } from '@oneie/sdk/vault-file';
|
|
7
7
|
import { proveAddresses } from '@oneie/sdk/address-proof';
|
|
8
8
|
import { askPath } from './lib/api-path.js';
|
|
9
|
+
import { workspaceFor } from './lib/keyfile.js';
|
|
10
|
+
import { resolveKey } from './lib/client.js';
|
|
9
11
|
import { wordsStdoutRefusal } from './lib/agent-env.js';
|
|
10
12
|
import { cliPrefix } from './lib/invoked-as.js';
|
|
11
13
|
import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
|
|
@@ -98,14 +100,14 @@ export async function openedWallet(blob, mnemonic) {
|
|
|
98
100
|
}
|
|
99
101
|
function resolveAuth(opts) {
|
|
100
102
|
const env = mergeEnv(process.cwd());
|
|
101
|
-
const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ??
|
|
103
|
+
const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? resolveKey();
|
|
102
104
|
return { base: opts.api.replace(/\/$/, ''), key };
|
|
103
105
|
}
|
|
106
|
+
export { workspaceFor };
|
|
104
107
|
function resolveWorkspace(explicit) {
|
|
105
|
-
const
|
|
106
|
-
const workspace = explicit ?? env.AGENCY_SLUG;
|
|
108
|
+
const workspace = workspaceFor(explicit, process.cwd(), mergeEnv(process.cwd()));
|
|
107
109
|
if (!workspace) {
|
|
108
|
-
process.stderr.write('--workspace required (or set AGENCY_SLUG)\n');
|
|
110
|
+
process.stderr.write('--workspace required (or set AGENCY_SLUG, or run from the folder `npx oneie` made)\n');
|
|
109
111
|
process.exit(1);
|
|
110
112
|
}
|
|
111
113
|
return workspace;
|