Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

686 B
Raw Blame
function isPlainObject(value: unknown): value is Record<string, unknown> {
  return !!value && typeof value === "object" && !Array.isArray(value);
}

/** Collect top-level and Responses Lite tool containers without altering their order. */
export function collectResponsesToolGroups(body: unknown): unknown[][] {
  if (!isPlainObject(body)) return [];

  const groups: unknown[][] = [];
  if (Array.isArray(body.tools)) groups.push(body.tools);
  if (!Array.isArray(body.input)) return groups;

  for (const item of body.input) {
    if (isPlainObject(item) && item.type === "additional_tools" && Array.isArray(item.tools)) {
      groups.push(item.tools);
    }
  }
  return groups;
}