Skip to content

feat(agent): create jobs from chat, publish to NEAR provenance, approval buttons - #148

Merged
Winter-Soren merged 1 commit into
mainfrom
feat/near-agent-jobs
Nov 14, 2026
Merged

Winter-Soren merged 1 commit into
mainfrom
feat/near-agent-jobs

Conversation

@Winter-Soren

Copy link
Copy Markdown
Member

Closes #147. Builds on the NEAR provenance registry from #142.

What changed

  • Jobs belong to the user. Agent MCP tools used to call the API unauthenticated, so jobs landed under dev-local. Each call now carries the same short-lived signed assertion the frontend uses, including the primary SIWE wallet.
  • Financial modelling. submit_portfolio_optimization posts a CSV to /api/v1/finance/submit.
  • NEAR publishing. prepare_near_anchor writes a near-<job_id> bundle per completed job (result hash, owner wallet) and returns the exact near contract call-function … anchor … command. attach_near_anchor verifies the transaction on-chain and attaches inclusion proofs. Existing bundles are reused so retries keep the same root. No NEAR key enters the backend.
  • Approvals. request_approval ends the turn and the chat shows Approve / Decline buttons; the choice is sent back as the next message. Stored with the session so it survives a reload.
  • Markdown. Fenced code blocks get a language label, copy button and token colours from the chart palette; nested/task lists, tables and long hashes wrap correctly.
  • Fix. The submit_quantum_circuit example used measure q -> c;, which the executor rejects, so model-written circuits failed.

Testing (UI only, signed in via SIWE with a test wallet, OpenRouter free model)

  • Bell and GHZ circuits submitted from chat, completed on mesh peers, visible on /runs.
  • 4-asset portfolio job submitted from chat, completed, visible on /finance/history.
  • Drug-discovery job (6LU7) submitted from chat, completed, visible on /pharma.
  • Prepare-anchor for three jobs returned a valid batch root; owner_wallet confirmed in the stored bundles. A real but non-matching transaction hash was rejected.
  • Approve button: agent asked, user clicked, agent ran the circuit and reported results.

Not tested

  • A real signed publication (the publisher key is not on the dev machine).
  • NEAR AI attestation (no free attested model).
  • Verifying transactions older than the RPC's retention may need an archival RPC.

Notes

  • Ruff: no new findings on lines added in platform_mcp.py / ai_agent_service.py; both files have older findings that are untouched.
  • chat/page.tsx already had react-hooks/set-state-in-effect lint errors on main; not addressed here.

…val buttons

- Agent tool calls now run as the chat owner (signed assertion) so jobs
  appear in their Runs, Finance and Pharma pages.
- New tools: submit_portfolio_optimization, prepare_near_anchor,
  attach_near_anchor, request_approval. The user signs the registry
  `anchor` call with their own NEAR CLI key; no NEAR key in the backend.
- Provenance bundles commit the signed-in primary SIWE wallet.
- Chat shows Approve / Decline buttons for agent approval requests.
- Chat markdown: code blocks with language label, copy button and token
  colours; nested and task lists; tables; long-token wrapping.
- Fix the circuit tool example (per-qubit measure).

Closes #147
@vercel

vercel Bot commented Nov 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
qmeshpy-frontend Ignored Ignored Nov 14, 2026 6:36pm UTC

@Winter-Soren
Winter-Soren merged commit 4ae1ef0 into main Nov 14, 2026
12 checks passed
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.

Agent chat: create jobs, publish to NEAR provenance, approval buttons, markdown

1 participant