@oxygen-agent/cli 1.1014.2101 → 1.1014.2119
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/README.md +1 -1
- package/dist/commands/sequences.js +2 -2
- package/node_modules/@oxygen/shared/dist/linkedin-sequences.d.ts +22 -0
- package/node_modules/@oxygen/shared/dist/linkedin-sequences.js +14 -0
- package/node_modules/@oxygen/shared/dist/product-analytics-events.d.ts +3 -1
- package/node_modules/@oxygen/shared/dist/product-analytics-events.js +3 -1
- package/node_modules/@oxygen/shared/dist/sequences.d.ts +18 -0
- package/node_modules/@oxygen/shared/dist/sequences.js +72 -0
- package/node_modules/@oxygen/shared/dist/version.generated.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/version.generated.js +1 -1
- package/node_modules/@oxygen/shared/dist/workspace-placement-bulk.js +1 -1
- package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.d.ts +50 -4
- package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.js +116 -5
- package/node_modules/@oxygen/shared/dist/workspace-placement-view.d.ts +14 -0
- package/node_modules/@oxygen/shared/dist/workspace-placement-view.js +11 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1789,7 +1789,7 @@ export function registerSequencesFamily(program, handleAsyncAction) {
|
|
|
1789
1789
|
.option("--activation-id <id>", "Guided activation UUID; requires --activation-revision and --expected-revision.")
|
|
1790
1790
|
.option("--activation-revision <revision>", "Current guided activation revision; requires --activation-id and --expected-revision.")
|
|
1791
1791
|
.option("--name <name>", "New human-readable sequence name.")
|
|
1792
|
-
.option("--steps-file <path>", "Path to a JSON file: { \"steps\": [...] } replacing the journey. Once started (paused included),
|
|
1792
|
+
.option("--steps-file <path>", "Path to a JSON file: { \"steps\": [...] } replacing the journey. Once started (paused included), existing wait steps may change days/hours/jitter_hours/working_days and existing steps may change their wording (templates, subjects, invite notes, A/B variant copy; queued unsent messages take the new wording): same step IDs, kinds, order and variant count (zero a delay, never delete its step). Connection-wait timeout_days/on_timeout/withdraw_on_timeout are draft-only; duplicate to change them after start. Copy supports {{column}} interpolation; every step also takes {{sender_first_name}} / {{sender_last_name}} / {{sender_full_name}} for the person who sends it, and email adds {{sender_email}} (a same-named row column wins). A `branch` can also route on the lead's data with a contact leaf { has_contact: \"email\" | \"linkedin\" | \"phone\" } or a data leaf { has_column: \"<key>\" } (present:false for \"missing\").")
|
|
1793
1793
|
.option("--channels <list>", "Draft only: comma-separated channels: linkedin,email,whatsapp,call,crm.")
|
|
1794
1794
|
.option("--whatsapp-cold-initiate", "WhatsApp: allow cold-initiating new chats (no prior conversation). Required to start a WhatsApp sequence live (draft-editable).")
|
|
1795
1795
|
.option("--no-whatsapp-cold-initiate", "WhatsApp: stop allowing cold chats; a live WhatsApp start then refuses.")
|
|
@@ -2193,7 +2193,7 @@ export function registerSequencesFamily(program, handleAsyncAction) {
|
|
|
2193
2193
|
await handleAsyncAction("sequences delete", options, () => requestOxygen(`/api/cli/sequences/${encodeURIComponent(sequence)}${options.approved ? "?approved=true" : ""}`, { method: "DELETE" }));
|
|
2194
2194
|
}))
|
|
2195
2195
|
.addCommand(new Command("enrollments")
|
|
2196
|
-
.description("List per-lead enrollment state plus the latest action status, error, attempts, and retry time. --view compact answers 'when is each lead's next message due' per lead: lead, status, invite (accepted, pending, not_invited), accepted_at, current_step and next_due. next_due.summary says it in words, at_local/gives_up_at_local give the time in the campaign's timezone (its schedule's, else UTC) and at/gives_up_at in UTC. Reasons: step_scheduled (planned send time; held_by names what holds it, e.g. send_cap_reached), planner_due (when the planner next looks at the lead), not_started (begins when the campaign is started or resumed), nothing_scheduled (enrolled, no step will run), waiting_for_connection / waiting_for_signal (no send time; acceptance makes the next step due at once; gives_up_at is when the wait ends, and on_timeout says whether the lead then leaves or moves on), finished. A failed lead carries failure: the cause in words (cause_recorded false when OXYGEN never recorded one) and provider_contact (made; none = the step never started; nothing_sent; unknown). missing_source_row is true for a lead whose source-table row was deleted: still enrolled and contacted (remove with `contacts-remove --missing-source-rows`); null when the campaign has no live source table to check against, or the check failed. channels says which of the sequence's channels reach each lead: usable, and unavailable with a reason (no_linkedin_profile = enrolled for email only, its LinkedIn steps are skipped; no_recipient_email; no_phone_number).")
|
|
2196
|
+
.description("List per-lead enrollment state plus the latest action status, error, attempts, and retry time. --view compact answers 'when is each lead's next message due' per lead: lead, status, invite (accepted, pending, not_invited), accepted_at, current_step and next_due. next_due.summary says it in words, at_local/gives_up_at_local give the time in the campaign's timezone (its schedule's, else UTC) and at/gives_up_at in UTC. Reasons: step_scheduled (planned send time; held_by names what holds it, e.g. send_cap_reached), planner_due (when the planner next looks at the lead), not_started (begins when the campaign is started or resumed), nothing_scheduled (enrolled, no step will run), waiting_for_connection / waiting_for_signal (no send time; acceptance makes the next step due at once; gives_up_at is when the wait ends, and on_timeout says whether the lead then leaves or moves on), finished. A failed lead carries failure: the cause in words (cause_recorded false when OXYGEN never recorded one) and provider_contact (made; none = the step never started; nothing_sent; unknown). missing_source_row is true for a lead whose source-table row was deleted: still enrolled and contacted (remove with `contacts-remove --missing-source-rows`); null when the campaign has no live source table to check against, or the check failed. channels says which of the sequence's channels reach each lead: usable, and unavailable with a reason (no_linkedin_profile = enrolled for email only, its LinkedIn steps are skipped; linkedin_profile_unreadable = LinkedIn would not open the profile, so its remaining LinkedIn steps are skipped and the other channels continue; no_recipient_email; no_phone_number).")
|
|
2197
2197
|
.argument("<sequence>", "Sequence id or slug.")
|
|
2198
2198
|
.option("--status <status>", "Filter by enrollment status (pending, active, waiting_connection, waiting_signal, replied, completed, stopped, failed, excluded). pending = enrolled, not started (next_due not_started); waiting_connection = invite sent, not accepted yet. Status is the lead's progress, not its invite: use --invite accepted for the leads that accepted.")
|
|
2199
2199
|
.option("--step <n>", "Only leads currently on this step (0-based index, as in the sequence's steps).")
|
|
@@ -208,6 +208,28 @@ export type LinkedInRefusalScope =
|
|
|
208
208
|
| "already_engaged"
|
|
209
209
|
/** Unrecognised. Callers MUST preserve their existing behaviour. */
|
|
210
210
|
| "unknown";
|
|
211
|
+
/**
|
|
212
|
+
* Classify a LinkedIn refusal from the provider's own account of it.
|
|
213
|
+
*
|
|
214
|
+
* Deliberately a CLOSED set of anchored, full-string matches, in the same
|
|
215
|
+
* discipline as the sequence-recovery allowlists: matching vendor prose is
|
|
216
|
+
* fragile, so an unrecognised message must degrade to `unknown` and leave the
|
|
217
|
+
* caller's behaviour exactly as it was. Extending the set is an evidence-driven
|
|
218
|
+
* act — callers log what they could not classify.
|
|
219
|
+
*
|
|
220
|
+
* Pure and total; never throws.
|
|
221
|
+
*/
|
|
222
|
+
/**
|
|
223
|
+
* Enrollment metadata key set when LinkedIn would not open the lead's profile on
|
|
224
|
+
* any attempt of a LinkedIn step, in a journey that still reaches the lead by
|
|
225
|
+
* email, call or WhatsApp.
|
|
226
|
+
* The planner then treats the lead as having no LinkedIn profile: each later
|
|
227
|
+
* LinkedIn step is skipped as linkedin_profile_unreadable, a connection wait
|
|
228
|
+
* passes and a connection branch takes its not-connected path, while the email,
|
|
229
|
+
* call, WhatsApp and CRM steps still run.
|
|
230
|
+
*/
|
|
231
|
+
export declare const LINKEDIN_PROFILE_UNREADABLE_METADATA_KEY = "linkedin_profile_unreadable";
|
|
232
|
+
export declare function linkedInProfileMarkedUnreadable(metadata: Record<string, unknown> | null | undefined): boolean;
|
|
211
233
|
export declare function classifyLinkedInRefusal(input: {
|
|
212
234
|
providerType: string | null;
|
|
213
235
|
providerMessage: string | null;
|
|
@@ -113,6 +113,20 @@ export const LINKEDIN_INVITE_NOTE_LIMIT_BASIC = 200;
|
|
|
113
113
|
*
|
|
114
114
|
* Pure and total; never throws.
|
|
115
115
|
*/
|
|
116
|
+
/**
|
|
117
|
+
* Enrollment metadata key set when LinkedIn would not open the lead's profile on
|
|
118
|
+
* any attempt of a LinkedIn step, in a journey that still reaches the lead by
|
|
119
|
+
* email, call or WhatsApp.
|
|
120
|
+
* The planner then treats the lead as having no LinkedIn profile: each later
|
|
121
|
+
* LinkedIn step is skipped as linkedin_profile_unreadable, a connection wait
|
|
122
|
+
* passes and a connection branch takes its not-connected path, while the email,
|
|
123
|
+
* call, WhatsApp and CRM steps still run.
|
|
124
|
+
*/
|
|
125
|
+
export const LINKEDIN_PROFILE_UNREADABLE_METADATA_KEY = "linkedin_profile_unreadable";
|
|
126
|
+
export function linkedInProfileMarkedUnreadable(metadata) {
|
|
127
|
+
const marker = metadata?.[LINKEDIN_PROFILE_UNREADABLE_METADATA_KEY];
|
|
128
|
+
return typeof marker === "object" && marker !== null;
|
|
129
|
+
}
|
|
116
130
|
/**
|
|
117
131
|
* LinkedIn's sentence when an invitation is refused because the member handled
|
|
118
132
|
* an earlier one from this account (accepted, ignored or withdrawn) within three
|
|
@@ -37,7 +37,9 @@ export declare const PRODUCT_EVENTS: {
|
|
|
37
37
|
/**
|
|
38
38
|
* Activation (Philipp, 2026-10-20): the person sent a play's prompt in their
|
|
39
39
|
* onboarding chat, verified from the chat's turn when onboarding finishes.
|
|
40
|
-
*
|
|
40
|
+
* Since 2026-10-27 also a request they typed there after the proposed plays;
|
|
41
|
+
* `kind` is play or own_request. Once per (workspace, person), gated by
|
|
42
|
+
* `organizations.metadata.onboarding_play_sent`.
|
|
41
43
|
*/
|
|
42
44
|
readonly ONBOARDING_PLAY_SENT: "onboarding_play_sent";
|
|
43
45
|
/**
|
|
@@ -37,7 +37,9 @@ export const PRODUCT_EVENTS = {
|
|
|
37
37
|
/**
|
|
38
38
|
* Activation (Philipp, 2026-10-20): the person sent a play's prompt in their
|
|
39
39
|
* onboarding chat, verified from the chat's turn when onboarding finishes.
|
|
40
|
-
*
|
|
40
|
+
* Since 2026-10-27 also a request they typed there after the proposed plays;
|
|
41
|
+
* `kind` is play or own_request. Once per (workspace, person), gated by
|
|
42
|
+
* `organizations.metadata.onboarding_play_sent`.
|
|
41
43
|
*/
|
|
42
44
|
ONBOARDING_PLAY_SENT: "onboarding_play_sent",
|
|
43
45
|
/**
|
|
@@ -1012,6 +1012,24 @@ export declare function sequenceWaitStepReadyAt(step: SequenceWaitStep, enrollme
|
|
|
1012
1012
|
* to bypass, so its builder inserts and deletes waits freely.
|
|
1013
1013
|
*/
|
|
1014
1014
|
export declare function sequenceDefinitionsDifferOnlyInTiming(before: SequenceDefinition, after: SequenceDefinition): boolean;
|
|
1015
|
+
/**
|
|
1016
|
+
* Whether `after` differs from `before` only in wait timing and step wording
|
|
1017
|
+
* (templates, subjects, notes and their A/B variants). This is the edit a
|
|
1018
|
+
* started sequence accepts: the same steps in the same order and kinds, so every
|
|
1019
|
+
* enrollment's integer `current_step_index` still points at the step it meant
|
|
1020
|
+
* (see sequenceDefinitionsDifferOnlyInTiming), on the same channels. Changed
|
|
1021
|
+
* wording reaches queued actions through the dispatcher's copy replan
|
|
1022
|
+
* (sequenceStepCopyDigest).
|
|
1023
|
+
*/
|
|
1024
|
+
export declare function sequenceDefinitionsDifferOnlyInTimingOrCopy(before: SequenceDefinition, after: SequenceDefinition): boolean;
|
|
1025
|
+
/** Ids of the steps whose wording differs between two same-shaped definitions. */
|
|
1026
|
+
export declare function sequenceStepsWithChangedCopy(before: SequenceDefinition, after: SequenceDefinition): string[];
|
|
1027
|
+
/**
|
|
1028
|
+
* A short digest of a step's wording, stamped on each planned action. The
|
|
1029
|
+
* dispatcher compares it with the live step to find queued actions planned
|
|
1030
|
+
* before a copy edit. Not a security hash; it only has to change with the copy.
|
|
1031
|
+
*/
|
|
1032
|
+
export declare function sequenceStepCopyDigest(step: SequenceStep): string;
|
|
1015
1033
|
/**
|
|
1016
1034
|
* Render a sequence-copy template against a row's values. Delegates to the shared
|
|
1017
1035
|
* deterministic engine (sequence-template.ts): `{{column}}` substitution plus
|
|
@@ -2207,6 +2207,78 @@ export function sequenceDefinitionsDifferOnlyInTiming(before, after) {
|
|
|
2207
2207
|
return timingFree(oldStep) === timingFree(newStep);
|
|
2208
2208
|
});
|
|
2209
2209
|
}
|
|
2210
|
+
/** The wording fields of each step kind: what a started sequence may still edit. */
|
|
2211
|
+
const SEQUENCE_STEP_COPY_FIELDS = {
|
|
2212
|
+
invite: ["note_template"],
|
|
2213
|
+
message: ["template"],
|
|
2214
|
+
whatsapp_message: ["template"],
|
|
2215
|
+
inmail: ["subject_template", "template"],
|
|
2216
|
+
comment_post: ["text_template"],
|
|
2217
|
+
email_send: ["subject_template", "body_template", "body_html_template"],
|
|
2218
|
+
email_reply: ["body_template", "body_html_template"],
|
|
2219
|
+
};
|
|
2220
|
+
function withoutCopy(step) {
|
|
2221
|
+
const fields = { ...step };
|
|
2222
|
+
for (const key of SEQUENCE_STEP_COPY_FIELDS[step.kind] ?? [])
|
|
2223
|
+
delete fields[key];
|
|
2224
|
+
const variants = step.variants;
|
|
2225
|
+
// A/B variants carry only copy, so their number is what stays fixed: adding or
|
|
2226
|
+
// removing one moves live leads between arms of a running test.
|
|
2227
|
+
if (Array.isArray(variants))
|
|
2228
|
+
fields.variants = variants.length;
|
|
2229
|
+
// An email_send without a subject threads onto the previous email, so adding or
|
|
2230
|
+
// dropping the subject changes what the step does, not only what it says.
|
|
2231
|
+
if (step.kind === "email_send")
|
|
2232
|
+
fields.has_subject = Boolean(step.subject_template);
|
|
2233
|
+
return fields;
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Whether `after` differs from `before` only in wait timing and step wording
|
|
2237
|
+
* (templates, subjects, notes and their A/B variants). This is the edit a
|
|
2238
|
+
* started sequence accepts: the same steps in the same order and kinds, so every
|
|
2239
|
+
* enrollment's integer `current_step_index` still points at the step it meant
|
|
2240
|
+
* (see sequenceDefinitionsDifferOnlyInTiming), on the same channels. Changed
|
|
2241
|
+
* wording reaches queued actions through the dispatcher's copy replan
|
|
2242
|
+
* (sequenceStepCopyDigest).
|
|
2243
|
+
*/
|
|
2244
|
+
export function sequenceDefinitionsDifferOnlyInTimingOrCopy(before, after) {
|
|
2245
|
+
const oldSteps = Array.isArray(before?.steps) ? before.steps : [];
|
|
2246
|
+
const newSteps = Array.isArray(after?.steps) ? after.steps : [];
|
|
2247
|
+
return sequenceDefinitionsDifferOnlyInTiming({ ...before, steps: oldSteps.map((step) => withoutCopy(step)) }, { ...after, steps: newSteps.map((step) => withoutCopy(step)) });
|
|
2248
|
+
}
|
|
2249
|
+
/** Ids of the steps whose wording differs between two same-shaped definitions. */
|
|
2250
|
+
export function sequenceStepsWithChangedCopy(before, after) {
|
|
2251
|
+
const previous = new Map((before?.steps ?? []).map((step) => [step.id, step]));
|
|
2252
|
+
return (after?.steps ?? []).flatMap((step) => {
|
|
2253
|
+
const old = previous.get(step.id);
|
|
2254
|
+
return old && old.kind === step.kind && sequenceStepCopyDigest(old) !== sequenceStepCopyDigest(step) ? [step.id] : [];
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* A short digest of a step's wording, stamped on each planned action. The
|
|
2259
|
+
* dispatcher compares it with the live step to find queued actions planned
|
|
2260
|
+
* before a copy edit. Not a security hash; it only has to change with the copy.
|
|
2261
|
+
*/
|
|
2262
|
+
export function sequenceStepCopyDigest(step) {
|
|
2263
|
+
const copy = {};
|
|
2264
|
+
for (const key of SEQUENCE_STEP_COPY_FIELDS[step.kind] ?? [])
|
|
2265
|
+
copy[key] = step[key];
|
|
2266
|
+
const variants = step.variants;
|
|
2267
|
+
if (Array.isArray(variants))
|
|
2268
|
+
copy.variants = variants;
|
|
2269
|
+
// cyrb53: a fast 53-bit string hash, plenty to tell two versions of a step apart.
|
|
2270
|
+
const text = stableJson(copy);
|
|
2271
|
+
let h1 = 0xdeadbeef;
|
|
2272
|
+
let h2 = 0x41c6ce57;
|
|
2273
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
2274
|
+
const code = text.charCodeAt(index);
|
|
2275
|
+
h1 = Math.imul(h1 ^ code, 2654435761);
|
|
2276
|
+
h2 = Math.imul(h2 ^ code, 1597334677);
|
|
2277
|
+
}
|
|
2278
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
2279
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
2280
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36);
|
|
2281
|
+
}
|
|
2210
2282
|
/**
|
|
2211
2283
|
* Render a sequence-copy template against a row's values. Delegates to the shared
|
|
2212
2284
|
* deterministic engine (sequence-template.ts): `{{column}}` substitution plus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const OXYGEN_BUILD_VERSION = "1.1014.
|
|
1
|
+
export declare const OXYGEN_BUILD_VERSION = "1.1014.2119";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// GENERATED by scripts/ci/version-stamp.mjs from VERSION + git history. Do not edit; do not commit.
|
|
2
|
-
export const OXYGEN_BUILD_VERSION = "1.1014.
|
|
2
|
+
export const OXYGEN_BUILD_VERSION = "1.1014.2119";
|
|
@@ -63,7 +63,7 @@ export function buildWorkspacePlacementBulkPlan(input) {
|
|
|
63
63
|
const child = { ...scheduling, request_id: bulkPlacementId(`${organizationId}:${requestId}:child:${offset / 50}`), organization_id: organizationId, provider: "internal", billing_mode: "internal", credits: 0, allow_paused_probe: input.allowPausedProbe, receiver_scope: "workspace", rendered_at: input.renderedAt, rendering: input.rendering, probes: probes.slice(offset, offset + 50), excluded_self_sends: 0, message_count: Math.min(50, probes.length - offset) };
|
|
64
64
|
children.push({ ...child, plan_hash: createHash("sha256").update(JSON.stringify(child)).digest("hex") });
|
|
65
65
|
}
|
|
66
|
-
const plan = { ...scheduling, ...(input.schedule ? { provider_directions: placementProviderDirections(probes), schedule_summary: placementScheduleSummary(probes.map(p => ({ scheduled_at: p.scheduled_at }))) } : {}), request_id: requestId, organization_id: organizationId, rendered_at: input.renderedAt, message_count: count, child_count: children.length, sender_count: senders.length, receiver_providers: providers, skipped_senders: [...(input.skippedSenders ?? [])].sort((a, b) => a.id.localeCompare(b.id)), coverage, children };
|
|
66
|
+
const plan = { ...scheduling, ...(input.schedule ? { provider_directions: placementProviderDirections(probes), schedule_summary: placementScheduleSummary(probes.map(p => ({ scheduled_at: p.scheduled_at })), { schedule: WORKSPACE_PLACEMENT_SCHEDULE, start: input.renderedAt }) } : {}), request_id: requestId, organization_id: organizationId, rendered_at: input.renderedAt, message_count: count, child_count: children.length, sender_count: senders.length, receiver_providers: providers, skipped_senders: [...(input.skippedSenders ?? [])].sort((a, b) => a.id.localeCompare(b.id)), coverage, children };
|
|
67
67
|
return { ...plan, plan_hash: createHash("sha256").update(JSON.stringify(plan)).digest("hex") };
|
|
68
68
|
}
|
|
69
69
|
export function bulkPlacementSkippedPage(plan, cursor) {
|
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
/** Native workspace diagnostics have their own allowance; campaign caps are unchanged. */
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const WORKSPACE_PLACEMENT_SCHEDULE_V1: {
|
|
3
3
|
readonly version: 1;
|
|
4
4
|
readonly daily_send_limit: 3;
|
|
5
5
|
readonly window_minutes: 30;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Every approved probe leaves within 30 minutes of approval (Philipp, 2026-10-27).
|
|
9
|
+
* Sends spread over the first `send_span_minutes`, leaving the rest of the window
|
|
10
|
+
* for the shared send rate; a probe still unsent at the deadline settles as not
|
|
11
|
+
* sent. The per-mailbox daily allowance still applies.
|
|
12
|
+
*/
|
|
13
|
+
export declare const WORKSPACE_PLACEMENT_SCHEDULE: {
|
|
14
|
+
readonly version: 2;
|
|
15
|
+
readonly daily_send_limit: 3;
|
|
16
|
+
readonly window_minutes: 30;
|
|
17
|
+
readonly send_span_minutes: 20;
|
|
18
|
+
};
|
|
19
|
+
export type WorkspacePlacementSchedule = typeof WORKSPACE_PLACEMENT_SCHEDULE_V1 | typeof WORKSPACE_PLACEMENT_SCHEDULE;
|
|
20
|
+
/** Terminal, pre-submission reasons a scheduled probe was never sent. */
|
|
21
|
+
export declare const PLACEMENT_NOT_SENT_CODES: readonly ["workspace_test_deadline_passed", "workspace_test_daily_allowance_reached"];
|
|
22
|
+
export type PlacementNotSentCode = (typeof PLACEMENT_NOT_SENT_CODES)[number];
|
|
23
|
+
export declare function isPlacementNotSentCode(value: unknown): value is PlacementNotSentCode;
|
|
24
|
+
export declare function isScheduledPlacementVersion(value: unknown): value is 1 | 2;
|
|
25
|
+
/** The outbound consumer's default fleet-wide ceiling (OXYGEN_OUTBOUND_SEND_GLOBAL_PER_MINUTE). */
|
|
26
|
+
export declare const PLACEMENT_SHARED_SEND_RATE_PER_MINUTE = 30;
|
|
27
|
+
/** Floor between two probes from one mailbox inside a version-2 window. */
|
|
28
|
+
export declare const PLACEMENT_SAME_SENDER_GAP_MS = 60000;
|
|
8
29
|
export type PlacementSlot = {
|
|
9
30
|
id: string;
|
|
10
31
|
mailbox_id: string;
|
|
11
32
|
scheduled_at: string;
|
|
12
33
|
spacing_ms: number;
|
|
34
|
+
/** Version 2 only: the approval-bound instant after which this probe never sends. */
|
|
35
|
+
deadline_at?: string;
|
|
13
36
|
};
|
|
14
37
|
export declare function placementUtcDay(at: number): number;
|
|
15
38
|
/** Deterministic estimate, also used under mailbox locks to reserve the actual schedule. */
|
|
@@ -21,13 +44,36 @@ export declare function planPlacementSlots(probes: Array<{
|
|
|
21
44
|
}>, start: Date, occupied?: Array<{
|
|
22
45
|
mailbox_id: string;
|
|
23
46
|
at: string;
|
|
24
|
-
}
|
|
47
|
+
}>, schedule?: WorkspacePlacementSchedule): PlacementSlot[];
|
|
48
|
+
/**
|
|
49
|
+
* Version 2 summaries need the window start (preview rendering or run creation):
|
|
50
|
+
* probes placed past the send span are those over a mailbox's daily allowance.
|
|
51
|
+
*/
|
|
25
52
|
export declare function placementScheduleSummary(slots: Array<{
|
|
26
53
|
scheduled_at: string;
|
|
27
|
-
}
|
|
54
|
+
}>, window?: {
|
|
55
|
+
schedule?: WorkspacePlacementSchedule;
|
|
56
|
+
start: string | Date;
|
|
57
|
+
}): {
|
|
58
|
+
first_send_at: string | null;
|
|
59
|
+
estimated_last_send_at: string | null;
|
|
60
|
+
daily_batches: number;
|
|
61
|
+
deadline_at?: never;
|
|
62
|
+
/** Over a mailbox's daily test allowance: recorded as not sent at the deadline. */
|
|
63
|
+
not_sendable_count?: never;
|
|
64
|
+
/** Planned sends per minute; above the shared ceiling some may miss the deadline. */
|
|
65
|
+
send_rate_per_minute?: never;
|
|
66
|
+
shared_send_rate_per_minute?: never;
|
|
67
|
+
} | {
|
|
28
68
|
first_send_at: string | null;
|
|
29
69
|
estimated_last_send_at: string | null;
|
|
30
70
|
daily_batches: number;
|
|
71
|
+
deadline_at: string;
|
|
72
|
+
/** Over a mailbox's daily test allowance: recorded as not sent at the deadline. */
|
|
73
|
+
not_sendable_count: number;
|
|
74
|
+
/** Planned sends per minute; above the shared ceiling some may miss the deadline. */
|
|
75
|
+
send_rate_per_minute: number;
|
|
76
|
+
shared_send_rate_per_minute: number;
|
|
31
77
|
};
|
|
32
78
|
export declare function placementProviderDirections(probes: Array<{
|
|
33
79
|
sender: {
|
|
@@ -1,16 +1,106 @@
|
|
|
1
1
|
/** Native workspace diagnostics have their own allowance; campaign caps are unchanged. */
|
|
2
|
-
export const
|
|
2
|
+
export const WORKSPACE_PLACEMENT_SCHEDULE_V1 = {
|
|
3
3
|
version: 1,
|
|
4
4
|
daily_send_limit: 3,
|
|
5
5
|
window_minutes: 30,
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Every approved probe leaves within 30 minutes of approval (Philipp, 2026-10-27).
|
|
9
|
+
* Sends spread over the first `send_span_minutes`, leaving the rest of the window
|
|
10
|
+
* for the shared send rate; a probe still unsent at the deadline settles as not
|
|
11
|
+
* sent. The per-mailbox daily allowance still applies.
|
|
12
|
+
*/
|
|
13
|
+
export const WORKSPACE_PLACEMENT_SCHEDULE = {
|
|
14
|
+
version: 2,
|
|
15
|
+
daily_send_limit: 3,
|
|
16
|
+
window_minutes: 30,
|
|
17
|
+
send_span_minutes: 20,
|
|
18
|
+
};
|
|
19
|
+
/** Terminal, pre-submission reasons a scheduled probe was never sent. */
|
|
20
|
+
export const PLACEMENT_NOT_SENT_CODES = [
|
|
21
|
+
"workspace_test_deadline_passed",
|
|
22
|
+
"workspace_test_daily_allowance_reached",
|
|
23
|
+
];
|
|
24
|
+
export function isPlacementNotSentCode(value) {
|
|
25
|
+
return PLACEMENT_NOT_SENT_CODES.includes(value);
|
|
26
|
+
}
|
|
27
|
+
export function isScheduledPlacementVersion(value) {
|
|
28
|
+
return value === 1 || value === 2;
|
|
29
|
+
}
|
|
30
|
+
/** The outbound consumer's default fleet-wide ceiling (OXYGEN_OUTBOUND_SEND_GLOBAL_PER_MINUTE). */
|
|
31
|
+
export const PLACEMENT_SHARED_SEND_RATE_PER_MINUTE = 30;
|
|
32
|
+
/** Floor between two probes from one mailbox inside a version-2 window. */
|
|
33
|
+
export const PLACEMENT_SAME_SENDER_GAP_MS = 60_000;
|
|
34
|
+
/**
|
|
35
|
+
* The slot table's CHECK floor for `spacing_ms` (version-1 spacing). Version-2 slots
|
|
36
|
+
* store it only to satisfy the column; their gate applies PLACEMENT_SAME_SENDER_GAP_MS.
|
|
37
|
+
*/
|
|
38
|
+
const SLOT_SPACING_FLOOR_MS = 900_000;
|
|
7
39
|
const DAY = 86_400_000;
|
|
8
40
|
const WINDOW = WORKSPACE_PLACEMENT_SCHEDULE.window_minutes * 60_000;
|
|
9
41
|
export function placementUtcDay(at) {
|
|
10
42
|
return Math.floor(at / DAY) * DAY;
|
|
11
43
|
}
|
|
12
44
|
/** Deterministic estimate, also used under mailbox locks to reserve the actual schedule. */
|
|
13
|
-
export function planPlacementSlots(probes, start, occupied = []) {
|
|
45
|
+
export function planPlacementSlots(probes, start, occupied = [], schedule = WORKSPACE_PLACEMENT_SCHEDULE) {
|
|
46
|
+
return schedule.version === 2
|
|
47
|
+
? planWindowSlots(probes, start, occupied)
|
|
48
|
+
: planDailySlots(probes, start, occupied);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Version 2: one window from approval. Probes interleave by each sender's rank (every
|
|
52
|
+
* sender's first probe, then every second probe) and spread evenly over the send span,
|
|
53
|
+
* so a sender's probes sit apart without a second wave. Probes beyond a mailbox's
|
|
54
|
+
* remaining daily allowance wait at the deadline, where they settle as not sent.
|
|
55
|
+
*/
|
|
56
|
+
function planWindowSlots(probes, start, occupied) {
|
|
57
|
+
const from = start.getTime();
|
|
58
|
+
const span = WORKSPACE_PLACEMENT_SCHEDULE.send_span_minutes * 60_000;
|
|
59
|
+
const deadline = new Date(from + WINDOW).toISOString();
|
|
60
|
+
const day = placementUtcDay(from);
|
|
61
|
+
const used = new Map();
|
|
62
|
+
for (const slot of occupied)
|
|
63
|
+
if (placementUtcDay(Date.parse(slot.at)) === day)
|
|
64
|
+
used.set(slot.mailbox_id, (used.get(slot.mailbox_id) ?? 0) + 1);
|
|
65
|
+
const rank = new Map();
|
|
66
|
+
const ordered = probes
|
|
67
|
+
.map((probe, index) => {
|
|
68
|
+
const r = rank.get(probe.sender.id) ?? 0;
|
|
69
|
+
rank.set(probe.sender.id, r + 1);
|
|
70
|
+
return { probe, r, index };
|
|
71
|
+
})
|
|
72
|
+
.sort((a, b) => a.r - b.r || a.index - b.index);
|
|
73
|
+
const inWindow = [];
|
|
74
|
+
const held = [];
|
|
75
|
+
for (const { probe } of ordered) {
|
|
76
|
+
const n = used.get(probe.sender.id) ?? 0;
|
|
77
|
+
if (n >= WORKSPACE_PLACEMENT_SCHEDULE.daily_send_limit)
|
|
78
|
+
held.push(probe);
|
|
79
|
+
else {
|
|
80
|
+
used.set(probe.sender.id, n + 1);
|
|
81
|
+
inWindow.push(probe);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const step = inWindow.length > 1 ? span / (inWindow.length - 1) : 0;
|
|
85
|
+
return [
|
|
86
|
+
...inWindow.map((probe, i) => ({
|
|
87
|
+
id: probe.id,
|
|
88
|
+
mailbox_id: probe.sender.id,
|
|
89
|
+
scheduled_at: new Date(from + Math.round(i * step)).toISOString(),
|
|
90
|
+
spacing_ms: SLOT_SPACING_FLOOR_MS,
|
|
91
|
+
deadline_at: deadline,
|
|
92
|
+
})),
|
|
93
|
+
...held.map((probe) => ({
|
|
94
|
+
id: probe.id,
|
|
95
|
+
mailbox_id: probe.sender.id,
|
|
96
|
+
scheduled_at: deadline,
|
|
97
|
+
spacing_ms: SLOT_SPACING_FLOOR_MS,
|
|
98
|
+
deadline_at: deadline,
|
|
99
|
+
})),
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
/** Version 1 (2026-10-23): up to three per mailbox per UTC day, each day over 30 minutes. */
|
|
103
|
+
function planDailySlots(probes, start, occupied) {
|
|
14
104
|
const groups = new Map();
|
|
15
105
|
for (const p of probes)
|
|
16
106
|
groups.set(p.sender.id, [...(groups.get(p.sender.id) ?? []), p.id]);
|
|
@@ -66,12 +156,33 @@ export function planPlacementSlots(probes, start, occupied = []) {
|
|
|
66
156
|
}
|
|
67
157
|
return result;
|
|
68
158
|
}
|
|
69
|
-
|
|
70
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Version 2 summaries need the window start (preview rendering or run creation):
|
|
161
|
+
* probes placed past the send span are those over a mailbox's daily allowance.
|
|
162
|
+
*/
|
|
163
|
+
export function placementScheduleSummary(slots, window) {
|
|
164
|
+
const all = slots.map((s) => s.scheduled_at).sort();
|
|
165
|
+
const schedule = window?.schedule;
|
|
166
|
+
if (!window || schedule?.version !== 2) {
|
|
167
|
+
return {
|
|
168
|
+
first_send_at: all[0] ?? null,
|
|
169
|
+
estimated_last_send_at: all.at(-1) ?? null,
|
|
170
|
+
daily_batches: new Set(all.map((at) => at.slice(0, 10))).size,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const start = new Date(window.start).getTime();
|
|
174
|
+
const spanEnd = start + (schedule.send_span_minutes + 1) * 60_000;
|
|
175
|
+
const times = all.filter((at) => Date.parse(at) <= spanEnd);
|
|
71
176
|
return {
|
|
72
177
|
first_send_at: times[0] ?? null,
|
|
73
178
|
estimated_last_send_at: times.at(-1) ?? null,
|
|
74
|
-
daily_batches:
|
|
179
|
+
daily_batches: times.length ? 1 : 0,
|
|
180
|
+
deadline_at: new Date(start + schedule.window_minutes * 60_000).toISOString(),
|
|
181
|
+
/** Over a mailbox's daily test allowance: recorded as not sent at the deadline. */
|
|
182
|
+
not_sendable_count: all.length - times.length,
|
|
183
|
+
/** Planned sends per minute; above the shared ceiling some may miss the deadline. */
|
|
184
|
+
send_rate_per_minute: Math.ceil(times.length / schedule.send_span_minutes),
|
|
185
|
+
shared_send_rate_per_minute: PLACEMENT_SHARED_SEND_RATE_PER_MINUTE,
|
|
75
186
|
};
|
|
76
187
|
}
|
|
77
188
|
export function placementProviderDirections(probes) {
|
|
@@ -45,6 +45,7 @@ export type WorkspacePlacementView = {
|
|
|
45
45
|
body_html_characters: number;
|
|
46
46
|
state: string;
|
|
47
47
|
status_label: string;
|
|
48
|
+
error_code?: string;
|
|
48
49
|
delivery?: {
|
|
49
50
|
id: string;
|
|
50
51
|
status: string;
|
|
@@ -67,6 +68,7 @@ export declare function workspacePlacementView(input: {
|
|
|
67
68
|
outcomes: Record<string, {
|
|
68
69
|
state: string;
|
|
69
70
|
observation?: WorkspacePlacementObservation;
|
|
71
|
+
error_code?: string;
|
|
70
72
|
}>;
|
|
71
73
|
deliveries?: Record<string, {
|
|
72
74
|
id: string;
|
|
@@ -171,5 +173,17 @@ export declare function workspacePlacementPreviewPage(plan: WorkspacePlacementPl
|
|
|
171
173
|
first_send_at: string | null;
|
|
172
174
|
estimated_last_send_at: string | null;
|
|
173
175
|
daily_batches: number;
|
|
176
|
+
deadline_at?: never;
|
|
177
|
+
not_sendable_count?: never;
|
|
178
|
+
send_rate_per_minute?: never;
|
|
179
|
+
shared_send_rate_per_minute?: never;
|
|
180
|
+
} | {
|
|
181
|
+
first_send_at: string | null;
|
|
182
|
+
estimated_last_send_at: string | null;
|
|
183
|
+
daily_batches: number;
|
|
184
|
+
deadline_at: string;
|
|
185
|
+
not_sendable_count: number;
|
|
186
|
+
send_rate_per_minute: number;
|
|
187
|
+
shared_send_rate_per_minute: number;
|
|
174
188
|
};
|
|
175
189
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { placementScheduleSummary, placementProviderDirections } from "./workspace-placement-schedule.js";
|
|
1
|
+
import { isPlacementNotSentCode, placementScheduleSummary, placementProviderDirections } from "./workspace-placement-schedule.js";
|
|
2
2
|
import { CliHttpError } from "./cli-http-error.js";
|
|
3
3
|
import { placementReceiverLabel } from "./workspace-placement.js";
|
|
4
4
|
export function workspacePlacementView(input, webUrl) {
|
|
@@ -47,16 +47,21 @@ export function workspacePlacementView(input, webUrl) {
|
|
|
47
47
|
v.send_unknown++;
|
|
48
48
|
else if (out?.state === "read_blocked")
|
|
49
49
|
v.read_blocked++;
|
|
50
|
-
const state = out?.state ?? (input.deliveries?.[p.id]?.status === "sent" ? "awaiting_results" : input.deliveries?.[p.id]?.status ?? "pending");
|
|
51
|
-
return { ...workspacePlacementProbeMeta(p), ...(input.deliveries?.[p.id]?.ready_at ? { scheduled_at: input.deliveries[p.id].ready_at } : {}), state, status_label: state === "pending" && input.plan.scheduling ? "Scheduled" : workspacePlacementStateLabel(state), ...(input.deliveries?.[p.id] ? { delivery: input.deliveries[p.id] } : {}), ...(o ? { observation: p.receiver.network_id ? { ...o, receiver_message_id: "private" } : o } : {}) };
|
|
50
|
+
const state = out?.state === "send_failed" && isPlacementNotSentCode(out.error_code) ? "not_sent" : out?.state ?? (input.deliveries?.[p.id]?.status === "sent" ? "awaiting_results" : input.deliveries?.[p.id]?.status ?? "pending");
|
|
51
|
+
return { ...workspacePlacementProbeMeta(p), ...(input.deliveries?.[p.id]?.ready_at ? { scheduled_at: input.deliveries[p.id].ready_at } : {}), state, status_label: state === "pending" && input.plan.scheduling ? "Scheduled" : workspacePlacementStateLabel(state), ...(input.deliveries?.[p.id] ? { delivery: input.deliveries[p.id] } : {}), ...(state === "not_sent" ? { error_code: out.error_code } : {}), ...(o ? { observation: p.receiver.network_id ? { ...o, receiver_message_id: "private" } : o } : {}) };
|
|
52
52
|
});
|
|
53
53
|
const settled = input.plan.probes.filter(p => input.outcomes[p.id]).length;
|
|
54
|
-
|
|
54
|
+
// A version-2 window starts at its first reserved slot; the row's creation time is
|
|
55
|
+
// only a fallback (it is the transaction start, possibly before lock waits).
|
|
56
|
+
const created = new Date(input.created_at).getTime();
|
|
57
|
+
const firstReady = Math.min(...probes.filter(p => p.scheduled_at).map(p => Date.parse(p.scheduled_at)));
|
|
58
|
+
const windowStart = Number.isFinite(firstReady) && firstReady - created < 5 * 60_000 ? new Date(firstReady) : new Date(created);
|
|
59
|
+
return { ...(input.plan.scheduling ? { provider_directions: placementProviderDirections(input.plan.probes), scheduling: input.plan.scheduling, schedule_summary: placementScheduleSummary(probes.filter(p => p.scheduled_at).map(p => ({ scheduled_at: p.scheduled_at })), { schedule: input.plan.scheduling, start: windowStart }) } : {}), id: input.id, provider: "internal", billing_mode: "internal", credits_used: 0, status: settled < probes.length ? "running" : probes.every(p => p.state === "observed") ? "completed" : "incomplete",
|
|
55
60
|
created_at: new Date(input.created_at).toISOString(), message_count: probes.length, variants: [...variants.values()], probes, plan_hash: input.plan.plan_hash, web_url: webUrl,
|
|
56
61
|
directional_note: "Observed placement in participating receiving accounts; not a campaign placement guarantee. Primary and Focused are separate provider classifications." };
|
|
57
62
|
}
|
|
58
63
|
export function workspacePlacementStateLabel(state) {
|
|
59
|
-
return { pending: "Queued", leased: "Preparing send", sent: "Awaiting receiver observation", awaiting_results: "Awaiting receiver observation", observed: "Observed", not_observed: "Not observed within two hours", send_failed: "Send failed", send_unknown: "Send outcome unknown; do not resend", read_blocked: "Receiver could not be checked", uncertain: "Send outcome unknown; do not resend", canceled: "Send canceled", failed: "Send failed" }[state] ?? "Pending";
|
|
64
|
+
return { pending: "Queued", leased: "Preparing send", sent: "Awaiting receiver observation", awaiting_results: "Awaiting receiver observation", observed: "Observed", not_observed: "Not observed within two hours", send_failed: "Send failed", not_sent: "Not sent within the 30-minute test window", send_unknown: "Send outcome unknown; do not resend", read_blocked: "Receiver could not be checked", uncertain: "Send outcome unknown; do not resend", canceled: "Send canceled", failed: "Send failed" }[state] ?? "Pending";
|
|
60
65
|
}
|
|
61
66
|
function pageNumber(value, fallback, max, field) {
|
|
62
67
|
if (value === undefined)
|
|
@@ -99,5 +104,5 @@ export function workspacePlacementProbePage(probes, input, defaultLimit = 10) {
|
|
|
99
104
|
}
|
|
100
105
|
export function workspacePlacementPreviewPage(plan, input = {}) {
|
|
101
106
|
const { probes: _probes, ...metadata } = plan;
|
|
102
|
-
return { ...metadata, ...(plan.scheduling ? { provider_directions: placementProviderDirections(plan.probes), schedule_summary: placementScheduleSummary(plan.probes.map(p => ({ scheduled_at: p.scheduled_at }))) } : {}), ...workspacePlacementProbePage(plan.probes.map(workspacePlacementProbeMeta), input, 5) };
|
|
107
|
+
return { ...metadata, ...(plan.scheduling ? { provider_directions: placementProviderDirections(plan.probes), schedule_summary: placementScheduleSummary(plan.probes.map(p => ({ scheduled_at: p.scheduled_at })), { schedule: plan.scheduling, start: plan.rendered_at ?? plan.probes[0]?.scheduled_at ?? new Date(0) }) } : {}), ...workspacePlacementProbePage(plan.probes.map(workspacePlacementProbeMeta), input, 5) };
|
|
103
108
|
}
|