@google/adk 1.2.0 → 1.3.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/base_agent.js +19 -1
- package/dist/cjs/agents/instructions.js +81 -33
- package/dist/cjs/agents/invocation_context.js +0 -1
- package/dist/cjs/agents/llm_agent.js +52 -5
- package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/cjs/agents/processors/content_processor_utils.js +37 -24
- package/dist/cjs/agents/processors/content_request_processor.js +7 -0
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/cjs/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/cjs/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/cjs/auth/auth_preprocessor.js +12 -10
- package/dist/cjs/auth/oauth2/oauth2_discovery.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +7 -7
- package/dist/cjs/common.js +39 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +11 -0
- package/dist/cjs/context/token_based_context_compactor.js +1 -1
- package/dist/cjs/events/event.js +1 -1
- package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
- package/dist/cjs/models/gemini_llm_connection.js +62 -19
- package/dist/cjs/models/google_llm.js +26 -8
- package/dist/cjs/plugins/security_plugin.js +16 -0
- package/dist/cjs/sessions/base_session_service.js +13 -2
- package/dist/cjs/sessions/database_session_service.js +2 -2
- package/dist/cjs/sessions/db/schema.js +45 -10
- package/dist/cjs/sessions/in_memory_session_service.js +2 -1
- package/dist/cjs/sessions/vertex_ai_session_service.js +2 -1
- package/dist/cjs/skills/gcp_skill_registry.js +104 -0
- package/dist/cjs/skills/loader.js +65 -0
- package/dist/cjs/skills/skill_registry.js +27 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +232 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +224 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +127 -0
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +133 -0
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +256 -0
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +25 -3
- package/dist/cjs/tools/skill/load_skill_tool.js +12 -1
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/cjs/tools/skill/search_skills_tool.js +108 -0
- package/dist/cjs/tools/skill/skill_toolset.js +40 -5
- package/dist/cjs/utils/async_queue.js +88 -0
- package/dist/cjs/utils/case_utils.js +53 -0
- package/dist/cjs/utils/env_aware_utils.js +4 -0
- package/dist/cjs/utils/live_connection_utils.js +284 -0
- package/dist/cjs/utils/model_name.js +9 -0
- package/dist/cjs/utils/streaming_utils.js +9 -8
- package/dist/cjs/version.js +1 -1
- package/dist/esm/agents/base_agent.js +19 -1
- package/dist/esm/agents/instructions.js +81 -33
- package/dist/esm/agents/invocation_context.js +0 -1
- package/dist/esm/agents/llm_agent.js +53 -5
- package/dist/esm/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/esm/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/esm/agents/processors/content_processor_utils.js +35 -23
- package/dist/esm/agents/processors/content_request_processor.js +7 -0
- package/dist/esm/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/esm/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/esm/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/esm/auth/auth_preprocessor.js +12 -10
- package/dist/esm/auth/oauth2/oauth2_discovery.js +1 -1
- package/dist/esm/code_executors/code_executor_context.js +7 -7
- package/dist/esm/common.js +33 -1
- package/dist/esm/context/summarizers/llm_summarizer.js +11 -0
- package/dist/esm/context/token_based_context_compactor.js +1 -1
- package/dist/esm/events/event.js +1 -1
- package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
- package/dist/esm/models/gemini_llm_connection.js +62 -19
- package/dist/esm/models/google_llm.js +26 -8
- package/dist/esm/plugins/security_plugin.js +16 -0
- package/dist/esm/sessions/base_session_service.js +11 -1
- package/dist/esm/sessions/database_session_service.js +2 -2
- package/dist/esm/sessions/db/schema.js +44 -10
- package/dist/esm/sessions/in_memory_session_service.js +4 -2
- package/dist/esm/sessions/vertex_ai_session_service.js +4 -2
- package/dist/esm/skills/gcp_skill_registry.js +78 -0
- package/dist/esm/skills/loader.js +64 -0
- package/dist/esm/skills/skill_registry.js +7 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +206 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +101 -0
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +97 -0
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +229 -0
- package/dist/esm/tools/skill/load_skill_resource_tool.js +25 -3
- package/dist/esm/tools/skill/load_skill_tool.js +12 -1
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/esm/tools/skill/search_skills_tool.js +82 -0
- package/dist/esm/tools/skill/skill_toolset.js +40 -5
- package/dist/esm/utils/async_queue.js +60 -0
- package/dist/esm/utils/case_utils.js +25 -0
- package/dist/esm/utils/env_aware_utils.js +4 -0
- package/dist/esm/utils/live_connection_utils.js +256 -0
- package/dist/esm/utils/model_name.js +8 -0
- package/dist/esm/utils/streaming_utils.js +9 -8
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +29 -4
- package/dist/types/a2a/event_converter_utils.d.ts +14 -1
- package/dist/types/a2a/metadata_converter_utils.d.ts +18 -0
- package/dist/types/a2a/part_converter_utils.d.ts +51 -6
- package/dist/types/agents/invocation_context.d.ts +0 -9
- package/dist/types/agents/llm_agent.d.ts +14 -0
- package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +14 -0
- package/dist/types/agents/processors/basic_llm_request_processor.d.ts +7 -0
- package/dist/types/agents/processors/content_processor_utils.d.ts +26 -0
- package/dist/types/agents/processors/content_request_processor.d.ts +16 -0
- package/dist/types/agents/processors/context_compactor_request_processor.d.ts +12 -0
- package/dist/types/agents/processors/identity_llm_request_processor.d.ts +7 -0
- package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +9 -1
- package/dist/types/agents/processors/tool_filter_request_processor.d.ts +12 -1
- package/dist/types/common.d.ts +15 -1
- package/dist/types/context/summarizers/llm_summarizer.d.ts +17 -0
- package/dist/types/events/event_actions.d.ts +1 -2
- package/dist/types/integrations/agent_registry/agent_registry_mcp_toolset.d.ts +21 -2
- package/dist/types/models/base_llm_connection.d.ts +10 -0
- package/dist/types/models/gemini_llm_connection.d.ts +15 -4
- package/dist/types/models/llm_response.d.ts +10 -1
- package/dist/types/plugins/security_plugin.d.ts +30 -0
- package/dist/types/sessions/base_session_service.d.ts +4 -0
- package/dist/types/sessions/db/schema.d.ts +1 -0
- package/dist/types/skills/gcp_skill_registry.d.ts +24 -0
- package/dist/types/skills/loader.d.ts +7 -0
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/skills/skill_registry.d.ts +29 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +34 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +59 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +23 -0
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +27 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +50 -0
- package/dist/types/tools/skill/load_skill_resource_tool.d.ts +1 -1
- package/dist/types/tools/skill/search_skills_tool.d.ts +14 -0
- package/dist/types/tools/skill/skill_toolset.d.ts +5 -0
- package/dist/types/utils/async_queue.d.ts +18 -0
- package/dist/types/utils/case_utils.d.ts +12 -0
- package/dist/types/utils/live_connection_utils.d.ts +30 -0
- package/dist/types/utils/model_name.d.ts +7 -0
- package/dist/types/utils/streaming_utils.d.ts +0 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/web/agents/base_agent.js +31 -1
- package/dist/web/agents/instructions.js +81 -33
- package/dist/web/agents/invocation_context.js +0 -1
- package/dist/web/agents/llm_agent.js +53 -5
- package/dist/web/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/web/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/web/agents/processors/content_processor_utils.js +53 -23
- package/dist/web/agents/processors/content_request_processor.js +7 -0
- package/dist/web/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/web/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/web/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/web/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/web/auth/auth_preprocessor.js +12 -10
- package/dist/web/auth/oauth2/oauth2_discovery.js +1 -1
- package/dist/web/code_executors/code_executor_context.js +7 -7
- package/dist/web/common.js +33 -1
- package/dist/web/context/summarizers/llm_summarizer.js +11 -0
- package/dist/web/context/token_based_context_compactor.js +1 -1
- package/dist/web/events/event.js +1 -1
- package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
- package/dist/web/models/gemini_llm_connection.js +75 -19
- package/dist/web/models/google_llm.js +26 -8
- package/dist/web/plugins/security_plugin.js +16 -0
- package/dist/web/sessions/base_session_service.js +11 -1
- package/dist/web/sessions/database_session_service.js +2 -2
- package/dist/web/sessions/db/schema.js +44 -10
- package/dist/web/sessions/in_memory_session_service.js +4 -2
- package/dist/web/sessions/vertex_ai_session_service.js +4 -2
- package/dist/web/skills/gcp_skill_registry.js +78 -0
- package/dist/web/skills/loader.js +64 -0
- package/dist/web/skills/skill_registry.js +7 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +221 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +101 -0
- package/dist/web/tools/openapi_tool/openapi_toolset.js +97 -0
- package/dist/web/tools/openapi_tool/rest_api_tool.js +229 -0
- package/dist/web/tools/skill/load_skill_resource_tool.js +25 -3
- package/dist/web/tools/skill/load_skill_tool.js +12 -1
- package/dist/web/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/web/tools/skill/search_skills_tool.js +82 -0
- package/dist/web/tools/skill/skill_toolset.js +40 -5
- package/dist/web/utils/async_queue.js +60 -0
- package/dist/web/utils/case_utils.js +25 -0
- package/dist/web/utils/env_aware_utils.js +4 -0
- package/dist/web/utils/live_connection_utils.js +254 -0
- package/dist/web/utils/model_name.js +8 -0
- package/dist/web/utils/streaming_utils.js +9 -8
- package/dist/web/version.js +1 -1
- package/package.json +3 -1
|
@@ -11,10 +11,21 @@ import {
|
|
|
11
11
|
import { stringifyContent } from "../../events/event.js";
|
|
12
12
|
const DEFAULT_PROMPT = "The following is a conversation history between a user and an AI agent. Please summarize the conversation, focusing on key information and decisions made, as well as any unresolved questions or tasks. The summary should be concise and capture the essence of the interaction.";
|
|
13
13
|
class LlmSummarizer {
|
|
14
|
+
/**
|
|
15
|
+
* @param options - Configuration specifying the LLM and optional prompt.
|
|
16
|
+
*/
|
|
14
17
|
constructor(options) {
|
|
15
18
|
this.llm = options.llm;
|
|
16
19
|
this.prompt = options.prompt || DEFAULT_PROMPT;
|
|
17
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Summarizes a list of events into a single {@link CompactedEvent} using the
|
|
23
|
+
* configured LLM.
|
|
24
|
+
*
|
|
25
|
+
* @param events - The events to summarize. Must be non-empty.
|
|
26
|
+
* @returns A promise resolving to the compacted representation.
|
|
27
|
+
* @throws {Error} If `events` is empty or the LLM returns no content.
|
|
28
|
+
*/
|
|
18
29
|
async summarize(events) {
|
|
19
30
|
var _a, _b, _c, _d, _e, _f;
|
|
20
31
|
if (events.length === 0) {
|
package/dist/esm/events/event.js
CHANGED
|
@@ -20,7 +20,7 @@ function createEvent(params = {}) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
function isFinalResponse(event) {
|
|
23
|
-
if (event.actions.skipSummarization || event.longRunningToolIds && event.longRunningToolIds.length > 0) {
|
|
23
|
+
if (event.actions.skipSummarization || event.longRunningToolIds && event.longRunningToolIds.length > 0 || event.actions.requestedAuthConfigs && Object.keys(event.actions.requestedAuthConfigs).length > 0) {
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
return getFunctionCalls(event).length === 0 && getFunctionResponses(event).length === 0 && !event.partial && !hasTrailingCodeExecutionResult(event);
|
|
@@ -12,6 +12,19 @@ import {
|
|
|
12
12
|
import { MCPTool } from "../../tools/mcp/mcp_tool.js";
|
|
13
13
|
import { GCP_MCP_SERVER_DESTINATION_ID } from "./types.js";
|
|
14
14
|
class AgentRegistrySingleMCPToolset extends BaseToolset {
|
|
15
|
+
/**
|
|
16
|
+
* @param options - Configuration for the MCP toolset.
|
|
17
|
+
* @param options.destinationResourceId - Telemetry identifier injected as
|
|
18
|
+
* `gcp.mcp.server.destination.id` into each resolved tool's custom metadata.
|
|
19
|
+
* @param options.connectionParams - HTTP connection parameters for the MCP server.
|
|
20
|
+
* @param options.toolFilter - Optional predicate or list of tool names to include.
|
|
21
|
+
* When omitted, all tools from the server are returned.
|
|
22
|
+
* @param options.prefix - Optional prefix prepended to each tool name (e.g. `myServer_toolName`).
|
|
23
|
+
* @param options.headerProvider - Optional async function called immediately before each
|
|
24
|
+
* {@link getTools} invocation to supply or refresh request headers (e.g. GCP auth tokens).
|
|
25
|
+
* @param options.authScheme - Optional auth scheme forwarded to each resolved tool.
|
|
26
|
+
* @param options.authCredential - Optional credential forwarded to each resolved tool.
|
|
27
|
+
*/
|
|
15
28
|
constructor(options) {
|
|
16
29
|
super(options.toolFilter || [], options.prefix);
|
|
17
30
|
this.destinationResourceId = options.destinationResourceId;
|
|
@@ -21,8 +34,14 @@ class AgentRegistrySingleMCPToolset extends BaseToolset {
|
|
|
21
34
|
this.authCredential = options.authCredential;
|
|
22
35
|
}
|
|
23
36
|
/**
|
|
24
|
-
* Connects to the underlying MCP server, retrieves tool definitions, prefixes
|
|
25
|
-
* and injects destination telemetry metadata.
|
|
37
|
+
* Connects to the underlying MCP server, retrieves tool definitions, prefixes
|
|
38
|
+
* tool names, and injects destination telemetry metadata into each tool.
|
|
39
|
+
*
|
|
40
|
+
* The `headerProvider`, if configured, is invoked immediately before the
|
|
41
|
+
* connection is established so that tokens are always fresh.
|
|
42
|
+
*
|
|
43
|
+
* @param context - Optional readonly agent context passed to the header provider.
|
|
44
|
+
* @returns The resolved and optionally filtered list of {@link MCPTool} instances.
|
|
26
45
|
*/
|
|
27
46
|
async getTools(context) {
|
|
28
47
|
var _a, _b, _c;
|
|
@@ -2,13 +2,17 @@ import {createRequire as topLevelCreateRequire} from 'module';
|
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
|
-
* Copyright
|
|
5
|
+
* Copyright 2026 Google LLC
|
|
6
6
|
* SPDX-License-Identifier: Apache-2.0
|
|
7
7
|
*/
|
|
8
|
+
import { LiveResponseAggregator } from "../utils/live_connection_utils.js";
|
|
8
9
|
import { logger } from "../utils/logger.js";
|
|
10
|
+
import { isGemini3xFlashLive } from "../utils/model_name.js";
|
|
9
11
|
class GeminiLlmConnection {
|
|
10
|
-
constructor(geminiSession) {
|
|
12
|
+
constructor(geminiSession, modelVersion, messageQueue) {
|
|
11
13
|
this.geminiSession = geminiSession;
|
|
14
|
+
this.modelVersion = modelVersion;
|
|
15
|
+
this.messageQueue = messageQueue;
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
14
18
|
* Sends the conversation history to the gemini model.
|
|
@@ -27,9 +31,10 @@ class GeminiLlmConnection {
|
|
|
27
31
|
}
|
|
28
32
|
);
|
|
29
33
|
if (contents.length > 0) {
|
|
34
|
+
const isGemini3x = isGemini3xFlashLive(this.modelVersion);
|
|
30
35
|
this.geminiSession.sendClientContent({
|
|
31
36
|
turns: contents,
|
|
32
|
-
turnComplete: contents[contents.length - 1].role === "user"
|
|
37
|
+
turnComplete: isGemini3x ? true : contents[contents.length - 1].role === "user"
|
|
33
38
|
});
|
|
34
39
|
} else {
|
|
35
40
|
logger.info("no content is sent");
|
|
@@ -56,10 +61,16 @@ class GeminiLlmConnection {
|
|
|
56
61
|
});
|
|
57
62
|
} else {
|
|
58
63
|
logger.debug("Sending LLM new content", content);
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
const isGemini3x = isGemini3xFlashLive(this.modelVersion);
|
|
65
|
+
if (isGemini3x && content.parts.length === 1 && content.parts[0].text) {
|
|
66
|
+
logger.debug("Using sendRealtimeInput for Gemini 3.x text input");
|
|
67
|
+
this.geminiSession.sendRealtimeInput({ text: content.parts[0].text });
|
|
68
|
+
} else {
|
|
69
|
+
this.geminiSession.sendClientContent({
|
|
70
|
+
turns: [content],
|
|
71
|
+
turnComplete: true
|
|
72
|
+
});
|
|
73
|
+
}
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
/**
|
|
@@ -68,8 +79,36 @@ class GeminiLlmConnection {
|
|
|
68
79
|
* @param blob The blob to send to the model.
|
|
69
80
|
*/
|
|
70
81
|
async sendRealtime(blob) {
|
|
82
|
+
var _a, _b, _c;
|
|
71
83
|
logger.debug("Sending LLM Blob:", blob);
|
|
72
|
-
|
|
84
|
+
const isGemini3x = isGemini3xFlashLive(this.modelVersion);
|
|
85
|
+
const isNativeAudio = (_a = this.modelVersion) == null ? void 0 : _a.includes("native-audio");
|
|
86
|
+
if (isGemini3x || isNativeAudio) {
|
|
87
|
+
if ((_b = blob.mimeType) == null ? void 0 : _b.startsWith("audio/")) {
|
|
88
|
+
this.geminiSession.sendRealtimeInput({ audio: blob });
|
|
89
|
+
} else if ((_c = blob.mimeType) == null ? void 0 : _c.startsWith("image/")) {
|
|
90
|
+
this.geminiSession.sendRealtimeInput({ video: blob });
|
|
91
|
+
} else {
|
|
92
|
+
logger.warn(
|
|
93
|
+
"Blob not sent. Unknown or empty mime type for sendRealtimeInput:",
|
|
94
|
+
blob.mimeType
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
this.geminiSession.sendRealtimeInput({ media: blob });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Sends an activity start signal to the model.
|
|
103
|
+
*/
|
|
104
|
+
async sendActivityStart() {
|
|
105
|
+
this.geminiSession.sendRealtimeInput({ activityStart: {} });
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Sends an activity end signal to the model.
|
|
109
|
+
*/
|
|
110
|
+
async sendActivityEnd() {
|
|
111
|
+
this.geminiSession.sendRealtimeInput({ activityEnd: {} });
|
|
73
112
|
}
|
|
74
113
|
/**
|
|
75
114
|
* Builds a full text response.
|
|
@@ -78,20 +117,24 @@ class GeminiLlmConnection {
|
|
|
78
117
|
* partial.
|
|
79
118
|
*
|
|
80
119
|
* @param text The text to be included in the response.
|
|
120
|
+
* @param isThought Whether the text is a thought.
|
|
121
|
+
* @param groundingMetadata The grounding metadata to include.
|
|
81
122
|
* @returns An LlmResponse containing the full text.
|
|
82
123
|
*/
|
|
83
|
-
buildFullTextResponse(text) {
|
|
84
|
-
return {
|
|
85
|
-
content: {
|
|
86
|
-
role: "model",
|
|
87
|
-
parts: [{ text }]
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
// TODO(b/425992518): GenAI SDK inconsistent API, missing methods.
|
|
92
|
-
// eslint-disable-next-line require-yield
|
|
93
124
|
async *receive() {
|
|
94
|
-
|
|
125
|
+
if (!this.messageQueue) {
|
|
126
|
+
throw new Error("Message queue is not initialized.");
|
|
127
|
+
}
|
|
128
|
+
const aggregator = new LiveResponseAggregator(this.modelVersion);
|
|
129
|
+
for await (const message of this.messageQueue) {
|
|
130
|
+
logger.debug("Got LLM Live message:", message);
|
|
131
|
+
for (const response of aggregator.processMessage(message)) {
|
|
132
|
+
yield response;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (const response of aggregator.close()) {
|
|
136
|
+
yield response;
|
|
137
|
+
}
|
|
95
138
|
}
|
|
96
139
|
/**
|
|
97
140
|
* Closes the llm server connection.
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { getBooleanEnvVar, isBrowser } from "../utils/env_aware_utils.js";
|
|
13
13
|
import { logger } from "../utils/logger.js";
|
|
14
14
|
import { GoogleLLMVariant } from "../utils/variant_utils.js";
|
|
15
|
+
import { AsyncQueue } from "../utils/async_queue.js";
|
|
15
16
|
import { StreamingResponseAggregator } from "../utils/streaming_utils.js";
|
|
16
17
|
import { BaseLlm } from "./base_llm.js";
|
|
17
18
|
import { GeminiLlmConnection } from "./gemini_llm_connection.js";
|
|
@@ -143,10 +144,19 @@ class Gemini extends BaseLlm {
|
|
|
143
144
|
}
|
|
144
145
|
get liveApiClient() {
|
|
145
146
|
if (!this._liveApiClient) {
|
|
146
|
-
this.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
if (this.vertexai) {
|
|
148
|
+
this._liveApiClient = new GoogleGenAI({
|
|
149
|
+
vertexai: this.vertexai,
|
|
150
|
+
project: this.project,
|
|
151
|
+
location: this.location || "global",
|
|
152
|
+
httpOptions: this.getLiveHttpOptions()
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
this._liveApiClient = new GoogleGenAI({
|
|
156
|
+
apiKey: this.apiKey,
|
|
157
|
+
httpOptions: this.getLiveHttpOptions()
|
|
158
|
+
});
|
|
159
|
+
}
|
|
150
160
|
}
|
|
151
161
|
return this._liveApiClient;
|
|
152
162
|
}
|
|
@@ -178,16 +188,24 @@ class Gemini extends BaseLlm {
|
|
|
178
188
|
};
|
|
179
189
|
}
|
|
180
190
|
llmRequest.liveConnectConfig.tools = (_c = llmRequest.config) == null ? void 0 : _c.tools;
|
|
191
|
+
const modelVersion = (_d = llmRequest.model) != null ? _d : this.model;
|
|
192
|
+
const messageQueue = new AsyncQueue();
|
|
181
193
|
const liveSession = await this.liveApiClient.live.connect({
|
|
182
|
-
model:
|
|
194
|
+
model: modelVersion,
|
|
183
195
|
config: llmRequest.liveConnectConfig,
|
|
184
196
|
callbacks: {
|
|
185
|
-
|
|
186
|
-
|
|
197
|
+
onmessage: (message) => {
|
|
198
|
+
messageQueue.push(message);
|
|
199
|
+
},
|
|
200
|
+
onerror: (error) => {
|
|
201
|
+
messageQueue.error(error);
|
|
202
|
+
},
|
|
203
|
+
onclose: () => {
|
|
204
|
+
messageQueue.close();
|
|
187
205
|
}
|
|
188
206
|
}
|
|
189
207
|
});
|
|
190
|
-
return new GeminiLlmConnection(liveSession);
|
|
208
|
+
return new GeminiLlmConnection(liveSession, modelVersion, messageQueue);
|
|
191
209
|
}
|
|
192
210
|
preprocessRequest(llmRequest) {
|
|
193
211
|
if (this.apiBackend === GoogleLLMVariant.GEMINI_API) {
|
|
@@ -16,6 +16,11 @@ var PolicyOutcome = /* @__PURE__ */ ((PolicyOutcome2) => {
|
|
|
16
16
|
return PolicyOutcome2;
|
|
17
17
|
})(PolicyOutcome || {});
|
|
18
18
|
class InMemoryPolicyEngine {
|
|
19
|
+
/**
|
|
20
|
+
* Always returns {@link PolicyOutcome.ALLOW} for every tool call.
|
|
21
|
+
*
|
|
22
|
+
* @returns A promise resolving to an ALLOW result.
|
|
23
|
+
*/
|
|
19
24
|
async evaluate() {
|
|
20
25
|
return Promise.resolve({
|
|
21
26
|
outcome: "ALLOW" /* ALLOW */,
|
|
@@ -24,11 +29,22 @@ class InMemoryPolicyEngine {
|
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
class SecurityPlugin extends BasePlugin {
|
|
32
|
+
/**
|
|
33
|
+
* @param params - Optional configuration. Defaults to {@link InMemoryPolicyEngine}
|
|
34
|
+
* when no policy engine is provided.
|
|
35
|
+
*/
|
|
27
36
|
constructor(params) {
|
|
28
37
|
var _a;
|
|
29
38
|
super("security_plugin");
|
|
30
39
|
this.policyEngine = (_a = params == null ? void 0 : params.policyEngine) != null ? _a : new InMemoryPolicyEngine();
|
|
31
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Intercepts tool calls, evaluating them against the policy engine before
|
|
43
|
+
* execution and handling confirmation flows for calls that require it.
|
|
44
|
+
*
|
|
45
|
+
* @returns A partial or error response object if the call is blocked or
|
|
46
|
+
* awaiting confirmation, or `undefined` to allow execution to proceed.
|
|
47
|
+
*/
|
|
32
48
|
async beforeToolCallback({
|
|
33
49
|
tool,
|
|
34
50
|
toolArgs,
|
|
@@ -74,6 +74,15 @@ function trimTempDeltaState(event) {
|
|
|
74
74
|
event.actions.stateDelta = filteredStateDelta;
|
|
75
75
|
return event;
|
|
76
76
|
}
|
|
77
|
+
function trimTempState(state) {
|
|
78
|
+
const filteredState = {};
|
|
79
|
+
for (const [key, value] of Object.entries(state)) {
|
|
80
|
+
if (!key.startsWith(State.TEMP_PREFIX)) {
|
|
81
|
+
filteredState[key] = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return filteredState;
|
|
85
|
+
}
|
|
77
86
|
function mergeStates(appState = {}, userState = {}, sessionState = {}) {
|
|
78
87
|
const merged = cloneDeep(sessionState);
|
|
79
88
|
for (const [k, v] of Object.entries(appState)) {
|
|
@@ -87,5 +96,6 @@ function mergeStates(appState = {}, userState = {}, sessionState = {}) {
|
|
|
87
96
|
export {
|
|
88
97
|
BaseSessionService,
|
|
89
98
|
mergeStates,
|
|
90
|
-
trimTempDeltaState
|
|
99
|
+
trimTempDeltaState,
|
|
100
|
+
trimTempState
|
|
91
101
|
};
|
|
@@ -108,7 +108,7 @@ class DatabaseSessionService extends BaseSessionService {
|
|
|
108
108
|
appStateDelta[key.replace(State.APP_PREFIX, "")] = value;
|
|
109
109
|
} else if (key.startsWith(State.USER_PREFIX)) {
|
|
110
110
|
userStateDelta[key.replace(State.USER_PREFIX, "")] = value;
|
|
111
|
-
} else {
|
|
111
|
+
} else if (!key.startsWith(State.TEMP_PREFIX)) {
|
|
112
112
|
sessionState[key] = value;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -357,7 +357,7 @@ class DatabaseSessionService extends BaseSessionService {
|
|
|
357
357
|
appDelta[key.replace(State.APP_PREFIX, "")] = value;
|
|
358
358
|
} else if (key.startsWith(State.USER_PREFIX)) {
|
|
359
359
|
userDelta[key.replace(State.USER_PREFIX, "")] = value;
|
|
360
|
-
} else {
|
|
360
|
+
} else if (!key.startsWith(State.TEMP_PREFIX)) {
|
|
361
361
|
sessionDelta[key] = value;
|
|
362
362
|
}
|
|
363
363
|
}
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "../../events/event.js";
|
|
23
23
|
const SCHEMA_VERSION_KEY = "schema_version";
|
|
24
24
|
const SCHEMA_VERSION_1_JSON = "1";
|
|
25
|
+
const STORAGE_KEY_COLUMN_LENGTH = 191;
|
|
25
26
|
class CamelCaseToSnakeCaseJsonType extends JsonType {
|
|
26
27
|
convertToDatabaseValue(value) {
|
|
27
28
|
return JSON.stringify(transformToSnakeCaseEvent(value));
|
|
@@ -50,7 +51,11 @@ let StorageAppState = class {
|
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
__decorateClass([
|
|
53
|
-
PrimaryKey({
|
|
54
|
+
PrimaryKey({
|
|
55
|
+
type: "string",
|
|
56
|
+
fieldName: "app_name",
|
|
57
|
+
length: STORAGE_KEY_COLUMN_LENGTH
|
|
58
|
+
})
|
|
54
59
|
], StorageAppState.prototype, "appName", 2);
|
|
55
60
|
__decorateClass([
|
|
56
61
|
Property({ type: "json" })
|
|
@@ -73,10 +78,18 @@ let StorageUserState = class {
|
|
|
73
78
|
}
|
|
74
79
|
};
|
|
75
80
|
__decorateClass([
|
|
76
|
-
PrimaryKey({
|
|
81
|
+
PrimaryKey({
|
|
82
|
+
type: "string",
|
|
83
|
+
fieldName: "app_name",
|
|
84
|
+
length: STORAGE_KEY_COLUMN_LENGTH
|
|
85
|
+
})
|
|
77
86
|
], StorageUserState.prototype, "appName", 2);
|
|
78
87
|
__decorateClass([
|
|
79
|
-
PrimaryKey({
|
|
88
|
+
PrimaryKey({
|
|
89
|
+
type: "string",
|
|
90
|
+
fieldName: "user_id",
|
|
91
|
+
length: STORAGE_KEY_COLUMN_LENGTH
|
|
92
|
+
})
|
|
80
93
|
], StorageUserState.prototype, "userId", 2);
|
|
81
94
|
__decorateClass([
|
|
82
95
|
Property({ type: "json" })
|
|
@@ -100,13 +113,21 @@ let StorageSession = class {
|
|
|
100
113
|
}
|
|
101
114
|
};
|
|
102
115
|
__decorateClass([
|
|
103
|
-
PrimaryKey({ type: "string" })
|
|
116
|
+
PrimaryKey({ type: "string", length: STORAGE_KEY_COLUMN_LENGTH })
|
|
104
117
|
], StorageSession.prototype, "id", 2);
|
|
105
118
|
__decorateClass([
|
|
106
|
-
PrimaryKey({
|
|
119
|
+
PrimaryKey({
|
|
120
|
+
type: "string",
|
|
121
|
+
fieldName: "app_name",
|
|
122
|
+
length: STORAGE_KEY_COLUMN_LENGTH
|
|
123
|
+
})
|
|
107
124
|
], StorageSession.prototype, "appName", 2);
|
|
108
125
|
__decorateClass([
|
|
109
|
-
PrimaryKey({
|
|
126
|
+
PrimaryKey({
|
|
127
|
+
type: "string",
|
|
128
|
+
fieldName: "user_id",
|
|
129
|
+
length: STORAGE_KEY_COLUMN_LENGTH
|
|
130
|
+
})
|
|
110
131
|
], StorageSession.prototype, "userId", 2);
|
|
111
132
|
__decorateClass([
|
|
112
133
|
Property({ type: "json" })
|
|
@@ -132,16 +153,28 @@ PrimaryKey.name;
|
|
|
132
153
|
let StorageEvent = class {
|
|
133
154
|
};
|
|
134
155
|
__decorateClass([
|
|
135
|
-
PrimaryKey({ type: "string" })
|
|
156
|
+
PrimaryKey({ type: "string", length: STORAGE_KEY_COLUMN_LENGTH })
|
|
136
157
|
], StorageEvent.prototype, "id", 2);
|
|
137
158
|
__decorateClass([
|
|
138
|
-
PrimaryKey({
|
|
159
|
+
PrimaryKey({
|
|
160
|
+
type: "string",
|
|
161
|
+
fieldName: "app_name",
|
|
162
|
+
length: STORAGE_KEY_COLUMN_LENGTH
|
|
163
|
+
})
|
|
139
164
|
], StorageEvent.prototype, "appName", 2);
|
|
140
165
|
__decorateClass([
|
|
141
|
-
PrimaryKey({
|
|
166
|
+
PrimaryKey({
|
|
167
|
+
type: "string",
|
|
168
|
+
fieldName: "user_id",
|
|
169
|
+
length: STORAGE_KEY_COLUMN_LENGTH
|
|
170
|
+
})
|
|
142
171
|
], StorageEvent.prototype, "userId", 2);
|
|
143
172
|
__decorateClass([
|
|
144
|
-
PrimaryKey({
|
|
173
|
+
PrimaryKey({
|
|
174
|
+
type: "string",
|
|
175
|
+
fieldName: "session_id",
|
|
176
|
+
length: STORAGE_KEY_COLUMN_LENGTH
|
|
177
|
+
})
|
|
145
178
|
], StorageEvent.prototype, "sessionId", 2);
|
|
146
179
|
__decorateClass([
|
|
147
180
|
Property({ type: "string", fieldName: "invocation_id" })
|
|
@@ -166,6 +199,7 @@ export {
|
|
|
166
199
|
ENTITIES,
|
|
167
200
|
SCHEMA_VERSION_1_JSON,
|
|
168
201
|
SCHEMA_VERSION_KEY,
|
|
202
|
+
STORAGE_KEY_COLUMN_LENGTH,
|
|
169
203
|
StorageAppState,
|
|
170
204
|
StorageEvent,
|
|
171
205
|
StorageMetadata,
|
|
@@ -10,7 +10,8 @@ import { randomUUID } from "../utils/env_aware_utils.js";
|
|
|
10
10
|
import { logger } from "../utils/logger.js";
|
|
11
11
|
import {
|
|
12
12
|
BaseSessionService,
|
|
13
|
-
mergeStates
|
|
13
|
+
mergeStates,
|
|
14
|
+
trimTempState
|
|
14
15
|
} from "./base_session_service.js";
|
|
15
16
|
import { createSession } from "./session.js";
|
|
16
17
|
import { State } from "./state.js";
|
|
@@ -41,11 +42,12 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
41
42
|
sessionId
|
|
42
43
|
}) {
|
|
43
44
|
var _a;
|
|
45
|
+
const filteredState = state ? trimTempState(state) : void 0;
|
|
44
46
|
const session = createSession({
|
|
45
47
|
id: sessionId || randomUUID(),
|
|
46
48
|
appName,
|
|
47
49
|
userId,
|
|
48
|
-
state,
|
|
50
|
+
state: filteredState,
|
|
49
51
|
events: [],
|
|
50
52
|
lastUpdateTime: Date.now()
|
|
51
53
|
});
|
|
@@ -22,7 +22,8 @@ import { logger } from "../utils/logger.js";
|
|
|
22
22
|
import { getExpressModeApiKey } from "../utils/vertex_ai_utils.js";
|
|
23
23
|
import { partialCopy } from "../utils/partial_copy.js";
|
|
24
24
|
import {
|
|
25
|
-
BaseSessionService
|
|
25
|
+
BaseSessionService,
|
|
26
|
+
trimTempState
|
|
26
27
|
} from "./base_session_service.js";
|
|
27
28
|
import { createSession } from "./session.js";
|
|
28
29
|
const DEFAULT_MAX_ATTEMPTS = 30;
|
|
@@ -83,11 +84,12 @@ let VertexAiSessionService = class extends BaseSessionService {
|
|
|
83
84
|
}) {
|
|
84
85
|
var _a;
|
|
85
86
|
const reasoningEngineId = this.getReasoningEngineId(appName);
|
|
87
|
+
const filteredState = state ? trimTempState(state) : void 0;
|
|
86
88
|
let apiResponse = await this.sessions.createInternal({
|
|
87
89
|
name: `reasoningEngines/${reasoningEngineId}`,
|
|
88
90
|
userId,
|
|
89
91
|
config: {
|
|
90
|
-
...
|
|
92
|
+
...filteredState ? { sessionState: filteredState } : {},
|
|
91
93
|
...sessionId ? { sessionId } : {}
|
|
92
94
|
}
|
|
93
95
|
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
6
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
7
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8
|
+
if (decorator = decorators[i])
|
|
9
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
10
|
+
if (kind && result) __defProp(target, key, result);
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @license
|
|
15
|
+
* Copyright 2026 Google LLC
|
|
16
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
*/
|
|
18
|
+
import { Client } from "@google-cloud/vertexai";
|
|
19
|
+
import { experimental } from "../utils/experimental.js";
|
|
20
|
+
import { loadSkillFromZipBuffer } from "./loader.js";
|
|
21
|
+
let GCPSkillRegistry = class {
|
|
22
|
+
constructor(options = {}) {
|
|
23
|
+
this.projectId = options.projectId || process.env.GOOGLE_CLOUD_PROJECT;
|
|
24
|
+
this.location = options.location || process.env.GOOGLE_CLOUD_LOCATION;
|
|
25
|
+
this.client = options.client || new Client({
|
|
26
|
+
project: this.projectId,
|
|
27
|
+
location: this.location
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async getSkill(name) {
|
|
31
|
+
const apiClient = this.client.apiClient;
|
|
32
|
+
const httpResponse = await apiClient.request({
|
|
33
|
+
path: `skills/${name}`,
|
|
34
|
+
httpMethod: "GET",
|
|
35
|
+
httpOptions: { apiVersion: "v1beta1" }
|
|
36
|
+
});
|
|
37
|
+
const response = await httpResponse.json();
|
|
38
|
+
const zippedFilesystem = response.zippedFilesystem || response.zipped_filesystem;
|
|
39
|
+
if (!zippedFilesystem) {
|
|
40
|
+
throw new Error(`Skill '${name}' does not contain zipped filesystem.`);
|
|
41
|
+
}
|
|
42
|
+
const zipBuffer = Buffer.from(zippedFilesystem, "base64");
|
|
43
|
+
return loadSkillFromZipBuffer(zipBuffer);
|
|
44
|
+
}
|
|
45
|
+
async searchSkills(query) {
|
|
46
|
+
const apiClient = this.client.apiClient;
|
|
47
|
+
const trimmedQuery = query.trim();
|
|
48
|
+
const isSearch = trimmedQuery.length > 0;
|
|
49
|
+
const path = isSearch ? `skills:retrieve?query=${encodeURIComponent(trimmedQuery)}` : "skills";
|
|
50
|
+
const httpResponse = await apiClient.request({
|
|
51
|
+
path,
|
|
52
|
+
httpMethod: "GET",
|
|
53
|
+
httpOptions: { apiVersion: "v1beta1" }
|
|
54
|
+
});
|
|
55
|
+
const response = await httpResponse.json();
|
|
56
|
+
const skillsList = isSearch ? response.retrievedSkills || response.retrieved_skills : response.skills;
|
|
57
|
+
const results = [];
|
|
58
|
+
if (skillsList && Array.isArray(skillsList)) {
|
|
59
|
+
for (const s of skillsList) {
|
|
60
|
+
const skillNameStr = s.skillName || s.skill_name || s.name || "";
|
|
61
|
+
const descriptionStr = s.description || "";
|
|
62
|
+
const parts = skillNameStr.split("/");
|
|
63
|
+
const name = skillNameStr ? parts[parts.length - 1] : "";
|
|
64
|
+
results.push({
|
|
65
|
+
name,
|
|
66
|
+
description: descriptionStr
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
GCPSkillRegistry = __decorateClass([
|
|
74
|
+
experimental
|
|
75
|
+
], GCPSkillRegistry);
|
|
76
|
+
export {
|
|
77
|
+
GCPSkillRegistry
|
|
78
|
+
};
|
|
@@ -5,6 +5,7 @@ const require = topLevelCreateRequire(import.meta.url);
|
|
|
5
5
|
* Copyright 2026 Google LLC
|
|
6
6
|
* SPDX-License-Identifier: Apache-2.0
|
|
7
7
|
*/
|
|
8
|
+
import AdmZip from "adm-zip";
|
|
8
9
|
import yaml from "js-yaml";
|
|
9
10
|
import * as fs from "node:fs/promises";
|
|
10
11
|
import * as path from "node:path";
|
|
@@ -236,9 +237,72 @@ async function loadAllSkillsInDir(skillsBasePath) {
|
|
|
236
237
|
}
|
|
237
238
|
return skills;
|
|
238
239
|
}
|
|
240
|
+
function loadSkillFromZipBuffer(zipBuffer) {
|
|
241
|
+
const zip = new AdmZip(zipBuffer);
|
|
242
|
+
const entries = zip.getEntries();
|
|
243
|
+
let skillMdContent = "";
|
|
244
|
+
for (const entry of entries) {
|
|
245
|
+
if (entry.isDirectory) continue;
|
|
246
|
+
if (entry.entryName.toLowerCase() === "skill.md") {
|
|
247
|
+
skillMdContent = entry.getData().toString("utf-8");
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (!skillMdContent) {
|
|
252
|
+
throw new Error("SKILL.md not found in zipped filesystem.");
|
|
253
|
+
}
|
|
254
|
+
const { frontmatter: parsed, body } = parseSkillMdContent(skillMdContent);
|
|
255
|
+
const frontmatter = FrontmatterSchema.parse(parsed);
|
|
256
|
+
const references = {};
|
|
257
|
+
const assets = {};
|
|
258
|
+
const scripts = {};
|
|
259
|
+
function loadZipDir(prefix) {
|
|
260
|
+
const res = {};
|
|
261
|
+
const normPrefix = prefix.endsWith("/") ? prefix : `${prefix}/`;
|
|
262
|
+
for (const entry of entries) {
|
|
263
|
+
if (entry.isDirectory) continue;
|
|
264
|
+
if (entry.entryName.startsWith(normPrefix)) {
|
|
265
|
+
if (entry.entryName.includes("__pycache__")) continue;
|
|
266
|
+
const relativePath = entry.entryName.substring(normPrefix.length);
|
|
267
|
+
if (!relativePath) continue;
|
|
268
|
+
const data = entry.getData();
|
|
269
|
+
try {
|
|
270
|
+
res[relativePath] = data.toString("utf-8");
|
|
271
|
+
} catch (_e) {
|
|
272
|
+
res[relativePath] = data;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return res;
|
|
277
|
+
}
|
|
278
|
+
const refFiles = loadZipDir("references");
|
|
279
|
+
for (const [key, val] of Object.entries(refFiles)) {
|
|
280
|
+
references[key] = val;
|
|
281
|
+
}
|
|
282
|
+
const assetFiles = loadZipDir("assets");
|
|
283
|
+
for (const [key, val] of Object.entries(assetFiles)) {
|
|
284
|
+
assets[key] = val;
|
|
285
|
+
}
|
|
286
|
+
const rawScripts = loadZipDir("scripts");
|
|
287
|
+
for (const [key, val] of Object.entries(rawScripts)) {
|
|
288
|
+
if (typeof val === "string") {
|
|
289
|
+
scripts[key] = { src: val };
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
frontmatter,
|
|
294
|
+
instructions: body,
|
|
295
|
+
resources: {
|
|
296
|
+
references,
|
|
297
|
+
assets,
|
|
298
|
+
scripts
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
239
302
|
export {
|
|
240
303
|
loadAllSkillsInDir,
|
|
241
304
|
loadSkillFromDir,
|
|
305
|
+
loadSkillFromZipBuffer,
|
|
242
306
|
parseSkillMdContent,
|
|
243
307
|
validateSkillDir
|
|
244
308
|
};
|