Commit Graph
2 Commits
Author SHA1 Message Date
caikn b228cc6a68 sap-aicore 0.3.2: accept session metadata, forward context_management with its beta (caikn, #851)
sap-aicore 0.3.1 refused two top-level Messages fields that real agents send:

- `metadata` (omp sends `metadata.user_id` on every request): now accepted and
  dropped in `bedrockBody`, the one builder both /invoke and
  /invoke-with-response-stream use, so it never reaches Bedrock.
- `context_management` (omp and Claude Code with thinking on send
  `{"edits":[{"type":"clear_thinking_20251015","keep":"all"}]}`), with
  `anthropic_beta`: both are accepted as opaque native fields and forwarded
  unchanged. When `context_management` comes without `anthropic_beta`, the body
  gets `anthropic_beta:["context-management-2025-06-27"]`, which SAP/Bedrock
  needs (without it SAP answers 400 "Extra inputs are not permitted"). An
  explicit `anthropic_beta` (including [] or null) is sent as given. SAP judges
  unknown edits and betas; its 400 surfaces once, redacted, with no retry. The
  author verified the literal directive against live SAP deployments (Opus 4.8,
  Opus 4.6, Sonnet 4.6, whole replies and streaming). Closes #864.

The test for #812 ("late failure does not delete a newer candidate") now waits
for the first token fetch to start instead of a 10ms sleep, and checks r1
failed, r2 succeeded and two fetches ran. Closes #812.

Version 0.3.1 -> 0.3.2 (the dist branch has 0.3.1; the package is not on npm).

Run at 76e1bfef2 (base 966cf717; origin/main 46fef953 has no sap-aicore change
since), on mote, HOME and TMPDIR under ~/runs, Bun 1.4.2:
- bun test packages/sap-aicore: 343 pass, 0 fail
- bun scripts/check.mjs sap-aicore: registry.json and sap-aicore ok
- bun test (repo root): 6895 tests, 6875 pass, 0 fail, 20 skip (HOME under TMPDIR; not through mote's suite lock, whose queue was hours long)
Broken by hand (messages.test.js + messages-stream.test.js, 46 tests):
- default beta line removed: 4 red (both agent-thinking tests, both defaulting tests)
- beta always set, overriding an explicit one: 4 red (override and novel-beta tests)
- context_management/anthropic_beta out of ALLOWED: 7 red
- main's messages.js: 9 red (adds both metadata tests)
The #812 test is unchanged since 19cabed44, where a 30ms delay injected in
authorize turned the old test red and the new one green.

Co-authored-by: Kanyin Cai <kanyin.cai@sap.com>
2026-11-08 21:48:44 +08:00
caikn 0daf0c7421 sap-aicore 0.3.0: a new provider for SAP AI Core's GPT Responses and Claude Messages deployments (caikn, #651)
A new provider package, @magpie-community/opencode-sap-aicore-auth 0.3.0
(packages/sap-aicore). It signs in from a local SAP AI Core client-secret
credential file, discovers the account's running GPT (Responses) and Claude
(Messages, Bedrock) deployments per resource group, and sends requests only to
https://*.authentication.*.hana.ondemand.com (token) and
https://api.ai.*.hana.ondemand.com (inference). Image input is gated per model
on the catalog's inputTypes. Also: the root README row, a registry.json entry,
.DS_Store in .gitignore, and scripts/check.mjs accepts an empty static model
list for a package whose provider.models hook is a function with the same id
(npm and the loader are still required).

Reviewed at head b44b3e1b68889c2a12bcaa37ad5d546a398bdde0, with main 9bba5fed
merged in locally, on a Mac mini (macOS, Bun 1.4.2), no real SAP account:
- bun test packages/sap-aicore scripts: 351 pass, 0 fail.
- bun scripts/check.mjs: every package ok, sap-aicore included.
- The two tests that reached the network at e955194 now use inputs root()
  really rejects (/oauth, /v1), and a new test stubs fetch and checks that
  /oauth/token and /v2 are accepted and the token is posted to
  <authUrl>/oauth/token once. plugin.test.js fails on any unstubbed fetch.
- Whole package under a preload that records every non-loopback fetch, connect
  and DNS lookup: 0 attempts (the preload caught a deliberate fetch to
  example.invalid, so it does record).
- Broken by hand: putting the e955194 inputs back turns the test red through
  the new guard; making root() keep the given path turns the new
  /oauth/token + /v2 test red; letting root() accept any path turns 3 URL
  tests red.
- Not tried: a real SAP AI Core account (the author's run record covers one
  GPT and one Claude turn, plain and with a tool call; no image turn).

The first version goes out through the dist branch (npm doesn't have the name).
2026-11-04 22:19:43 +08:00