oneie 5.7.1 → 5.7.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneie",
3
- "version": "5.7.1",
3
+ "version": "5.7.2",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -96,8 +96,12 @@ export interface JourneyOptions {
96
96
  name: string;
97
97
  email?: string;
98
98
  products: ProductSpec[];
99
- /** Seconds to keep reading back the sale before ending at `pending`. 0 = read once. */
100
- waitSeconds: number;
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): {
@@ -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
- const deadline = deps.now() + Math.max(0, o.waitSeconds) * 1000;
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(o.pollMs ?? 5000);
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
- const sale = await saleStep(deps, o, state, k.key);
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 300` to wait here)'
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
  }
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', '0')
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneie",
3
- "version": "5.7.1",
3
+ "version": "5.7.2",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {