Announce Idempotency Key Generator (agents/announce-idempotency.ts)

ScienceClaw · src/agents/announce-idempotency.ts · typescript · MIT
automation, ai, infra, lang:typescript, tag:idempotency

Generates idempotency keys and unique identifiers for child run announcements in agent queues. Reuse to handle background task de-duplication.

// Source: https://github.com/beita6969/ScienceClaw | License: MIT | Copyright 2025 Peter Steinberger
// Provided via justclaw.it.com; keep this notice with the code.
export type AnnounceIdFromChildRunParams = {
  childSessionKey: string;
  childRunId: string;
};

export function buildAnnounceIdFromChildRun(params: AnnounceIdFromChildRunParams): string {
  return `v1:${params.childSessionKey}:${params.childRunId}`;
}

export function buildAnnounceIdempotencyKey(announceId: string): string {
  return `announce:${announceId}`;
}

export function resolveQueueAnnounceId(params: {
  announceId?: string;
  sessionKey: string;
  enqueuedAt: number;
}): string {
  const announceId = params.announceId?.trim();
  if (announceId) {
    return announceId;
  }
  // Backward-compatible fallback for queu

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key