@google/adk 1.3.0 → 1.4.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/dist/cjs/agents/active_streaming_tool.js +6 -1
- package/dist/cjs/agents/context.js +1 -11
- package/dist/cjs/agents/functions.js +35 -16
- package/dist/cjs/agents/instructions.js +23 -5
- package/dist/cjs/agents/invocation_context.js +2 -5
- package/dist/cjs/agents/llm_agent.js +8 -6
- package/dist/cjs/agents/processors/code_execution_request_processor.js +0 -3
- package/dist/cjs/agents/processors/content_processor_utils.js +16 -3
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +4 -2
- package/dist/cjs/agents/processors/interactions_request_processor.js +63 -0
- package/dist/cjs/apps/app.js +79 -0
- package/dist/cjs/apps/resumability_config.js +44 -0
- package/dist/cjs/artifacts/file_artifact_service.js +14 -1
- package/dist/cjs/artifacts/gcs_artifact_service.js +57 -15
- package/dist/cjs/artifacts/in_memory_artifact_service.js +5 -1
- package/dist/cjs/artifacts/scoped_artifact_service.js +101 -0
- package/dist/cjs/artifacts/session_artifact_service.js +27 -0
- package/dist/cjs/auth/oauth2/oauth2_discovery.js +17 -5
- package/dist/cjs/auth/oauth2/oauth2_utils.js +12 -1
- package/dist/cjs/common.js +47 -0
- package/dist/cjs/context/agent_controlled_context_compactor.js +109 -0
- package/dist/cjs/context/token_based_context_compactor.js +42 -10
- package/dist/cjs/context/trajectory_thought_pruning_compactor.js +71 -0
- package/dist/cjs/events/event.js +24 -0
- package/dist/cjs/models/google_llm.js +25 -10
- package/dist/cjs/models/interactions_utils.js +732 -0
- package/dist/cjs/plugins/base_plugin.js +1 -0
- package/dist/cjs/runner/in_memory_runner.js +13 -2
- package/dist/cjs/runner/runner.js +93 -72
- package/dist/cjs/sessions/base_session_service.js +6 -1
- package/dist/cjs/sessions/database_session_service.js +24 -7
- package/dist/cjs/sessions/vertex_ai_session_service.js +19 -4
- package/dist/cjs/skills/loader.js +2 -2
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/consolidate_context_tool.js +79 -0
- package/dist/cjs/tools/forwarding_artifact_service.js +16 -28
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +2 -12
- package/dist/cjs/utils/async_hooks_shim.js +52 -0
- package/dist/cjs/utils/client_labels.js +41 -3
- package/dist/cjs/utils/env_aware_utils.js +10 -1
- package/dist/cjs/utils/streaming_utils.js +10 -4
- package/dist/cjs/utils/task.js +62 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/agents/active_streaming_tool.js +6 -1
- package/dist/esm/agents/context.js +1 -11
- package/dist/esm/agents/functions.js +36 -15
- package/dist/esm/agents/instructions.js +23 -5
- package/dist/esm/agents/invocation_context.js +2 -5
- package/dist/esm/agents/llm_agent.js +8 -6
- package/dist/esm/agents/processors/code_execution_request_processor.js +0 -3
- package/dist/esm/agents/processors/content_processor_utils.js +14 -2
- package/dist/esm/agents/processors/context_compactor_request_processor.js +4 -2
- package/dist/esm/agents/processors/interactions_request_processor.js +34 -0
- package/dist/esm/apps/app.js +49 -0
- package/dist/esm/apps/resumability_config.js +16 -0
- package/dist/esm/artifacts/file_artifact_service.js +14 -1
- package/dist/esm/artifacts/gcs_artifact_service.js +57 -15
- package/dist/esm/artifacts/in_memory_artifact_service.js +5 -1
- package/dist/esm/artifacts/scoped_artifact_service.js +73 -0
- package/dist/esm/artifacts/session_artifact_service.js +7 -0
- package/dist/esm/auth/oauth2/oauth2_discovery.js +14 -4
- package/dist/esm/auth/oauth2/oauth2_utils.js +12 -1
- package/dist/esm/common.js +42 -2
- package/dist/esm/context/agent_controlled_context_compactor.js +81 -0
- package/dist/esm/context/token_based_context_compactor.js +42 -10
- package/dist/esm/context/trajectory_thought_pruning_compactor.js +43 -0
- package/dist/esm/events/event.js +22 -0
- package/dist/esm/models/google_llm.js +23 -9
- package/dist/esm/models/interactions_utils.js +697 -0
- package/dist/esm/plugins/base_plugin.js +1 -0
- package/dist/esm/runner/in_memory_runner.js +13 -2
- package/dist/esm/runner/runner.js +91 -73
- package/dist/esm/sessions/base_session_service.js +6 -1
- package/dist/esm/sessions/database_session_service.js +24 -7
- package/dist/esm/sessions/vertex_ai_session_service.js +17 -3
- package/dist/esm/skills/loader.js +2 -2
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/consolidate_context_tool.js +51 -0
- package/dist/esm/tools/forwarding_artifact_service.js +16 -28
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +2 -12
- package/dist/esm/utils/async_hooks_shim.js +24 -0
- package/dist/esm/utils/client_labels.js +38 -2
- package/dist/esm/utils/env_aware_utils.js +10 -1
- package/dist/esm/utils/streaming_utils.js +10 -4
- package/dist/esm/utils/task.js +34 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/agents/active_streaming_tool.d.ts +3 -4
- package/dist/types/agents/functions.d.ts +12 -9
- package/dist/types/agents/invocation_context.d.ts +7 -3
- package/dist/types/agents/processors/content_processor_utils.d.ts +8 -0
- package/dist/types/agents/processors/interactions_request_processor.d.ts +17 -0
- package/dist/types/apps/app.d.ts +52 -0
- package/dist/types/apps/resumability_config.d.ts +27 -0
- package/dist/types/artifacts/base_artifact_service.d.ts +6 -36
- package/dist/types/artifacts/gcs_artifact_service.d.ts +2 -1
- package/dist/types/artifacts/scoped_artifact_service.d.ts +25 -0
- package/dist/types/artifacts/session_artifact_service.d.ts +25 -0
- package/dist/types/auth/oauth2/oauth2_discovery.d.ts +11 -0
- package/dist/types/common.d.ts +20 -3
- package/dist/types/context/agent_controlled_context_compactor.d.ts +24 -0
- package/dist/types/context/base_context_compactor.d.ts +3 -0
- package/dist/types/context/token_based_context_compactor.d.ts +6 -1
- package/dist/types/context/trajectory_thought_pruning_compactor.d.ts +27 -0
- package/dist/types/events/event.d.ts +8 -0
- package/dist/types/models/google_llm.d.ts +15 -1
- package/dist/types/models/interactions_utils.d.ts +92 -0
- package/dist/types/models/llm_request.d.ts +4 -0
- package/dist/types/models/llm_response.d.ts +4 -0
- package/dist/types/plugins/base_plugin.d.ts +2 -1
- package/dist/types/runner/in_memory_runner.d.ts +7 -1
- package/dist/types/runner/runner.d.ts +43 -9
- package/dist/types/sessions/base_session_service.d.ts +3 -16
- package/dist/types/sessions/session.d.ts +11 -0
- package/dist/types/sessions/vertex_ai_session_service.d.ts +9 -1
- package/dist/types/tools/consolidate_context_tool.d.ts +19 -0
- package/dist/types/tools/forwarding_artifact_service.d.ts +3 -2
- package/dist/types/utils/async_hooks_shim.d.ts +10 -0
- package/dist/types/utils/client_labels.d.ts +10 -0
- package/dist/types/utils/env_aware_utils.d.ts +3 -3
- package/dist/types/utils/task.d.ts +24 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/web/agents/active_streaming_tool.js +6 -1
- package/dist/web/agents/context.js +1 -11
- package/dist/web/agents/functions.js +36 -15
- package/dist/web/agents/instructions.js +23 -5
- package/dist/web/agents/invocation_context.js +2 -5
- package/dist/web/agents/llm_agent.js +8 -6
- package/dist/web/agents/processors/code_execution_request_processor.js +0 -3
- package/dist/web/agents/processors/content_processor_utils.js +14 -2
- package/dist/web/agents/processors/context_compactor_request_processor.js +4 -2
- package/dist/web/agents/processors/interactions_request_processor.js +52 -0
- package/dist/web/apps/app.js +49 -0
- package/dist/web/apps/resumability_config.js +31 -0
- package/dist/web/artifacts/file_artifact_service.js +14 -1
- package/dist/web/artifacts/gcs_artifact_service.js +55 -15
- package/dist/web/artifacts/in_memory_artifact_service.js +5 -1
- package/dist/web/artifacts/scoped_artifact_service.js +86 -0
- package/dist/web/artifacts/session_artifact_service.js +7 -0
- package/dist/web/auth/oauth2/oauth2_discovery.js +14 -4
- package/dist/web/auth/oauth2/oauth2_utils.js +12 -1
- package/dist/web/common.js +42 -2
- package/dist/web/context/agent_controlled_context_compactor.js +81 -0
- package/dist/web/context/token_based_context_compactor.js +42 -10
- package/dist/web/context/trajectory_thought_pruning_compactor.js +43 -0
- package/dist/web/events/event.js +20 -0
- package/dist/web/models/google_llm.js +54 -9
- package/dist/web/models/interactions_utils.js +728 -0
- package/dist/web/plugins/base_plugin.js +1 -0
- package/dist/web/runner/in_memory_runner.js +13 -2
- package/dist/web/runner/runner.js +111 -75
- package/dist/web/sessions/base_session_service.js +6 -1
- package/dist/web/sessions/database_session_service.js +24 -7
- package/dist/web/sessions/vertex_ai_session_service.js +17 -3
- package/dist/web/skills/loader.js +2 -2
- package/dist/web/tools/base_toolset.js +1 -1
- package/dist/web/tools/consolidate_context_tool.js +51 -0
- package/dist/web/tools/forwarding_artifact_service.js +16 -28
- package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +2 -12
- package/dist/web/utils/async_hooks_shim.js +24 -0
- package/dist/web/utils/client_labels.js +38 -2
- package/dist/web/utils/env_aware_utils.js +10 -1
- package/dist/web/utils/streaming_utils.js +10 -4
- package/dist/web/utils/task.js +34 -0
- package/dist/web/version.js +1 -1
- package/package.json +2 -2
|
@@ -15,9 +15,6 @@ async function resolveKey(key, isOptional, rawMatch, readonlyContext) {
|
|
|
15
15
|
throw new Error("Artifact service is not initialized.");
|
|
16
16
|
}
|
|
17
17
|
const artifact = await invocationContext.artifactService.loadArtifact({
|
|
18
|
-
appName: invocationContext.session.appName,
|
|
19
|
-
userId: invocationContext.session.userId,
|
|
20
|
-
sessionId: invocationContext.session.id,
|
|
21
18
|
filename: fileName
|
|
22
19
|
});
|
|
23
20
|
if (!artifact) {
|
|
@@ -26,19 +23,40 @@ async function resolveKey(key, isOptional, rawMatch, readonlyContext) {
|
|
|
26
23
|
}
|
|
27
24
|
throw new Error("Artifact ".concat(fileName, " not found."));
|
|
28
25
|
}
|
|
29
|
-
return
|
|
26
|
+
return formatValue(artifact, true);
|
|
30
27
|
}
|
|
31
28
|
if (!isValidStateName(key)) {
|
|
32
29
|
return rawMatch;
|
|
33
30
|
}
|
|
34
31
|
if (key in invocationContext.session.state) {
|
|
35
|
-
return
|
|
32
|
+
return formatValue(invocationContext.session.state[key], false);
|
|
36
33
|
}
|
|
37
34
|
if (isOptional) {
|
|
38
35
|
return "";
|
|
39
36
|
}
|
|
40
37
|
throw new Error("Context variable not found: `".concat(key, "`."));
|
|
41
38
|
}
|
|
39
|
+
function formatValue(value, isArtifact = false) {
|
|
40
|
+
if (typeof value === "string") {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
if (typeof value === "object" && value !== null) {
|
|
44
|
+
if (isArtifact && "text" in value && typeof value.text === "string") {
|
|
45
|
+
return value.text;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const json = JSON.stringify(value);
|
|
49
|
+
if (json !== void 0) {
|
|
50
|
+
return json;
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
"Failed to serialize value for instruction template: ".concat(e instanceof Error ? e.message : String(e))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return String(value);
|
|
59
|
+
}
|
|
42
60
|
async function injectSessionState(template, readonlyContext) {
|
|
43
61
|
const pattern = /\{+[^{}]*}+/g;
|
|
44
62
|
const matches = Array.from(template.matchAll(pattern));
|
|
@@ -30,11 +30,7 @@ class InvocationContext {
|
|
|
30
30
|
* @param params The parameters for creating an invocation context.
|
|
31
31
|
*/
|
|
32
32
|
constructor(params) {
|
|
33
|
-
|
|
34
|
-
* A container to keep track of different kinds of costs incurred as a part of
|
|
35
|
-
* this invocation.
|
|
36
|
-
*/
|
|
37
|
-
this.invocationCostManager = new InvocationCostManager();
|
|
33
|
+
var _a;
|
|
38
34
|
this.artifactService = params.artifactService;
|
|
39
35
|
this.sessionService = params.sessionService;
|
|
40
36
|
this.memoryService = params.memoryService;
|
|
@@ -49,6 +45,7 @@ class InvocationContext {
|
|
|
49
45
|
this.activeStreamingTools = params.activeStreamingTools;
|
|
50
46
|
this.pluginManager = params.pluginManager;
|
|
51
47
|
this.abortSignal = params.abortSignal;
|
|
48
|
+
this.invocationCostManager = (_a = params.invocationCostManager) != null ? _a : new InvocationCostManager();
|
|
52
49
|
}
|
|
53
50
|
/**
|
|
54
51
|
* The app name of the current session.
|
|
@@ -106,6 +106,7 @@ import { CONTENT_REQUEST_PROCESSOR } from "./processors/content_request_processo
|
|
|
106
106
|
import { ContextCompactorRequestProcessor } from "./processors/context_compactor_request_processor.js";
|
|
107
107
|
import { IDENTITY_LLM_REQUEST_PROCESSOR } from "./processors/identity_llm_request_processor.js";
|
|
108
108
|
import { INSTRUCTIONS_LLM_REQUEST_PROCESSOR } from "./processors/instructions_llm_request_processor.js";
|
|
109
|
+
import { INTERACTIONS_REQUEST_PROCESSOR } from "./processors/interactions_request_processor.js";
|
|
109
110
|
import { REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR } from "./processors/request_confirmation_llm_request_processor.js";
|
|
110
111
|
import { TOOL_FILTER_REQUEST_PROCESSOR } from "./processors/tool_filter_request_processor.js";
|
|
111
112
|
import { ReadonlyContext } from "./readonly_context.js";
|
|
@@ -150,6 +151,7 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
150
151
|
INSTRUCTIONS_LLM_REQUEST_PROCESSOR,
|
|
151
152
|
REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR,
|
|
152
153
|
CONTENT_REQUEST_PROCESSOR,
|
|
154
|
+
INTERACTIONS_REQUEST_PROCESSOR,
|
|
153
155
|
CODE_EXECUTION_REQUEST_PROCESSOR,
|
|
154
156
|
TOOL_FILTER_REQUEST_PROCESSOR
|
|
155
157
|
];
|
|
@@ -605,7 +607,7 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
605
607
|
}
|
|
606
608
|
postprocess(invocationContext, llmRequest, llmResponse, modelResponseEvent) {
|
|
607
609
|
return __asyncGenerator(this, null, function* () {
|
|
608
|
-
var _a2, _b2, _c, _d, _e;
|
|
610
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
609
611
|
for (const processor of this.responseProcessors) {
|
|
610
612
|
try {
|
|
611
613
|
for (var iter = __forAwait(processor.runAsync(
|
|
@@ -629,7 +631,7 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
629
631
|
}
|
|
630
632
|
}
|
|
631
633
|
}
|
|
632
|
-
if (!llmResponse.content && !llmResponse.errorCode && !llmResponse.interrupted) {
|
|
634
|
+
if ((!llmResponse.content || ((_b2 = llmResponse.content.parts) == null ? void 0 : _b2.length) === 0) && !llmResponse.errorCode && !llmResponse.interrupted) {
|
|
633
635
|
return;
|
|
634
636
|
}
|
|
635
637
|
const mergedEvent = createEvent(__spreadValues(__spreadValues({}, modelResponseEvent), llmResponse));
|
|
@@ -650,10 +652,10 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
650
652
|
}
|
|
651
653
|
}
|
|
652
654
|
yield mergedEvent;
|
|
653
|
-
if (!((
|
|
655
|
+
if (!((_c = getFunctionCalls(mergedEvent)) == null ? void 0 : _c.length)) {
|
|
654
656
|
return;
|
|
655
657
|
}
|
|
656
|
-
if ((
|
|
658
|
+
if ((_d = invocationContext.runConfig) == null ? void 0 : _d.pauseOnToolCalls) {
|
|
657
659
|
invocationContext.endInvocation = true;
|
|
658
660
|
return;
|
|
659
661
|
}
|
|
@@ -664,7 +666,7 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
664
666
|
beforeToolCallbacks: this.canonicalBeforeToolCallbacks,
|
|
665
667
|
afterToolCallbacks: this.canonicalAfterToolCallbacks
|
|
666
668
|
}));
|
|
667
|
-
if (!functionResponseEvent || ((
|
|
669
|
+
if (!functionResponseEvent || ((_e = invocationContext.abortSignal) == null ? void 0 : _e.aborted)) {
|
|
668
670
|
return;
|
|
669
671
|
}
|
|
670
672
|
const authEvent = generateAuthEvent(
|
|
@@ -691,7 +693,7 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
691
693
|
try {
|
|
692
694
|
for (var iter2 = __forAwait(nextAgent.runAsync(invocationContext)), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
|
|
693
695
|
const event = temp2.value;
|
|
694
|
-
if ((
|
|
696
|
+
if ((_f = invocationContext.abortSignal) == null ? void 0 : _f.aborted) {
|
|
695
697
|
return;
|
|
696
698
|
}
|
|
697
699
|
yield event;
|
|
@@ -327,9 +327,6 @@ async function postProcessCodeExecutionResult(invocationContext, codeExecutorCon
|
|
|
327
327
|
}
|
|
328
328
|
for (const outputFile of codeExecutionResult.outputFiles) {
|
|
329
329
|
const version = await invocationContext.artifactService.saveArtifact({
|
|
330
|
-
appName: invocationContext.appName || "",
|
|
331
|
-
userId: invocationContext.userId || "",
|
|
332
|
-
sessionId: invocationContext.session.id,
|
|
333
330
|
filename: outputFile.name,
|
|
334
331
|
artifact: {
|
|
335
332
|
inlineData: { data: outputFile.content, mimeType: outputFile.mimeType }
|
|
@@ -35,10 +35,21 @@ import {
|
|
|
35
35
|
getFunctionResponses
|
|
36
36
|
} from "../../events/event.js";
|
|
37
37
|
import {
|
|
38
|
-
|
|
38
|
+
AF_FUNCTION_CALL_ID_PREFIX,
|
|
39
39
|
REQUEST_CONFIRMATION_FUNCTION_CALL_NAME,
|
|
40
40
|
REQUEST_EUC_FUNCTION_CALL_NAME
|
|
41
41
|
} from "../functions.js";
|
|
42
|
+
function removeClientFunctionCallId(content) {
|
|
43
|
+
var _a, _b, _c, _d, _e;
|
|
44
|
+
for (const part of (_a = content == null ? void 0 : content.parts) != null ? _a : []) {
|
|
45
|
+
if ((_c = (_b = part.functionCall) == null ? void 0 : _b.id) == null ? void 0 : _c.startsWith(AF_FUNCTION_CALL_ID_PREFIX)) {
|
|
46
|
+
part.functionCall.id = void 0;
|
|
47
|
+
}
|
|
48
|
+
if ((_e = (_d = part.functionResponse) == null ? void 0 : _d.id) == null ? void 0 : _e.startsWith(AF_FUNCTION_CALL_ID_PREFIX)) {
|
|
49
|
+
part.functionResponse.id = void 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
42
53
|
function getContents(events, agentName, currentBranch) {
|
|
43
54
|
var _a, _b, _c;
|
|
44
55
|
const filteredEvents = [];
|
|
@@ -344,5 +355,6 @@ function convertCompactedEvent(event) {
|
|
|
344
355
|
export {
|
|
345
356
|
getContents,
|
|
346
357
|
getCurrentTurnContents,
|
|
347
|
-
mergeFunctionResponseEvents
|
|
358
|
+
mergeFunctionResponseEvents,
|
|
359
|
+
removeClientFunctionCallId
|
|
348
360
|
};
|
|
@@ -40,20 +40,22 @@ class ContextCompactorRequestProcessor {
|
|
|
40
40
|
*/
|
|
41
41
|
runAsync(invocationContext, _llmRequest) {
|
|
42
42
|
return __asyncGenerator(this, null, function* () {
|
|
43
|
+
var _a;
|
|
43
44
|
for (const compactor of this.compactors) {
|
|
44
45
|
const shouldCompact = yield new __await(Promise.resolve(
|
|
45
46
|
compactor.shouldCompact(invocationContext)
|
|
46
47
|
));
|
|
47
48
|
if (shouldCompact) {
|
|
49
|
+
const trigger = (_a = compactor.trigger) != null ? _a : ContextCompactionTrigger.Auto;
|
|
48
50
|
yield new __await(invocationContext.pluginManager.runBeforeContextCompaction({
|
|
49
51
|
invocationContext,
|
|
50
|
-
trigger
|
|
52
|
+
trigger
|
|
51
53
|
}));
|
|
52
54
|
const oldEvents = new Set(invocationContext.session.events);
|
|
53
55
|
yield new __await(Promise.resolve(compactor.compact(invocationContext)));
|
|
54
56
|
yield new __await(invocationContext.pluginManager.runAfterContextCompaction({
|
|
55
57
|
invocationContext,
|
|
56
|
-
trigger
|
|
58
|
+
trigger
|
|
57
59
|
}));
|
|
58
60
|
const newEvents = invocationContext.session.events.filter(
|
|
59
61
|
(e) => !oldEvents.has(e)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
4
|
+
var __await = function(promise, isYieldStar) {
|
|
5
|
+
this[0] = promise;
|
|
6
|
+
this[1] = isYieldStar;
|
|
7
|
+
};
|
|
8
|
+
var __asyncGenerator = (__this, __arguments, generator) => {
|
|
9
|
+
var resume = (k, v, yes, no) => {
|
|
10
|
+
try {
|
|
11
|
+
var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
|
|
12
|
+
Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
no(e);
|
|
15
|
+
}
|
|
16
|
+
}, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
|
|
17
|
+
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @license
|
|
21
|
+
* Copyright 2026 Google LLC
|
|
22
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
23
|
+
*/
|
|
24
|
+
import { isGemini } from "../../models/google_llm.js";
|
|
25
|
+
import { isLlmAgent } from "../llm_agent.js";
|
|
26
|
+
class InteractionsRequestProcessor {
|
|
27
|
+
// eslint-disable-next-line require-yield
|
|
28
|
+
runAsync(invocationContext, llmRequest) {
|
|
29
|
+
return __asyncGenerator(this, null, function* () {
|
|
30
|
+
const agent = invocationContext.agent;
|
|
31
|
+
if (!agent || !isLlmAgent(agent)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const model = agent.canonicalModel;
|
|
35
|
+
if (isGemini(model) && model.useInteractionsApi) {
|
|
36
|
+
const events = invocationContext.session.events;
|
|
37
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
38
|
+
const event = events[i];
|
|
39
|
+
if (event.branch === invocationContext.branch && event.author === agent.name && event.interactionId) {
|
|
40
|
+
llmRequest.previousInteractionId = event.interactionId;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const INTERACTIONS_REQUEST_PROCESSOR = new InteractionsRequestProcessor();
|
|
49
|
+
export {
|
|
50
|
+
INTERACTIONS_REQUEST_PROCESSOR,
|
|
51
|
+
InteractionsRequestProcessor
|
|
52
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2026 Google LLC
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
var _a;
|
|
9
|
+
import { isBaseAgent } from "../agents/base_agent.js";
|
|
10
|
+
const VALID_APP_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
11
|
+
function validateAppName(name) {
|
|
12
|
+
if (!VALID_APP_NAME_RE.test(name)) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
"Invalid app name '".concat(name, "': must start with a letter and can only consist of letters, digits, underscores, and hyphens.")
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (name === "user") {
|
|
18
|
+
throw new Error("App name cannot be 'user'; reserved for end-user input.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const APP_SIGNATURE_SYMBOL = Symbol.for("google.adk.app");
|
|
22
|
+
function isApp(obj) {
|
|
23
|
+
return typeof obj === "object" && obj !== null && APP_SIGNATURE_SYMBOL in obj && obj[APP_SIGNATURE_SYMBOL] === true;
|
|
24
|
+
}
|
|
25
|
+
_a = APP_SIGNATURE_SYMBOL;
|
|
26
|
+
class App {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this[_a] = true;
|
|
29
|
+
var _a2, _b, _c, _d;
|
|
30
|
+
validateAppName(options.name);
|
|
31
|
+
if (options.rootAgent === void 0 || options.rootAgent === null) {
|
|
32
|
+
throw new Error("rootAgent must be provided.");
|
|
33
|
+
}
|
|
34
|
+
if (!isBaseAgent(options.rootAgent)) {
|
|
35
|
+
throw new TypeError(
|
|
36
|
+
"rootAgent must be a BaseAgent instance, got ".concat((_c = (_b = (_a2 = options.rootAgent) == null ? void 0 : _a2.constructor) == null ? void 0 : _b.name) != null ? _c : typeof options.rootAgent)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
this.name = options.name;
|
|
40
|
+
this.rootAgent = options.rootAgent;
|
|
41
|
+
this.plugins = (_d = options.plugins) != null ? _d : [];
|
|
42
|
+
this.resumabilityConfig = options.resumabilityConfig;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
App,
|
|
47
|
+
isApp,
|
|
48
|
+
validateAppName
|
|
49
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @license
|
|
21
|
+
* Copyright 2026 Google LLC
|
|
22
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
23
|
+
*/
|
|
24
|
+
function createResumabilityConfig(params = {}) {
|
|
25
|
+
return __spreadValues({
|
|
26
|
+
isResumable: false
|
|
27
|
+
}, params);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
createResumabilityConfig
|
|
31
|
+
};
|
|
@@ -43,7 +43,7 @@ class FileArtifactService {
|
|
|
43
43
|
artifact,
|
|
44
44
|
customMetadata
|
|
45
45
|
}) {
|
|
46
|
-
if (!artifact.inlineData && !artifact.text) {
|
|
46
|
+
if (!artifact.inlineData && !artifact.text && !artifact.fileData) {
|
|
47
47
|
throw new Error("Artifact must have either inlineData or text content.");
|
|
48
48
|
}
|
|
49
49
|
const artifactDir = getArtifactDir(
|
|
@@ -61,12 +61,19 @@ class FileArtifactService {
|
|
|
61
61
|
const storedFilename = path.basename(artifactDir);
|
|
62
62
|
const contentPath = path.join(versionDir, storedFilename);
|
|
63
63
|
let mimeType;
|
|
64
|
+
let fileUri;
|
|
64
65
|
if (artifact.inlineData) {
|
|
65
66
|
const data = artifact.inlineData.data || "";
|
|
66
67
|
await fs.writeFile(contentPath, Buffer.from(data, "base64"));
|
|
67
68
|
mimeType = artifact.inlineData.mimeType || "application/octet-stream";
|
|
68
69
|
} else if (artifact.text !== void 0) {
|
|
69
70
|
await fs.writeFile(contentPath, artifact.text, "utf-8");
|
|
71
|
+
} else {
|
|
72
|
+
fileUri = artifact.fileData.fileUri;
|
|
73
|
+
if (!fileUri) {
|
|
74
|
+
throw new Error("Artifact fileData must have a fileUri.");
|
|
75
|
+
}
|
|
76
|
+
mimeType = artifact.fileData.mimeType;
|
|
70
77
|
}
|
|
71
78
|
const canonicalUri = await getCanonicalUri(
|
|
72
79
|
this.rootDir,
|
|
@@ -78,6 +85,7 @@ class FileArtifactService {
|
|
|
78
85
|
const metadata = {
|
|
79
86
|
fileName: filename,
|
|
80
87
|
mimeType,
|
|
88
|
+
fileUri,
|
|
81
89
|
version: nextVersion,
|
|
82
90
|
canonicalUri,
|
|
83
91
|
customMetadata
|
|
@@ -129,6 +137,11 @@ class FileArtifactService {
|
|
|
129
137
|
);
|
|
130
138
|
const metadataPath = path.join(versionDir, "metadata.json");
|
|
131
139
|
const metadata = await readMetadata(metadataPath);
|
|
140
|
+
if (metadata.fileUri) {
|
|
141
|
+
return {
|
|
142
|
+
fileData: { fileUri: metadata.fileUri, mimeType: metadata.mimeType }
|
|
143
|
+
};
|
|
144
|
+
}
|
|
132
145
|
const storedFilename = path.basename(artifactDir);
|
|
133
146
|
let contentPath = path.join(versionDir, storedFilename);
|
|
134
147
|
if (metadata.canonicalUri) {
|
|
@@ -27,12 +27,16 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
27
27
|
import { Storage } from "@google-cloud/storage";
|
|
28
28
|
import { createPartFromBase64, createPartFromText } from "@google/genai";
|
|
29
29
|
import { logger } from "../utils/logger.js";
|
|
30
|
+
const GCS_FILE_URI_METADATA_KEY = "adkFileUri";
|
|
31
|
+
const GCS_FILE_MIME_TYPE_METADATA_KEY = "adkFileMimeType";
|
|
32
|
+
const GCS_DISPLAY_NAME_METADATA_KEY = "adkDisplayName";
|
|
33
|
+
const GCS_IS_TEXT_METADATA_KEY = "adkIsText";
|
|
30
34
|
class GcsArtifactService {
|
|
31
|
-
constructor(bucket) {
|
|
32
|
-
this.bucket = new Storage().bucket(bucket);
|
|
35
|
+
constructor(bucket, options) {
|
|
36
|
+
this.bucket = new Storage(options).bucket(bucket);
|
|
33
37
|
}
|
|
34
38
|
async saveArtifact(request) {
|
|
35
|
-
if (!request.artifact.inlineData && !request.artifact.text) {
|
|
39
|
+
if (!request.artifact.inlineData && !request.artifact.text && !request.artifact.fileData) {
|
|
36
40
|
throw new Error("Artifact must have either inlineData or text content.");
|
|
37
41
|
}
|
|
38
42
|
const versions = await this.listVersions(request);
|
|
@@ -42,24 +46,46 @@ class GcsArtifactService {
|
|
|
42
46
|
version
|
|
43
47
|
}))
|
|
44
48
|
);
|
|
45
|
-
const
|
|
49
|
+
const customMetadata = __spreadValues({}, request.customMetadata);
|
|
46
50
|
if (request.artifact.inlineData) {
|
|
51
|
+
if (request.artifact.inlineData.displayName) {
|
|
52
|
+
customMetadata[GCS_DISPLAY_NAME_METADATA_KEY] = request.artifact.inlineData.displayName;
|
|
53
|
+
}
|
|
47
54
|
await file.save(
|
|
48
55
|
Buffer.from(request.artifact.inlineData.data || "", "base64"),
|
|
49
56
|
{
|
|
50
57
|
contentType: request.artifact.inlineData.mimeType,
|
|
51
|
-
metadata
|
|
58
|
+
metadata: { metadata: customMetadata }
|
|
52
59
|
}
|
|
53
60
|
);
|
|
54
61
|
return version;
|
|
62
|
+
} else if (request.artifact.text !== void 0) {
|
|
63
|
+
await file.save(request.artifact.text, {
|
|
64
|
+
contentType: "text/plain",
|
|
65
|
+
metadata: {
|
|
66
|
+
metadata: __spreadProps(__spreadValues({}, customMetadata), { [GCS_IS_TEXT_METADATA_KEY]: "true" })
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return version;
|
|
70
|
+
} else {
|
|
71
|
+
const fileData = request.artifact.fileData;
|
|
72
|
+
const fileUri = fileData == null ? void 0 : fileData.fileUri;
|
|
73
|
+
if (!fileUri) {
|
|
74
|
+
throw new Error("Artifact fileData must have a fileUri.");
|
|
75
|
+
}
|
|
76
|
+
customMetadata[GCS_FILE_URI_METADATA_KEY] = fileUri;
|
|
77
|
+
if (fileData.mimeType) {
|
|
78
|
+
customMetadata[GCS_FILE_MIME_TYPE_METADATA_KEY] = fileData.mimeType;
|
|
79
|
+
}
|
|
80
|
+
await file.save("", {
|
|
81
|
+
contentType: fileData.mimeType || void 0,
|
|
82
|
+
metadata: { metadata: customMetadata }
|
|
83
|
+
});
|
|
84
|
+
return version;
|
|
55
85
|
}
|
|
56
|
-
await file.save(request.artifact.text, {
|
|
57
|
-
contentType: "text/plain",
|
|
58
|
-
metadata
|
|
59
|
-
});
|
|
60
|
-
return version;
|
|
61
86
|
}
|
|
62
87
|
async loadArtifact(request) {
|
|
88
|
+
var _a, _b, _c;
|
|
63
89
|
try {
|
|
64
90
|
let version = request.version;
|
|
65
91
|
if (version === void 0) {
|
|
@@ -74,11 +100,25 @@ class GcsArtifactService {
|
|
|
74
100
|
version
|
|
75
101
|
}))
|
|
76
102
|
);
|
|
77
|
-
const [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
103
|
+
const [metadata] = await file.getMetadata();
|
|
104
|
+
const customMeta = (_a = metadata.metadata) != null ? _a : {};
|
|
105
|
+
const fileUri = customMeta[GCS_FILE_URI_METADATA_KEY];
|
|
106
|
+
if (fileUri) {
|
|
107
|
+
const mimeType = (_c = (_b = customMeta[GCS_FILE_MIME_TYPE_METADATA_KEY]) != null ? _b : metadata.contentType) != null ? _c : void 0;
|
|
108
|
+
return { fileData: { fileUri, mimeType } };
|
|
109
|
+
}
|
|
110
|
+
const [rawDataBuffer] = await file.download();
|
|
111
|
+
const displayName = customMeta[GCS_DISPLAY_NAME_METADATA_KEY];
|
|
112
|
+
if (displayName) {
|
|
113
|
+
return {
|
|
114
|
+
inlineData: {
|
|
115
|
+
data: rawDataBuffer.toString("base64"),
|
|
116
|
+
mimeType: metadata.contentType,
|
|
117
|
+
displayName
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (customMeta[GCS_IS_TEXT_METADATA_KEY] === "true" || metadata.contentType === "text/plain") {
|
|
82
122
|
return createPartFromText(rawDataBuffer.toString("utf-8"));
|
|
83
123
|
}
|
|
84
124
|
return createPartFromBase64(
|
|
@@ -20,7 +20,7 @@ class InMemoryArtifactService {
|
|
|
20
20
|
artifact,
|
|
21
21
|
customMetadata
|
|
22
22
|
}) {
|
|
23
|
-
if (!artifact.inlineData && !artifact.text) {
|
|
23
|
+
if (!artifact.inlineData && !artifact.text && !artifact.fileData) {
|
|
24
24
|
return Promise.reject(
|
|
25
25
|
new Error("Artifact must have either inlineData or text content.")
|
|
26
26
|
);
|
|
@@ -34,6 +34,10 @@ class InMemoryArtifactService {
|
|
|
34
34
|
version,
|
|
35
35
|
customMetadata
|
|
36
36
|
};
|
|
37
|
+
if (!artifact.inlineData && artifact.text === void 0) {
|
|
38
|
+
const fileData = artifact.fileData;
|
|
39
|
+
metadata.mimeType = fileData.mimeType;
|
|
40
|
+
}
|
|
37
41
|
this.artifacts[path].push({ part: artifact, metadata });
|
|
38
42
|
return Promise.resolve(version);
|
|
39
43
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @license
|
|
21
|
+
* Copyright 2026 Google LLC
|
|
22
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
23
|
+
*/
|
|
24
|
+
class ScopedArtifactService {
|
|
25
|
+
constructor(delegate, appName, userId, sessionId) {
|
|
26
|
+
this.delegate = delegate;
|
|
27
|
+
this.appName = appName;
|
|
28
|
+
this.userId = userId;
|
|
29
|
+
this.sessionId = sessionId;
|
|
30
|
+
}
|
|
31
|
+
async saveArtifact(request) {
|
|
32
|
+
return this.delegate.saveArtifact(__spreadValues({
|
|
33
|
+
appName: this.appName,
|
|
34
|
+
userId: this.userId,
|
|
35
|
+
sessionId: this.sessionId
|
|
36
|
+
}, request));
|
|
37
|
+
}
|
|
38
|
+
async loadArtifact(request) {
|
|
39
|
+
return this.delegate.loadArtifact(__spreadValues({
|
|
40
|
+
appName: this.appName,
|
|
41
|
+
userId: this.userId,
|
|
42
|
+
sessionId: this.sessionId
|
|
43
|
+
}, request));
|
|
44
|
+
}
|
|
45
|
+
async listArtifactKeys() {
|
|
46
|
+
return this.delegate.listArtifactKeys({
|
|
47
|
+
appName: this.appName,
|
|
48
|
+
userId: this.userId,
|
|
49
|
+
sessionId: this.sessionId
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async deleteArtifact(filename) {
|
|
53
|
+
return this.delegate.deleteArtifact({
|
|
54
|
+
appName: this.appName,
|
|
55
|
+
userId: this.userId,
|
|
56
|
+
sessionId: this.sessionId,
|
|
57
|
+
filename
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async listVersions(filename) {
|
|
61
|
+
return this.delegate.listVersions({
|
|
62
|
+
appName: this.appName,
|
|
63
|
+
userId: this.userId,
|
|
64
|
+
sessionId: this.sessionId,
|
|
65
|
+
filename
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async listArtifactVersions(filename) {
|
|
69
|
+
return this.delegate.listArtifactVersions({
|
|
70
|
+
appName: this.appName,
|
|
71
|
+
userId: this.userId,
|
|
72
|
+
sessionId: this.sessionId,
|
|
73
|
+
filename
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async getArtifactVersion(request) {
|
|
77
|
+
return this.delegate.getArtifactVersion(__spreadValues({
|
|
78
|
+
appName: this.appName,
|
|
79
|
+
userId: this.userId,
|
|
80
|
+
sessionId: this.sessionId
|
|
81
|
+
}, request));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
ScopedArtifactService
|
|
86
|
+
};
|
|
@@ -55,7 +55,11 @@ class OAuth2DiscoveryManager {
|
|
|
55
55
|
method: "GET",
|
|
56
56
|
headers: {
|
|
57
57
|
Accept: "application/json"
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
|
+
// Never follow redirects: validateDiscoveryUrl only checks the
|
|
60
|
+
// initial URL, so following a 3xx would let a validated host
|
|
61
|
+
// redirect discovery to a private/cloud-metadata address (CWE-918).
|
|
62
|
+
redirect: "error"
|
|
59
63
|
});
|
|
60
64
|
if (!response.ok) {
|
|
61
65
|
continue;
|
|
@@ -103,7 +107,11 @@ class OAuth2DiscoveryManager {
|
|
|
103
107
|
method: "GET",
|
|
104
108
|
headers: {
|
|
105
109
|
Accept: "application/json"
|
|
106
|
-
}
|
|
110
|
+
},
|
|
111
|
+
// Never follow redirects: validateDiscoveryUrl only checks the
|
|
112
|
+
// initial URL, so following a 3xx would let a validated host
|
|
113
|
+
// redirect discovery to a private/cloud-metadata address (CWE-918).
|
|
114
|
+
redirect: "error"
|
|
107
115
|
});
|
|
108
116
|
if (!response.ok) {
|
|
109
117
|
return void 0;
|
|
@@ -143,7 +151,7 @@ function validateDiscoveryUrl(urlStr) {
|
|
|
143
151
|
return false;
|
|
144
152
|
}
|
|
145
153
|
const host = normaliseHostname(url.hostname.toLowerCase());
|
|
146
|
-
if (host === "localhost" || host === "metadata.google.internal" || host === "metadata.goog" || host.startsWith("127.") || host === "[::1]" || host === "0.0.0.0" || host.startsWith("10.") || host.startsWith("192.168.") || host.startsWith("169.254.")) {
|
|
154
|
+
if (host === "localhost" || host === "metadata.google.internal" || host === "metadata.goog" || host.startsWith("127.") || host === "[::1]" || host === "[::]" || host === "0.0.0.0" || host.startsWith("10.") || host.startsWith("192.168.") || host.startsWith("169.254.")) {
|
|
147
155
|
logger.warn("Unsafe host for discovery URL: ".concat(host));
|
|
148
156
|
return false;
|
|
149
157
|
}
|
|
@@ -176,5 +184,7 @@ function validateDiscoveryUrl(urlStr) {
|
|
|
176
184
|
export {
|
|
177
185
|
AuthorizationServerMetadataSchema,
|
|
178
186
|
OAuth2DiscoveryManager,
|
|
179
|
-
ProtectedResourceMetadataSchema
|
|
187
|
+
ProtectedResourceMetadataSchema,
|
|
188
|
+
normaliseHostname,
|
|
189
|
+
validateDiscoveryUrl
|
|
180
190
|
};
|