Skip to content

feat: added ts-sdk with openAI sdk support#55

Merged
yanny-sec merged 26 commits into
secureagentics:mainfrom
Adarsh9977:ts-openai
Jun 25, 2026
Merged

feat: added ts-sdk with openAI sdk support#55
yanny-sec merged 26 commits into
secureagentics:mainfrom
Adarsh9977:ts-openai

Conversation

@Adarsh9977

Copy link
Copy Markdown
Contributor

Summary

Adds @secureagentics/adrian-openai, a TypeScript provider package that instruments the official OpenAI Node SDK for Adrian security monitoring.

  • adrian.openai(client) — proxy wrapper around an existing OpenAI client; instruments chat.completions.create and responses.create without changing call sites
  • Chat Completions — captures paired LLM events for non-stream and streaming responses, including streamed tool-call aggregation and usage tokens
  • Responses API — captures text output, function/tool calls, instructions, and array-shaped input (including prior tool calls and outputs) for both stream and non-stream paths
  • adrian.captureTool() — wraps manual tool execution so tool start/end events are emitted and BLOCK/HITL policy can halt execution before the handler runs
  • Error capture — failed OpenAI requests and tool executions are recorded as LLM/tool events with error metadata
  • Shared capture helpers — reuses @secureagentics/adrian/capture from the core package for consistent event pairing and policy gating
  • Depends on @secureagentics/adrian (core TypeScript SDK). feat: added ts-core sdk #50

Test plan

  • cd sdk/typescript and run npm test -w @secureagentics/adrian-openai

Checklist

  • CLA signed (see CLA.md)
  • Tests pass locally
  • Docs updated where needed
  • British English; no em-dashes; no marketing fluff

Introduce @secureagentics/adrian with the event pipeline, PII redaction,
WebSocket streaming, policy gating, and core test suite. Includes shared
proto layout and workspace scaffolding for provider packages.
Remove the legacy root proto/event.proto after relocating the schema into
the Python SDK package layout.
Restore proto/event.proto at the repo root and drop the unrelated Python
proto relocation, Makefile, and SDK changes from the ts-core branch.
Fix init option resolution so explicit params beat env vars and wsUrl: null
disables WebSocket. Align BLOCK-mode with Python fail-open, wire 4003 quota
reconnect delay, refactor shouldHalt to switch, export adrian namespace,
merge README docs, and add init/policy/ws tests.
Add @secureagentics/adrian-openai with client wrapping, tool capture,
streaming support, and OpenAI-specific tests. Updates workspace docs for
the provider package workflow.
@shahtajkhalid

Copy link
Copy Markdown
Contributor

Thanks for PR @Adarsh9977, needs to fix the following before we can merge:

  1. invocation_id is being randomly regenerated per call. Both captureLlmCall (common.ts:27) and captureTool (index.ts:66) is calling runWithInvocationId(randomUUID(), …), hence each LLM call and each tool call gets its own invocation, which degrades our classifier's context, since our backend groups context by the
    (session, invocation, agent_id) tuple.

@Adarsh9977

Copy link
Copy Markdown
Contributor Author

Thanks for PR @Adarsh9977, needs to fix the following before we can merge:

  1. invocation_id is being randomly regenerated per call. Both captureLlmCall (common.ts:27) and captureTool (index.ts:66) is calling runWithInvocationId(randomUUID(), …), hence each LLM call and each tool call gets its own invocation, which degrades our classifier's context, since our backend groups context by the
    (session, invocation, agent_id) tuple.

I'm looking on it thanks @shahtajkhalid

@Adarsh9977

Copy link
Copy Markdown
Contributor Author

@shahtajkhalid Done with the changes. Now it's taking the active invocation Id and if not present then it passes null. Just like we're doing in python.

Please take a look and let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants