@silverprotocol/google-adk 0.6.6 → 0.7.0
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.
- package/README.md +10 -2
- package/dist/auth-objects.d.ts +56 -0
- package/dist/auth-objects.d.ts.map +1 -0
- package/dist/auth-objects.js +405 -0
- package/dist/auth-objects.js.map +1 -0
- package/dist/index.d.ts +55 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +484 -384
- package/dist/index.js.map +1 -1
- package/dist/json-guards.d.ts +11 -0
- package/dist/json-guards.d.ts.map +1 -0
- package/dist/json-guards.js +15 -0
- package/dist/json-guards.js.map +1 -0
- package/package.json +2 -2
- package/src/auth-objects.ts +407 -0
- package/src/index.ts +556 -396
- package/src/json-guards.ts +20 -0
package/README.md
CHANGED
|
@@ -58,6 +58,8 @@ facet's per-field dispositions, including its disclosed `silently-dropped` gaps)
|
|
|
58
58
|
|
|
59
59
|
> **Usage semantics (spec draft.3).** `usage.outputTokens` includes reasoning: the facet folds Gemini's sibling `thoughtsTokenCount` into `outputTokens` (candidates + thoughts, guarded by Gemini's own total so an already-inclusive endpoint is not double-added), and `reasoningTokens` is the breakdown — never add the two. `inputTokens + outputTokens + (toolUseInputTokens ?? 0) == totalTokens` holds on every Gemini response. Known upstream gap: on `@google/adk`'s Interactions-API route (`useInteractionsApi`) the SDK synthesizes `usageMetadata` without thoughts, so there `outputTokens` is exclusive and `reasoningTokens` absent.
|
|
60
60
|
|
|
61
|
+
> **Tool outcomes (spec draft.4, §8.0 item 25).** ADK reports a failed tool call as a `functionResponse` whose `response` carries Gemini's `error` key. The facet maps it to `tool.done` `outcome:"error"` with `isError:true`, plus `errorText` when `error` is a string and `errorCode` from `error_code`/`errorCode`. This covers an unresolvable tool name, a thrown tool (including a thrown MCP call) and several built-in tools. An MCP result with `isError:true` also reads `"error"` with `isError:true`. A declined approval (a FunctionTool or SecurityPlugin rejection, a policy-engine DENY, `CONFIRMATION_REJECTED`) reads `"denied"`. ADK's pending-confirmation placeholder stays `"ok"`; the pause rides `hitl.ask`. The response always stays verbatim in `content`. So a tool of yours that returns `{error: …}` as ordinary data now reads as a failure.
|
|
62
|
+
|
|
61
63
|
```ts
|
|
62
64
|
import { LlmAgent, InMemoryRunner } from "@google/adk";
|
|
63
65
|
import { createAdkNormalizer } from "@silverprotocol/google-adk";
|
|
@@ -89,7 +91,13 @@ agEvents.push(...n.flush()); // seal anything still open
|
|
|
89
91
|
`flush()` drains buffered end-of-stream state. Any async/sync iterable of ADK
|
|
90
92
|
`Event`s works — a live `runAsync()` run, or events you captured earlier.
|
|
91
93
|
|
|
92
|
-
> **ADK pauses and Workflow runs.** Construct one normalizer per `runAsync()` call and call `flush()` once when it ends. When ADK pauses a run for a human, the turn closes from `push()` as `turn.done` with `outcome: "paused"` and `finishReason: "paused"`, carrying one ask per pending request.
|
|
94
|
+
> **ADK pauses and Workflow runs.** Construct one normalizer per `runAsync()` call and call `flush()` once when it ends. When ADK pauses a run for a human, the turn closes from `push()` as `turn.done` with `outcome: "paused"` and `finishReason: "paused"`, carrying one ask per pending request (spec §8.0 item 26). ADK's reserved calls map as follows: `adk_request_input` becomes a `text` ask (`form` when it declares a `response_schema`); `adk_request_credential` becomes an `auth` ask; `adk_request_confirmation` becomes an `approval` ask. Each ask's `toolCallId` is the reserved call's id, the id ADK accepts as the answer (`resumeBinding: "id"`), and the original tool call's id rides `metadata.originalFunctionCallId`. On a graph `Workflow`, a node's own final answer never ends the run.
|
|
95
|
+
>
|
|
96
|
+
> **Completion (spec §8.0 host obligation 4).** ADK's stream carries no end marker for a completed run. Opt in with `createAdkNormalizer({ hostCompletion: true })` and push `{ type: "__host_complete__" }` after `runAsync()` returns NORMALLY, never after a cancel, an abort signal or a thrown error, and before `flush()`. The turn then closes from `push()`: `paused` if an ask is pending, `success` otherwise; a non-HITL long-running call that is still unanswered leaves the turn to `flush()`. With the option on, a success close waits for that event, so SequentialAgent roots and after-agent callback content no longer land after the terminal. Without the opt-in, or when the host doesn't feed the event, a completed Workflow run closes at `flush()` as `turn.abort` (`stream-truncated`), with its usage on the `message.end`. The `__host_complete__` object is a host↔facet contract input, like the error sentinel of host obligation 1, not an ADK event. So with the option off the normalizer ignores it on purpose, and the §8.0 rule against silently dropping a framework event does not apply to it.
|
|
97
|
+
|
|
98
|
+
> **Errors the runtime throws (spec §8.0 host obligation 1).** When ADK throws instead of ending the stream (for example its LLM-call limit), catch it and push `{ type: "__host_error__", code, message, usage?, invocationId? }` (exported as `ADK_HOST_ERROR_TYPE`) before `flush()`: the open turn closes `turn.error` with that code and message, and with no turn open a fresh terminal turn carries it. That turn is named from the invoke's own `invocationId`, so it stays unique across the invokes a host folds together; for an error before any event, pass `invocationId` if you have it (otherwise a per-instance stem is used). The sentinel may be the caught Error itself with `type` and `code` assigned; its message is kept.
|
|
99
|
+
|
|
100
|
+
> **Credential material (spec §8.0 item 28).** ADK credential material is the one exception to the compatibility table's "carried losslessly". In an `adk_request_credential` call and its reply, the facet carries only the auth-config members it knows to be non-secret. In `state.delta` it omits every entry that holds an ADK credential object, and every `temp:` entry. Inside a `provider-raw` carry it reduces each ADK credential object, and each response to `adk_request_credential`, to its non-secret members; when that reduces a node's output, the text part ADK renders from that output is skipped too. A credential an application keeps in a shape of its own is not recognised, and rides unchanged.
|
|
93
101
|
|
|
94
102
|
Then fold the resulting `AgEvent`s into messages and turns with
|
|
95
103
|
`@silverprotocol/core`'s `reduce()` — the same client code regardless of which
|
|
@@ -97,4 +105,4 @@ framework produced the stream.
|
|
|
97
105
|
|
|
98
106
|
Spec: [silverprotocol.io/AgJSON](https://silverprotocol.io/AgJSON) — canonical
|
|
99
107
|
in [silverprotocol/AgJSON](https://github.com/silverprotocol/AgJSON); wire
|
|
100
|
-
version `1.0.0-draft.
|
|
108
|
+
version `1.0.0-draft.4`.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADK auth objects inside anything the facet carries: the flat AgAuthConfig
|
|
3
|
+
* view, the member allowlists, the shared-state credential omission and the
|
|
4
|
+
* node-data reduction. Internal to @silverprotocol/google-adk (not part of its
|
|
5
|
+
* package exports); index.ts is the only importer, and the tests call these
|
|
6
|
+
* helpers directly.
|
|
7
|
+
*/
|
|
8
|
+
import { JsonValue, type AgAuthConfig } from "@silverprotocol/core";
|
|
9
|
+
export declare const ADK_REQUEST_CREDENTIAL = "adk_request_credential";
|
|
10
|
+
type AllowSpec = {
|
|
11
|
+
[key: string]: true | ((v: JsonValue) => JsonValue | undefined);
|
|
12
|
+
};
|
|
13
|
+
export declare function snakeKey(k: string): string;
|
|
14
|
+
/** Copy only the allowlisted members of `v` (camel or snake spelling), each
|
|
15
|
+
* either verbatim (`true`) or through its nested allowlist. */
|
|
16
|
+
export declare function pickAllowed(v: JsonValue | undefined, spec: AllowSpec): JsonValue | undefined;
|
|
17
|
+
/** Whether `v` is, or holds at any depth (arrays included), an ADK
|
|
18
|
+
* AuthCredential. Iterative and cycle-safe over the raw native value; a value
|
|
19
|
+
* that cannot be walked counts as holding one, so this never throws. */
|
|
20
|
+
export declare function holdsAuthCredential(v: unknown): boolean;
|
|
21
|
+
/** The state map ADK yields, minus its "temp:" entries and every entry that
|
|
22
|
+
* holds an ADK AuthCredential, in the original key order. A map with none of
|
|
23
|
+
* those is carried exactly as before. When entries were omitted, a remaining
|
|
24
|
+
* entry that is not JSON is dropped rather than thrown on, since a throw would
|
|
25
|
+
* hand the raw native event to the host's error path. A value that is not a
|
|
26
|
+
* map of entries (an array, a scalar, or an ADK AuthCredential itself) is
|
|
27
|
+
* carried as before, or as {} if it holds a credential. */
|
|
28
|
+
export declare function scrubStateMap(raw: unknown): JsonValue;
|
|
29
|
+
/** The ADK AuthConfig reduced to its non-secret members ({} for a non-object). */
|
|
30
|
+
export declare function scrubAdkAuthConfig(native: JsonValue): JsonValue;
|
|
31
|
+
/** A reserved-credential functionResponse (the client's answer) scrubbed the
|
|
32
|
+
* same way; undefined when the response is not an object. */
|
|
33
|
+
export declare function scrubbedResponse(response: unknown): {
|
|
34
|
+
readonly [k: string]: JsonValue;
|
|
35
|
+
} | undefined;
|
|
36
|
+
/** Any value the facet carries in a provider-raw block, with every ADK
|
|
37
|
+
* AuthCredential and every response named adk_request_credential reduced as
|
|
38
|
+
* for node data (see above). A value holding neither is returned unchanged;
|
|
39
|
+
* one that cannot be reduced is carried as {}. Never throws. */
|
|
40
|
+
export declare function reduceCarried(v: JsonValue): JsonValue;
|
|
41
|
+
/** A node-data value for a provider-raw carry. `changed` says whether the
|
|
42
|
+
* reduction altered it; `undefined` omits the unit. */
|
|
43
|
+
export declare function carryNodeValue(raw: unknown): {
|
|
44
|
+
value: JsonValue;
|
|
45
|
+
changed: boolean;
|
|
46
|
+
} | undefined;
|
|
47
|
+
/** JSON.stringify of a raw `output` whose node-data reduction changed or
|
|
48
|
+
* omitted it: the text ADK renders from that output. `undefined` otherwise
|
|
49
|
+
* (including a string output, which ADK renders as itself). */
|
|
50
|
+
export declare function changedOutputRendering(output: unknown): string | undefined;
|
|
51
|
+
/** The reserved credential call's args: its id, its message and the scrubbed
|
|
52
|
+
* AuthConfig. Nothing else is forwarded. */
|
|
53
|
+
export declare function scrubCredentialCallArgs(args: JsonValue): JsonValue;
|
|
54
|
+
export declare function adkAuthConfigView(native: JsonValue): AgAuthConfig | undefined;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=auth-objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-objects.d.ts","sourceRoot":"","sources":["../src/auth-objects.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAoCpE,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,KAAK,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,SAAS,GAAG,SAAS,CAAC,CAAA;CAAE,CAAC;AAErF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;gEACgE;AAChE,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAa5F;AA2ID;;yEAEyE;AACzE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEvD;AA0BD;;;;;;4DAM4D;AAC5D,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAYrD;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAE/D;AAED;8DAC8D;AAC9D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG;IAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAInG;AAgCD;;;iEAGiE;AACjE,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,CAOrD;AAaD;wDACwD;AACxD,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAU/F;AAED;;gEAEgE;AAChE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAY1E;AAED;6CAC6C;AAC7C,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAQlE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CAuC7E"}
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADK auth objects inside anything the facet carries: the flat AgAuthConfig
|
|
3
|
+
* view, the member allowlists, the shared-state credential omission and the
|
|
4
|
+
* node-data reduction. Internal to @silverprotocol/google-adk (not part of its
|
|
5
|
+
* package exports); index.ts is the only importer, and the tests call these
|
|
6
|
+
* helpers directly.
|
|
7
|
+
*/
|
|
8
|
+
import { JsonValue } from "@silverprotocol/core";
|
|
9
|
+
import { isJsonObject, stringMember } from "./json-guards.js";
|
|
10
|
+
// ─── ADK AuthConfig → flat AgAuthConfig view (SPEC §8.0 item 12) ─────────────
|
|
11
|
+
// ADK's AuthConfig (@google/adk 2.1.0 dist/types/auth/auth_tool.d.ts:12-42) is
|
|
12
|
+
// `{ authScheme, rawAuthCredential?, exchangedAuthCredential?, credentialKey }`,
|
|
13
|
+
// with authScheme an OpenAPI v3 SecuritySchemeObject or OIDC-with-config
|
|
14
|
+
// (auth_schemes.d.ts:12, :25). The view maps ONLY what has a native value:
|
|
15
|
+
// - scheme ← authScheme.type, verbatim; no string type → no view at all (the
|
|
16
|
+
// field is required and never invented);
|
|
17
|
+
// - authorizationUrl / tokenUrl / scopes follow ADK's own derivation
|
|
18
|
+
// (dist/esm/auth/auth_handler.js:112-128): OIDC-with-config's
|
|
19
|
+
// authorizationEndpoint / tokenEndpoint / scopes; for oauth2, the first
|
|
20
|
+
// present flow of implicit > authorizationCode > clientCredentials >
|
|
21
|
+
// password, with scopes = the keys of its OpenAPI scopes map;
|
|
22
|
+
// - clientId / audience ← rawAuthCredential.oauth2 (auth_credential.d.ts:35-62).
|
|
23
|
+
// credentialKey, secrets and exchange state never enter the view.
|
|
24
|
+
// ─── ADK auth objects: carry only members known to be non-secret ─────────────
|
|
25
|
+
// An ADK AuthConfig, and the credential objects inside it, can hold credential
|
|
26
|
+
// material. Anything the facet forwards is persisted by hosts (hitl.ask →
|
|
27
|
+
// turn.done paused asks[]; tool-call blocks). So every carrier of an ADK auth
|
|
28
|
+
// object is an ALLOWLIST: a member is forwarded only when it is known to be
|
|
29
|
+
// non-secret, and every other member, at any depth, is omitted. The list is
|
|
30
|
+
// checked against @google/adk 2.1.0 dist/types/auth/auth_tool.d.ts and
|
|
31
|
+
// auth_credential.d.ts. Keys match in camelCase or snake_case (the reserved
|
|
32
|
+
// call's args arrive snake_case at the top level); a kept key keeps its wire
|
|
33
|
+
// spelling.
|
|
34
|
+
//
|
|
35
|
+
// Resume safety (ADK 2.1.0, a tool's credential request inside an LlmAgent):
|
|
36
|
+
// the credential resume rebuilds the request
|
|
37
|
+
// server-side from the session's own reserved call (auth_preprocessor.js
|
|
38
|
+
// requestedAuthConfigs) and takes only the auth code / response URI from the
|
|
39
|
+
// client's answer (credential_response_binding.js bindCredential; the raw
|
|
40
|
+
// credential is restored from the request). An oauth2/OIDC request always
|
|
41
|
+
// carries a generated authUri (auth_handler.js generateAuthRequest). So what
|
|
42
|
+
// the allowlist omits is never needed to answer the ask.
|
|
43
|
+
export const ADK_REQUEST_CREDENTIAL = "adk_request_credential";
|
|
44
|
+
export function snakeKey(k) {
|
|
45
|
+
return k.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
46
|
+
}
|
|
47
|
+
/** Copy only the allowlisted members of `v` (camel or snake spelling), each
|
|
48
|
+
* either verbatim (`true`) or through its nested allowlist. */
|
|
49
|
+
export function pickAllowed(v, spec) {
|
|
50
|
+
if (!isJsonObject(v))
|
|
51
|
+
return undefined;
|
|
52
|
+
const out = {};
|
|
53
|
+
for (const [name, rule] of Object.entries(spec)) {
|
|
54
|
+
for (const key of name === snakeKey(name) ? [name] : [name, snakeKey(name)]) {
|
|
55
|
+
if (!Object.hasOwn(v, key))
|
|
56
|
+
continue;
|
|
57
|
+
const member = v[key];
|
|
58
|
+
if (member === undefined)
|
|
59
|
+
continue;
|
|
60
|
+
const kept = rule === true ? member : rule(member);
|
|
61
|
+
if (kept !== undefined)
|
|
62
|
+
out[key] = kept;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
const OAUTH2_ALLOW = {
|
|
68
|
+
clientId: true,
|
|
69
|
+
authUri: true,
|
|
70
|
+
redirectUri: true,
|
|
71
|
+
scopes: true,
|
|
72
|
+
codeChallengeMethod: true,
|
|
73
|
+
tokenEndpointAuthMethod: true,
|
|
74
|
+
expiresAt: true,
|
|
75
|
+
expiresIn: true,
|
|
76
|
+
audience: true,
|
|
77
|
+
};
|
|
78
|
+
const SERVICE_ACCOUNT_ALLOW = {
|
|
79
|
+
scopes: true,
|
|
80
|
+
useDefaultCredential: true,
|
|
81
|
+
useIdToken: true,
|
|
82
|
+
audience: true,
|
|
83
|
+
serviceAccountCredential: (v) => pickAllowed(v, { projectId: true, clientEmail: true, tokenUri: true, universeDomain: true }),
|
|
84
|
+
};
|
|
85
|
+
const AUTH_CREDENTIAL_ALLOW = {
|
|
86
|
+
authType: true,
|
|
87
|
+
resourceRef: true,
|
|
88
|
+
oauth2: (v) => pickAllowed(v, OAUTH2_ALLOW),
|
|
89
|
+
serviceAccount: (v) => pickAllowed(v, SERVICE_ACCOUNT_ALLOW),
|
|
90
|
+
};
|
|
91
|
+
// The security scheme, member by member: an OpenAPI 3.0 SecuritySchemeObject
|
|
92
|
+
// (openapi-types 12.1.3 OpenAPIV3: http, apiKey, oauth2 and openIdConnect,
|
|
93
|
+
// the type @google/adk 2.1.0's auth_schemes.d.ts names) or ADK's
|
|
94
|
+
// OpenIdConnectWithConfig. Every leaf is a string, a string list or a map of
|
|
95
|
+
// strings, and only those survive. A scheme member no type declares (a vendor
|
|
96
|
+
// extension, a stray field) never rides.
|
|
97
|
+
const schemeString = (v) => (typeof v === "string" ? v : undefined);
|
|
98
|
+
const schemeStringList = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : undefined;
|
|
99
|
+
/** A map this facet rebuilds from native entries never carries an own
|
|
100
|
+
* `__proto__` key (SPEC §13.7): JsonValue.parse drops one, and
|
|
101
|
+
* Object.fromEntries would re-create it as an own property. */
|
|
102
|
+
function isReservedMapKey(k) {
|
|
103
|
+
return k === "__proto__";
|
|
104
|
+
}
|
|
105
|
+
/** OAuth2 flow scopes are a map of scope name -> description; OIDC config
|
|
106
|
+
* scopes are a list. Either keeps only its string entries. */
|
|
107
|
+
const schemeScopes = (v) => Array.isArray(v)
|
|
108
|
+
? schemeStringList(v)
|
|
109
|
+
: isJsonObject(v)
|
|
110
|
+
? Object.fromEntries(Object.entries(v).filter((e) => !isReservedMapKey(e[0]) && typeof e[1] === "string"))
|
|
111
|
+
: undefined;
|
|
112
|
+
const OAUTH2_FLOW_ALLOW = {
|
|
113
|
+
authorizationUrl: schemeString,
|
|
114
|
+
tokenUrl: schemeString,
|
|
115
|
+
refreshUrl: schemeString,
|
|
116
|
+
scopes: schemeScopes,
|
|
117
|
+
};
|
|
118
|
+
const AUTH_SCHEME_ALLOW = {
|
|
119
|
+
type: schemeString,
|
|
120
|
+
description: schemeString,
|
|
121
|
+
// http
|
|
122
|
+
scheme: schemeString,
|
|
123
|
+
bearerFormat: schemeString,
|
|
124
|
+
// apiKey (the header/query parameter's name and location, never its value)
|
|
125
|
+
name: schemeString,
|
|
126
|
+
in: schemeString,
|
|
127
|
+
// oauth2 (flows.password is the password-GRANT flow: a tokenUrl and scopes)
|
|
128
|
+
flows: (v) => pickAllowed(v, {
|
|
129
|
+
implicit: (f) => pickAllowed(f, OAUTH2_FLOW_ALLOW),
|
|
130
|
+
password: (f) => pickAllowed(f, OAUTH2_FLOW_ALLOW),
|
|
131
|
+
clientCredentials: (f) => pickAllowed(f, OAUTH2_FLOW_ALLOW),
|
|
132
|
+
authorizationCode: (f) => pickAllowed(f, OAUTH2_FLOW_ALLOW),
|
|
133
|
+
}),
|
|
134
|
+
// openIdConnect
|
|
135
|
+
openIdConnectUrl: schemeString,
|
|
136
|
+
// OpenIdConnectWithConfig
|
|
137
|
+
authorizationEndpoint: schemeString,
|
|
138
|
+
tokenEndpoint: schemeString,
|
|
139
|
+
userinfoEndpoint: schemeString,
|
|
140
|
+
revocationEndpoint: schemeString,
|
|
141
|
+
tokenEndpointAuthMethodsSupported: schemeStringList,
|
|
142
|
+
grantTypesSupported: schemeStringList,
|
|
143
|
+
scopes: schemeScopes,
|
|
144
|
+
};
|
|
145
|
+
const AUTH_CONFIG_ALLOW = {
|
|
146
|
+
authScheme: (v) => pickAllowed(v, AUTH_SCHEME_ALLOW),
|
|
147
|
+
credentialKey: true,
|
|
148
|
+
rawAuthCredential: (v) => pickAllowed(v, AUTH_CREDENTIAL_ALLOW),
|
|
149
|
+
exchangedAuthCredential: (v) => pickAllowed(v, AUTH_CREDENTIAL_ALLOW),
|
|
150
|
+
};
|
|
151
|
+
// ─── shared state (state.delta) ──────────────────────────────────────────────
|
|
152
|
+
// ADK itself writes an exchanged AuthCredential into the event's
|
|
153
|
+
// actions.stateDelta on two paths (@google/adk 2.1.0):
|
|
154
|
+
// - a Runner configured with SessionStateCredentialService saves it under the
|
|
155
|
+
// bare credentialKey (session_state_credential_service.js; ToolContext's
|
|
156
|
+
// State writes value AND delta, agents/context.js:37-39, sessions/state.js:97-102);
|
|
157
|
+
// - a Workflow FunctionNode whose auth step runs again on resume stores it
|
|
158
|
+
// under "temp:" + credentialKey (auth_handler.js:35-38, :47), and function_node.js
|
|
159
|
+
// copies every new delta entry into the event it yields (:93-127). A Runner
|
|
160
|
+
// removes "temp:" entries from a non-partial event as it appends it to the
|
|
161
|
+
// session, before yielding it; a partial event, or an event read before
|
|
162
|
+
// that append, still carries them.
|
|
163
|
+
// ADK treats any value under the key as a stored credential
|
|
164
|
+
// (hitl_utils.js:131-133), so the entry is omitted whole: a redacted value left
|
|
165
|
+
// behind would read as a credential. Every "temp:" entry is omitted too
|
|
166
|
+
// (invocation-scoped by ADK's contract). Every other entry rides unchanged.
|
|
167
|
+
const ADK_TEMP_STATE_PREFIX = "temp:";
|
|
168
|
+
const AUTH_CREDENTIAL_TYPES = new Set(["apiKey", "http", "oauth2", "openIdConnect", "serviceAccount"]);
|
|
169
|
+
// resourceRef (auth_credential.d.ts:244) names a stored credential: ADK's
|
|
170
|
+
// presence readers treat an object holding it as a held credential.
|
|
171
|
+
const AUTH_CREDENTIAL_MEMBERS = [
|
|
172
|
+
"apiKey",
|
|
173
|
+
"api_key",
|
|
174
|
+
"http",
|
|
175
|
+
"oauth2",
|
|
176
|
+
"serviceAccount",
|
|
177
|
+
"service_account",
|
|
178
|
+
"resourceRef",
|
|
179
|
+
"resource_ref",
|
|
180
|
+
];
|
|
181
|
+
function isObjectRecord(v) {
|
|
182
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
183
|
+
}
|
|
184
|
+
/** An ADK AuthCredential: `authType` (either spelling) is one of ADK's
|
|
185
|
+
* credential types (auth_credential.d.ts) and a credential member is present
|
|
186
|
+
* and non-null. */
|
|
187
|
+
function isAuthCredentialObject(v) {
|
|
188
|
+
const typed = ["authType", "auth_type"].some((k) => {
|
|
189
|
+
const t = Object.hasOwn(v, k) ? v[k] : undefined;
|
|
190
|
+
return typeof t === "string" && AUTH_CREDENTIAL_TYPES.has(t);
|
|
191
|
+
});
|
|
192
|
+
return typed && AUTH_CREDENTIAL_MEMBERS.some((m) => Object.hasOwn(v, m) && v[m] !== null && v[m] !== undefined);
|
|
193
|
+
}
|
|
194
|
+
/** Whether `v` is, or holds at any depth (arrays included), an ADK
|
|
195
|
+
* AuthCredential. Iterative and cycle-safe over the raw native value; a value
|
|
196
|
+
* that cannot be walked counts as holding one, so this never throws. */
|
|
197
|
+
export function holdsAuthCredential(v) {
|
|
198
|
+
return holdsObject(v, isAuthCredentialObject);
|
|
199
|
+
}
|
|
200
|
+
/** Whether `v` is, or holds at any depth (arrays included), an object `match`
|
|
201
|
+
* accepts. Iterative and cycle-safe over the raw native value; a value that
|
|
202
|
+
* cannot be walked counts as holding one, so this never throws. */
|
|
203
|
+
function holdsObject(v, match) {
|
|
204
|
+
try {
|
|
205
|
+
const seen = new Set();
|
|
206
|
+
const stack = [v];
|
|
207
|
+
while (stack.length > 0) {
|
|
208
|
+
const x = stack.pop();
|
|
209
|
+
if (x === null || typeof x !== "object" || seen.has(x))
|
|
210
|
+
continue;
|
|
211
|
+
seen.add(x);
|
|
212
|
+
if (Array.isArray(x)) {
|
|
213
|
+
for (const y of x)
|
|
214
|
+
stack.push(y);
|
|
215
|
+
}
|
|
216
|
+
else if (isObjectRecord(x)) {
|
|
217
|
+
if (match(x))
|
|
218
|
+
return true;
|
|
219
|
+
for (const k of Object.keys(x))
|
|
220
|
+
stack.push(x[k]);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/** The state map ADK yields, minus its "temp:" entries and every entry that
|
|
230
|
+
* holds an ADK AuthCredential, in the original key order. A map with none of
|
|
231
|
+
* those is carried exactly as before. When entries were omitted, a remaining
|
|
232
|
+
* entry that is not JSON is dropped rather than thrown on, since a throw would
|
|
233
|
+
* hand the raw native event to the host's error path. A value that is not a
|
|
234
|
+
* map of entries (an array, a scalar, or an ADK AuthCredential itself) is
|
|
235
|
+
* carried as before, or as {} if it holds a credential. */
|
|
236
|
+
export function scrubStateMap(raw) {
|
|
237
|
+
if (!isObjectRecord(raw) || isAuthCredentialObject(raw))
|
|
238
|
+
return holdsAuthCredential(raw) ? {} : JsonValue.parse(raw);
|
|
239
|
+
const keys = Object.keys(raw);
|
|
240
|
+
const omitted = keys.map((k) => k.startsWith(ADK_TEMP_STATE_PREFIX) || holdsAuthCredential(raw[k]));
|
|
241
|
+
if (!omitted.includes(true))
|
|
242
|
+
return JsonValue.parse(raw);
|
|
243
|
+
const kept = [];
|
|
244
|
+
keys.forEach((k, i) => {
|
|
245
|
+
if (omitted[i] === true || isReservedMapKey(k))
|
|
246
|
+
return;
|
|
247
|
+
const parsed = JsonValue.safeParse(raw[k]);
|
|
248
|
+
if (parsed.success)
|
|
249
|
+
kept.push([k, parsed.data]);
|
|
250
|
+
});
|
|
251
|
+
return Object.fromEntries(kept);
|
|
252
|
+
}
|
|
253
|
+
/** The ADK AuthConfig reduced to its non-secret members ({} for a non-object). */
|
|
254
|
+
export function scrubAdkAuthConfig(native) {
|
|
255
|
+
return pickAllowed(native, AUTH_CONFIG_ALLOW) ?? {};
|
|
256
|
+
}
|
|
257
|
+
/** A reserved-credential functionResponse (the client's answer) scrubbed the
|
|
258
|
+
* same way; undefined when the response is not an object. */
|
|
259
|
+
export function scrubbedResponse(response) {
|
|
260
|
+
if (!isJsonObject(response))
|
|
261
|
+
return undefined;
|
|
262
|
+
const scrubbed = scrubAdkAuthConfig(response);
|
|
263
|
+
return isJsonObject(scrubbed) ? scrubbed : undefined;
|
|
264
|
+
}
|
|
265
|
+
// ─── provider-raw carries of node data ───────────────────────────────────────
|
|
266
|
+
// A Workflow event's `output` and `actions.agentState` ride verbatim in
|
|
267
|
+
// provider-raw. Inside them, each ADK AuthCredential (detected as for shared
|
|
268
|
+
// state) is reduced to its allowlisted members, and each response named
|
|
269
|
+
// adk_request_credential (matched by that name at any depth, never by id)
|
|
270
|
+
// keeps only its id, its name and the reserved-credential answer's
|
|
271
|
+
// allowlisted response, so an untyped reply becomes {}. Every other member
|
|
272
|
+
// rides unchanged. A value with neither is parsed exactly as before; a value
|
|
273
|
+
// that cannot be walked or reduced is omitted, never thrown on.
|
|
274
|
+
/** A response named adk_request_credential (a functionResponse object). */
|
|
275
|
+
function isCredentialRequestResponse(v) {
|
|
276
|
+
return v["name"] === ADK_REQUEST_CREDENTIAL && Object.hasOwn(v, "name") && Object.hasOwn(v, "response");
|
|
277
|
+
}
|
|
278
|
+
/** One JSON value with every credential object and credential-request
|
|
279
|
+
* response reduced (see above); recursion stops at a reduced unit. */
|
|
280
|
+
function reduceCredentialCarry(v) {
|
|
281
|
+
if (Array.isArray(v))
|
|
282
|
+
return v.map(reduceCredentialCarry);
|
|
283
|
+
if (!isJsonObject(v))
|
|
284
|
+
return v;
|
|
285
|
+
if (isAuthCredentialObject(v))
|
|
286
|
+
return pickAllowed(v, AUTH_CREDENTIAL_ALLOW) ?? {};
|
|
287
|
+
if (isCredentialRequestResponse(v))
|
|
288
|
+
return pickAllowed(v, { id: true, name: true, response: (r) => scrubbedResponse(r) }) ?? {};
|
|
289
|
+
return Object.fromEntries(Object.entries(v)
|
|
290
|
+
.filter(([k]) => !isReservedMapKey(k))
|
|
291
|
+
.map(([k, x]) => [k, reduceCredentialCarry(x)]));
|
|
292
|
+
}
|
|
293
|
+
/** Any value the facet carries in a provider-raw block, with every ADK
|
|
294
|
+
* AuthCredential and every response named adk_request_credential reduced as
|
|
295
|
+
* for node data (see above). A value holding neither is returned unchanged;
|
|
296
|
+
* one that cannot be reduced is carried as {}. Never throws. */
|
|
297
|
+
export function reduceCarried(v) {
|
|
298
|
+
if (!holdsAuthCredential(v) && !holdsObject(v, isCredentialRequestResponse))
|
|
299
|
+
return v;
|
|
300
|
+
try {
|
|
301
|
+
return reduceCredentialCarry(v);
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
return {};
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/** JSON with object keys in sorted order: "did the reduction change it"
|
|
308
|
+
* compares members, not the order an allowlist writes them in. */
|
|
309
|
+
function canonicalJson(v) {
|
|
310
|
+
if (Array.isArray(v))
|
|
311
|
+
return `[${v.map(canonicalJson).join(",")}]`;
|
|
312
|
+
if (!isJsonObject(v))
|
|
313
|
+
return JSON.stringify(v);
|
|
314
|
+
return `{${Object.keys(v)
|
|
315
|
+
.sort()
|
|
316
|
+
.map((k) => `${JSON.stringify(k)}:${canonicalJson(v[k] ?? null)}`)
|
|
317
|
+
.join(",")}}`;
|
|
318
|
+
}
|
|
319
|
+
/** A node-data value for a provider-raw carry. `changed` says whether the
|
|
320
|
+
* reduction altered it; `undefined` omits the unit. */
|
|
321
|
+
export function carryNodeValue(raw) {
|
|
322
|
+
if (!holdsAuthCredential(raw) && !holdsObject(raw, isCredentialRequestResponse))
|
|
323
|
+
return { value: JsonValue.parse(raw), changed: false };
|
|
324
|
+
try {
|
|
325
|
+
const before = JsonValue.parse(JSON.parse(JSON.stringify(raw)));
|
|
326
|
+
const value = reduceCredentialCarry(before);
|
|
327
|
+
return { value, changed: canonicalJson(value) !== canonicalJson(before) };
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/** JSON.stringify of a raw `output` whose node-data reduction changed or
|
|
334
|
+
* omitted it: the text ADK renders from that output. `undefined` otherwise
|
|
335
|
+
* (including a string output, which ADK renders as itself). */
|
|
336
|
+
export function changedOutputRendering(output) {
|
|
337
|
+
if (output === undefined || output === null || typeof output !== "object")
|
|
338
|
+
return undefined;
|
|
339
|
+
// Detection first, so an output holding neither is never parsed here.
|
|
340
|
+
if (!holdsAuthCredential(output) && !holdsObject(output, isCredentialRequestResponse))
|
|
341
|
+
return undefined;
|
|
342
|
+
const carried = carryNodeValue(output);
|
|
343
|
+
if (carried !== undefined && !carried.changed)
|
|
344
|
+
return undefined;
|
|
345
|
+
try {
|
|
346
|
+
const rendered = JSON.stringify(output);
|
|
347
|
+
return typeof rendered === "string" ? rendered : undefined;
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
return undefined;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/** The reserved credential call's args: its id, its message and the scrubbed
|
|
354
|
+
* AuthConfig. Nothing else is forwarded. */
|
|
355
|
+
export function scrubCredentialCallArgs(args) {
|
|
356
|
+
return (pickAllowed(args, {
|
|
357
|
+
functionCallId: true,
|
|
358
|
+
message: true,
|
|
359
|
+
authConfig: (v) => scrubAdkAuthConfig(v),
|
|
360
|
+
}) ?? {});
|
|
361
|
+
}
|
|
362
|
+
export function adkAuthConfigView(native) {
|
|
363
|
+
if (!isJsonObject(native))
|
|
364
|
+
return undefined;
|
|
365
|
+
const authScheme = native["authScheme"];
|
|
366
|
+
const scheme = stringMember(authScheme, "type");
|
|
367
|
+
if (scheme === undefined || !isJsonObject(authScheme))
|
|
368
|
+
return undefined;
|
|
369
|
+
let authorizationUrl;
|
|
370
|
+
let tokenUrl;
|
|
371
|
+
let scopes;
|
|
372
|
+
if ("authorizationEndpoint" in authScheme) {
|
|
373
|
+
authorizationUrl = stringMember(authScheme, "authorizationEndpoint");
|
|
374
|
+
tokenUrl = stringMember(authScheme, "tokenEndpoint");
|
|
375
|
+
const s = authScheme["scopes"];
|
|
376
|
+
if (Array.isArray(s))
|
|
377
|
+
scopes = s.filter((x) => typeof x === "string");
|
|
378
|
+
}
|
|
379
|
+
else if (scheme === "oauth2") {
|
|
380
|
+
const flows = authScheme["flows"];
|
|
381
|
+
const flow = isJsonObject(flows)
|
|
382
|
+
? [flows["implicit"], flows["authorizationCode"], flows["clientCredentials"], flows["password"]].find(isJsonObject)
|
|
383
|
+
: undefined;
|
|
384
|
+
if (flow !== undefined) {
|
|
385
|
+
authorizationUrl = stringMember(flow, "authorizationUrl");
|
|
386
|
+
tokenUrl = stringMember(flow, "tokenUrl");
|
|
387
|
+
const s = flow["scopes"];
|
|
388
|
+
if (isJsonObject(s))
|
|
389
|
+
scopes = Object.keys(s);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const raw = native["rawAuthCredential"];
|
|
393
|
+
const oauth2 = isJsonObject(raw) ? raw["oauth2"] : undefined;
|
|
394
|
+
const clientId = stringMember(oauth2, "clientId");
|
|
395
|
+
const audience = stringMember(oauth2, "audience");
|
|
396
|
+
return {
|
|
397
|
+
scheme,
|
|
398
|
+
...(scopes !== undefined ? { scopes } : {}),
|
|
399
|
+
...(authorizationUrl !== undefined ? { authorizationUrl } : {}),
|
|
400
|
+
...(tokenUrl !== undefined ? { tokenUrl } : {}),
|
|
401
|
+
...(clientId !== undefined ? { clientId } : {}),
|
|
402
|
+
...(audience !== undefined ? { audience } : {}),
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=auth-objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-objects.js","sourceRoot":"","sources":["../src/au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E,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,14 @@
|
|
|
48
48
|
* surface. The Python ADK uses the snake_case aliases (`turn_complete`,
|
|
49
49
|
* `function_call`); a runtime adapter would map those before this seam. This
|
|
50
50
|
* fixture contract is the camelCase wire projection.
|
|
51
|
+
*
|
|
52
|
+
* NOTE on turn ids across invokes: google-adk derives turn ids from ADK's
|
|
53
|
+
* `invocationId`, which ADK-JS mints fresh on every `runAsync` (including a
|
|
54
|
+
* resume), so they don't repeat across the invokes of a fold. ADK-Python's
|
|
55
|
+
* resumable resume reuses `invocation_id`, and this facet also accepts events
|
|
56
|
+
* serialized from Python: fed that resume, it would repeat `turn_${invocationId}`
|
|
57
|
+
* (and the message id derived from it) across the fold. Supporting that path
|
|
58
|
+
* needs a per-invoke stem; it is queued, not part of this release.
|
|
51
59
|
*/
|
|
52
60
|
import { type AgFinishReason, JsonValue, type Normalizer } from "@silverprotocol/core";
|
|
53
61
|
/** A Gemini `Part` — the discriminated-by-presence union (one of the arms
|
|
@@ -417,5 +425,51 @@ export declare function mapFinishReason(reason: string | undefined | null): AgFi
|
|
|
417
425
|
* table — the lossy arms). Exported for the same testability reason as
|
|
418
426
|
* mapFinishReason. */
|
|
419
427
|
export declare function isLossyFinishReason(reason: string): boolean;
|
|
420
|
-
|
|
428
|
+
/** Options for {@link createAdkNormalizer}. */
|
|
429
|
+
export interface AdkNormalizerOptions {
|
|
430
|
+
/**
|
|
431
|
+
* Opt in to SPEC §8.0 host obligation 4 (draft.4): the host feeds
|
|
432
|
+
* `{ type: "__host_complete__" }` after the ADK run returned NORMALLY (never
|
|
433
|
+
* after a cancel, an abort signal or a thrown error), before `flush()`.
|
|
434
|
+
* Then a success close waits for that event (so a Workflow, a
|
|
435
|
+
* SequentialAgent or after-agent callback content can follow a node's final
|
|
436
|
+
* text), and on it each still-open turn closes: `paused` if an ask is
|
|
437
|
+
* pending, left to `flush()` if a non-HITL long-running call is unanswered,
|
|
438
|
+
* else `success`. Default off: the step-1 behaviour.
|
|
439
|
+
*/
|
|
440
|
+
hostCompletion?: boolean;
|
|
441
|
+
}
|
|
442
|
+
/** The facet-local host-completion native (§8.0 host obligation 4). */
|
|
443
|
+
export declare const ADK_HOST_COMPLETE_TYPE = "__host_complete__";
|
|
444
|
+
/**
|
|
445
|
+
* SPEC §8.0 host obligation 1: when the ADK runtime THROWS instead of ending
|
|
446
|
+
* the stream (e.g. its LLM-call limit), the host catches it and pushes
|
|
447
|
+
* `{ type: "__host_error__", code, message, usage?, invocationId? }`. The
|
|
448
|
+
* open turn closes `turn.error` with that code and message. The shape matches the OpenAI
|
|
449
|
+
* facet's sentinel. A host may build it from the caught Error itself
|
|
450
|
+
* (`Object.assign(err, { type: "__host_error__", code })`): the sentinel is
|
|
451
|
+
* read from the raw native, so the Error's own message is kept.
|
|
452
|
+
*/
|
|
453
|
+
export declare const ADK_HOST_ERROR_TYPE = "__host_error__";
|
|
454
|
+
/**
|
|
455
|
+
* The google-adk Normalizer: the inner, deterministic normalizer below wrapped
|
|
456
|
+
* in core's withAtomicPush (the fleet guard ruling). Every push() is atomic:
|
|
457
|
+
* - The native is read once as plain JSON through core's toJsonValueSafe, so a
|
|
458
|
+
* host may push the live Event objects ADK yields (undefined members, a
|
|
459
|
+
* Date, an Error, a cycle) and they map exactly like the recorded corpus.
|
|
460
|
+
* - If mapping one native throws (an event whose envelope is valid but whose
|
|
461
|
+
* inner members have unexpected types), its partial batch is discarded
|
|
462
|
+
* without consuming seq, the inner is rebuilt by re-driving every native
|
|
463
|
+
* accepted so far (the inner never reads the clock or randomness; ids come
|
|
464
|
+
* from invocationId and per-invoke ordinals, and the one random stem, for a
|
|
465
|
+
* host error before any event, is drawn outside the inner and kept), and
|
|
466
|
+
* ONE core `error {message:
|
|
467
|
+
* "normalizer error", code: <constructor name>}` takes the next seq, with no
|
|
468
|
+
* payload and no message text.
|
|
469
|
+
* - flush() is guarded the same way; the wrapper closes what the consumer saw
|
|
470
|
+
* open itself, without calling the inner again.
|
|
471
|
+
* So push() never throws (SPEC §8.0), and no facet state believes a turn,
|
|
472
|
+
* message or block is open that never reached the wire.
|
|
473
|
+
*/
|
|
474
|
+
export declare function createAdkNormalizer(options?: AdkNormalizerOptions): Normalizer;
|
|
421
475
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,OAAO,EAKL,KAAK,cAAc,EAMnB,SAAS,EACT,KAAK,UAAU,EAKhB,MAAM,sBAAsB,CAAC;AAsB9B;;;qEAGqE;AACrE,MAAM,WAAW,OAAO;IACtB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gFAAgF;IAChF,YAAY,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE;YAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SAAE,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;K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