@xema/omni-protocol 0.1.129 → 0.1.130

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/testing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { browserSessionKey, sameCapabilities, } from "./index.js";
2
- import { assertNoViolations, validateAuthenticationState, validateBreakTransition, validateEventEnvelope, validateHostGuarantees, validateHostReport, validateUserDetails, observeRules, ruleTested, validateHostMute, validateHostRecording, validateLoginStore, validateHistoryReport, validateManifest, validateResult, validateSnapshot, validateTask, validateLanguages, validateTimeZone, validatePhone, validateTaskCommand, isTimeZone, sameTimeZone, } from "./validation.js";
2
+ import { assertNoViolations, validateAuthenticationState, validateBreakTransition, validateEventEnvelope, validateHostGuarantees, validateHostReport, validateUserDetails, observeRules, ruleTested, validateHostMute, validateHostRecording, validateSessionStore, validateHistoryReport, validateManifest, validateResult, validateSnapshot, validateTask, validateLanguages, validateTimeZone, validatePhone, validateTaskCommand, isTimeZone, sameTimeZone, } from "./validation.js";
3
3
  export { ProtocolConformanceError, assertNoViolations } from "./validation.js";
4
4
  /**
5
5
  * A part of the contract a run may never reach: state nothing obliges an adapter to publish, so
@@ -84,11 +84,8 @@ function observeTask(value, seen) {
84
84
  const capabilities = isRecord(value.capabilities) ? value.capabilities : {};
85
85
  if (isRecord(capabilities.outcomes))
86
86
  seen.add("task.outcomes");
87
- for (const directory of ["coldTransfer", "warmTransfer", "conference"]) {
88
- const declared = capabilities[directory];
89
- if (isRecord(declared) && some(declared.destinations))
90
- seen.add("task.destinations");
91
- }
87
+ if (isRecord(capabilities.addToCall) && typeof capabilities.addToCall.destinations === "string")
88
+ seen.add("task.destinations");
92
89
  if (some(capabilities.custom))
93
90
  seen.add("task.custom");
94
91
  if (Object.values(capabilities).some(declared => isRecord(declared) && declared.lockedBy !== undefined))
@@ -215,7 +212,7 @@ function observeEvent(envelope, seen) {
215
212
  * Adapter conformance exercise: validates the manifest, opens an authenticated session,
216
213
  * connects, checks that every method the declarations require is implemented, subscribes,
217
214
  * validates the snapshot, every delivered event, and every authentication state the session
218
- * publishes during the run -- against the latest login, since capabilities are current, not
215
+ * publishes during the run -- against the latest session, since capabilities are current, not
219
216
  * fixed -- states a capacity, then unsubscribes and disconnects.
220
217
  *
221
218
  * Violations are collected rather than thrown from inside the adapter's own
@@ -249,7 +246,7 @@ export async function testAdapter(adapter, context, options = {}) {
249
246
  let unsubscribeAuthentication;
250
247
  let unsubscribeHost;
251
248
  let authenticationState;
252
- let login;
249
+ let signedIn;
253
250
  let disconnectWasClean = false;
254
251
  try {
255
252
  authenticationState = await authentication.state();
@@ -258,18 +255,18 @@ export async function testAdapter(adapter, context, options = {}) {
258
255
  if (authenticationState.status !== "authenticated") {
259
256
  throw new Error(`Adapter contract exercise requires authenticated test state, received ${authenticationState.status}`);
260
257
  }
261
- // The harness knows who is signed in and what their login declares, so it can hold the
258
+ // The harness knows who is signed in and what their capabilities include, so it can hold the
262
259
  // adapter to rules the structural validators cannot check alone: a team member list never carries the
263
260
  // agent it is published to, a lead's snapshot always carries one, nobody else's ever does.
264
- // Capabilities are current, not fixed, so the login is read when something is validated,
261
+ // Capabilities are current, not fixed, so the session is read when something is validated,
265
262
  // never captured at sign-in: a provider that withdraws one republishes `authenticated`, and
266
263
  // everything published after that is held to the new set. A published state that fails
267
- // validation is reported and not adopted -- the harness keeps the last login it could trust.
268
- login = authenticationState;
264
+ // validation is reported and not adopted -- the harness keeps the last session it could trust.
265
+ signedIn = authenticationState;
269
266
  const current = () => {
270
- if (login === undefined)
271
- throw new Error("unreachable: the exercise has an authenticated login");
272
- return login;
267
+ if (signedIn === undefined)
268
+ throw new Error("unreachable: the exercise has an authenticated session");
269
+ return signedIn;
273
270
  };
274
271
  // Off until the application has said otherwise: the provider assumes nothing of the team feature.
275
272
  let leadFeaturesOn = false;
@@ -278,7 +275,7 @@ export async function testAdapter(adapter, context, options = {}) {
278
275
  capabilities: current().capabilities,
279
276
  leadFeatures: leadFeaturesOn,
280
277
  phone: context.phone,
281
- loginId: context.loginId,
278
+ sessionId: context.sessionId,
282
279
  autoAcceptTasks: context.autoAcceptTasks,
283
280
  locked: options.lockedValues,
284
281
  });
@@ -301,19 +298,19 @@ export async function testAdapter(adapter, context, options = {}) {
301
298
  // The four stand or fall together: `granted` is a promise to honour a later commit, and
302
299
  // an adapter with requestBreak but no commitBreak leaves an agent a break that never starts.
303
300
  for (const method of ["requestBreak", "commitBreak", "cancelBreak", "endBreak"]) {
304
- requireMethod(on, method, "the login declares capabilities.breaks");
301
+ requireMethod(on, method, "the user's capabilities include breaks");
305
302
  }
306
303
  }
307
- if (capabilities.lead === true)
308
- requireMethod(on, "executeTeam", "the login declares capabilities.lead");
304
+ if (capabilities.lead !== undefined)
305
+ requireMethod(on, "executeTeam", "the user's capabilities include lead");
309
306
  if (capabilities.nextCall === true) {
310
307
  // The ask, its withdrawal and the release stand together: a lined-up call the agent could neither withdraw nor let go is a promise with no way out.
311
308
  for (const method of ["requestNextCall", "cancelNextCall", "releaseLinedUp"]) {
312
- requireMethod(on, method, "the login declares capabilities.nextCall");
309
+ requireMethod(on, method, "the user's capabilities include nextCall");
313
310
  }
314
311
  }
315
312
  if (some(capabilities.preferences))
316
- requireMethod(on, "setPreference", "the login declares capabilities.preferences");
313
+ requireMethod(on, "setPreference", "the user's capabilities include preferences");
317
314
  };
318
315
  const onAuthenticationState = (state) => {
319
316
  const own = validateAuthenticationState(state, "authentication", { levels });
@@ -335,7 +332,7 @@ export async function testAdapter(adapter, context, options = {}) {
335
332
  violations.push(...refreshingCarriesOver(current(), state, "authentication"));
336
333
  }
337
334
  else if (state.status === "authenticated") {
338
- login = state;
335
+ signedIn = state;
339
336
  // A capability granted later requires its methods just as one declared at sign-in does.
340
337
  if (connection !== undefined)
341
338
  requireCapabilityMethods(connection, state.capabilities);
@@ -360,16 +357,16 @@ export async function testAdapter(adapter, context, options = {}) {
360
357
  violations.push(...validateHostReport(first, "context.host"));
361
358
  const hasAudio = isRecord(first) && first.audio !== undefined;
362
359
  if (softphone && !hasAudio) {
363
- violations.push({ rule: "context.host.audio.required", path: "context.host.audio", message: "a softphone login's host reports its audio" });
360
+ violations.push({ rule: "context.host.audio.required", path: "context.host.audio", message: "a softphone session's host reports its audio" });
364
361
  }
365
362
  if (!softphone && hasAudio) {
366
363
  violations.push({ rule: "context.host.audio.unexpected", path: "context.host.audio",
367
- message: adapter.manifest.channel === "voice" ? "a hardphone login has no audio in the host to report" : `a ${adapter.manifest.channel} connection has no audio for the host to report` });
364
+ message: adapter.manifest.channel === "voice" ? "a hardphone session has no audio in the host to report" : `a ${adapter.manifest.channel} connection has no audio for the host to report` });
368
365
  }
369
366
  // What the host's Mute does is stated where the host holds a microphone, and nowhere else.
370
367
  violations.push(...validateHostMute(context.host.mute, softphone, "context.host.mute"));
371
- // The login's store is the host's to provide: an adapter that composes a record keeps in it what its platform cannot.
372
- const storeShape = validateLoginStore(context.store, "context.store");
368
+ // The session's store is the host's to provide: an adapter that composes a record keeps in it what its platform cannot.
369
+ const storeShape = validateSessionStore(context.store, "context.store");
373
370
  violations.push(...storeShape);
374
371
  // The harness watches the store it hands over, so what an adapter leaves behind is seen rather than asked for.
375
372
  const watched = storeShape.length === 0 ? watchStore(context.store) : { store: context.store, held: new Set(), everHeld: new Set() };
@@ -412,11 +409,11 @@ export async function testAdapter(adapter, context, options = {}) {
412
409
  requireMethod(on, "dial", "the manifest declares dial");
413
410
  // On a softphone the call's audio lands in Omni, so the adapter has to open it; on a hardphone the host opens nothing.
414
411
  if (softphone)
415
- requireMethod(on, "openAudio", "the login is on a softphone");
412
+ requireMethod(on, "openAudio", "the session is on a softphone");
416
413
  // The microphone is the host's, so on a softphone every call can be muted by it, and the
417
414
  // record of that leg is the provider's to take; on a hardphone the host holds no microphone.
418
415
  if (softphone)
419
- requireMethod(on, "recordStep", "the login is on a softphone, whose microphone the host mutes");
416
+ requireMethod(on, "recordStep", "the session is on a softphone, whose microphone the host mutes");
420
417
  };
421
418
  connectObligations(live);
422
419
  const tellRefused = (report) => {
@@ -486,7 +483,7 @@ export async function testAdapter(adapter, context, options = {}) {
486
483
  if (earlier !== undefined) {
487
484
  if (earlier !== payload) {
488
485
  violations.push({ rule: "event.id.reused", path: "event.id",
489
- message: `envelope ${envelope.id} was delivered again with a different event: an id names one event for the life of the login` });
486
+ message: `envelope ${envelope.id} was delivered again with a different event: an id names one event for the life of the session` });
490
487
  }
491
488
  return;
492
489
  }
@@ -537,8 +534,8 @@ export async function testAdapter(adapter, context, options = {}) {
537
534
  authentication = session;
538
535
  connection = second;
539
536
  live = second;
540
- // The second client is held to everything the first was on connect: its methods, its login's
541
- // methods, the login it publishes from here, and a capacity stated to it, since the first's
537
+ // The second client is held to everything the first was on connect: its methods, its session's
538
+ // methods, the session it publishes from here, and a capacity stated to it, since the first's
542
539
  // statement died with the first and nothing may be assigned against a count nobody stated to it.
543
540
  connectObligations(second);
544
541
  requireCapabilityMethods(second, current().capabilities);
@@ -660,7 +657,7 @@ export async function testAdapter(adapter, context, options = {}) {
660
657
  // reaches the lead, which the reader held the connect snapshot to. A reloaded client is a
661
658
  // connect too: it is told again, after its capacity, and held the same way.
662
659
  const switchOnLeadFeatures = async (on, at) => {
663
- if (current().capabilities.lead !== true || typeof on.executeTeam !== "function")
660
+ if (current().capabilities.lead === undefined || typeof on.executeTeam !== "function")
664
661
  return;
665
662
  const from = events.length;
666
663
  let switched;
@@ -789,7 +786,7 @@ export async function testAdapter(adapter, context, options = {}) {
789
786
  return {
790
787
  events: events,
791
788
  authenticationState: authenticationState,
792
- login: (login ?? authenticationState),
789
+ signedIn: (signedIn ?? authenticationState),
793
790
  notTested: CONTRACT_SUBJECTS.filter(subject => !seen.has(subject)),
794
791
  disconnectWasClean,
795
792
  violations,
@@ -887,23 +884,23 @@ function eventNamesUsers(envelope) {
887
884
  }
888
885
  }
889
886
  /**
890
- * `refreshing` carries the identity and capabilities of the login it refreshes. A change to
891
- * either is published as `authenticated`; a different identity is a new login.
887
+ * `refreshing` carries the identity and capabilities of the session it refreshes. A change to
888
+ * either is published as `authenticated`; a different identity is a new session.
892
889
  */
893
- function refreshingCarriesOver(login, state, path) {
890
+ function refreshingCarriesOver(signedIn, state, path) {
894
891
  const found = [];
895
- if (state.identity.id !== login.identity.id) {
892
+ if (state.identity.id !== signedIn.identity.id) {
896
893
  found.push({
897
894
  rule: "authentication.refreshing.identity",
898
895
  path: `${path}.identity.id`,
899
- message: "refreshing carries the identity of the login it refreshes; a different identity is a new login",
896
+ message: "refreshing carries the identity of the session it refreshes; a different identity is a new session",
900
897
  });
901
898
  }
902
- if (!sameCapabilities(state.capabilities, login.capabilities)) {
899
+ if (!sameCapabilities(state.capabilities, signedIn.capabilities)) {
903
900
  found.push({
904
901
  rule: "authentication.refreshing.capabilities",
905
902
  path: `${path}.capabilities`,
906
- message: "refreshing carries the capabilities of the login it refreshes; a change is published as authenticated",
903
+ message: "refreshing carries the capabilities of the session it refreshes; a change is published as authenticated",
907
904
  });
908
905
  }
909
906
  return found;
@@ -958,10 +955,10 @@ function connectingReports(context, violations) {
958
955
  settled: () => { settled = true; },
959
956
  };
960
957
  }
961
- /** Validates each state of a published sequence, and that every `refreshing` carries over the login before it. */
962
- function assertLoginSequence(states, levels, summary) {
958
+ /** Validates each state of a published sequence, and that every `refreshing` carries over the session before it. */
959
+ function assertSignedInSequence(states, levels, summary) {
963
960
  const found = [];
964
- let login;
961
+ let signedIn;
965
962
  states.forEach((state, index) => {
966
963
  const path = `states[${index}]`;
967
964
  const own = validateAuthenticationState(state, path, { levels });
@@ -969,18 +966,18 @@ function assertLoginSequence(states, levels, summary) {
969
966
  if (own.length > 0)
970
967
  return;
971
968
  if (state.status === "authenticated")
972
- login = state;
973
- else if (state.status === "refreshing" && login !== undefined)
974
- found.push(...refreshingCarriesOver(login, state, path));
969
+ signedIn = state;
970
+ else if (state.status === "refreshing" && signedIn !== undefined)
971
+ found.push(...refreshingCarriesOver(signedIn, state, path));
975
972
  });
976
973
  assertNoViolations(found, summary);
977
974
  }
978
975
  /**
979
976
  * Validates restored authentication followed by a refresh failure or expiry. Every state is
980
- * validated against the manifest's levels, and a `refreshing` state must carry over the login it refreshes.
977
+ * validated against the manifest's levels, and a `refreshing` state must carry over the session it refreshes.
981
978
  */
982
979
  export function assertAuthenticationRestoreAndExpiry(states, manifest) {
983
- assertLoginSequence(states, declaredLevels(manifest), "Authentication scenario");
980
+ assertSignedInSequence(states, declaredLevels(manifest), "Authentication scenario");
984
981
  if (states.length < 2 || states[0]?.status !== "authenticated") {
985
982
  throw new Error("Authentication scenario must start with a restored authenticated state");
986
983
  }
@@ -1039,34 +1036,34 @@ function notYetReadTasks(tasks, path) {
1039
1036
  * Capabilities are current, not fixed. A provider that withdraws one republishes `authenticated`
1040
1037
  * with the new set, and the next snapshot agrees with it. `states` is what the authentication
1041
1038
  * session published, first to last: beginning and ending `authenticated` for the same identity,
1042
- * passing only through usable states (`expired`, `terminated` or `signed-out` ends the login instead), with at
1039
+ * passing only through usable states (`expired`, `terminated` or `signed-out` ends the session instead), with at
1043
1040
  * least one capability gone by the end. `snapshot` is the first snapshot published after the last
1044
- * state, validated against that login -- so a team member list still published to a login that no longer
1041
+ * state, validated against that sign-in -- so a team member list still published to a session that no longer
1045
1042
  * leads, or requests to one that may no longer join, is the failure.
1046
1043
  */
1047
1044
  export function assertCapabilityWithdrawal(states, snapshot, manifest) {
1048
- assertLoginSequence(states, declaredLevels(manifest), "Capability withdrawal");
1045
+ assertSignedInSequence(states, declaredLevels(manifest), "Capability withdrawal");
1049
1046
  const stray = states.findIndex(state => state.status !== "authenticated" && state.status !== "refreshing");
1050
1047
  if (stray >= 0) {
1051
- throw new Error(`Capability withdrawal passes only through usable states; states[${stray}] is ${states[stray]?.status}, which ends the login`);
1048
+ throw new Error(`Capability withdrawal passes only through usable states; states[${stray}] is ${states[stray]?.status}, which ends the session`);
1052
1049
  }
1053
1050
  const first = states[0];
1054
1051
  const last = states.at(-1);
1055
1052
  if (first?.status !== "authenticated" || last?.status !== "authenticated") {
1056
- throw new Error("Capability withdrawal must begin and end with an authenticated login");
1053
+ throw new Error("Capability withdrawal must begin and end with an authenticated session");
1057
1054
  }
1058
1055
  if (first.identity.id !== last.identity.id) {
1059
- throw new Error("Capability withdrawal must keep the identity: a different identity is a new login");
1056
+ throw new Error("Capability withdrawal must keep the identity: a different identity is a new session");
1060
1057
  }
1061
1058
  const before = first.capabilities;
1062
1059
  const after = last.capabilities;
1063
1060
  const withdrawn = (before.breaks === true && after.breaks !== true) ||
1064
- (before.lead === true && after.lead !== true) ||
1061
+ Object.keys(before.lead ?? {}).some(name => after.lead?.[name] !== true) ||
1065
1062
  (before.preferences ?? []).some(was => !(after.preferences ?? []).some(now => now.id === was.id));
1066
1063
  if (!withdrawn) {
1067
- throw new Error("Capability withdrawal must end with at least one capability the first login declared withdrawn");
1064
+ throw new Error("Capability withdrawal must end with at least one capability the first session declared withdrawn");
1068
1065
  }
1069
- assertNoViolations(validateSnapshot(snapshot, manifest, "snapshot", { self: last.identity.id, capabilities: after }), "Capability withdrawal: the snapshot after the last login must agree with it");
1066
+ assertNoViolations(validateSnapshot(snapshot, manifest, "snapshot", { self: last.identity.id, capabilities: after }), "Capability withdrawal: the snapshot after the last session must agree with it");
1070
1067
  }
1071
1068
  /**
1072
1069
  * A command that arrives after its capability was withdrawn is answered `failed` with
@@ -1692,14 +1689,14 @@ async function testOneCall(call) {
1692
1689
  try {
1693
1690
  const restoredSession = await again.createAuthenticationSession({ ...call.context, secrets: call.secrets });
1694
1691
  // The reload is a restore before it is anything else: the second session stands authenticated
1695
- // as the same person, from the secrets alone, or nothing it reads afterwards is this login's.
1692
+ // as the same person, from the secrets alone, or nothing it reads afterwards is this session's.
1696
1693
  const restored = await restoredSession.state();
1697
- found.push(...validateAuthenticationState(restored, "test.reload.login", { levels: declaredLevels(call.manifest) }));
1698
- ruleTested("test.reload.login");
1694
+ found.push(...validateAuthenticationState(restored, "test.reload.session", { levels: declaredLevels(call.manifest) }));
1695
+ ruleTested("test.reload.session");
1699
1696
  const same = isRecord(restored) && restored.status === "authenticated" && isRecord(restored.identity) && restored.identity.id === call.reader().self;
1700
1697
  if (!same) {
1701
- refuse("test.reload.login", "test.reload.login", `a second adapter built from the same login and secrets did not restore it: the session says ${String(isRecord(restored) ? restored.status : restored)}${isRecord(restored) && isRecord(restored.identity) ? ` as ${String(restored.identity.id)}` : ""}, and the login is ${String(call.reader().self)}`);
1702
- // A reload that cannot restore the login is a sign-in screen, not a connection: the run ends here.
1698
+ refuse("test.reload.session", "test.reload.session", `a second adapter built from the same session and secrets did not restore it: the authentication session says ${String(isRecord(restored) ? restored.status : restored)}${isRecord(restored) && isRecord(restored.identity) ? ` as ${String(restored.identity.id)}` : ""}, and the session is ${String(call.reader().self)}`);
1699
+ // A reload that cannot restore the session is a sign-in screen, not a connection: the run ends here.
1703
1700
  try {
1704
1701
  await restoredSession.close();
1705
1702
  }
@@ -1730,7 +1727,7 @@ async function testOneCall(call) {
1730
1727
  ? snapshot.tasks.find(task => isRecord(task) && task.assignmentId === taskId) : undefined;
1731
1728
  ruleTested("test.reload.snapshot");
1732
1729
  if (carried === undefined) {
1733
- refuse("test.reload.snapshot", "test.reload.snapshot", `a second adapter built from the same login does not carry ${taskId} on its snapshot, and the task is still open`);
1730
+ refuse("test.reload.snapshot", "test.reload.snapshot", `a second adapter built from the same session does not carry ${taskId} on its snapshot, and the task is still open`);
1734
1731
  return;
1735
1732
  }
1736
1733
  ruleTested("test.reload.history");
@@ -1742,11 +1739,11 @@ async function testOneCall(call) {
1742
1739
  const lost = wasRead.filter(entry => !steps.some(now => isRecord(now) && now.step === entry.step && now.at === entry.at))
1743
1740
  .map(entry => `${String(entry.step)}@${String(entry.at)}`);
1744
1741
  if (lost.length > 0) {
1745
- refuse("test.reload.history", "test.reload.history", `a second adapter built from the same login carries ${taskId} without ${lost.join(", ")}, which the first had published: a record once read is not unread`);
1742
+ refuse("test.reload.history", "test.reload.history", `a second adapter built from the same session carries ${taskId} without ${lost.join(", ")}, which the first had published: a record once read is not unread`);
1746
1743
  }
1747
1744
  const leg = steps.find(entry => isRecord(entry) && entry.step === "muted" && entry.at === at);
1748
1745
  if (leg === undefined) {
1749
- refuse("test.reload.history", "test.reload.history", `a second adapter built from the same login carries ${taskId} without the muted leg at ${at}: the record was composed in memory and died with the adapter; the login's store is where it lives`);
1746
+ refuse("test.reload.history", "test.reload.history", `a second adapter built from the same session carries ${taskId} without the muted leg at ${at}: the record was composed in memory and died with the adapter; the session's store is where it lives`);
1750
1747
  }
1751
1748
  else if (leg.mutedBy !== "host") {
1752
1749
  refuse("test.reload.history", "test.reload.history", `the reloaded record's muted leg at ${at} says mutedBy ${String(leg.mutedBy)}; the host reported host`);
@@ -1772,7 +1769,7 @@ async function testOneCall(call) {
1772
1769
  if (malformed.length === 0 && isRecord(reopened) && reopened.status === "opened")
1773
1770
  session = reopened.audio;
1774
1771
  else if (malformed.length === 0)
1775
- refuse("test.reload.openAudio", "test.reload.openAudio", `a second adapter built from the same login could not open the audio of ${taskId}, which its own snapshot carries with audio started`);
1772
+ refuse("test.reload.openAudio", "test.reload.openAudio", `a second adapter built from the same session could not open the audio of ${taskId}, which its own snapshot carries with audio started`);
1776
1773
  }
1777
1774
  }
1778
1775
  catch (error) {
@@ -1794,7 +1791,7 @@ async function testOneCall(call) {
1794
1791
  if (call.everHeldForTask(taskId))
1795
1792
  ruleTested("test.store.retained");
1796
1793
  if (retained.length > 0) {
1797
- refuse("test.store.retained", "test.store", `${taskId} has ended and the login's store still holds ${retained.join(", ")}: a task's keys go with the task, or the next offer of the same id inherits them`);
1794
+ refuse("test.store.retained", "test.store", `${taskId} has ended and the session's store still holds ${retained.join(", ")}: a task's keys go with the task, or the next offer of the same id inherits them`);
1798
1795
  }
1799
1796
  };
1800
1797
  // A key written about the task after its end -- a persist hung off a timer, a late command -- is the
@@ -1805,7 +1802,7 @@ async function testOneCall(call) {
1805
1802
  ruleTested("test.store.late");
1806
1803
  const late = [...call.held].filter(key => namesTask(key, taskId) && !retainedAtEnd.has(key));
1807
1804
  if (late.length > 0) {
1808
- refuse("test.store.late", "test.store", `${taskId} had ended with its keys gone, and the login's store now holds ${late.join(", ")}: something wrote about the task after its end`);
1805
+ refuse("test.store.late", "test.store", `${taskId} had ended with its keys gone, and the session's store now holds ${late.join(", ")}: something wrote about the task after its end`);
1809
1806
  }
1810
1807
  };
1811
1808
  // The task, as first seen: on the snapshot, or on the first offer.
@@ -1999,7 +1996,7 @@ async function testOneCall(call) {
1999
1996
  if (malformed.length === 0 && isRecord(opened) && opened.status === "opened")
2000
1997
  session = opened.audio;
2001
1998
  else if (malformed.length === 0 && isRecord(opened))
2002
- refuse("test.openAudio.unavailable", "test.openAudio", "a softphone login's adapter could not open the call's audio");
1999
+ refuse("test.openAudio.unavailable", "test.openAudio", "a softphone session's adapter could not open the call's audio");
2003
2000
  }
2004
2001
  // 3b. The microphone is the host's. With the audio open, the test mutes it for a moment and
2005
2002
  // reports the leg the provider's record would otherwise miss -- begun, then ended -- and
@@ -2064,8 +2061,8 @@ async function testOneCall(call) {
2064
2061
  setMuted(false);
2065
2062
  await report({ at, seconds: Math.round((Date.now() - began) / 1000), ended: true });
2066
2063
  reportedLegs.push({ at: canonicalTimes.get(at), task: latestTask() });
2067
- // 3c. A host reload destroys the adapter object and keeps the login's store. Built again from
2068
- // the same login, a second adapter carries the task and the leg -- from its platform, or from
2064
+ // 3c. A host reload destroys the adapter object and keeps the session's store. Built again from
2065
+ // the same session, a second adapter carries the task and the leg -- from its platform, or from
2069
2066
  // the store -- or it composed the record in memory and the record died with it.
2070
2067
  if (call.rebuild !== undefined && canonicalTimes.has(at)) {
2071
2068
  await recordSurvivesReload(canonicalTimes.get(at));
@@ -2074,7 +2071,7 @@ async function testOneCall(call) {
2074
2071
  return found;
2075
2072
  }
2076
2073
  }
2077
- // The host's Mute is unavailable on hold, and the host promised as much at login: a host holds the
2074
+ // The host's Mute is unavailable on hold, and the host promised as much at sign-in: a host holds the
2078
2075
  // report back (historyReport.muted.held), and an adapter that receives one anyway must refuse it --
2079
2076
  // so the test sends a mute begun on hold past the validator and expects failed.
2080
2077
  const muteRefusedOnHold = async () => {
@@ -2359,7 +2356,7 @@ export class BreakStream {
2359
2356
  recovery = true;
2360
2357
  /** True until a validated authoritative snapshot establishes a usable baseline. */
2361
2358
  get needsRecovery() { return this.recovery; }
2362
- /** Caller establishes snapshot freshness/login scope separately; malformed state never replaces the baseline. */
2359
+ /** Caller establishes snapshot freshness/session scope separately; malformed state never replaces the baseline. */
2363
2360
  seed(snapshot) {
2364
2361
  const state = isRecord(snapshot) ? snapshot.break : undefined;
2365
2362
  const found = validateBreakTransition(state, state, "snapshot.break");
@@ -2434,7 +2431,7 @@ function watchStore(store) {
2434
2431
  },
2435
2432
  };
2436
2433
  }
2437
- /** A login store that lives in memory for the test: what most adapter tests hand `testAdapter` as `context.store`. */
2434
+ /** A session store that lives in memory for the test: what most adapter tests hand `testAdapter` as `context.store`. */
2438
2435
  export function memoryStore() {
2439
2436
  const kept = new Map();
2440
2437
  return {
@@ -2469,7 +2466,7 @@ export function assertHistoryAgreesAcrossTasks(earlier, later) {
2469
2466
  }
2470
2467
  before.forEach((step, index) => {
2471
2468
  const restated = after[index];
2472
- for (const field of ["step", "at", "by", "dialId", "destinationId", "mutedBy"]) {
2469
+ for (const field of ["step", "at", "by", "dialId", "contactId", "mutedBy"]) {
2473
2470
  if (step[field] !== restated[field]) {
2474
2471
  throw new Error(`steps[${index}].${field} is ${String(step[field])} on ${earlier.assignmentId} and ${String(restated[field])} on ${later.assignmentId}: one call has one history`);
2475
2472
  }
@@ -2479,12 +2476,12 @@ export function assertHistoryAgreesAcrossTasks(earlier, later) {
2479
2476
  }
2480
2477
  });
2481
2478
  }
2482
- const usableLogin = (status) => status === "authenticated" || status === "refreshing";
2479
+ const usableSession = (status) => status === "authenticated" || status === "refreshing";
2483
2480
  /**
2484
2481
  * A break one provider forces stops the agent everywhere: the host states a capacity of zero on
2485
2482
  * every other usable provider holding capacity -- taken, never refused, and nothing the agent can
2486
2483
  * cancel -- and on the forcing provider states nothing, since the break itself holds the agent
2487
- * there. A provider whose login is not usable is left alone, as a break attempt leaves it.
2484
+ * there. A provider whose session is not usable is left alone, as a break attempt leaves it.
2488
2485
  */
2489
2486
  export function assertForcedBreakStopsTheRest(forcedOn, candidates, stopped) {
2490
2487
  if (!candidates.some(candidate => candidate.id === forcedOn))
@@ -2499,19 +2496,19 @@ export function assertForcedBreakStopsTheRest(forcedOn, candidates, stopped) {
2499
2496
  for (const candidate of candidates) {
2500
2497
  if (candidate.id === forcedOn)
2501
2498
  continue;
2502
- const expected = usableLogin(candidate.authentication) && candidate.holdsCapacity;
2499
+ const expected = usableSession(candidate.authentication) && candidate.holdsCapacity;
2503
2500
  if (expected && !chosen.has(candidate.id)) {
2504
2501
  throw new Error(`${candidate.id} can give the agent work and must be stopped: capacity 0 stated`);
2505
2502
  }
2506
2503
  if (!expected && chosen.has(candidate.id)) {
2507
- const why = usableLogin(candidate.authentication) ? "holds no capacity" : `is ${candidate.authentication}`;
2504
+ const why = usableSession(candidate.authentication) ? "holds no capacity" : `is ${candidate.authentication}`;
2508
2505
  throw new Error(`${candidate.id} ${why} and is not stopped: there is nothing to stop`);
2509
2506
  }
2510
2507
  }
2511
2508
  }
2512
2509
  /**
2513
2510
  * A break attempt asks every connected provider from which the agent can currently receive work.
2514
- * A provider whose login is not usable -- `expired` above all -- is not asked, whatever else is
2511
+ * A provider whose session is not usable -- `expired` above all -- is not asked, whatever else is
2515
2512
  * true of it: nothing can be asked of it, and a host that waits on it stalls the break for
2516
2513
  * everyone. A usable provider holding capacity is asked, and cannot be left out. `refreshing` is
2517
2514
  * usable: identity and capabilities remain available and work continues.
@@ -2523,12 +2520,12 @@ export function assertBreakAttemptProviders(candidates, asked) {
2523
2520
  throw new Error(`${id} is not a provider the host knows`);
2524
2521
  }
2525
2522
  for (const candidate of candidates) {
2526
- const expected = usableLogin(candidate.authentication) && candidate.holdsCapacity;
2523
+ const expected = usableSession(candidate.authentication) && candidate.holdsCapacity;
2527
2524
  if (expected && !chosen.has(candidate.id)) {
2528
2525
  throw new Error(`${candidate.id} can give the agent work and must be asked`);
2529
2526
  }
2530
2527
  if (!expected && chosen.has(candidate.id)) {
2531
- const why = usableLogin(candidate.authentication) ? "holds no capacity" : `is ${candidate.authentication}`;
2528
+ const why = usableSession(candidate.authentication) ? "holds no capacity" : `is ${candidate.authentication}`;
2532
2529
  throw new Error(`${candidate.id} ${why} and is not asked: nothing can be asked of it`);
2533
2530
  }
2534
2531
  }
@@ -18,7 +18,7 @@ export declare function ruleTested(...rules: readonly string[]): void;
18
18
  export declare function validateContact(contact: unknown, levels: readonly string[], path?: string): ProtocolViolation[];
19
19
  export declare function validateScheduledActivity(activity: unknown, levels: readonly string[], path?: string): ProtocolViolation[];
20
20
  /**
21
- * The host's choice of phone for a login, held to the manifest: one the platform listed, required
21
+ * The host's choice of phone for a session, held to the manifest: one the platform listed, required
22
22
  * on voice, absent elsewhere.
23
23
  */
24
24
  export declare function validatePhone(value: unknown, manifest: unknown, path?: string): ProtocolViolation[];
@@ -28,7 +28,7 @@ export declare function validateProviderTimeEstimate(value: unknown, scope: unkn
28
28
  export declare function validateProviderTimeCheckPolicy(value: unknown, path?: string): ProtocolViolation[];
29
29
  export declare function validateProviderTimeCheckRequest(value: unknown, path?: string): ProtocolViolation[];
30
30
  /** Checks response shape/correlation, not source-clock accuracy, round-trip delay or freshness. */
31
- export declare function validateProviderTimeCheckResult(value: unknown, request: unknown, loginId: string, path?: string): ProtocolViolation[];
31
+ export declare function validateProviderTimeCheckResult(value: unknown, request: unknown, sessionId: string, path?: string): ProtocolViolation[];
32
32
  export declare function validateManifest(manifest: unknown, path?: string): ProtocolViolation[];
33
33
  /** The agent's languages, as a host states them on both contexts: BCP 47 tags, most preferred first, at least one. */
34
34
  export declare function validateLanguages(value: unknown, path?: string): ProtocolViolation[];
@@ -46,7 +46,7 @@ export interface TaskValidationContext {
46
46
  /** Whether the manifest declares the `calendar` idle capability. A task that may schedule needs it to; absent, the question is not asked. */
47
47
  calendarDeclared?: boolean;
48
48
  /**
49
- * The values the queue locked on this login's tasks -- a party's number or email -- as whoever
49
+ * The values the queue locked on this session's tasks -- a party's number or email -- as whoever
50
50
  * runs the validator knows them. Where a task's party stands locked, no other field of it may
51
51
  * carry one of these. Unknown to a host, which never sees the value, and then unchecked.
52
52
  */
@@ -64,7 +64,7 @@ export declare function validateBreakStatus(state: unknown, tasks: unknown, path
64
64
  /**
65
65
  * Checks a lead command before dispatch, against the current authentication, transport and team
66
66
  * member list (`team`) and, for force-break and end-forced-break, the target's full `memberBreak`.
67
- * The authority is the login's `lead` flag; the provider rechecks the target and the state
67
+ * The authority is the lead capability the command needs, on the session's `lead`; the provider rechecks the target and the state
68
68
  * atomically, since a team member list is not authority to act after it has changed.
69
69
  */
70
70
  export declare function validateTeamCommand(request: unknown, context: unknown, path?: string): ProtocolViolation[];
@@ -77,7 +77,7 @@ export type BreakMethod = "requestBreak" | "commitBreak" | "cancelBreak" | "endB
77
77
  */
78
78
  export declare function validateBreakCommand(method: BreakMethod, request: unknown, state: unknown, context: unknown, path?: string): ProtocolViolation[];
79
79
  /**
80
- * Checks two complete break states within one provider/login's ordered event stream.
80
+ * Checks two complete break states within one provider/session's ordered event stream.
81
81
  * Call before replacing accepted state; report violations and reconcile on failure.
82
82
  * This is not a freshness check: validate a fresh authoritative snapshot separately and
83
83
  * use it as a new baseline, never as an event transition. Source ordering and connection
@@ -85,8 +85,8 @@ export declare function validateBreakCommand(method: BreakMethod, request: unkno
85
85
  */
86
86
  export declare function validateBreakTransition(before: unknown, after: unknown, path?: string): ProtocolViolation[];
87
87
  /**
88
- * Who is reading what the adapter published, and what their login declares. The validators check
89
- * structure without it; given it, they also hold what the adapter publishes to the login.
88
+ * Who is reading what the adapter published, and what their capabilities include. The validators check
89
+ * structure without it; given it, they also hold what the adapter publishes to the session.
90
90
  */
91
91
  export interface ReaderContext {
92
92
  /**
@@ -95,16 +95,16 @@ export interface ReaderContext {
95
95
  */
96
96
  self?: UserId;
97
97
  /**
98
- * The login's `AuthenticationState.capabilities`. The login is the permission: a lead's
99
- * snapshot carries a team member list, nobody else's does, and `requests` need `team.leadAssistControl`.
98
+ * The user's `AuthenticationState.capabilities`, for the session. They are the permission: a lead's
99
+ * snapshot carries a team member list, and nobody else's does.
100
100
  */
101
101
  capabilities?: UserCapabilities;
102
102
  /** The level ids the manifest declares. `validateSnapshot` and `validateEventEnvelope` take them from the manifest unless given. */
103
103
  levels?: readonly string[];
104
- /** The login's `loginId`. A snapshot or event naming another belongs to a login that is gone. */
105
- loginId?: string;
104
+ /** The session's `sessionId`. A snapshot or event naming another belongs to a session that is gone. */
105
+ sessionId?: string;
106
106
  /**
107
- * The phone the host chose for this login at connect, `ConnectContext.phone`. A phone state
107
+ * The phone the host chose for this session at connect, `ConnectContext.phone`. A phone state
108
108
  * naming another is the wrong phone. Unknown to a caller without the context, and then unchecked.
109
109
  */
110
110
  phone?: Phone;
@@ -117,7 +117,7 @@ export interface ReaderContext {
117
117
  /** The provider's channel, for a member's task that states none. Filled from the manifest by `validateSnapshot` and `validateEventEnvelope`. */
118
118
  channel?: Channel;
119
119
  /**
120
- * The values the queue locked on this login's tasks, as whoever runs the validator knows them:
120
+ * The values the queue locked on this session's tasks, as whoever runs the validator knows them:
121
121
  * a conformance run states them, a host never has them. Where a task's party stands locked, no
122
122
  * other field of it may carry one (`task.locked.leak`). Absent, unchecked.
123
123
  */
@@ -141,14 +141,14 @@ export declare function validateLinedUp(value: unknown, levels: readonly string[
141
141
  /** The phone as the platform sees it: the agent's device for this provider, whether it can take a call, its own mute where observed. */
142
142
  export declare function validatePhoneState(value: unknown, path?: string, context?: ReaderContext): ProtocolViolation[];
143
143
  /**
144
- * What pressing Mute does on this host, stated on a softphone login and nowhere else: on an agent computer
144
+ * What pressing Mute does on this host, stated on a softphone session and nowhere else: on an agent computer
145
145
  * phone the microphone is the phone's, and off voice there is none. Neither the value nor its
146
146
  * absence is inferred from what kind of application the host is.
147
147
  */
148
148
  /** What the host states as capacity: a whole number, zero or more, zero being host-stopped. */
149
149
  export declare function validateCapacity(capacity: unknown, path?: string): ProtocolViolation[];
150
- /** The login's store, which the host provides on every connection: three functions, and nothing else is a store. */
151
- export declare function validateLoginStore(store: unknown, path?: string): ProtocolViolation[];
150
+ /** The session's store, which the host provides on every connection: three functions, and nothing else is a store. */
151
+ export declare function validateSessionStore(store: unknown, path?: string): ProtocolViolation[];
152
152
  export declare function validateHostMute(mute: unknown, softphone: boolean, path?: string): ProtocolViolation[];
153
153
  /**
154
154
  * What a host promises. Presence is the guarantee, so a key declared `false` is refused: a
@@ -194,9 +194,9 @@ export declare function validateTimeZone(value: unknown, path?: string): Protoco
194
194
  * answers somebody nobody asked about.
195
195
  */
196
196
  export declare function validateUserDetails(users: unknown, asked: readonly string[], path?: string): ProtocolViolation[];
197
- /** What a login is validated against beyond its own shape. */
198
- export interface LoginValidationContext {
199
- /** The level ids the manifest declares, `Manifest.orgLevels`: a level the login names must be one of them. */
197
+ /** What a session is validated against beyond its own shape. */
198
+ export interface SessionValidationContext {
199
+ /** The level ids the manifest declares, `Manifest.orgLevels`: a level the session names must be one of them. */
200
200
  levels: readonly string[];
201
201
  }
202
202
  export declare function validateAuthenticationFailure(failure: unknown, path?: string): ProtocolViolation[];
@@ -207,12 +207,12 @@ export declare function validateAuthenticationFailure(failure: unknown, path?: s
207
207
  */
208
208
  export declare function validateRedirectUri(value: unknown, path?: string): ProtocolViolation[];
209
209
  /**
210
- * What `start()` or `complete()` answered: a challenge or a rejection from `start`, a login or a
211
- * rejection from `complete`. A rejection carries a failure the host can show, and a login is held
210
+ * What `start()` or `complete()` answered: a challenge or a rejection from `start`, a session or a
211
+ * rejection from `complete`. A rejection carries a failure the host can show, and a session is held
212
212
  * to the same rules as any `authenticated` state.
213
213
  */
214
- export declare function validateAuthenticationResult(result: unknown, method: "start" | "complete", path: string, context: LoginValidationContext): ProtocolViolation[];
215
- export declare function validateAuthenticationState(state: unknown, path: string, context: LoginValidationContext): ProtocolViolation[];
214
+ export declare function validateAuthenticationResult(result: unknown, method: "start" | "complete", path: string, context: SessionValidationContext): ProtocolViolation[];
215
+ export declare function validateAuthenticationState(state: unknown, path: string, context: SessionValidationContext): ProtocolViolation[];
216
216
  /**
217
217
  * One recorder's recordings for one task, as published: each with its id, the side it follows,
218
218
  * its status, and a reason where it is paused or unknown; ids unique, and at most one recording