akm-cli
Version:
akm (Agent Knowledge Manager) — a portable, local-first capability library for AI agents. Discover, load, share, and improve reusable skills, scripts, workflows, and knowledge across any shell-capable coding agent, including Claude Code, OpenCode, and Cur
21 lines (20 loc) • 921 B
JavaScript
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
/**
* A child workflow run's idempotency key, derived from the parent unit's input
* hash: `publishChildWorkflowRun` is idempotent on `(parent_run_id, invocation_key)`.
*/
import { createHash } from "node:crypto";
import { canonicalJson } from "../ir/plan-hash.js";
/** `sha256hex("akm.workflow.child-invocation\0v1\0" + canonicalJson({parentRunId, parentUnitId, unitInputHash}))`. */
export function computeChildInvocationKey(input) {
return createHash("sha256")
.update("akm.workflow.child-invocation\0v1\0")
.update(canonicalJson({
parentRunId: input.parentRunId,
parentUnitId: input.parentUnitId,
unitInputHash: input.unitInputHash,
}))
.digest("hex");
}