@thinkingai/ae-cli 6.1.39 → 6.1.40
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/ai-monitor.js +1 -1
- package/dist/{chunk-TVSGS5QB.js → chunk-RW6Z2NN3.js} +1 -1
- package/dist/index.js +3 -3
- package/dist/{te-analysis-XHAMRMTQ.js → te-analysis-NJHSEKGW.js} +3 -1
- package/dist/{web-runtime-ZJHOIPKX.js → web-runtime-HIXOSNJ6.js} +85 -5
- package/package.json +1 -1
- package/skills/ae-onboarding/SKILL.md +2 -2
- package/skills/ae-onboarding/references/demo-operations.md +3 -2
- package/skills/ae-onboarding/references/onboarding_experiment_launch.md +4 -2
package/dist/ai-monitor.js
CHANGED
|
@@ -470,7 +470,7 @@ function createRuntimeContext(cmd, opts, globalOpts) {
|
|
|
470
470
|
}
|
|
471
471
|
const ctx = {
|
|
472
472
|
async onboarding(action, input) {
|
|
473
|
-
const { invokeOnboarding } = await import("./web-runtime-
|
|
473
|
+
const { invokeOnboarding } = await import("./web-runtime-HIXOSNJ6.js");
|
|
474
474
|
return invokeOnboarding(action, input);
|
|
475
475
|
},
|
|
476
476
|
has(name) {
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
configureBusinessCommands,
|
|
19
19
|
parseProgram,
|
|
20
20
|
runCommand
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-RW6Z2NN3.js";
|
|
22
22
|
import "./chunk-GYODT7C4.js";
|
|
23
23
|
import "./chunk-L7MT53VM.js";
|
|
24
24
|
import {
|
|
@@ -2134,7 +2134,7 @@ function isOnboardingInvocation(args) {
|
|
|
2134
2134
|
if (argument === "--") break;
|
|
2135
2135
|
if (argument.startsWith("-")) {
|
|
2136
2136
|
if (!argument.includes("=") && values.has(argument)) i++;
|
|
2137
|
-
else if (["--sdk-complete", "--upload-metric-event", "--prepare-approver", "--start-only"].includes(argument) && ["true", "false", "0", "1", "yes", "no", "y", "n", "on", "off"].includes((args[i + 1] ?? "").toLowerCase())) i++;
|
|
2137
|
+
else if (["--sdk-complete", "--upload-metric-event", "--prepare-approver", "--start-only", "--wait-report"].includes(argument) && ["true", "false", "0", "1", "yes", "no", "y", "n", "on", "off"].includes((args[i + 1] ?? "").toLowerCase())) i++;
|
|
2138
2138
|
continue;
|
|
2139
2139
|
}
|
|
2140
2140
|
positional.push(argument);
|
|
@@ -2167,7 +2167,7 @@ function warnLoadFailure(label, err) {
|
|
|
2167
2167
|
async function loadCommands() {
|
|
2168
2168
|
const commands = [];
|
|
2169
2169
|
try {
|
|
2170
|
-
const teAnalysis = await import("./te-analysis-
|
|
2170
|
+
const teAnalysis = await import("./te-analysis-NJHSEKGW.js");
|
|
2171
2171
|
commands.push(...teAnalysis.default);
|
|
2172
2172
|
} catch (err) {
|
|
2173
2173
|
warnLoadFailure("domain te-analysis", err);
|
|
@@ -11913,7 +11913,8 @@ function input(ctx) {
|
|
|
11913
11913
|
upload_metric_event: ctx.bool("upload-metric-event"),
|
|
11914
11914
|
prepare_approver: ctx.bool("prepare-approver"),
|
|
11915
11915
|
run_id: ctx.str("run-id") || void 0,
|
|
11916
|
-
start_only: ctx.bool("start-only")
|
|
11916
|
+
start_only: ctx.bool("start-only"),
|
|
11917
|
+
wait_report: ctx.bool("wait-report")
|
|
11917
11918
|
};
|
|
11918
11919
|
}
|
|
11919
11920
|
function invoke(ctx, action) {
|
|
@@ -11993,6 +11994,7 @@ var onboardingExperimentLaunch = {
|
|
|
11993
11994
|
flags: [
|
|
11994
11995
|
{ ...sharedFlags[0], required: true },
|
|
11995
11996
|
{ name: "run-id", type: "string", required: true, desc: "Run ID returned by experiment-plan for the confirmed Demo proposal." },
|
|
11997
|
+
{ name: "wait-report", type: "boolean", desc: "Wait up to 25 seconds for the replay sample-size query. Resume the same run on wait_experiment_report." },
|
|
11996
11998
|
{ name: "start-only", type: "boolean", desc: "Return the link when the experiment is running. Resume with the same run ID to send the replay." }
|
|
11997
11999
|
],
|
|
11998
12000
|
dryRun: (ctx) => invoke(ctx, "experiment-launch-preview"),
|
|
@@ -1291,6 +1291,59 @@ async function prepareExperimentReplay(options) {
|
|
|
1291
1291
|
}
|
|
1292
1292
|
}
|
|
1293
1293
|
|
|
1294
|
+
// src/core/onboarding/experiment-report-wait.ts
|
|
1295
|
+
function replayReportDates(receipt) {
|
|
1296
|
+
const zone = /^([+-])(\d{2}):(\d{2})$/.exec(receipt.timezone);
|
|
1297
|
+
if (!zone || Number(zone[2]) > 14 || Number(zone[3]) > 59 || Number(zone[2]) === 14 && Number(zone[3]) !== 0) throw new Error("The replay reporting timezone is invalid.");
|
|
1298
|
+
const offset = (Number(zone[2]) * 60 + Number(zone[3])) * 6e4 * (zone[1] === "-" ? -1 : 1);
|
|
1299
|
+
const start = Date.parse(receipt.start);
|
|
1300
|
+
const end = Date.parse(receipt.end);
|
|
1301
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start) throw new Error("The replay interval is invalid.");
|
|
1302
|
+
return {
|
|
1303
|
+
start_time: new Date(start + offset).toISOString().slice(0, 10),
|
|
1304
|
+
end_time: new Date(end + offset).toISOString().slice(0, 10)
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
function isReportPending(error, projectId) {
|
|
1308
|
+
if (!(error instanceof CapabilityGatewayError) || error.type === "validation" || error.httpStatus === 401 || error.httpStatus === 403) return false;
|
|
1309
|
+
const view = `hive.hermes.v_atlas_experiment_exposure_${projectId}`.replaceAll(".", "\\.");
|
|
1310
|
+
return new RegExp("\\bTable\\s+['\"`]?" + view + "['\"`]?\\s+does not exist\\b", "i").test(error.message) || /^(atlas\.service\.error\.report\.data_unavailable|Report data is temporarily unavailable\.|报告数据暂不可用|レポートデータを一時的に利用できません|리포트 데이터를 일시적으로 사용할 수 없습니다)/.test(error.message);
|
|
1311
|
+
}
|
|
1312
|
+
async function waitForExperimentSampleSize(query, input, budgetMs = 25e3, delayMs = 5e3) {
|
|
1313
|
+
const deadline = Date.now() + budgetMs;
|
|
1314
|
+
let attempts = 0;
|
|
1315
|
+
do {
|
|
1316
|
+
attempts++;
|
|
1317
|
+
try {
|
|
1318
|
+
const response = await query(
|
|
1319
|
+
{ ...input, force_refresh: true },
|
|
1320
|
+
AbortSignal.timeout(Math.max(1, Math.min(NETWORK_BUDGET_MS, deadline - Date.now())))
|
|
1321
|
+
);
|
|
1322
|
+
if (!response || typeof response.report !== "object" || response.report === null) {
|
|
1323
|
+
throw new Error("The sample-size query returned no report.");
|
|
1324
|
+
}
|
|
1325
|
+
if (response.report.has_data !== false) {
|
|
1326
|
+
return { phase: "complete", next_action: "verify_experiment_results", report_dates: {
|
|
1327
|
+
start_time: input.start_time,
|
|
1328
|
+
end_time: input.end_time
|
|
1329
|
+
}, sample_size_report: response.report, report_query_attempts: attempts };
|
|
1330
|
+
}
|
|
1331
|
+
} catch (error) {
|
|
1332
|
+
if (!isReportPending(error, input.project_id) && !(error instanceof DOMException && ["TimeoutError", "AbortError"].includes(error.name))) throw error;
|
|
1333
|
+
}
|
|
1334
|
+
const remaining = deadline - Date.now();
|
|
1335
|
+
if (remaining <= 0) break;
|
|
1336
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(delayMs, remaining)));
|
|
1337
|
+
} while (Date.now() < deadline);
|
|
1338
|
+
return {
|
|
1339
|
+
phase: "pending",
|
|
1340
|
+
next_action: "wait_experiment_report",
|
|
1341
|
+
poll_after_ms: delayMs,
|
|
1342
|
+
report_dates: { start_time: input.start_time, end_time: input.end_time },
|
|
1343
|
+
report_query_attempts: attempts
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1294
1347
|
// src/core/onboarding/experiment-launch.ts
|
|
1295
1348
|
function isApprovalBlocker(error) {
|
|
1296
1349
|
return error instanceof SecureStoreAuthError || error instanceof PermissionError || error instanceof CapabilityGatewayError && (error.httpStatus === 401 || error.httpStatus === 403 || error.type === "validation");
|
|
@@ -1336,7 +1389,7 @@ async function runOnboardingExperimentLaunch(store, deps, input, preview) {
|
|
|
1336
1389
|
...plan.approver ? [] : ["add_signed_in_approver_if_needed"],
|
|
1337
1390
|
"approve",
|
|
1338
1391
|
"start",
|
|
1339
|
-
...input.start_only ? [] : ["upload_one_replay_batch"]
|
|
1392
|
+
...input.start_only ? [] : ["upload_one_replay_batch", ...input.wait_report ? ["wait_for_sample_size_report"] : []]
|
|
1340
1393
|
] };
|
|
1341
1394
|
const key = session.credential_key;
|
|
1342
1395
|
const checkAccount = () => {
|
|
@@ -1344,9 +1397,9 @@ async function runOnboardingExperimentLaunch(store, deps, input, preview) {
|
|
|
1344
1397
|
throw new Error("Resume onboarding with the signed-in account that generated the Demo plan.");
|
|
1345
1398
|
}
|
|
1346
1399
|
};
|
|
1347
|
-
const request2 = async (id, params) => {
|
|
1400
|
+
const request2 = async (id, params, waitSignal) => {
|
|
1348
1401
|
checkAccount();
|
|
1349
|
-
const signal = AbortSignal.timeout(NETWORK_BUDGET_MS);
|
|
1402
|
+
const signal = waitSignal ?? AbortSignal.timeout(NETWORK_BUDGET_MS);
|
|
1350
1403
|
const response = await deps.capability(host, id, params, signal);
|
|
1351
1404
|
signal.throwIfAborted();
|
|
1352
1405
|
return response;
|
|
@@ -1372,7 +1425,34 @@ async function runOnboardingExperimentLaunch(store, deps, input, preview) {
|
|
|
1372
1425
|
next_action: "verify_experiment_results"
|
|
1373
1426
|
});
|
|
1374
1427
|
const started = () => ({ ...result("running"), approval_state: "approved", next_action: "upload_experiment_replay" });
|
|
1375
|
-
|
|
1428
|
+
const finishReplay = async () => {
|
|
1429
|
+
const accepted = completed();
|
|
1430
|
+
if (!input.wait_report) return accepted;
|
|
1431
|
+
try {
|
|
1432
|
+
const receipt = store.read(`experiment-replay-${runId}.json`);
|
|
1433
|
+
if (!receipt || receipt.run_id !== runId || receipt.experiment_id !== progress.experiment_id || receipt.sample_id !== scope.sample_id || receipt.item_id !== scope.item_id) {
|
|
1434
|
+
throw new Error("The replay receipt does not match this Demo experiment.");
|
|
1435
|
+
}
|
|
1436
|
+
const dates = replayReportDates(receipt);
|
|
1437
|
+
const report = await waitForExperimentSampleSize(
|
|
1438
|
+
(params, signal) => request2("experiment.report.sample-size", params, signal),
|
|
1439
|
+
{ project_id: scope.project_id, exp_id: progress.experiment_id, ...dates }
|
|
1440
|
+
);
|
|
1441
|
+
return { ...accepted, ...report };
|
|
1442
|
+
} catch (error) {
|
|
1443
|
+
return {
|
|
1444
|
+
...accepted,
|
|
1445
|
+
phase: "action_required",
|
|
1446
|
+
failed_stage: "wait_experiment_report",
|
|
1447
|
+
next_action: "inspect_experiment_report",
|
|
1448
|
+
error: {
|
|
1449
|
+
message: error instanceof Error ? error.message : "The report query failed.",
|
|
1450
|
+
...error instanceof CapabilityGatewayError ? { code: error.code, meta: error.meta } : {}
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
if (progress.replay?.status === "receiver_accepted") return finishReplay();
|
|
1376
1456
|
if (progress.replay) return { ...result("action_required"), next_action: "reconcile_replay_delivery" };
|
|
1377
1457
|
let stage = "prepare_requests";
|
|
1378
1458
|
const call = (id, params = {}) => request2(id, { ...project, ...params });
|
|
@@ -1624,7 +1704,7 @@ async function runOnboardingExperimentLaunch(store, deps, input, preview) {
|
|
|
1624
1704
|
}
|
|
1625
1705
|
progress.replay.status = "receiver_accepted";
|
|
1626
1706
|
});
|
|
1627
|
-
return
|
|
1707
|
+
return finishReplay();
|
|
1628
1708
|
} catch (error) {
|
|
1629
1709
|
return {
|
|
1630
1710
|
...result("action_required"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ae-onboarding
|
|
3
|
-
version: 1.1.
|
|
3
|
+
version: 1.1.38
|
|
4
4
|
description: "Guide Demo analysis and a follow-up A/B experiment in AE onboarding, with SDK integration available in a local agent."
|
|
5
5
|
metadata:
|
|
6
6
|
internal: true
|
|
@@ -56,7 +56,7 @@ On `phase=ready`, retain `run_id` and show the [A/B comparison table](references
|
|
|
56
56
|
|
|
57
57
|
### Confirm and start the A/B experiment
|
|
58
58
|
|
|
59
|
-
When the customer chooses **确认并启动 A/B 实验** or confirms the displayed plan, call [experiment-launch](references/onboarding_experiment_launch.md) with its saved `run_id`. **Required for every onboarding Demo approval:** only `ae-cli analysis onboarding experiment-launch` may submit or approve the draft. This applies after creation and on every retry or resume. Never substitute standalone approval writes. For checkout recovery, use `--start-only` first. On `upload_experiment_replay`, show the link in a progress update and resume the same run to send the replay. Follow [launch handling](references/demo-operations.md#start-and-replay-the-confirmed-experiment) for other actions. After Receiver acceptance, continue [result verification](references/demo-operations.md#report-verified-results) in the same turn.
|
|
59
|
+
When the customer chooses **确认并启动 A/B 实验** or confirms the displayed plan, call [experiment-launch](references/onboarding_experiment_launch.md) with its saved `run_id` and `--wait-report`. **Required for every onboarding Demo approval:** only `ae-cli analysis onboarding experiment-launch` may submit or approve the draft. This applies after creation and on every retry or resume. Never substitute standalone approval writes. For checkout recovery, use `--start-only` first. On `upload_experiment_replay`, show the link in a progress update and resume the same run with `--wait-report` to send the replay. On `wait_experiment_report`, wait `poll_after_ms` and resume that same launch command in the current turn. Use this command's internal wait for exposure-view readiness before separate report reads. Follow [launch handling](references/demo-operations.md#start-and-replay-the-confirmed-experiment) for other actions. After Receiver acceptance, continue [result verification](references/demo-operations.md#report-verified-results) in the same turn.
|
|
60
60
|
|
|
61
61
|
For an explicit request to launch a Demo experiment, use the requested or previously selected scenario. If neither is available, use the default. Obtain a `run_id` and launch using the existing authorization. For a draft-only request, follow [draft-only creation](references/demo-operations.md#draft-only-creation). In a local agent, if the customer chooses business data, use the same onboarding session with `--choice business` and follow Business SDK.
|
|
62
62
|
|
|
@@ -40,10 +40,11 @@ After showing the preview, use the host's choice control with **Confirm and star
|
|
|
40
40
|
|
|
41
41
|
## Start and replay the confirmed experiment
|
|
42
42
|
|
|
43
|
-
Use [`experiment-launch`](onboarding_experiment_launch.md) with the confirmed plan. It creates the Feature and metrics, saves the draft, checks readiness, approves the exact round as the signed-in approver, and verifies that the experiment is running. Replay sends exposure and payment events in one Receiver batch. The coupon scenario also sends coupon claims. Outcomes are timestamped five seconds after the account's exposure.
|
|
43
|
+
Use [`experiment-launch`](onboarding_experiment_launch.md) with the confirmed plan and `--wait-report` when replaying. It creates the Feature and metrics, saves the draft, checks readiness, approves the exact round as the signed-in approver, and verifies that the experiment is running. Replay sends exposure and payment events in one Receiver batch. The coupon scenario also sends coupon claims. Outcomes are timestamped five seconds after the account's exposure.
|
|
44
44
|
|
|
45
45
|
- Use the launch command as the sole path for approval writes, including after the draft already exists. Do not invoke standalone `experiment approval submit` or `experiment approval approve`, the corresponding raw capabilities, or a UI approval as a fallback. A read-only approval check can help diagnose a blocker.
|
|
46
46
|
- While the command is running, wait for the same process in the current turn. If the execution tool returns a process handle, keep polling that handle. The CLI already polls the approval round and retries recoverable errors. A pending round or a generic `CAPABILITY_EXECUTION_FAILED` does not justify stopping an active invocation or switching commands.
|
|
47
|
+
- On `wait_experiment_report`, wait `poll_after_ms` and resume `experiment-launch --wait-report` with the same session and run IDs in this turn. Keep using the saved replay.
|
|
47
48
|
- When the CLI returns `experiment_url` with a running experiment, show **View experiment** as a clickable progress link. For `upload_experiment_replay`, resume the same run without `--start-only`. For `verify_experiment_results` or an older `phase=complete` response, continue to [Report verified results](#report-verified-results) in the same turn.
|
|
48
49
|
- On `wait_for_other_demo_experiment`, show the existing experiment link when present. The user can still explore either scenario. Resume the confirmed run after the other experiment has ended.
|
|
49
50
|
- On `run_checkout_recovery_growth`, refresh the baseline, generate a new proposal and get confirmation for the new plan.
|
|
@@ -62,7 +63,7 @@ Use the experiment ID, run ID, and replay receipt returned by `experiment-launch
|
|
|
62
63
|
|
|
63
64
|
Once ingestion is verified, request the experiment report reads in parallel. Pass `--project-id` and `--exp-id` to each. Refresh `ae-cli experiment report summary` with `--force-refresh true`. For `ae-cli experiment report sample-size` and `ae-cli experiment report metric-trend`, use `--start-time` and `--end-time` for the project-local replay dates and pass `--metric-id` for each trend. The sample dashboard describes the historical growth baseline. Keep replay results scoped to the experiment report.
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
Wait for the exposure view through `experiment-launch --wait-report`. If a separate sample-size read finds the view missing or returns the specific temporary report-unavailable message, return to that same launch command with the saved IDs. It handles the wait internally and returns a normal pending result for continuation. Keep the turn open and repeat on `wait_experiment_report`; do not repeatedly invoke a failing standalone sample-size command. Use the returned `report_dates` for subsequent report reads, including a replay crossing local midnight. Reuse `sample_size_report` when present. Continue event-ingestion verification and summary/trend reads; sample-size query success alone does not prove the replay has arrived.
|
|
66
67
|
|
|
67
68
|
Use the saved assignment receipt for assigned counts, and use query results for exposure, coupon claims, purchases, and order amounts. Match outcome accounts to the verified exposure groups, keep the run and item filters, and deduplicate buyers by account and orders by `order_id`.
|
|
68
69
|
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
```sh
|
|
4
4
|
ae-cli analysis onboarding experiment-launch --session-id <session-id> --run-id <run-id> --start-only --format json
|
|
5
|
-
ae-cli analysis onboarding experiment-launch --session-id <session-id> --run-id <run-id> --format json
|
|
5
|
+
ae-cli analysis onboarding experiment-launch --session-id <session-id> --run-id <run-id> --wait-report --format json
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
Use the session and run IDs from the confirmed Demo proposal. For checkout recovery, run with `--start-only`. On `upload_experiment_replay`, show the experiment link and immediately run the second command with the same IDs. For the coupon flow, the second command can start and replay in one call. `--dry-run` previews the stages without making changes.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
The replay command must include `--wait-report` in onboarding. It queries sample size internally for up to 25 seconds with five-second intervals, using the replay receipt's project-local start and end dates. Missing exposure views and the specific report-unavailable response remain pending. On `phase=pending` and `next_action=wait_experiment_report`, wait `poll_after_ms` and repeat the same command with the same session and run IDs. An accepted replay is reused without resending events. Poll an active process handle until it returns before starting another invocation. A permission, validation or unrelated query failure returns `inspect_experiment_report`; report that blocker.
|
|
11
|
+
|
|
12
|
+
Show the returned `experiment_url` as soon as the command confirms running. Use it again as the report link after verification. `phase=complete` means the Receiver accepted the batch. A successful sample-size query returns `sample_size_report` and `report_dates`; it does not verify event persistence or all other reports. Follow `next_action=verify_experiment_results` in the current turn to wait for ingestion and reports.
|
|
11
13
|
|
|
12
14
|
See [launch handling](demo-operations.md#start-and-replay-the-confirmed-experiment) for resuming an interrupted launch and verifying ingestion.
|