/** * Generic per-integration UI attach-job scheduler. Lifted from * `packages/cli/src/daemon/openclaw.ts` (which still re-exports the * OpenClaw-named bindings as a backwards-compat alias) in S1 of issue * #386 because adapter-hermes' S3 work needs an identically-shaped * scheduler keyed on `'hermes'` instead of `'openclaw'`. * * The previous OpenClaw-only Map (`pendingOpenClawUiAttachJobs`) + * helpers (`scheduleOpenClawUiAttachJob`, `cancelPendingLocalAgentAttachJob`, * `isOpenClawUiAttachCancelled`) keyed everything on a string * `integrationId`, so the migration is a rename: the same Map and the * same scheduling/cancellation logic just lose the `OpenClaw` substring * from the public symbols. Existing OpenClaw call sites continue to * import the legacy names from `daemon/openclaw.ts` (re-exports). New * Hermes call sites in S3 should import the generic names from this * module directly. * * Module-private state: `pendingAttachJobs` is intentionally NOT * exported. All access goes through the helpers below; that's what lets * `cancelPending(id)` reach into the same Map that `scheduleAttachJob(id)` * populated without a global registry. */ export type PendingAttachJob = { job: Promise; controller: AbortController; cancelled: boolean; }; /** * Schedule (or join) a per-integration UI attach job. If a job for * `integrationId` is already pending, the existing job is returned and * `task` is NOT invoked — the second caller observes the in-flight * promise. If no job is pending, a new `AbortController` + `PendingAttachJob` * is created, `task(job)` is invoked, and the entry is auto-cleared * from the registry when the task settles (success or failure). * * `onAttachScheduled` lets the daemon route emit a notice + transition * the integration record to `'connecting'` synchronously while the * background job runs. */ export declare function scheduleAttachJob(integrationId: string, task: (job: PendingAttachJob) => Promise, onAttachScheduled?: (id: string, job: Promise) => void): { started: boolean; job: Promise; controller: AbortController; }; /** * Cancel an in-flight attach job for `integrationId`. Aborts the * associated `AbortController`, marks `cancelled: true` so * `isCancelled(job)` returns `true` even before the abort propagates, * and removes the entry from the registry so a subsequent * `scheduleAttachJob(integrationId, ...)` can start fresh. */ export declare function cancelPending(integrationId: string): void; /** * `true` when the job's `cancelled` flag was set OR its `AbortController` * has been aborted from any side. Used by long-running attach tasks to * exit early between step boundaries. */ export declare function isCancelled(job: PendingAttachJob): boolean; //# sourceMappingURL=local-agent-attach-jobs.d.ts.map