@inupedia/spotlight-client 0.1.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 +77 -0
- package/dist/agentCapability.d.ts +43 -0
- package/dist/agentCapability.d.ts.map +1 -0
- package/dist/agentCapability.js +84 -0
- package/dist/agentDecoratorTypes.d.ts +26 -0
- package/dist/agentDecoratorTypes.d.ts.map +1 -0
- package/dist/agentDecoratorTypes.js +1 -0
- package/dist/agentExecutor.d.ts +35 -0
- package/dist/agentExecutor.d.ts.map +1 -0
- package/dist/agentExecutor.js +224 -0
- package/dist/agentRegistry.d.ts +110 -0
- package/dist/agentRegistry.d.ts.map +1 -0
- package/dist/agentRegistry.js +171 -0
- package/dist/contextualAction.d.ts +8 -0
- package/dist/contextualAction.d.ts.map +1 -0
- package/dist/contextualAction.js +9 -0
- package/dist/defineAgentService.d.ts +13 -0
- package/dist/defineAgentService.d.ts.map +1 -0
- package/dist/defineAgentService.js +14 -0
- package/dist/defineAgentTool.d.ts +37 -0
- package/dist/defineAgentTool.d.ts.map +1 -0
- package/dist/defineAgentTool.js +48 -0
- package/dist/defineToolsFromRegistry.d.ts +20 -0
- package/dist/defineToolsFromRegistry.d.ts.map +1 -0
- package/dist/defineToolsFromRegistry.js +19 -0
- package/dist/host.d.ts +40 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +160 -0
- package/dist/http.d.ts +20 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +58 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/registryBridge.d.ts +27 -0
- package/dist/registryBridge.d.ts.map +1 -0
- package/dist/registryBridge.js +18 -0
- package/dist/skillPrompt.d.ts +20 -0
- package/dist/skillPrompt.d.ts.map +1 -0
- package/dist/skillPrompt.js +59 -0
- package/dist/skillScriptRunner.d.ts +19 -0
- package/dist/skillScriptRunner.d.ts.map +1 -0
- package/dist/skillScriptRunner.js +39 -0
- package/dist/skillScriptTool.d.ts +18 -0
- package/dist/skillScriptTool.d.ts.map +1 -0
- package/dist/skillScriptTool.js +53 -0
- package/dist/skillServiceStandard.d.ts +20 -0
- package/dist/skillServiceStandard.d.ts.map +1 -0
- package/dist/skillServiceStandard.js +82 -0
- package/dist/vite/index.d.ts +4 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +1 -0
- package/dist/vite/spotlightAgentIoc.d.ts +11 -0
- package/dist/vite/spotlightAgentIoc.d.ts.map +1 -0
- package/dist/vite/spotlightAgentIoc.js +331 -0
- package/package.json +58 -0
- package/src/agentDecorator.d.ts +17 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { SpotlightClientConfig } from "./http.js";
|
|
2
|
+
export { appendProjectQuery, buildJsonHeaders, createSpotlightHttp, normalizeServerUrl, resolveSpotlightClientConfig, type SpotlightHttp, } from "./http.js";
|
|
3
|
+
export { buildClientToolsManifest, createSpotlightHostAdapter, executeHostTool, fetchDefaultCommandCatalog, fetchHostToolsManifest, mergeCommandCatalogs, resetHostToolsManifestCacheForTests, resolveHostTools, serializeSkillsForRemote, type SessionHostToolHandler, type SpotlightHostAdapter, type SpotlightHostTool, type SpotlightHostToolHandlerContext, } from "./host.js";
|
|
4
|
+
export { bridgeAgentRegistryToHostTools, type AgentRegistryBridgeDeps, type AgentRegistryTool, } from "./registryBridge.js";
|
|
5
|
+
export { defineToolsFromAgentRegistry, type AgentRegistryHostTools, } from "./defineToolsFromRegistry.js";
|
|
6
|
+
export { registerTool, getTool, listTools, listLoopTools, getToolsByPrefix, clearTools, createToolInputSchema, createLooseObjectSchema, getToolTitle, getToolAvailabilityCheck, getToolRequirements, getToolContextHint, getToolPreflight, getToolInvoker, getToolExecutionMode, getToolExecutionTarget, getToolExposeToLoop, getToolTimeoutMs, getToolRecovery, getToolResultSummarizer, getToolHostEffectBuilder, type AgentTool, type ToolContextHint, type ToolExecutionMode, type ToolInputSchema, type ToolPreflightContext, type ToolPreflightResult, type ToolRecoveryConfig, } from "./agentRegistry.js";
|
|
7
|
+
export { createAgentExecutor, type AgentExecutorContext, type AgentExecutorNavigation, type CreateAgentExecutorOptions, type ToolResult, type ToolTraceEvent, } from "./agentExecutor.js";
|
|
8
|
+
export { defineAgentTool, hostEffect, type AgentToolDef, type HostEffectConfig, type ToolFieldSchema, } from "./defineAgentTool.js";
|
|
9
|
+
export { agent, Agent, loadAgentCapabilities, registerAgentCapability, registerExportedAgentCapabilities, getAgentCapabilityMeta, type AgentCapabilityMeta, type AgentCapabilityHandler, type AgentCapabilityDecorator, } from "./agentCapability.js";
|
|
10
|
+
export { createContextualAction } from "./contextualAction.js";
|
|
11
|
+
export { buildAgentServiceHost, type BuildAgentServiceHostOptions, } from "./defineAgentService.js";
|
|
12
|
+
export { validateSkillFrontmatter, describeCapabilitySurface, SPOTLIGHT_LAYOUT, SPOTLIGHT_SKILL_LOAD_LEVELS, spotlightSkillsGlobPattern, type SkillValidationResult, type SpotlightSkillFrontmatter, } from "./skillServiceStandard.js";
|
|
13
|
+
export { substituteSkillPlaceholders, executeInlineShellInMarkdown, prepareSkillMarkdownContent, } from "./skillPrompt.js";
|
|
14
|
+
export { registerSkillScriptTool, type RegisterSkillScriptToolOptions, type SkillScriptRunner, } from "./skillScriptTool.js";
|
|
15
|
+
export { joinSkillScriptPath, createNodeSkillScriptRunner, type SkillScriptRunResult, } from "./skillScriptRunner.js";
|
|
16
|
+
export type { AgentDef } from "./agentDecoratorTypes.js";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,KAAK,aAAa,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,mCAAmC,EACnC,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,+BAA+B,GACrC,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,8BAA8B,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,4BAA4B,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,YAAY,EACZ,OAAO,EACP,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,UAAU,EACf,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,eAAe,EACf,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,EACL,KAAK,EACL,qBAAqB,EACrB,uBAAuB,EACvB,iCAAiC,EACjC,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EACL,qBAAqB,EACrB,KAAK,4BAA4B,GAClC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { appendProjectQuery, buildJsonHeaders, createSpotlightHttp, normalizeServerUrl, resolveSpotlightClientConfig, } from "./http.js";
|
|
2
|
+
export { buildClientToolsManifest, createSpotlightHostAdapter, executeHostTool, fetchDefaultCommandCatalog, fetchHostToolsManifest, mergeCommandCatalogs, resetHostToolsManifestCacheForTests, resolveHostTools, serializeSkillsForRemote, } from "./host.js";
|
|
3
|
+
export { bridgeAgentRegistryToHostTools, } from "./registryBridge.js";
|
|
4
|
+
export { defineToolsFromAgentRegistry, } from "./defineToolsFromRegistry.js";
|
|
5
|
+
export { registerTool, getTool, listTools, listLoopTools, getToolsByPrefix, clearTools, createToolInputSchema, createLooseObjectSchema, getToolTitle, getToolAvailabilityCheck, getToolRequirements, getToolContextHint, getToolPreflight, getToolInvoker, getToolExecutionMode, getToolExecutionTarget, getToolExposeToLoop, getToolTimeoutMs, getToolRecovery, getToolResultSummarizer, getToolHostEffectBuilder, } from "./agentRegistry.js";
|
|
6
|
+
export { createAgentExecutor, } from "./agentExecutor.js";
|
|
7
|
+
export { defineAgentTool, hostEffect, } from "./defineAgentTool.js";
|
|
8
|
+
export { agent, Agent, loadAgentCapabilities, registerAgentCapability, registerExportedAgentCapabilities, getAgentCapabilityMeta, } from "./agentCapability.js";
|
|
9
|
+
export { createContextualAction } from "./contextualAction.js";
|
|
10
|
+
export { buildAgentServiceHost, } from "./defineAgentService.js";
|
|
11
|
+
export { validateSkillFrontmatter, describeCapabilitySurface, SPOTLIGHT_LAYOUT, SPOTLIGHT_SKILL_LOAD_LEVELS, spotlightSkillsGlobPattern, } from "./skillServiceStandard.js";
|
|
12
|
+
export { substituteSkillPlaceholders, executeInlineShellInMarkdown, prepareSkillMarkdownContent, } from "./skillPrompt.js";
|
|
13
|
+
export { registerSkillScriptTool, } from "./skillScriptTool.js";
|
|
14
|
+
export { joinSkillScriptPath, createNodeSkillScriptRunner, } from "./skillScriptRunner.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ToolExecutionTarget } from "@inupedia/spotlight-protocol";
|
|
2
|
+
import type { SpotlightHostTool } from "./host.js";
|
|
3
|
+
export type AgentRegistryTool = {
|
|
4
|
+
name: string;
|
|
5
|
+
displayName?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
};
|
|
9
|
+
export type AgentRegistryBridgeDeps = {
|
|
10
|
+
listTools: () => Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
displayName?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
}>;
|
|
16
|
+
getToolExecutionTarget: (tool: {
|
|
17
|
+
name: string;
|
|
18
|
+
}) => ToolExecutionTarget;
|
|
19
|
+
runTool: (name: string, input: Record<string, unknown>) => Promise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
data?: unknown;
|
|
22
|
+
error?: string;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
/** Map a host-side agent tool registry to Spotlight host tools for SSE bridge. */
|
|
26
|
+
export declare function bridgeAgentRegistryToHostTools(deps: AgentRegistryBridgeDeps): SpotlightHostTool[];
|
|
27
|
+
//# sourceMappingURL=registryBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryBridge.d.ts","sourceRoot":"","sources":["../src/registryBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,MAAM,KAAK,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;IACH,sBAAsB,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,mBAAmB,CAAC;IACxE,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC3B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpE,CAAC;AAEF,kFAAkF;AAClF,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,uBAAuB,GAC5B,iBAAiB,EAAE,CAgBrB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Map a host-side agent tool registry to Spotlight host tools for SSE bridge. */
|
|
2
|
+
export function bridgeAgentRegistryToHostTools(deps) {
|
|
3
|
+
return deps
|
|
4
|
+
.listTools()
|
|
5
|
+
.filter((tool) => deps.getToolExecutionTarget(tool) === "host")
|
|
6
|
+
.map((tool) => ({
|
|
7
|
+
name: tool.name,
|
|
8
|
+
displayName: tool.displayName ?? tool.title,
|
|
9
|
+
description: tool.description,
|
|
10
|
+
handler: async ({ input }) => {
|
|
11
|
+
const result = await deps.runTool(tool.name, input);
|
|
12
|
+
if (!result.success) {
|
|
13
|
+
throw new Error(result.error ?? `Host tool failed: ${tool.name}`);
|
|
14
|
+
}
|
|
15
|
+
return result.data;
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type SkillPlaceholderContext = {
|
|
2
|
+
skillDir?: string;
|
|
3
|
+
projectDir?: string;
|
|
4
|
+
sessionId?: string;
|
|
5
|
+
};
|
|
6
|
+
/** Replace Inupedia skill placeholders (and legacy CLAUDE_* aliases). */
|
|
7
|
+
export declare function substituteSkillPlaceholders(content: string, ctx: SkillPlaceholderContext): string;
|
|
8
|
+
/**
|
|
9
|
+
* Expand lines like !`git status` before the model sees skill content.
|
|
10
|
+
* Only runs when host provides `runInlineShell` (browser SaaS 默认跳过).
|
|
11
|
+
*/
|
|
12
|
+
export declare function executeInlineShellInMarkdown(content: string, options: {
|
|
13
|
+
cwd: string;
|
|
14
|
+
runInlineShell: (command: string, cwd: string) => Promise<string>;
|
|
15
|
+
}): Promise<string>;
|
|
16
|
+
export declare function prepareSkillMarkdownContent(content: string, options: SkillPlaceholderContext & {
|
|
17
|
+
cwd?: string;
|
|
18
|
+
runInlineShell?: (command: string, cwd: string) => Promise<string>;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
//# sourceMappingURL=skillPrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillPrompt.d.ts","sourceRoot":"","sources":["../src/skillPrompt.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,yEAAyE;AACzE,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,uBAAuB,GAC3B,MAAM,CAiBR;AAID;;;GAGG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACnE,GACA,OAAO,CAAC,MAAM,CAAC,CAwBjB;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,uBAAuB,GAAG;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACpE,GACA,OAAO,CAAC,MAAM,CAAC,CASjB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { INUPEDIA_SKILL_PLACEHOLDERS } from "@inupedia/spotlight-protocol";
|
|
2
|
+
/** Replace Inupedia skill placeholders (and legacy CLAUDE_* aliases). */
|
|
3
|
+
export function substituteSkillPlaceholders(content, ctx) {
|
|
4
|
+
let out = content;
|
|
5
|
+
const skillDir = ctx.skillDir ?? "";
|
|
6
|
+
const projectDir = ctx.projectDir ?? "";
|
|
7
|
+
const sessionId = ctx.sessionId ?? "";
|
|
8
|
+
const pairs = [
|
|
9
|
+
[INUPEDIA_SKILL_PLACEHOLDERS.skillDir, skillDir],
|
|
10
|
+
[INUPEDIA_SKILL_PLACEHOLDERS.legacySkillDir, skillDir],
|
|
11
|
+
[INUPEDIA_SKILL_PLACEHOLDERS.projectDir, projectDir],
|
|
12
|
+
[INUPEDIA_SKILL_PLACEHOLDERS.legacyProjectDir, projectDir],
|
|
13
|
+
[INUPEDIA_SKILL_PLACEHOLDERS.sessionId, sessionId],
|
|
14
|
+
];
|
|
15
|
+
for (const [token, value] of pairs) {
|
|
16
|
+
out = out.split(token).join(value);
|
|
17
|
+
}
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
const INLINE_SHELL_LINE = /^(?:[^\S\n]*)(!\`([^`]+)\`)/m;
|
|
21
|
+
/**
|
|
22
|
+
* Expand lines like !`git status` before the model sees skill content.
|
|
23
|
+
* Only runs when host provides `runInlineShell` (browser SaaS 默认跳过).
|
|
24
|
+
*/
|
|
25
|
+
export async function executeInlineShellInMarkdown(content, options) {
|
|
26
|
+
const lines = content.split("\n");
|
|
27
|
+
const out = [];
|
|
28
|
+
for (const line of lines) {
|
|
29
|
+
const match = line.match(INLINE_SHELL_LINE);
|
|
30
|
+
if (!match) {
|
|
31
|
+
out.push(line);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const command = match[2]?.trim() ?? "";
|
|
35
|
+
if (!command) {
|
|
36
|
+
out.push(line);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const result = await options.runInlineShell(command, options.cwd);
|
|
41
|
+
out.push(result.trimEnd());
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const message = error instanceof Error ? error.message : String(error ?? "unknown error");
|
|
45
|
+
out.push(`[shell execution failed: ${message}]`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out.join("\n");
|
|
49
|
+
}
|
|
50
|
+
export async function prepareSkillMarkdownContent(content, options) {
|
|
51
|
+
let prepared = substituteSkillPlaceholders(content, options);
|
|
52
|
+
if (options.runInlineShell && options.cwd) {
|
|
53
|
+
prepared = await executeInlineShellInMarkdown(prepared, {
|
|
54
|
+
cwd: options.cwd,
|
|
55
|
+
runInlineShell: options.runInlineShell,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return prepared;
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type SkillScriptRunResult = {
|
|
2
|
+
stdout: string;
|
|
3
|
+
stderr: string;
|
|
4
|
+
exitCode: number;
|
|
5
|
+
};
|
|
6
|
+
/** Resolve scripts/foo.sh under skill root; rejects path traversal. */
|
|
7
|
+
export declare function joinSkillScriptPath(skillRoot: string, scriptRelative: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Node 宿主默认脚本执行器(浏览器宿主请自定义 runScript)。
|
|
10
|
+
*/
|
|
11
|
+
export declare function createNodeSkillScriptRunner(options: {
|
|
12
|
+
defaultCwd: string;
|
|
13
|
+
}): Promise<(params: {
|
|
14
|
+
skillRoot: string;
|
|
15
|
+
scriptPath: string;
|
|
16
|
+
args?: string;
|
|
17
|
+
cwd: string;
|
|
18
|
+
}) => Promise<SkillScriptRunResult>>;
|
|
19
|
+
//# sourceMappingURL=skillScriptRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillScriptRunner.d.ts","sourceRoot":"","sources":["../src/skillScriptRunner.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GACrB,MAAM,CAUR;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CACT,CAAC,MAAM,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,KAAK,OAAO,CAAC,oBAAoB,CAAC,CACpC,CA0BA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @ts-nocheck — Node-only script runner; not typechecked in browser vue-tsc graph.
|
|
2
|
+
/** Resolve scripts/foo.sh under skill root; rejects path traversal. */
|
|
3
|
+
export function joinSkillScriptPath(skillRoot, scriptRelative) {
|
|
4
|
+
const root = skillRoot.replace(/\\/g, "/").replace(/\/$/, "");
|
|
5
|
+
const rel = scriptRelative
|
|
6
|
+
.replace(/\\/g, "/")
|
|
7
|
+
.replace(/^\.\/+/, "")
|
|
8
|
+
.replace(/^scripts\//, "");
|
|
9
|
+
if (!rel || rel.includes("..")) {
|
|
10
|
+
throw new Error(`非法脚本路径:${scriptRelative}`);
|
|
11
|
+
}
|
|
12
|
+
return `${root}/scripts/${rel}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Node 宿主默认脚本执行器(浏览器宿主请自定义 runScript)。
|
|
16
|
+
*/
|
|
17
|
+
export async function createNodeSkillScriptRunner(options) {
|
|
18
|
+
const { spawn } = await import("node:child_process");
|
|
19
|
+
return async ({ scriptPath, args, cwd }) => {
|
|
20
|
+
const argv = args?.trim() ? [scriptPath, args.trim()] : [scriptPath];
|
|
21
|
+
const child = spawn("bash", argv, {
|
|
22
|
+
cwd: cwd || options.defaultCwd,
|
|
23
|
+
env: process.env,
|
|
24
|
+
});
|
|
25
|
+
let stdout = "";
|
|
26
|
+
let stderr = "";
|
|
27
|
+
child.stdout?.on("data", (chunk) => {
|
|
28
|
+
stdout += String(chunk);
|
|
29
|
+
});
|
|
30
|
+
child.stderr?.on("data", (chunk) => {
|
|
31
|
+
stderr += String(chunk);
|
|
32
|
+
});
|
|
33
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
34
|
+
child.on("error", reject);
|
|
35
|
+
child.on("close", (code) => resolve(code ?? 1));
|
|
36
|
+
});
|
|
37
|
+
return { stdout, stderr, exitCode };
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SkillScriptRunResult } from "./skillScriptRunner.js";
|
|
2
|
+
export type SkillScriptRunner = (params: {
|
|
3
|
+
skillRoot: string;
|
|
4
|
+
scriptPath: string;
|
|
5
|
+
args?: string;
|
|
6
|
+
cwd: string;
|
|
7
|
+
}) => Promise<SkillScriptRunResult>;
|
|
8
|
+
export type RegisterSkillScriptToolOptions = {
|
|
9
|
+
getSkillRoot: (skillName: string) => string | undefined;
|
|
10
|
+
projectDir: string;
|
|
11
|
+
runScript: SkillScriptRunner;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Host-only tool: run a file under skill/scripts/.
|
|
15
|
+
* Register via defineSpotlightHost({ skillExecution: { ... } }).
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerSkillScriptTool(options: RegisterSkillScriptToolOptions): void;
|
|
18
|
+
//# sourceMappingURL=skillScriptTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillScriptTool.d.ts","sourceRoot":"","sources":["../src/skillScriptTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAExF,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEpC,MAAM,MAAM,8BAA8B,GAAG;IAC3C,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,8BAA8B,GACtC,IAAI,CAmDN"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineAgentTool } from "./defineAgentTool.js";
|
|
2
|
+
import { joinSkillScriptPath } from "./skillScriptRunner.js";
|
|
3
|
+
/**
|
|
4
|
+
* Host-only tool: run a file under skill/scripts/.
|
|
5
|
+
* Register via defineSpotlightHost({ skillExecution: { ... } }).
|
|
6
|
+
*/
|
|
7
|
+
export function registerSkillScriptTool(options) {
|
|
8
|
+
defineAgentTool({
|
|
9
|
+
name: "skill.runScript",
|
|
10
|
+
displayName: "运行 Skill 脚本",
|
|
11
|
+
description: "执行当前 skill 目录 scripts/ 下的脚本(API 胶水、批处理)。须先 skill.invoke 加载对应 skill。",
|
|
12
|
+
input: {
|
|
13
|
+
skillName: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "skill id,例如 skill.knowledge",
|
|
16
|
+
},
|
|
17
|
+
script: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "scripts/ 下相对路径,例如 fetch-gas.sh",
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
type: "string",
|
|
23
|
+
optional: true,
|
|
24
|
+
description: "传给脚本的参数字符串",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
executionTarget: "host",
|
|
28
|
+
exposeToLoop: false,
|
|
29
|
+
invoke: async (input) => {
|
|
30
|
+
const skillRoot = options.getSkillRoot(input.skillName.trim());
|
|
31
|
+
if (!skillRoot) {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
error: `未知 skill 或缺少 skillRoot:${input.skillName}`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const scriptPath = joinSkillScriptPath(skillRoot, input.script);
|
|
38
|
+
const result = await options.runScript({
|
|
39
|
+
skillRoot,
|
|
40
|
+
scriptPath,
|
|
41
|
+
args: input.args?.trim(),
|
|
42
|
+
cwd: options.projectDir,
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
success: result.exitCode === 0,
|
|
46
|
+
data: result,
|
|
47
|
+
...(result.exitCode !== 0
|
|
48
|
+
? { error: result.stderr || `脚本退出码 ${result.exitCode}` }
|
|
49
|
+
: {}),
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SPOTLIGHT_LAYOUT, SPOTLIGHT_SKILL_LOAD_LEVELS, spotlightSkillsGlobPattern, type CapabilitySurface, type SpotlightSkillFrontmatter } from "@inupedia/spotlight-protocol";
|
|
2
|
+
export type SkillValidationIssue = {
|
|
3
|
+
level: "error" | "warning";
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
export type SkillValidationResult = {
|
|
7
|
+
ok: boolean;
|
|
8
|
+
errors: string[];
|
|
9
|
+
warnings: string[];
|
|
10
|
+
issues: SkillValidationIssue[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Validate skill frontmatter against Spotlight + Agent Skills conventions.
|
|
14
|
+
* Use in CI or local skill authoring tools.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateSkillFrontmatter(data: Record<string, unknown>): SkillValidationResult;
|
|
17
|
+
/** Document how to wire a capability by execution surface. */
|
|
18
|
+
export declare function describeCapabilitySurface(surface: CapabilitySurface): string;
|
|
19
|
+
export { SPOTLIGHT_LAYOUT, SPOTLIGHT_SKILL_LOAD_LEVELS, spotlightSkillsGlobPattern, type SpotlightSkillFrontmatter, };
|
|
20
|
+
//# sourceMappingURL=skillServiceStandard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillServiceStandard.d.ts","sourceRoot":"","sources":["../src/skillServiceStandard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,EAC1B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC/B,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC,CAAC;AAgBF;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,qBAAqB,CA0DvB;AAED,8DAA8D;AAC9D,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAa5E;AAED,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,EAC1B,KAAK,yBAAyB,GAC/B,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { SPOTLIGHT_LAYOUT, SPOTLIGHT_SKILL_LOAD_LEVELS, spotlightSkillsGlobPattern, } from "@inupedia/spotlight-protocol";
|
|
2
|
+
function asStringList(value) {
|
|
3
|
+
if (value == null)
|
|
4
|
+
return [];
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
return value.filter((item) => typeof item === "string");
|
|
7
|
+
}
|
|
8
|
+
if (typeof value === "string") {
|
|
9
|
+
return value
|
|
10
|
+
.split(",")
|
|
11
|
+
.map((item) => item.trim())
|
|
12
|
+
.filter(Boolean);
|
|
13
|
+
}
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Validate skill frontmatter against Spotlight + Agent Skills conventions.
|
|
18
|
+
* Use in CI or local skill authoring tools.
|
|
19
|
+
*/
|
|
20
|
+
export function validateSkillFrontmatter(data) {
|
|
21
|
+
const issues = [];
|
|
22
|
+
const description = typeof data.description === "string" ? data.description.trim() : "";
|
|
23
|
+
if (!description) {
|
|
24
|
+
issues.push({
|
|
25
|
+
level: "error",
|
|
26
|
+
message: "缺少 description(模型靠它发现技能)",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const id = typeof data.id === "string" ? data.id.trim() : "";
|
|
30
|
+
if (id && !/^skill\.[a-z0-9][a-z0-9._-]*$/i.test(id)) {
|
|
31
|
+
issues.push({
|
|
32
|
+
level: "warning",
|
|
33
|
+
message: `id 建议使用 skill.<domain>.<name> 格式,当前: ${id}`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const whenToUse = typeof data.when_to_use === "string" ? data.when_to_use.trim() : "";
|
|
37
|
+
if (!whenToUse) {
|
|
38
|
+
issues.push({
|
|
39
|
+
level: "warning",
|
|
40
|
+
message: "建议填写 when_to_use,便于与其它 skill 区分",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const strategy = typeof data["spotlight-response-strategy"] === "string"
|
|
44
|
+
? data["spotlight-response-strategy"]
|
|
45
|
+
: typeof data["response-strategy"] === "string"
|
|
46
|
+
? data["response-strategy"]
|
|
47
|
+
: "";
|
|
48
|
+
const allowedTools = asStringList(data["allowed-tools"]);
|
|
49
|
+
if (strategy === "tool_answer" && allowedTools.length === 0) {
|
|
50
|
+
issues.push({
|
|
51
|
+
level: "error",
|
|
52
|
+
message: "spotlight-response-strategy: tool_answer 时必须声明 allowed-tools",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (data.keywords != null) {
|
|
56
|
+
issues.push({
|
|
57
|
+
level: "warning",
|
|
58
|
+
message: "不要使用 keywords 做路由;用 description + when_to_use",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const errors = issues.filter((i) => i.level === "error").map((i) => i.message);
|
|
62
|
+
const warnings = issues
|
|
63
|
+
.filter((i) => i.level === "warning")
|
|
64
|
+
.map((i) => i.message);
|
|
65
|
+
return { ok: errors.length === 0, errors, warnings, issues };
|
|
66
|
+
}
|
|
67
|
+
/** Document how to wire a capability by execution surface. */
|
|
68
|
+
export function describeCapabilitySurface(surface) {
|
|
69
|
+
switch (surface) {
|
|
70
|
+
case "host-tool":
|
|
71
|
+
return "在 service/agent/capabilities 用 @agent 注册;allowed-tools 写 tool 名。";
|
|
72
|
+
case "skill-script":
|
|
73
|
+
return "放在 skill/scripts/;SKILL.md 说明何时运行;宿主或 MCP 负责执行。";
|
|
74
|
+
case "mcp":
|
|
75
|
+
return "在 MCP 服务器注册;allowed-tools 写 MCP tool 名。";
|
|
76
|
+
case "runtime":
|
|
77
|
+
return "在 spotlight-server 注册 runtime tool;客户端 manifest 暴露即可。";
|
|
78
|
+
default:
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export { SPOTLIGHT_LAYOUT, SPOTLIGHT_SKILL_LOAD_LEVELS, spotlightSkillsGlobPattern, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAEzC,OAAO,EACL,0BAA0B,EAC1B,OAAO,GACR,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { transformSpotlightAgentIoc, default, } from "./spotlightAgentIoc.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
export type SpotlightAgentIocOptions = {
|
|
3
|
+
includePath?: string | RegExp;
|
|
4
|
+
agentPreset?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function transformSpotlightAgentIoc(code: string, id: string, options?: Pick<SpotlightAgentIocOptions, "agentPreset">): {
|
|
7
|
+
code: string;
|
|
8
|
+
map: import("magic-string").SourceMap | null;
|
|
9
|
+
} | null;
|
|
10
|
+
export default function spotlightAgentIoc(options?: SpotlightAgentIocOptions): Plugin;
|
|
11
|
+
//# sourceMappingURL=spotlightAgentIoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spotlightAgentIoc.d.ts","sourceRoot":"","sources":["../../src/vite/spotlightAgentIoc.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAYnC,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA0TF,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAM,GAC1D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,cAAc,EAAE,SAAS,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAkBvE;AASD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,OAAO,GAAE,wBAA6B,GACrC,MAAM,CAeR"}
|