openmates 0.18.0-alpha.39 → 0.18.0-alpha.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.
@@ -81003,6 +81003,65 @@ async function openUrl(url) {
81003
81003
  }
81004
81004
  });
81005
81005
  }
81006
+ async function waitForWorkflowRun(client, workflowId, initialRun, options = {}) {
81007
+ const deadline = Date.now() + (options.timeoutMs ?? 18e4);
81008
+ const runId = initialRun.id;
81009
+ let run = initialRun;
81010
+ let lastSyncError = "";
81011
+ const timeoutError = () => new Error(
81012
+ `Workflow run ${runId} is still ${run.status === "completed" ? "waiting for chat delivery acknowledgement" : run.status}. Inspect it with workflows run-show; retry with the same --idempotency-key to avoid rerunning skills.` + (lastSyncError ? ` Last delivery sync error: ${lastSyncError}` : "")
81013
+ );
81014
+ async function withinBudget(operation) {
81015
+ const remaining = deadline - Date.now();
81016
+ if (remaining <= 0) throw timeoutError();
81017
+ let timer;
81018
+ try {
81019
+ return await Promise.race([
81020
+ operation(),
81021
+ new Promise((_, reject) => {
81022
+ timer = setTimeout(() => reject(timeoutError()), remaining);
81023
+ })
81024
+ ]);
81025
+ } finally {
81026
+ clearTimeout(timer);
81027
+ }
81028
+ }
81029
+ const pause = () => withinBudget(() => new Promise((resolve13) => setTimeout(resolve13, Math.min(options.pollIntervalMs ?? 2e3, deadline - Date.now()))));
81030
+ const refresh = async () => {
81031
+ run = await withinBudget(() => client.getWorkflowRun(workflowId, runId));
81032
+ };
81033
+ while (["queued", "planned", "running", "waiting", "cancellation_requested"].includes(run.status)) {
81034
+ await pause();
81035
+ await refresh();
81036
+ }
81037
+ await refresh();
81038
+ let nextSyncAt = 0;
81039
+ while (true) {
81040
+ if (run.status !== "completed") {
81041
+ throw new Error(`Workflow run ${runId} ${run.status}: ${run.error_summary ?? "inspect workflows run-show for details"}`);
81042
+ }
81043
+ const projection = run.output_summary?.deliveries;
81044
+ const deliveries = isRecord3(projection) ? Object.values(projection).filter(isRecord3) : [];
81045
+ const failed = deliveries.find((delivery) => ["cancelled", "expired"].includes(String(delivery.status)));
81046
+ if (failed) throw new Error(`Workflow run ${runId} completed, but chat delivery ${String(failed.delivery_id)} is ${String(failed.status)}.`);
81047
+ if (deliveries.every((delivery) => delivery.status === "acknowledged")) return run;
81048
+ if (Date.now() >= deadline) throw timeoutError();
81049
+ if (Date.now() >= nextSyncAt) {
81050
+ try {
81051
+ await withinBudget(() => client.ensureSynced(true, [], { personal: true }));
81052
+ lastSyncError = "";
81053
+ } catch (error) {
81054
+ lastSyncError = error instanceof Error ? error.message : String(error);
81055
+ if (Date.now() >= deadline) throw timeoutError();
81056
+ }
81057
+ nextSyncAt = Date.now() + (options.syncIntervalMs ?? 1e4);
81058
+ await refresh();
81059
+ continue;
81060
+ }
81061
+ await pause();
81062
+ await refresh();
81063
+ }
81064
+ }
81006
81065
  async function handleWorkflows(client, subcommand, rest, flags, redactor) {
81007
81066
  if (!subcommand || subcommand === "help" || flags.help === true) {
81008
81067
  printWorkflowsHelp();
@@ -81283,15 +81342,7 @@ async function handleWorkflows(client, subcommand, rest, flags, redactor) {
81283
81342
  const input = typeof flags.input === "string" ? parseJsonFlag(flags.input, "--input") : {};
81284
81343
  let run = await client.runWorkflow(workflowId, { idempotencyKey, mode, input });
81285
81344
  if (flags.wait === true) {
81286
- const deadline = Date.now() + 18e4;
81287
- while (["queued", "planned", "running"].includes(run.status) && Date.now() < deadline) {
81288
- await new Promise((resolve13) => setTimeout(resolve13, 2e3));
81289
- run = await client.getWorkflowRun(workflowId, run.id);
81290
- }
81291
- if (["queued", "planned", "running"].includes(run.status)) throw new Error(`Workflow run ${run.id} is still running. Inspect it with workflows run-show.`);
81292
- if (run.status === "failed") throw new Error(`Workflow run ${run.id} failed: ${run.error_summary ?? "inspect run-show for details"}`);
81293
- await client.ensureSynced(true);
81294
- run = await client.getWorkflowRun(workflowId, run.id);
81345
+ run = await waitForWorkflowRun(client, workflowId, run);
81295
81346
  }
81296
81347
  if (flags.json === true) {
81297
81348
  printJson2(run);
@@ -87631,6 +87682,9 @@ function printWorkflowsHelp() {
87631
87682
  Workflows run on the OpenMates server, not in this terminal process. The CLI
87632
87683
  uses your paired session and shows the same workflow/run records as web, SDKs,
87633
87684
  and Apple clients.
87685
+ --wait waits up to three minutes for this run and its selected chat deliveries to
87686
+ be acknowledged. No new results completes without creating a chat. On timeout,
87687
+ inspect run-show or retry the same --idempotency-key; skills are not rerun.
87634
87688
 
87635
87689
  Examples:
87636
87690
  openmates workflows list
@@ -87945,6 +87999,7 @@ export {
87945
87999
  assertTrustedAccountGuardEnvironment,
87946
88000
  resolveProjectContext,
87947
88001
  requireExactConfirmation,
88002
+ waitForWorkflowRun,
87948
88003
  classifyImagesAiDetection,
87949
88004
  formatImagesAiDetectionLabel,
87950
88005
  buildImagesAiDetectionSummary,
@@ -3007,6 +3007,12 @@ declare function resolveProjectContext(client: OpenMatesClient, flags: Record<st
3007
3007
  personal?: boolean;
3008
3008
  }>;
3009
3009
  declare function requireExactConfirmation(label: string, exactValue: string, flags: Record<string, string | boolean>): Promise<void>;
3010
+ /** Wait for this accepted run and its selected chat deliveries, never dispatch again. */
3011
+ declare function waitForWorkflowRun(client: Pick<OpenMatesClient, "getWorkflowRun" | "ensureSynced">, workflowId: string, initialRun: WorkflowRunDetail, options?: {
3012
+ timeoutMs?: number;
3013
+ pollIntervalMs?: number;
3014
+ syncIntervalMs?: number;
3015
+ }): Promise<WorkflowRunDetail>;
3010
3016
  type ImagesAiDetectionClassification = "likely_ai_generated" | "possibly_ai_generated" | "likely_not_ai_generated" | "unavailable";
3011
3017
  interface ImagesAiDetectionSummary {
3012
3018
  file: string;
@@ -3038,4 +3044,4 @@ declare function serializeToYaml(data: Record<string, unknown>, indent?: number)
3038
3044
  /** Map language identifier to file extension for code embed downloads. */
3039
3045
  declare function getExtForLang(language: string): string;
3040
3046
 
3041
- export { type CachedNewChatSuggestion as $, type WorkflowRunContentRetention as A, type WorkflowRunDetail as B, type WorkflowNode as C, type DecryptedUserTask as D, type ExternalChatContext as E, type WorkflowRunCancellationResult as F, type WorkflowTemplateProjectionUpsertParams as G, type WorkflowTemplateProjectionResult as H, type PublicWorkflowTemplateProjection as I, type WorkflowTemplateProjectionRevocationResult as J, type WorkflowTemplateBindingCompletionParams as K, type WorkflowTemplateBindingCompletionResult as L, type WorkflowTemplateShortUrlParams as M, type WorkflowTemplateShortUrlResult as N, type WorkflowTemplateImportPayload as O, type ProjectItemRecord as P, type ImportedWorkflowTemplate as Q, type AuthMethodsStatus as R, type ShortUrlRevokeResult as S, type TaskCreateOptions as T, type UserPlanStatus as U, type AuthoritativeChatReconciliation as V, type WorkflowSummary as W, type BackupCodesResult as X, type BankTransferOrderDetails as Y, type BankTransferStatus as Z, type CachedChat as _, type UserPlanRecord as a, type ChatListPage as a0, type CliSignupResult as a1, type DecryptedDraft as a2, type DecryptedEmbed as a3, type DecryptedMemoryEntry as a4, type DecryptedMessage as a5, type DecryptedNewChatSuggestion as a6, type DocsFile as a7, type DocsFolder as a8, type DocsSearchResult as a9, normalizeInterestTagIds as aA, reconcileAuthoritativeChats as aB, serializeToYaml as aC, assertTrustedAccountCommandAllowed as aD, assertTrustedAccountGuardEnvironment as aE, buildTravelConnectionsRequest as aF, printWhoAmI as aG, requireExactConfirmation as aH, resolveProjectContext as aI, shouldRequireTrustedAccountGuard as aJ, type DocsTree as aa, type EncryptedDraft as ab, type GiftCardBankTransferStatus as ac, INTEREST_TAG_IDS as ad, type ImagesAiDetectionClassification as ae, type ImagesAiDetectionSummary as af, type InterestTagId as ag, MATE_NAMES as ah, MEMORY_TYPE_REGISTRY as ai, type MemoryFieldDef as aj, type MemoryTypeDef as ak, OpenMatesClient as al, type OpenMatesClientOptions as am, type OpenMatesSession as an, type SyncCache as ao, type TopicPreferencesPayload as ap, type TotpSetupStartResult as aq, type WorkflowEdge as ar, type WorkflowNodeRun as as, type WorkflowNodeType as at, type WorkflowRunContentStorage as au, buildImagesAiDetectionSummary as av, classifyImagesAiDetection as aw, deriveAppUrl as ax, formatImagesAiDetectionLabel as ay, getExtForLang as az, type UserPlanVerificationStatus as b, type UserPlanLearningType as c, type UserPlanLearningTargetKind as d, type UserPlanLearningStatus as e, type UserPlanLearningLevel as f, type UserPlanLearningRecord as g, type UserPlanCriterionRecord as h, type UserPlanVerificationRecord as i, type UserPlanCreateInput as j, type UserPlanUpdateInput as k, type TaskUpdateOptions as l, type UserPlanLearningCreateTasksInput as m, type UserPlanLearningCreateTasksResult as n, type UserTaskStatus as o, type TaskPriorityLevel as p, type DecryptedTaskActivityEntry as q, type TaskActivityCreateOptions as r, type UserTaskReorderInput as s, type WorkflowCapability as t, type WorkflowDetail as u, type WorkflowInputStartParams as v, type WorkflowInputSessionResult as w, type WorkflowInputSessionDetail as x, type WorkflowInputEvent as y, type WorkflowGraph as z };
3047
+ export { type CachedNewChatSuggestion as $, type WorkflowRunContentRetention as A, type WorkflowRunDetail as B, type WorkflowNode as C, type DecryptedUserTask as D, type ExternalChatContext as E, type WorkflowRunCancellationResult as F, type WorkflowTemplateProjectionUpsertParams as G, type WorkflowTemplateProjectionResult as H, type PublicWorkflowTemplateProjection as I, type WorkflowTemplateProjectionRevocationResult as J, type WorkflowTemplateBindingCompletionParams as K, type WorkflowTemplateBindingCompletionResult as L, type WorkflowTemplateShortUrlParams as M, type WorkflowTemplateShortUrlResult as N, type WorkflowTemplateImportPayload as O, type ProjectItemRecord as P, type ImportedWorkflowTemplate as Q, type AuthMethodsStatus as R, type ShortUrlRevokeResult as S, type TaskCreateOptions as T, type UserPlanStatus as U, type AuthoritativeChatReconciliation as V, type WorkflowSummary as W, type BackupCodesResult as X, type BankTransferOrderDetails as Y, type BankTransferStatus as Z, type CachedChat as _, type UserPlanRecord as a, type ChatListPage as a0, type CliSignupResult as a1, type DecryptedDraft as a2, type DecryptedEmbed as a3, type DecryptedMemoryEntry as a4, type DecryptedMessage as a5, type DecryptedNewChatSuggestion as a6, type DocsFile as a7, type DocsFolder as a8, type DocsSearchResult as a9, normalizeInterestTagIds as aA, reconcileAuthoritativeChats as aB, serializeToYaml as aC, assertTrustedAccountCommandAllowed as aD, assertTrustedAccountGuardEnvironment as aE, buildTravelConnectionsRequest as aF, printWhoAmI as aG, requireExactConfirmation as aH, resolveProjectContext as aI, shouldRequireTrustedAccountGuard as aJ, waitForWorkflowRun as aK, type DocsTree as aa, type EncryptedDraft as ab, type GiftCardBankTransferStatus as ac, INTEREST_TAG_IDS as ad, type ImagesAiDetectionClassification as ae, type ImagesAiDetectionSummary as af, type InterestTagId as ag, MATE_NAMES as ah, MEMORY_TYPE_REGISTRY as ai, type MemoryFieldDef as aj, type MemoryTypeDef as ak, OpenMatesClient as al, type OpenMatesClientOptions as am, type OpenMatesSession as an, type SyncCache as ao, type TopicPreferencesPayload as ap, type TotpSetupStartResult as aq, type WorkflowEdge as ar, type WorkflowNodeRun as as, type WorkflowNodeType as at, type WorkflowRunContentStorage as au, buildImagesAiDetectionSummary as av, classifyImagesAiDetection as aw, deriveAppUrl as ax, formatImagesAiDetectionLabel as ay, getExtForLang as az, type UserPlanVerificationStatus as b, type UserPlanLearningType as c, type UserPlanLearningTargetKind as d, type UserPlanLearningStatus as e, type UserPlanLearningLevel as f, type UserPlanLearningRecord as g, type UserPlanCriterionRecord as h, type UserPlanVerificationRecord as i, type UserPlanCreateInput as j, type UserPlanUpdateInput as k, type TaskUpdateOptions as l, type UserPlanLearningCreateTasksInput as m, type UserPlanLearningCreateTasksResult as n, type UserTaskStatus as o, type TaskPriorityLevel as p, type DecryptedTaskActivityEntry as q, type TaskActivityCreateOptions as r, type UserTaskReorderInput as s, type WorkflowCapability as t, type WorkflowDetail as u, type WorkflowInputStartParams as v, type WorkflowInputSessionResult as w, type WorkflowInputSessionDetail as x, type WorkflowInputEvent as y, type WorkflowGraph as z };
package/dist/cli.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export { ae as ImagesAiDetectionClassification, af as ImagesAiDetectionSummary, aD as assertTrustedAccountCommandAllowed, aE as assertTrustedAccountGuardEnvironment, av as buildImagesAiDetectionSummary, aF as buildTravelConnectionsRequest, aw as classifyImagesAiDetection, ay as formatImagesAiDetectionLabel, az as getExtForLang, aG as printWhoAmI, aH as requireExactConfirmation, aI as resolveProjectContext, aC as serializeToYaml, aJ as shouldRequireTrustedAccountGuard } from './cli-DfLQ_qY9.js';
2
+ export { ae as ImagesAiDetectionClassification, af as ImagesAiDetectionSummary, aD as assertTrustedAccountCommandAllowed, aE as assertTrustedAccountGuardEnvironment, av as buildImagesAiDetectionSummary, aF as buildTravelConnectionsRequest, aw as classifyImagesAiDetection, ay as formatImagesAiDetectionLabel, az as getExtForLang, aG as printWhoAmI, aH as requireExactConfirmation, aI as resolveProjectContext, aC as serializeToYaml, aJ as shouldRequireTrustedAccountGuard, aK as waitForWorkflowRun } from './cli-R8wBnwBN.js';
package/dist/cli.js CHANGED
@@ -11,8 +11,9 @@ import {
11
11
  requireExactConfirmation,
12
12
  resolveProjectContext,
13
13
  serializeToYaml,
14
- shouldRequireTrustedAccountGuard
15
- } from "./chunk-HHNJW3Z6.js";
14
+ shouldRequireTrustedAccountGuard,
15
+ waitForWorkflowRun
16
+ } from "./chunk-J4PI327H.js";
16
17
  import "./chunk-IWKP55ZB.js";
17
18
  import "./chunk-BBKJZ23O.js";
18
19
  export {
@@ -27,5 +28,6 @@ export {
27
28
  requireExactConfirmation,
28
29
  resolveProjectContext,
29
30
  serializeToYaml,
30
- shouldRequireTrustedAccountGuard
31
+ shouldRequireTrustedAccountGuard,
32
+ waitForWorkflowRun
31
33
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UserPlanStatus, a as UserPlanRecord, b as UserPlanVerificationStatus, c as UserPlanLearningType, d as UserPlanLearningTargetKind, e as UserPlanLearningStatus, f as UserPlanLearningLevel, g as UserPlanLearningRecord, h as UserPlanCriterionRecord, i as UserPlanVerificationRecord, j as UserPlanCreateInput, k as UserPlanUpdateInput, P as ProjectItemRecord, T as TaskCreateOptions, l as TaskUpdateOptions, m as UserPlanLearningCreateTasksInput, n as UserPlanLearningCreateTasksResult, o as UserTaskStatus, E as ExternalChatContext, p as TaskPriorityLevel, D as DecryptedUserTask, q as DecryptedTaskActivityEntry, r as TaskActivityCreateOptions, s as UserTaskReorderInput, W as WorkflowSummary, t as WorkflowCapability, u as WorkflowDetail, v as WorkflowInputStartParams, w as WorkflowInputSessionResult, x as WorkflowInputSessionDetail, y as WorkflowInputEvent, z as WorkflowGraph, A as WorkflowRunContentRetention, B as WorkflowRunDetail, C as WorkflowNode, F as WorkflowRunCancellationResult, G as WorkflowTemplateProjectionUpsertParams, H as WorkflowTemplateProjectionResult, I as PublicWorkflowTemplateProjection, J as WorkflowTemplateProjectionRevocationResult, K as WorkflowTemplateBindingCompletionParams, L as WorkflowTemplateBindingCompletionResult, M as WorkflowTemplateShortUrlParams, N as WorkflowTemplateShortUrlResult, S as ShortUrlRevokeResult, O as WorkflowTemplateImportPayload, Q as ImportedWorkflowTemplate } from './cli-DfLQ_qY9.js';
2
- export { R as AuthMethodsStatus, V as AuthoritativeChatReconciliation, X as BackupCodesResult, Y as BankTransferOrderDetails, Z as BankTransferStatus, _ as CachedChat, $ as CachedNewChatSuggestion, a0 as ChatListPage, a1 as CliSignupResult, a2 as DecryptedDraft, a3 as DecryptedEmbed, a4 as DecryptedMemoryEntry, a5 as DecryptedMessage, a6 as DecryptedNewChatSuggestion, a7 as DocsFile, a8 as DocsFolder, a9 as DocsSearchResult, aa as DocsTree, ab as EncryptedDraft, ac as GiftCardBankTransferStatus, ad as INTEREST_TAG_IDS, ae as ImagesAiDetectionClassification, af as ImagesAiDetectionSummary, ag as InterestTagId, ah as MATE_NAMES, ai as MEMORY_TYPE_REGISTRY, aj as MemoryFieldDef, ak as MemoryTypeDef, al as OpenMatesClient, am as OpenMatesClientOptions, an as OpenMatesSession, ao as SyncCache, ap as TopicPreferencesPayload, aq as TotpSetupStartResult, ar as WorkflowEdge, as as WorkflowNodeRun, at as WorkflowNodeType, au as WorkflowRunContentStorage, av as buildImagesAiDetectionSummary, aw as classifyImagesAiDetection, ax as deriveAppUrl, ay as formatImagesAiDetectionLabel, az as getExtForLang, aA as normalizeInterestTagIds, aB as reconcileAuthoritativeChats, aC as serializeToYaml } from './cli-DfLQ_qY9.js';
1
+ import { U as UserPlanStatus, a as UserPlanRecord, b as UserPlanVerificationStatus, c as UserPlanLearningType, d as UserPlanLearningTargetKind, e as UserPlanLearningStatus, f as UserPlanLearningLevel, g as UserPlanLearningRecord, h as UserPlanCriterionRecord, i as UserPlanVerificationRecord, j as UserPlanCreateInput, k as UserPlanUpdateInput, P as ProjectItemRecord, T as TaskCreateOptions, l as TaskUpdateOptions, m as UserPlanLearningCreateTasksInput, n as UserPlanLearningCreateTasksResult, o as UserTaskStatus, E as ExternalChatContext, p as TaskPriorityLevel, D as DecryptedUserTask, q as DecryptedTaskActivityEntry, r as TaskActivityCreateOptions, s as UserTaskReorderInput, W as WorkflowSummary, t as WorkflowCapability, u as WorkflowDetail, v as WorkflowInputStartParams, w as WorkflowInputSessionResult, x as WorkflowInputSessionDetail, y as WorkflowInputEvent, z as WorkflowGraph, A as WorkflowRunContentRetention, B as WorkflowRunDetail, C as WorkflowNode, F as WorkflowRunCancellationResult, G as WorkflowTemplateProjectionUpsertParams, H as WorkflowTemplateProjectionResult, I as PublicWorkflowTemplateProjection, J as WorkflowTemplateProjectionRevocationResult, K as WorkflowTemplateBindingCompletionParams, L as WorkflowTemplateBindingCompletionResult, M as WorkflowTemplateShortUrlParams, N as WorkflowTemplateShortUrlResult, S as ShortUrlRevokeResult, O as WorkflowTemplateImportPayload, Q as ImportedWorkflowTemplate } from './cli-R8wBnwBN.js';
2
+ export { R as AuthMethodsStatus, V as AuthoritativeChatReconciliation, X as BackupCodesResult, Y as BankTransferOrderDetails, Z as BankTransferStatus, _ as CachedChat, $ as CachedNewChatSuggestion, a0 as ChatListPage, a1 as CliSignupResult, a2 as DecryptedDraft, a3 as DecryptedEmbed, a4 as DecryptedMemoryEntry, a5 as DecryptedMessage, a6 as DecryptedNewChatSuggestion, a7 as DocsFile, a8 as DocsFolder, a9 as DocsSearchResult, aa as DocsTree, ab as EncryptedDraft, ac as GiftCardBankTransferStatus, ad as INTEREST_TAG_IDS, ae as ImagesAiDetectionClassification, af as ImagesAiDetectionSummary, ag as InterestTagId, ah as MATE_NAMES, ai as MEMORY_TYPE_REGISTRY, aj as MemoryFieldDef, ak as MemoryTypeDef, al as OpenMatesClient, am as OpenMatesClientOptions, an as OpenMatesSession, ao as SyncCache, ap as TopicPreferencesPayload, aq as TotpSetupStartResult, ar as WorkflowEdge, as as WorkflowNodeRun, at as WorkflowNodeType, au as WorkflowRunContentStorage, av as buildImagesAiDetectionSummary, aw as classifyImagesAiDetection, ax as deriveAppUrl, ay as formatImagesAiDetectionLabel, az as getExtForLang, aA as normalizeInterestTagIds, aB as reconcileAuthoritativeChats, aC as serializeToYaml } from './cli-R8wBnwBN.js';
3
3
 
4
4
  interface ProjectedAssistantSpeechSegment {
5
5
  sequence: number;
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ import {
42
42
  selectAssistantMessagesForSpeech,
43
43
  serializeToYaml,
44
44
  summarizeAssistantSpeech
45
- } from "./chunk-HHNJW3Z6.js";
45
+ } from "./chunk-J4PI327H.js";
46
46
  import "./chunk-IWKP55ZB.js";
47
47
  import "./chunk-BBKJZ23O.js";
48
48
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmates",
3
- "version": "0.18.0-alpha.39",
3
+ "version": "0.18.0-alpha.40",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",