feat(clients): Part.thoughtSignature and file-backed access tokens; plan rules updated

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 05:02:18 +02:00
co-authored by Claude Sonnet 5.5
parent fcdb7242be
commit 29d775a923
6 changed files with 98 additions and 18 deletions
+34
View File
@@ -1,6 +1,9 @@
// Foundation shared by every agent-platform module: all-verb client,
// streaming decoder, typed Gemini content, resource names, operations,
// pagination.
#include <unistd.h>
#include <fstream>
#include <memory>
#include "framework.h"
@@ -261,3 +264,34 @@ TEST(foundation, access_token_beats_key) {
ASSERT_EQ(std::string(Credentials::from_env()->scheme()), "apikey");
unsetenv("GOOGLE_API_KEY");
}
TEST(foundation, thought_signature_roundtrips) {
Part p = Part::of_call(FunctionCall{"f", Json::object(), ""});
p.thought_signature = "c2lnbmF0dXJl";
Part back = Part::from_json(Json::parse(p.to_json().dump()));
ASSERT_EQ(back.thought_signature, "c2lnbmF0dXJl");
ASSERT_TRUE(back.function_call.has_value());
Part plain = Part::of_text("x");
ASSERT_TRUE(plain.to_json().find("thoughtSignature") == nullptr);
}
TEST(foundation, file_token_is_reread_per_request) {
char path[] = "/tmp/molo_tokenXXXXXX";
int fd = mkstemp(path);
ASSERT_TRUE(fd >= 0);
close(fd);
auto write = [&](const std::string& t) { std::ofstream(path, std::ios::trunc) << t; };
FileTokenAuth auth(path);
molo::clients::ClientRequest r1 = molo::clients::ClientRequest::get("https://x.googleapis.com/");
write("tok-one\n");
auth.apply(r1);
ASSERT_EQ(r1.headers().get_or("Authorization", ""), "Bearer tok-one");
molo::clients::ClientRequest r2 = molo::clients::ClientRequest::get("https://x.googleapis.com/");
write("tok-two");
auth.apply(r2);
ASSERT_EQ(r2.headers().get_or("Authorization", ""), "Bearer tok-two");
write("");
molo::clients::ClientRequest r3 = molo::clients::ClientRequest::get("https://x.googleapis.com/");
ASSERT_THROW(auth.apply(r3), GoogleError);
unlink(path);
}