google-agents-cli-extensions 1.14.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- core/claude/README.md +35 -0
- core/claude/template/.agents/skills/agents-cli-claude/SKILL.md +106 -0
- core/claude/template/.agents/skills/agents-cli-claude/references/claude.md +386 -0
- core/claude/template/.agents/skills/agents-cli-claude/references/migrate-claude-agent.md +318 -0
- core/claude/template/.agents/skills/agents-cli-claude/references/migrate-from-aws.md +132 -0
- core/claude/template/.dockerignore +28 -0
- core/claude/template/.env +18 -0
- core/claude/template/.env.example +17 -0
- core/claude/template/.template/templateconfig.yaml +31 -0
- core/claude/template/AGENTS.md +33 -0
- core/claude/template/Dockerfile +55 -0
- core/claude/template/agent_config/README.md +9 -0
- core/claude/template/agents-cli-extension.yaml +49 -0
- core/claude/template/app/__init__.py +15 -0
- core/claude/template/app/agent.py +49 -0
- core/claude/template/app/app_utils/a2a.py +245 -0
- core/claude/template/app/app_utils/bq_analytics/__init__.py +124 -0
- core/claude/template/app/app_utils/bq_analytics/recorder.py +593 -0
- core/claude/template/app/app_utils/bq_analytics/redaction.py +209 -0
- core/claude/template/app/app_utils/bq_analytics/schema.py +394 -0
- core/claude/template/app/app_utils/bq_analytics/tables.py +104 -0
- core/claude/template/app/app_utils/bq_analytics/uploader.py +188 -0
- core/claude/template/app/app_utils/claude.py +297 -0
- core/claude/template/app/app_utils/completions.py +225 -0
- core/claude/template/app/app_utils/conversation.py +29 -0
- core/claude/template/app/app_utils/memory_bank.py +308 -0
- core/claude/template/app/app_utils/project_settings.py +91 -0
- core/claude/template/app/app_utils/reasoning_engine.py +237 -0
- core/claude/template/app/app_utils/remote_agents.py +349 -0
- core/claude/template/app/app_utils/remote_auth.py +159 -0
- core/claude/template/app/app_utils/replies.py +143 -0
- core/claude/template/app/app_utils/session_store.py +174 -0
- core/claude/template/app/app_utils/settings.py +24 -0
- core/claude/template/app/app_utils/telemetry/__init__.py +114 -0
- core/claude/template/app/app_utils/telemetry/call_counts.py +44 -0
- core/claude/template/app/app_utils/telemetry/cli_relay.py +266 -0
- core/claude/template/app/app_utils/telemetry/config.py +133 -0
- core/claude/template/app/app_utils/telemetry/logs.py +175 -0
- core/claude/template/app/app_utils/telemetry/metrics.py +270 -0
- core/claude/template/app/app_utils/telemetry/request_flush.py +104 -0
- core/claude/template/app/app_utils/telemetry/subagent_spans.py +80 -0
- core/claude/template/app/app_utils/telemetry/traces.py +166 -0
- core/claude/template/app/app_utils/turn_events.py +463 -0
- core/claude/template/app/app_utils/turn_options.py +219 -0
- core/claude/template/app/app_utils/workspaces.py +65 -0
- core/claude/template/app/fast_api_app.py +71 -0
- core/claude/template/app/feature_tools.py +27 -0
- core/claude/template/pyproject.toml +100 -0
- core/claude/template/scripts/eval_generate.py +340 -0
- core/claude/template/scripts/publish.py +66 -0
- core/claude/template/scripts/run.py +85 -0
- core/claude/template/scripts/unsupported.py +48 -0
- core/claude/template/tests/eval/datasets/basic-dataset.json +31 -0
- core/claude/template/tests/eval/eval_config.yaml +17 -0
- core/claude/template/tests/eval/response_quality.py +60 -0
- core/claude/template/tests/integration/test_server_e2e.py +168 -0
- core/claude/template/tests/load_test/.results/.placeholder +0 -0
- core/claude/template/tests/load_test/README.md +24 -0
- core/claude/template/tests/load_test/load_test.py +118 -0
- core/claude/template/tests/unit/conftest.py +63 -0
- core/claude/template/tests/unit/helpers.py +32 -0
- core/claude/template/tests/unit/test_a2a.py +432 -0
- core/claude/template/tests/unit/test_bq_analytics.py +928 -0
- core/claude/template/tests/unit/test_bq_redaction.py +89 -0
- core/claude/template/tests/unit/test_claude.py +825 -0
- core/claude/template/tests/unit/test_completions.py +369 -0
- core/claude/template/tests/unit/test_fast_api_app.py +59 -0
- core/claude/template/tests/unit/test_feature_tools.py +55 -0
- core/claude/template/tests/unit/test_memory_bank.py +625 -0
- core/claude/template/tests/unit/test_reasoning_engine.py +295 -0
- core/claude/template/tests/unit/test_remote_agents.py +517 -0
- core/claude/template/tests/unit/test_telemetry.py +991 -0
- core/claude/template/tests/unit/test_turn_events.py +309 -0
- core/claude/template/tests/unit/test_turn_options.py +394 -0
- core/claude/template/uv.lock +3029 -0
- core/langchain/README.md +54 -0
- core/langchain/template/.agents/skills/agents-cli-langchain/SKILL.md +84 -0
- core/langchain/template/.agents/skills/agents-cli-langchain/references/langchain.md +120 -0
- core/langchain/template/.agents/skills/agents-cli-langchain/references/samples.md +42 -0
- core/langchain/template/.template/templateconfig.yaml +32 -0
- core/langchain/template/AGENTS.md +35 -0
- core/langchain/template/agents-cli-extension.yaml +54 -0
- core/langchain/template/app/__init__.py +19 -0
- core/langchain/template/app/agent.py +61 -0
- core/langchain/template/app/app_utils/a2a.py +176 -0
- core/langchain/template/app/app_utils/content.py +37 -0
- core/langchain/template/app/app_utils/telemetry.py +154 -0
- core/langchain/template/app/fast_api_app.py +68 -0
- core/langchain/template/langgraph.json +7 -0
- core/langchain/template/pyproject.toml +102 -0
- core/langchain/template/scripts/_content.py +40 -0
- core/langchain/template/scripts/eval_generate.py +202 -0
- core/langchain/template/scripts/publish.py +59 -0
- core/langchain/template/scripts/run.py +59 -0
- core/langchain/template/scripts/unsupported.py +48 -0
- core/langchain/template/tests/eval/datasets/basic-dataset.json +16 -0
- core/langchain/template/tests/eval/eval_config.yaml +32 -0
- core/langchain/template/tests/eval/response_quality.py +60 -0
- core/langchain/template/tests/integration/test_server_e2e.py +173 -0
- core/langchain/template/tests/load_test/.results/.placeholder +0 -0
- core/langchain/template/tests/load_test/README.md +20 -0
- core/langchain/template/tests/load_test/load_test.py +82 -0
- core/langchain/template/uv.lock +3820 -0
- google_agents_cli_extensions-1.14.2.dist-info/METADATA +133 -0
- google_agents_cli_extensions-1.14.2.dist-info/RECORD +107 -0
- google_agents_cli_extensions-1.14.2.dist-info/WHEEL +4 -0
- google_agents_cli_extensions-1.14.2.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Redact credentials and cap the size of row content.
|
|
16
|
+
|
|
17
|
+
Adapted from google-adk 2.12.0's BigQuery Agent Analytics plugin: the same
|
|
18
|
+
sensitive keys and text patterns, for the plain JSON values the Claude Agent
|
|
19
|
+
SDK produces (dicts, lists, strings and scalars).
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import base64
|
|
25
|
+
import binascii
|
|
26
|
+
import json
|
|
27
|
+
import re
|
|
28
|
+
from typing import Any
|
|
29
|
+
|
|
30
|
+
REDACTED = "[REDACTED]"
|
|
31
|
+
_REDACTED_TEXT = "[REDACTED_SENSITIVE_TEXT]"
|
|
32
|
+
_MAX_DEPTH = 50
|
|
33
|
+
|
|
34
|
+
_SENSITIVE_KEYS = frozenset(
|
|
35
|
+
{
|
|
36
|
+
"client_secret",
|
|
37
|
+
"access_token",
|
|
38
|
+
"refresh_token",
|
|
39
|
+
"id_token",
|
|
40
|
+
"api_key",
|
|
41
|
+
"password",
|
|
42
|
+
"private_key",
|
|
43
|
+
"proxy_authorization",
|
|
44
|
+
"google_access_id",
|
|
45
|
+
"sig",
|
|
46
|
+
"signature",
|
|
47
|
+
"token",
|
|
48
|
+
"secret",
|
|
49
|
+
"authorization",
|
|
50
|
+
"x_api_key",
|
|
51
|
+
"x_amz_credential",
|
|
52
|
+
"x_amz_signature",
|
|
53
|
+
"x_goog_credential",
|
|
54
|
+
"x_goog_security_token",
|
|
55
|
+
"x_goog_signature",
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
# `key: value` / `key=value` / `"key": "value"` for any sensitive key, in text.
|
|
59
|
+
_KEY_VALUE_RE = re.compile(
|
|
60
|
+
r"(?i)(?P<prefix>(?<![A-Za-z0-9_-])(?:[\"'])?(?:"
|
|
61
|
+
r"temp:[A-Za-z0-9_.-]+|"
|
|
62
|
+
+ "|".join(
|
|
63
|
+
sorted(
|
|
64
|
+
(re.escape(key).replace("_", "[-_]") for key in _SENSITIVE_KEYS),
|
|
65
|
+
key=len,
|
|
66
|
+
reverse=True,
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
+ r")(?:[\"'])?\s*[:=]\s*)(?P<value>"
|
|
70
|
+
r'"(?:\\.|[^"\\])*"'
|
|
71
|
+
r"|'(?:\\.|[^'\\])*'"
|
|
72
|
+
r"|[^\s,;&}]+)"
|
|
73
|
+
)
|
|
74
|
+
_AUTH_HEADER_RE = re.compile(
|
|
75
|
+
r"(?im)(?P<prefix>\b(?:authorization|proxy-authorization|x-api-key|api-key)"
|
|
76
|
+
r"[ \t]*:[ \t]*)[^\r\n]*"
|
|
77
|
+
)
|
|
78
|
+
_BEARER_TOKEN_RE = re.compile(r"(?i)(?P<prefix>\bbearer\s+)(?!of(?:\s|$))[^\s,;]+")
|
|
79
|
+
_BASIC_TOKEN_RE = re.compile(
|
|
80
|
+
r"(?i)(?P<prefix>\bbasic\s+)(?P<value>[A-Za-z0-9+/]+={0,2})"
|
|
81
|
+
r"(?![A-Za-z0-9+/=])"
|
|
82
|
+
)
|
|
83
|
+
_MAX_BASIC_TOKEN_CHARS = 16 * 1024
|
|
84
|
+
_HEX_DIGITS = frozenset("0123456789abcdefABCDEF")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def sanitize(value: Any, max_len: int) -> tuple[Any, bool]:
|
|
88
|
+
"""`value` with credentials redacted and strings capped at `max_len`.
|
|
89
|
+
|
|
90
|
+
Returns the sanitized value and whether any content was cut.
|
|
91
|
+
"""
|
|
92
|
+
return _sanitize(value, max_len, 0)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _sanitize(value: Any, max_len: int, depth: int) -> tuple[Any, bool]:
|
|
96
|
+
if depth >= _MAX_DEPTH:
|
|
97
|
+
return "[MAX_DEPTH_EXCEEDED]", True
|
|
98
|
+
if isinstance(value, str):
|
|
99
|
+
return _sanitize_text(value, max_len, depth)
|
|
100
|
+
if isinstance(value, dict):
|
|
101
|
+
out: dict[Any, Any] = {}
|
|
102
|
+
cut = False
|
|
103
|
+
for key, item in value.items():
|
|
104
|
+
if isinstance(key, str) and _is_sensitive_key(key):
|
|
105
|
+
out[key] = REDACTED
|
|
106
|
+
continue
|
|
107
|
+
out[key], item_cut = _sanitize(item, max_len, depth + 1)
|
|
108
|
+
cut = cut or item_cut
|
|
109
|
+
return out, cut
|
|
110
|
+
if isinstance(value, (list, tuple)):
|
|
111
|
+
items = [_sanitize(item, max_len, depth + 1) for item in value]
|
|
112
|
+
return [item for item, _ in items], any(cut for _, cut in items)
|
|
113
|
+
return value, False
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _is_sensitive_key(key: str) -> bool:
|
|
117
|
+
normalized = key.lower().replace("-", "_")
|
|
118
|
+
return normalized in _SENSITIVE_KEYS or normalized.startswith("temp:")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _sanitize_text(text: str, max_len: int, depth: int) -> tuple[str, bool]:
|
|
122
|
+
cut = False
|
|
123
|
+
stripped = text.strip()
|
|
124
|
+
if stripped[:1] in ("{", "["):
|
|
125
|
+
# A JSON document in a string (cached credentials, a serialized
|
|
126
|
+
# payload) gets the same key redaction as a structured value.
|
|
127
|
+
try:
|
|
128
|
+
parsed = json.loads(stripped)
|
|
129
|
+
except ValueError:
|
|
130
|
+
pass
|
|
131
|
+
else:
|
|
132
|
+
sanitized, cut = _sanitize(parsed, max_len, depth + 1)
|
|
133
|
+
if sanitized != parsed:
|
|
134
|
+
text = json.dumps(sanitized)
|
|
135
|
+
text = _redact_patterns(text)
|
|
136
|
+
# Credentials hidden behind \u, \x or % escapes can't be rewritten in
|
|
137
|
+
# place safely, so the whole text is withheld.
|
|
138
|
+
canonical = _decode_ascii_escapes(text)
|
|
139
|
+
if canonical != text and _redact_patterns(canonical) != canonical:
|
|
140
|
+
return _REDACTED_TEXT, True
|
|
141
|
+
if len(text) > max_len:
|
|
142
|
+
return text[:max_len] + "...[TRUNCATED]", True
|
|
143
|
+
return text, cut
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _redact_patterns(text: str) -> str:
|
|
147
|
+
text = _AUTH_HEADER_RE.sub(lambda m: f"{m.group('prefix')}{REDACTED}", text)
|
|
148
|
+
text = _BEARER_TOKEN_RE.sub(lambda m: f"{m.group('prefix')}{REDACTED}", text)
|
|
149
|
+
text = _BASIC_TOKEN_RE.sub(_redact_basic_token, text)
|
|
150
|
+
return _KEY_VALUE_RE.sub(_redact_key_value, text)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _redact_key_value(match: re.Match[str]) -> str:
|
|
154
|
+
value = match.group("value")
|
|
155
|
+
if value == REDACTED:
|
|
156
|
+
return match.group(0)
|
|
157
|
+
quote = value[:1] if value[:1] in ('"', "'") else ""
|
|
158
|
+
return f"{match.group('prefix')}{quote}{REDACTED}{quote}"
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _redact_basic_token(match: re.Match[str]) -> str:
|
|
162
|
+
"""Redact `Basic <token>` only when the token is base64 credentials."""
|
|
163
|
+
encoded = match.group("value")
|
|
164
|
+
if len(encoded) > _MAX_BASIC_TOKEN_CHARS:
|
|
165
|
+
return f"{match.group('prefix')}{REDACTED}"
|
|
166
|
+
try:
|
|
167
|
+
decoded = base64.b64decode(encoded, validate=True)
|
|
168
|
+
except (binascii.Error, ValueError):
|
|
169
|
+
return match.group(0)
|
|
170
|
+
# "Basic plan" is prose; "Basic dXNlcjpwYXNz" decodes to "user:pass".
|
|
171
|
+
if "=" not in encoded and b":" not in decoded:
|
|
172
|
+
return match.group(0)
|
|
173
|
+
return f"{match.group('prefix')}{REDACTED}"
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _decode_ascii_escapes(text: str) -> str:
|
|
177
|
+
"""Decode nested ASCII \\u, \\x and %XX escapes, in one pass."""
|
|
178
|
+
output: list[str] = []
|
|
179
|
+
for char in text:
|
|
180
|
+
output.append(char)
|
|
181
|
+
while True:
|
|
182
|
+
if (
|
|
183
|
+
len(output) >= 6
|
|
184
|
+
and output[-6] == "\\"
|
|
185
|
+
and output[-5] in ("u", "U")
|
|
186
|
+
and all(c in _HEX_DIGITS for c in output[-4:])
|
|
187
|
+
):
|
|
188
|
+
start, digits = len(output) - 6, "".join(output[-4:])
|
|
189
|
+
elif (
|
|
190
|
+
len(output) >= 4
|
|
191
|
+
and output[-4] == "\\"
|
|
192
|
+
and output[-3] in ("x", "X")
|
|
193
|
+
and all(c in _HEX_DIGITS for c in output[-2:])
|
|
194
|
+
):
|
|
195
|
+
start, digits = len(output) - 4, "".join(output[-2:])
|
|
196
|
+
elif (
|
|
197
|
+
len(output) >= 3
|
|
198
|
+
and output[-3] == "%"
|
|
199
|
+
and all(c in _HEX_DIGITS for c in output[-2:])
|
|
200
|
+
):
|
|
201
|
+
start, digits = len(output) - 3, "".join(output[-2:])
|
|
202
|
+
else:
|
|
203
|
+
break
|
|
204
|
+
decoded = int(digits, 16)
|
|
205
|
+
if decoded > 0x7F:
|
|
206
|
+
break
|
|
207
|
+
del output[start:]
|
|
208
|
+
output.append(chr(decoded))
|
|
209
|
+
return "".join(output)
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""BigQuery Agent Analytics table schema and views, copied from google-adk 2.12.0."""
|
|
16
|
+
|
|
17
|
+
SCHEMA_VERSION = "2"
|
|
18
|
+
|
|
19
|
+
TABLE = "agent_events"
|
|
20
|
+
|
|
21
|
+
CLUSTERING_FIELDS = ["event_type", "agent", "user_id"]
|
|
22
|
+
|
|
23
|
+
VIEW_PREFIX = "v"
|
|
24
|
+
|
|
25
|
+
EVENTS_SCHEMA = [
|
|
26
|
+
{
|
|
27
|
+
"name": "timestamp",
|
|
28
|
+
"type": "TIMESTAMP",
|
|
29
|
+
"mode": "REQUIRED",
|
|
30
|
+
"description": "The UTC timestamp when the event occurred. Used for ordering events "
|
|
31
|
+
"within a session.",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "event_id",
|
|
35
|
+
"type": "STRING",
|
|
36
|
+
"mode": "NULLABLE",
|
|
37
|
+
"description": "A unique identifier assigned before enqueue. Storage Write API "
|
|
38
|
+
"retries preserve this value so duplicate rows can be identified "
|
|
39
|
+
"reliably.",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "event_type",
|
|
43
|
+
"type": "STRING",
|
|
44
|
+
"mode": "NULLABLE",
|
|
45
|
+
"description": "The category of the event (e.g., 'LLM_REQUEST', 'TOOL_CALL', "
|
|
46
|
+
"'AGENT_RESPONSE'). Helps in filtering specific types of "
|
|
47
|
+
"interactions.",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "agent",
|
|
51
|
+
"type": "STRING",
|
|
52
|
+
"mode": "NULLABLE",
|
|
53
|
+
"description": "The name of the agent that generated this event. Useful for "
|
|
54
|
+
"multi-agent systems.",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "session_id",
|
|
58
|
+
"type": "STRING",
|
|
59
|
+
"mode": "NULLABLE",
|
|
60
|
+
"description": "A unique identifier for the entire conversation session. Used to "
|
|
61
|
+
"group all events belonging to a single user interaction.",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "invocation_id",
|
|
65
|
+
"type": "STRING",
|
|
66
|
+
"mode": "NULLABLE",
|
|
67
|
+
"description": "A unique identifier for a single turn or execution within a session. "
|
|
68
|
+
"Groups related events like LLM request and response.",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "user_id",
|
|
72
|
+
"type": "STRING",
|
|
73
|
+
"mode": "NULLABLE",
|
|
74
|
+
"description": "The identifier of the end-user participating in the session, if "
|
|
75
|
+
"available.",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "trace_id",
|
|
79
|
+
"type": "STRING",
|
|
80
|
+
"mode": "NULLABLE",
|
|
81
|
+
"description": "OpenTelemetry trace ID for distributed tracing across services.",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "span_id",
|
|
85
|
+
"type": "STRING",
|
|
86
|
+
"mode": "NULLABLE",
|
|
87
|
+
"description": "BQAA-internal execution-tree span id for this operation. This is the "
|
|
88
|
+
"plugin's own correlation id used with parent_span_id to reconstruct "
|
|
89
|
+
"the agent/LLM/tool tree -- NOT the OpenTelemetry span id, except on "
|
|
90
|
+
"the root/invocation row where it may reuse the ambient OTel span id. "
|
|
91
|
+
"For span-level Cloud Trace correlation use attributes.otel.span_id "
|
|
92
|
+
"(best-effort).",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "parent_span_id",
|
|
96
|
+
"type": "STRING",
|
|
97
|
+
"mode": "NULLABLE",
|
|
98
|
+
"description": "BQAA-internal parent execution-tree span id, used to reconstruct the "
|
|
99
|
+
"operation hierarchy. Points at another BQAA row, not an "
|
|
100
|
+
"OpenTelemetry parent span.",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "content",
|
|
104
|
+
"type": "JSON",
|
|
105
|
+
"mode": "NULLABLE",
|
|
106
|
+
"description": "The primary payload of the event, stored as a JSON string. The "
|
|
107
|
+
"structure depends on the event_type (e.g., prompt text for "
|
|
108
|
+
"LLM_REQUEST, tool output for TOOL_RESPONSE).",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "content_parts",
|
|
112
|
+
"type": "RECORD",
|
|
113
|
+
"mode": "REPEATED",
|
|
114
|
+
"description": "For multi-modal events, contains a list of content parts (text, "
|
|
115
|
+
"images, etc.).",
|
|
116
|
+
"fields": [
|
|
117
|
+
{
|
|
118
|
+
"name": "mime_type",
|
|
119
|
+
"type": "STRING",
|
|
120
|
+
"mode": "NULLABLE",
|
|
121
|
+
"description": "The MIME type of the content part (e.g., 'text/plain', "
|
|
122
|
+
"'image/png').",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "uri",
|
|
126
|
+
"type": "STRING",
|
|
127
|
+
"mode": "NULLABLE",
|
|
128
|
+
"description": "The URI of the content part if stored externally (e.g., "
|
|
129
|
+
"GCS bucket path).",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "object_ref",
|
|
133
|
+
"type": "RECORD",
|
|
134
|
+
"mode": "NULLABLE",
|
|
135
|
+
"description": "The ObjectRef of the content part if stored externally.",
|
|
136
|
+
"fields": [
|
|
137
|
+
{
|
|
138
|
+
"name": "uri",
|
|
139
|
+
"type": "STRING",
|
|
140
|
+
"mode": "NULLABLE",
|
|
141
|
+
"description": "The URI of the object.",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "version",
|
|
145
|
+
"type": "STRING",
|
|
146
|
+
"mode": "NULLABLE",
|
|
147
|
+
"description": "The version of the object.",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "authorizer",
|
|
151
|
+
"type": "STRING",
|
|
152
|
+
"mode": "NULLABLE",
|
|
153
|
+
"description": "The authorizer for the object.",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "details",
|
|
157
|
+
"type": "JSON",
|
|
158
|
+
"mode": "NULLABLE",
|
|
159
|
+
"description": "Additional details about the object.",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "text",
|
|
165
|
+
"type": "STRING",
|
|
166
|
+
"mode": "NULLABLE",
|
|
167
|
+
"description": "The raw text content if the part is text-based.",
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "part_index",
|
|
171
|
+
"type": "INTEGER",
|
|
172
|
+
"mode": "NULLABLE",
|
|
173
|
+
"description": "The zero-based index of this part within the content.",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "part_attributes",
|
|
177
|
+
"type": "STRING",
|
|
178
|
+
"mode": "NULLABLE",
|
|
179
|
+
"description": "Additional metadata for this content part as a JSON "
|
|
180
|
+
"object (serialized to string).",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "storage_mode",
|
|
184
|
+
"type": "STRING",
|
|
185
|
+
"mode": "NULLABLE",
|
|
186
|
+
"description": "Indicates how the content part is stored (e.g., "
|
|
187
|
+
"'INLINE', 'GCS_REFERENCE', 'EXTERNAL_URI').",
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "attributes",
|
|
193
|
+
"type": "JSON",
|
|
194
|
+
"mode": "NULLABLE",
|
|
195
|
+
"description": "A JSON object containing arbitrary key-value pairs for additional "
|
|
196
|
+
"event metadata. Includes enrichment fields like 'root_agent_name' "
|
|
197
|
+
"(turn orchestration), 'model' (request model), 'model_version' "
|
|
198
|
+
"(response version), and 'usage_metadata' (detailed token counts). "
|
|
199
|
+
"May also carry 'otel' (best-effort ambient Cloud Trace span/trace "
|
|
200
|
+
"ids) and 'custom_metadata' (allowlisted event.custom_metadata "
|
|
201
|
+
"keys).",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"name": "latency_ms",
|
|
205
|
+
"type": "JSON",
|
|
206
|
+
"mode": "NULLABLE",
|
|
207
|
+
"description": "A JSON object containing latency measurements, such as 'total_ms' "
|
|
208
|
+
"and 'time_to_first_token_ms'.",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "status",
|
|
212
|
+
"type": "STRING",
|
|
213
|
+
"mode": "NULLABLE",
|
|
214
|
+
"description": "The outcome of the event, typically 'OK' or 'ERROR'.",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"name": "error_message",
|
|
218
|
+
"type": "STRING",
|
|
219
|
+
"mode": "NULLABLE",
|
|
220
|
+
"description": "Diagnostic message for errors and model termination details; may be "
|
|
221
|
+
"populated on rows whose status is 'OK', such as LLM_RESPONSE rows "
|
|
222
|
+
"and rows whose content_formatter failed.",
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"name": "is_truncated",
|
|
226
|
+
"type": "BOOLEAN",
|
|
227
|
+
"mode": "NULLABLE",
|
|
228
|
+
"description": "Boolean flag indicating if the content or metadata payload was "
|
|
229
|
+
"truncated because it exceeded the maximum allowed size. Set when "
|
|
230
|
+
"'content', captured 'custom_metadata', or A2A metadata is truncated; "
|
|
231
|
+
"redaction of sensitive keys does not set this flag.",
|
|
232
|
+
},
|
|
233
|
+
]
|
|
234
|
+
|
|
235
|
+
VIEW_COMMON_COLUMNS = [
|
|
236
|
+
"timestamp",
|
|
237
|
+
"event_id",
|
|
238
|
+
"event_type",
|
|
239
|
+
"agent",
|
|
240
|
+
"session_id",
|
|
241
|
+
"invocation_id",
|
|
242
|
+
"user_id",
|
|
243
|
+
"trace_id",
|
|
244
|
+
"span_id",
|
|
245
|
+
"parent_span_id",
|
|
246
|
+
"status",
|
|
247
|
+
"error_message",
|
|
248
|
+
"is_truncated",
|
|
249
|
+
]
|
|
250
|
+
|
|
251
|
+
EVENT_VIEW_DEFS = {
|
|
252
|
+
"USER_MESSAGE_RECEIVED": [],
|
|
253
|
+
"LLM_REQUEST": [
|
|
254
|
+
"JSON_VALUE(attributes, '$.model') AS model",
|
|
255
|
+
"content AS request_content",
|
|
256
|
+
"JSON_QUERY(attributes, '$.llm_config') AS llm_config",
|
|
257
|
+
"JSON_QUERY(attributes, '$.tools') AS tools",
|
|
258
|
+
],
|
|
259
|
+
"LLM_RESPONSE": [
|
|
260
|
+
"JSON_QUERY(content, '$.response') AS response",
|
|
261
|
+
"CAST(JSON_VALUE(content, '$.usage.prompt') AS INT64) AS usage_prompt_tokens",
|
|
262
|
+
"CAST(JSON_VALUE(content, '$.usage.completion') AS INT64) AS "
|
|
263
|
+
"usage_completion_tokens",
|
|
264
|
+
"CAST(JSON_VALUE(content, '$.usage.total') AS INT64) AS usage_total_tokens",
|
|
265
|
+
"CAST(JSON_VALUE(attributes, "
|
|
266
|
+
"'$.usage_metadata.cached_content_token_count') AS INT64) AS "
|
|
267
|
+
"usage_cached_tokens",
|
|
268
|
+
"CAST(JSON_VALUE(attributes, "
|
|
269
|
+
"'$.usage_metadata.thoughts_token_count') AS INT64) AS "
|
|
270
|
+
"usage_thinking_tokens",
|
|
271
|
+
"CAST(JSON_VALUE(attributes, "
|
|
272
|
+
"'$.usage_metadata.tool_use_prompt_token_count') AS INT64) AS "
|
|
273
|
+
"usage_tool_use_tokens",
|
|
274
|
+
"SAFE_DIVIDE(CAST(JSON_VALUE(attributes, "
|
|
275
|
+
"'$.usage_metadata.cached_content_token_count') AS "
|
|
276
|
+
"INT64),CAST(JSON_VALUE(content, '$.usage.prompt') AS INT64)) AS "
|
|
277
|
+
"context_cache_hit_rate",
|
|
278
|
+
"CAST(JSON_VALUE(latency_ms, '$.total_ms') AS INT64) AS total_ms",
|
|
279
|
+
"CAST(JSON_VALUE(latency_ms, '$.time_to_first_token_ms') AS INT64) AS ttft_ms",
|
|
280
|
+
"JSON_VALUE(attributes, '$.model_version') AS model_version",
|
|
281
|
+
"JSON_QUERY(attributes, '$.usage_metadata') AS usage_metadata",
|
|
282
|
+
"JSON_QUERY(attributes, '$.cache_metadata') AS cache_metadata",
|
|
283
|
+
"JSON_VALUE(attributes, '$.cache_type') AS cache_type",
|
|
284
|
+
"JSON_VALUE(attributes, '$.finish_reason') AS finish_reason",
|
|
285
|
+
],
|
|
286
|
+
"LLM_ERROR": ["CAST(JSON_VALUE(latency_ms, '$.total_ms') AS INT64) AS total_ms"],
|
|
287
|
+
"TOOL_STARTING": [
|
|
288
|
+
"JSON_VALUE(content, '$.tool') AS tool_name",
|
|
289
|
+
"JSON_QUERY(content, '$.args') AS tool_args",
|
|
290
|
+
"JSON_VALUE(content, '$.tool_origin') AS tool_origin",
|
|
291
|
+
],
|
|
292
|
+
"TOOL_COMPLETED": [
|
|
293
|
+
"JSON_VALUE(content, '$.tool') AS tool_name",
|
|
294
|
+
"JSON_QUERY(content, '$.result') AS tool_result",
|
|
295
|
+
"JSON_VALUE(content, '$.tool_origin') AS tool_origin",
|
|
296
|
+
"CAST(JSON_VALUE(latency_ms, '$.total_ms') AS INT64) AS total_ms",
|
|
297
|
+
"JSON_VALUE(attributes, '$.adk.pause_kind') AS pause_kind",
|
|
298
|
+
"JSON_VALUE(attributes, '$.adk.function_call_id') AS function_call_id",
|
|
299
|
+
],
|
|
300
|
+
"TOOL_ERROR": [
|
|
301
|
+
"JSON_VALUE(content, '$.tool') AS tool_name",
|
|
302
|
+
"JSON_QUERY(content, '$.args') AS tool_args",
|
|
303
|
+
"JSON_VALUE(content, '$.tool_origin') AS tool_origin",
|
|
304
|
+
"CAST(JSON_VALUE(latency_ms, '$.total_ms') AS INT64) AS total_ms",
|
|
305
|
+
],
|
|
306
|
+
"AGENT_STARTING": [
|
|
307
|
+
"COALESCE(JSON_VALUE(content, '$.text_summary'), "
|
|
308
|
+
"IF(REGEXP_CONTAINS(JSON_VALUE(content, '$'), "
|
|
309
|
+
"r'^(?:<(?:function|bound method) |<.+ at "
|
|
310
|
+
"0x[0-9a-fA-F]+>|functools\\.partial\\()'), NULL, "
|
|
311
|
+
"JSON_VALUE(content, '$'))) AS agent_instruction",
|
|
312
|
+
"JSON_VALUE(attributes, '$.instruction_source') AS instruction_source",
|
|
313
|
+
"JSON_VALUE(attributes, '$.static_instruction') AS static_instruction",
|
|
314
|
+
"JSON_VALUE(attributes, '$.agent_description') AS agent_description",
|
|
315
|
+
"JSON_VALUE(attributes, '$.model') AS model",
|
|
316
|
+
"JSON_QUERY(attributes, '$.sub_agents') AS sub_agents",
|
|
317
|
+
],
|
|
318
|
+
"AGENT_COMPLETED": [
|
|
319
|
+
"CAST(JSON_VALUE(latency_ms, '$.total_ms') AS INT64) AS total_ms"
|
|
320
|
+
],
|
|
321
|
+
"AGENT_ERROR": [
|
|
322
|
+
"CAST(JSON_VALUE(latency_ms, '$.total_ms') AS INT64) AS total_ms",
|
|
323
|
+
"JSON_VALUE(content, '$.error_traceback') AS error_traceback",
|
|
324
|
+
],
|
|
325
|
+
"INVOCATION_STARTING": [],
|
|
326
|
+
"INVOCATION_COMPLETED": [],
|
|
327
|
+
"INVOCATION_ERROR": ["JSON_VALUE(content, '$.error_traceback') AS error_traceback"],
|
|
328
|
+
"STATE_DELTA": ["JSON_QUERY(attributes, '$.state_delta') AS state_delta"],
|
|
329
|
+
"HITL_CREDENTIAL_REQUEST": [
|
|
330
|
+
"JSON_VALUE(content, '$.tool') AS tool_name",
|
|
331
|
+
"JSON_QUERY(content, '$.args') AS tool_args",
|
|
332
|
+
],
|
|
333
|
+
"HITL_CONFIRMATION_REQUEST": [
|
|
334
|
+
"JSON_VALUE(content, '$.tool') AS tool_name",
|
|
335
|
+
"JSON_QUERY(content, '$.args') AS tool_args",
|
|
336
|
+
],
|
|
337
|
+
"HITL_INPUT_REQUEST": [
|
|
338
|
+
"JSON_VALUE(content, '$.tool') AS tool_name",
|
|
339
|
+
"JSON_QUERY(content, '$.args') AS tool_args",
|
|
340
|
+
],
|
|
341
|
+
"A2A_INTERACTION": [
|
|
342
|
+
"content AS response_content",
|
|
343
|
+
"JSON_VALUE(attributes, '$.a2a_metadata.\"a2a:task_id\"') AS a2a_task_id",
|
|
344
|
+
"JSON_VALUE(attributes, '$.a2a_metadata.\"a2a:context_id\"') AS a2a_context_id",
|
|
345
|
+
"JSON_QUERY(attributes, '$.a2a_metadata.\"a2a:request\"') AS a2a_request",
|
|
346
|
+
"JSON_QUERY(attributes, '$.a2a_metadata.\"a2a:response\"') AS a2a_response",
|
|
347
|
+
],
|
|
348
|
+
"AGENT_RESPONSE": [
|
|
349
|
+
"JSON_VALUE(content, '$.response') AS response_text",
|
|
350
|
+
"JSON_VALUE(attributes, '$.source_event_id') AS source_event_id",
|
|
351
|
+
"JSON_VALUE(attributes, '$.source_event_author') AS source_event_author",
|
|
352
|
+
"JSON_VALUE(attributes, '$.source_event_branch') AS source_event_branch",
|
|
353
|
+
],
|
|
354
|
+
"AGENT_TRANSFER": [
|
|
355
|
+
"JSON_VALUE(content, '$.from_agent') AS from_agent",
|
|
356
|
+
"JSON_VALUE(content, '$.to_agent') AS to_agent",
|
|
357
|
+
"JSON_VALUE(attributes, '$.adk.source_event_id') AS source_event_id",
|
|
358
|
+
],
|
|
359
|
+
"EVENT_COMPACTION": [
|
|
360
|
+
"CAST(JSON_VALUE(content, '$.start_timestamp') AS FLOAT64) AS start_seconds",
|
|
361
|
+
"CAST(JSON_VALUE(content, '$.end_timestamp') AS FLOAT64) AS end_seconds",
|
|
362
|
+
"TIMESTAMP_MICROS(CAST(CAST(JSON_VALUE(content, "
|
|
363
|
+
"'$.start_timestamp') AS FLOAT64) * 1000000 AS INT64)) AS "
|
|
364
|
+
"window_start",
|
|
365
|
+
"TIMESTAMP_MICROS(CAST(CAST(JSON_VALUE(content, "
|
|
366
|
+
"'$.end_timestamp') AS FLOAT64) * 1000000 AS INT64)) AS "
|
|
367
|
+
"window_end",
|
|
368
|
+
"JSON_QUERY(content, '$.compacted_content') AS compacted_content",
|
|
369
|
+
],
|
|
370
|
+
"AGENT_STATE_CHECKPOINT": [
|
|
371
|
+
"JSON_QUERY(content, '$.agent_state') AS agent_state",
|
|
372
|
+
"JSON_TYPE(JSON_QUERY(content, '$.agent_state')) AS agent_state_type",
|
|
373
|
+
"SAFE_CAST(JSON_VALUE(content, '$.end_of_agent') AS BOOL) AS end_of_agent",
|
|
374
|
+
"JSON_VALUE(attributes, '$.adk.source_event_id') AS source_event_id",
|
|
375
|
+
],
|
|
376
|
+
"TOOL_PAUSED": [
|
|
377
|
+
"JSON_VALUE(content, '$.tool') AS tool_name",
|
|
378
|
+
"JSON_QUERY(content, '$.args') AS tool_args",
|
|
379
|
+
"JSON_VALUE(attributes, '$.adk.pause_kind') AS pause_kind",
|
|
380
|
+
"JSON_VALUE(attributes, '$.adk.function_call_id') AS function_call_id",
|
|
381
|
+
],
|
|
382
|
+
"NODE_OUTPUT": [
|
|
383
|
+
"JSON_VALUE(attributes, '$.adk.node.path') AS node_path",
|
|
384
|
+
"JSON_VALUE(attributes, '$.adk.node.run_id') AS node_run_id",
|
|
385
|
+
"JSON_VALUE(attributes, '$.adk.node.parent_run_id') AS node_parent_run_id",
|
|
386
|
+
"content AS output",
|
|
387
|
+
],
|
|
388
|
+
"NODE_ERROR": [
|
|
389
|
+
"JSON_VALUE(attributes, '$.adk.node.path') AS node_path",
|
|
390
|
+
"JSON_VALUE(attributes, '$.adk.node.run_id') AS node_run_id",
|
|
391
|
+
"JSON_VALUE(attributes, '$.adk.node.parent_run_id') AS node_parent_run_id",
|
|
392
|
+
"JSON_VALUE(content, '$.error_code') AS error_code",
|
|
393
|
+
],
|
|
394
|
+
}
|