@squidcloud/client
    Preparing search index...

    Class JobClient

    Handles job subscriptions and notifications.

    Important: Each jobId must be globally unique and kept private. Anyone who knows a job’s ID can query its status or result.

    A job that Squid starts under an ID it builds itself (a knowledge base graph rebuild or re-upsert, an external-source check, an ontology generation, a relationship inference) can be read and awaited only with an API key. The prefixes of these IDs are reserved: a job ID you choose cannot start with graph-rebuild-, reupsert-kb-, kb-external-source-, ontology-generation- or relationship-inference-.

    Index
    • Waits until the specified job finishes, then resolves with its result or throws if the job fails. The thrown error is a JobError: check its errorType (e.g. 'AI_PROVIDER_ERROR') to branch on the failure kind without parsing message.

      Type Parameters

      • T = any

      Parameters

      • jobId: string

        A unique, private identifier for the job. Do not reuse a jobId across clients—possessing the ID allows anyone to inspect the job’s state.

      Returns Promise<T>

    • Cancels a running server-executed job (e.g. an AI chat) so it stops spending resources. Allowed with the API key, or for the client that started the job. The job ends as cancelled and awaitJob rejects with a JobError whose errorType is 'JOB_CANCELLED'. No-op if it already finished.

      Parameters

      • jobId: string

        The identifier of the job to cancel.

      Returns Promise<void>

    • Resolves a job this client owns successfully with its result. A result that does not fit in 16MB with the job's metadata cannot be stored, so the job fails instead.

      Type Parameters

      • T = unknown

      Parameters

      • jobId: string
      • result: T

      Returns Promise<void>

    • Resolves a job this client owns as failed with an error message.

      Parameters

      • jobId: string
      • error: string

      Returns Promise<void>

    • Retrieves the current status (and, if completed, the result) of a job.

      Type Parameters

      • T = any

      Parameters

      • jobId: string

        A unique, private identifier for the job. Do not reuse a jobId across clients—possessing the ID allows anyone to inspect the job’s state.

      Returns Promise<AsyncJob<T> | undefined>

    • Starts a long-running job under a caller-generated jobId. The client owns the job until it resolves it via completeJob or failJob; while owned, the job is kept alive so core does not fail it. The jobId must be globally unique and kept private.

      Parameters

      • jobId: string

      Returns Promise<void>