Skip to content

improve llm orchestration#5

Open
gabririgo wants to merge 11 commits intomainfrom
fix/llm-orchestration
Open

improve llm orchestration#5
gabririgo wants to merge 11 commits intomainfrom
fix/llm-orchestration

Conversation

@gabririgo
Copy link
Copy Markdown
Contributor

  • refactor schema
  • auth improvements

- refactor schema
- auth improvements
@gabririgo gabririgo added the enhancement New feature or request label Apr 21, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the LLM/tool orchestration flow and request gating to better separate “reasoning” vs “tool execution”, while also expanding agent-discovery endpoints and aligning SDK/types for new routing modes.

Changes:

  • Add DeepSeek→Llama dual-model routing (plus new llama_only mode), improved streaming behavior, and stricter browser vs agent tool gating.
  • Improve swap quoting/building robustness (0x taker fallback, gas-estimation fallbacks, NAV precheck warning behavior).
  • Add agent discovery endpoints/headers + new skill doc, and update x402 route metadata.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/types.ts Adds ASSETS binding and isBrowserRequest; extends routingMode union.
src/services/zeroXTrading.ts Avoids invalid 0x taker (zero-address) for quote-only flows.
src/routes/chat.ts Passes isBrowserRequest into request context; adjusts SSE event emission.
src/middleware/x402.ts Updates protected route metadata; adds extra diagnostic logging on payments.
src/llm/client.ts Implements DeepSeek-first reasoning + Llama tool execution; adds vault-tx gating; defaults swaps to 0x; improves error extraction.
src/index.ts Adds /api discovery 402 response and homepage Link headers; adds well-known discovery endpoints.
sdk/src/types.ts Extends SDK routingMode types to include llama_only.
scripts/trigger-bazaar.ts Updates bazaar trigger timings and tool arguments format.
public/rigoblock-skill/SKILL.md Adds a comprehensive external-agent skill doc.
public/openapi.json Updates OpenAPI descriptions/paths (but currently contains corrupted/placeholder content).
public/index.html UI streaming fixes + per-address auth caching + WebMCP tool registration.
public/_headers Adds Link header for discovery on /.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread public/openapi.json Outdated
Comment thread public/openapi.json Outdated
Comment thread src/index.ts
Comment thread public/openapi.json Outdated
Comment thread public/openapi.json Outdated
Comment thread public/openapi.json Outdated
Comment thread public/openapi.json Outdated
Comment thread src/llm/client.ts
Comment thread src/middleware/x402.ts Outdated
Comment thread public/openapi.json Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/routes/tools.ts
Comment thread public/openapi.json Outdated
Comment thread public/index.html Outdated
Comment thread public/rigoblock-skill/SKILL.md Outdated
Comment thread src/llm/client.ts
Comment thread src/llm/client.ts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread public/rigoblock-skill/SKILL.md Outdated
Comment thread src/middleware/x402.ts
Comment thread src/routes/chat.ts
Comment thread src/types.ts Outdated
Comment thread src/llm/client.ts
Comment thread src/llm/client.ts
Comment thread public/index.html
Comment thread src/routes/tools.ts
Comment thread src/index.ts
Comment thread src/llm/client.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/middleware/x402.ts:266

  • The payment-exemption logic grants free access based solely on Origin/Referer. Any non-browser client can forge these headers and bypass x402 payment for protected routes. If the intent is to exempt only your own frontend, consider requiring an additional server-issued proof (e.g. an HttpOnly cookie / signed token set by the Worker) or removing the exemption for non-authenticated requests in production.
  // Exempt own-frontend requests from payment
  server.onProtectedRequest(async (ctx) => {
    const adapter = ctx.adapter;

    const origin = adapter.getHeader("origin");
    if (origin && EXEMPT_ORIGINS.has(origin)) {
      return { grantAccess: true };
    }

    const referer = adapter.getHeader("referer");
    if (referer) {
      for (const o of EXEMPT_ORIGINS) {
        if (referer.startsWith(o)) {
          return { grantAccess: true };

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/llm/client.ts
Comment thread src/middleware/x402.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/types.ts Outdated
Comment thread src/llm/client.ts
Comment thread src/llm/client.ts
Comment thread public/openapi.json
Comment thread tests/client-security.test.ts
Comment thread src/skills/twap.ts
Comment thread src/middleware/x402.ts Outdated
Comment thread src/routes/chat.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 21 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread public/index.html
Comment thread public/index.html Outdated
Comment thread sdk/src/types.ts Outdated
Comment thread src/utils/session.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/middleware/x402.ts Outdated
Comment thread public/index.html
Comment thread src/utils/session.ts Outdated
Comment thread public/openapi.json Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants