🚀. Socket Launch Week Day 3:Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions.Learn more
Sign In

@orangecheck/agent-openai

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orangecheck/agent-openai

Wrap OpenAI function-calling (Responses API + Chat Completions tool path) with OC Agent scope enforcement and emit a signed agent-action envelope per function invocation.

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
7
-70.83%
Maintainers
1
Weekly downloads
 
Created
Source

@orangecheck/agent-openai

Wrap OpenAI function calls with OC Agent scope enforcement and emit a signed agent-action envelope per invocation. Covers both the new Responses API (function_call items) and the legacy Chat Completions tool path (tool_calls).

Why

Function calling is the OpenAI-shaped way agents reach out to the world. Without scope enforcement and a cryptographic action receipt, "the model called this function" is the entire audit trail. With this adapter, every call carries: the agent address (BIP-322 signed), the active delegation, the exercised scope, the content hash of the inputs, and the OC Stamp anchor — replayable offline forever.

Status

v0.0.1 · in design. API shape is stable; canonicalization is locked. Production wiring (per-event streaming integration with the OpenAI SDK's responses.stream() / chat.completions.create()) lands when the first design partner names the integration.

Install

npm i @orangecheck/agent-openai
# peer deps:
npm i @orangecheck/agent-core @orangecheck/agent-signer

Quickstart

import { invokeWithStamp } from '@orangecheck/agent-openai';

// Pull a tool_call out of a Chat Completions response …
const toolCall = response.choices[0].message.tool_calls[0];

const { result, action, call } = await invokeWithStamp({
    agent,
    delegation,
    call: toolCall, // raw OpenAI shape — we normalize
    execute: async (c) => myInvoiceCreateImpl(c.arguments),
});

// `result` becomes the tool result you feed back to the model.
// `call` is the normalized OpenAiFunctionCall (id, name, arguments).
// `action` is the signed envelope; ship to your audit bundle / Nostr.

The same invokeWithStamp works on Responses-API function_call items — parseFunctionCall handles the call_id / id and string-vs-object arguments differences automatically.

What gets stamped

The stamp's content.hash is a SHA-256 of the RFC-8785-canonicalized JSON:

{
  "arguments": <canonical JSON of arguments>,
  "id":        "<call id>",
  "name":      "<function name>"
}

The action's scope_exercised defaults to openai:function(name=<name>). Override via scopeExercised.

API

  • parseFunctionCall(raw) — normalizes a Chat Completions tool_call or Responses function_call into {id, name, arguments}.
  • canonicalizeFunctionCall(call) — RFC 8785 canonical bytes.
  • functionCallHash(call)sha256:<64-hex> for content.hash.
  • stampFunctionCall(input) — sign without executing.
  • invokeWithStamp(input) — sign + execute + return both.

License

MIT.

Keywords

bitcoin

FAQs

Package last updated on 03 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts