@botbotgo/kit 1.0.104
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 +65 -0
- package/config/build/build.sh +182 -0
- package/config/build/tsconfig.dts.json +34 -0
- package/config/build/tsup.config.ts +19 -0
- package/config/build/vitest.config.ts +29 -0
- package/config/tool.yaml +11 -0
- package/dist/agent-context.d.ts +3 -0
- package/dist/agent-context.d.ts.map +1 -0
- package/dist/api/adapters/LangChainToolsHub.d.ts +35 -0
- package/dist/api/adapters/LangChainToolsHub.d.ts.map +1 -0
- package/dist/api/createAgentTools.d.ts +52 -0
- package/dist/api/createAgentTools.d.ts.map +1 -0
- package/dist/api/expose/extension-init/index.d.ts +3 -0
- package/dist/api/expose/extension-init/index.d.ts.map +1 -0
- package/dist/api/expose/extension-init/initExtension.d.ts +21 -0
- package/dist/api/expose/extension-init/initExtension.d.ts.map +1 -0
- package/dist/api/expose/index.d.ts +16 -0
- package/dist/api/expose/index.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/build.d.ts +21 -0
- package/dist/api/expose/mcp-build/build.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/generator.d.ts +15 -0
- package/dist/api/expose/mcp-build/generator.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/index.d.ts +8 -0
- package/dist/api/expose/mcp-build/index.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/init.d.ts +17 -0
- package/dist/api/expose/mcp-build/init.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/run.d.ts +17 -0
- package/dist/api/expose/mcp-build/run.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/types.d.ts +25 -0
- package/dist/api/expose/mcp-build/types.d.ts.map +1 -0
- package/dist/api/expose/mcpServer.d.ts +74 -0
- package/dist/api/expose/mcpServer.d.ts.map +1 -0
- package/dist/api/expose/openapi.d.ts +23 -0
- package/dist/api/expose/openapi.d.ts.map +1 -0
- package/dist/api/expose/openapiHttp.d.ts +51 -0
- package/dist/api/expose/openapiHttp.d.ts.map +1 -0
- package/dist/api/extension/contextRunner.d.ts +10 -0
- package/dist/api/extension/contextRunner.d.ts.map +1 -0
- package/dist/api/extension/createExtension.d.ts +38 -0
- package/dist/api/extension/createExtension.d.ts.map +1 -0
- package/dist/api/extension/dynamicImportAdapter.d.ts +25 -0
- package/dist/api/extension/dynamicImportAdapter.d.ts.map +1 -0
- package/dist/api/extension/generateExtensionManifest.d.ts +29 -0
- package/dist/api/extension/generateExtensionManifest.d.ts.map +1 -0
- package/dist/api/extension/index.d.ts +23 -0
- package/dist/api/extension/index.d.ts.map +1 -0
- package/dist/api/extension/loadToolYaml.d.ts +7 -0
- package/dist/api/extension/loadToolYaml.d.ts.map +1 -0
- package/dist/api/extension/overrideWithConfig.d.ts +2 -0
- package/dist/api/extension/overrideWithConfig.d.ts.map +1 -0
- package/dist/api/extension/registerExtension.d.ts +32 -0
- package/dist/api/extension/registerExtension.d.ts.map +1 -0
- package/dist/api/extension/registerFromManifest.d.ts +43 -0
- package/dist/api/extension/registerFromManifest.d.ts.map +1 -0
- package/dist/api/extension/resolvePackageRoot.d.ts +2 -0
- package/dist/api/extension/resolvePackageRoot.d.ts.map +1 -0
- package/dist/api/extension/support/groupPrefix.d.ts +21 -0
- package/dist/api/extension/support/groupPrefix.d.ts.map +1 -0
- package/dist/api/extension/support/types.d.ts +15 -0
- package/dist/api/extension/support/types.d.ts.map +1 -0
- package/dist/api/register-tools.d.ts +17 -0
- package/dist/api/register-tools.d.ts.map +1 -0
- package/dist/api/resolveAgentSkillRoots.d.ts +7 -0
- package/dist/api/resolveAgentSkillRoots.d.ts.map +1 -0
- package/dist/api/runtimeFromConfig.d.ts +20 -0
- package/dist/api/runtimeFromConfig.d.ts.map +1 -0
- package/dist/api/runtimeFromConfig.helpers.d.ts +12 -0
- package/dist/api/runtimeFromConfig.helpers.d.ts.map +1 -0
- package/dist/api/runtimeFromConfig.types.d.ts +37 -0
- package/dist/api/runtimeFromConfig.types.d.ts.map +1 -0
- package/dist/build.cjs +30 -0
- package/dist/build.cjs.map +1 -0
- package/dist/build.d.ts +13 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +5 -0
- package/dist/build.js.map +1 -0
- package/dist/canonicalCoreSchemas-PHGTNPN5.js +3 -0
- package/dist/canonicalCoreSchemas-PHGTNPN5.js.map +1 -0
- package/dist/canonicalCoreSchemas-TY7NCWCC.cjs +16 -0
- package/dist/canonicalCoreSchemas-TY7NCWCC.cjs.map +1 -0
- package/dist/chunk-4OOTCNR7.js +324 -0
- package/dist/chunk-4OOTCNR7.js.map +1 -0
- package/dist/chunk-AGLGFQUW.cjs +259 -0
- package/dist/chunk-AGLGFQUW.cjs.map +1 -0
- package/dist/chunk-AZUXVVGV.cjs +1073 -0
- package/dist/chunk-AZUXVVGV.cjs.map +1 -0
- package/dist/chunk-BDUSB6GT.js +520 -0
- package/dist/chunk-BDUSB6GT.js.map +1 -0
- package/dist/chunk-BNIE2IKZ.cjs +100 -0
- package/dist/chunk-BNIE2IKZ.cjs.map +1 -0
- package/dist/chunk-BTHDNP3C.cjs +350 -0
- package/dist/chunk-BTHDNP3C.cjs.map +1 -0
- package/dist/chunk-GGFAGLDC.js +1049 -0
- package/dist/chunk-GGFAGLDC.js.map +1 -0
- package/dist/chunk-ITX6A2BT.js +92 -0
- package/dist/chunk-ITX6A2BT.js.map +1 -0
- package/dist/chunk-IVL4TBFB.js +248 -0
- package/dist/chunk-IVL4TBFB.js.map +1 -0
- package/dist/chunk-JW4EMVTE.cjs +553 -0
- package/dist/chunk-JW4EMVTE.cjs.map +1 -0
- package/dist/chunk-LNVK4GO7.cjs +3043 -0
- package/dist/chunk-LNVK4GO7.cjs.map +1 -0
- package/dist/chunk-NTWOVFEY.js +16 -0
- package/dist/chunk-NTWOVFEY.js.map +1 -0
- package/dist/chunk-P5XFA3MW.js +3013 -0
- package/dist/chunk-P5XFA3MW.js.map +1 -0
- package/dist/chunk-UUNG3GL3.cjs +19 -0
- package/dist/chunk-UUNG3GL3.cjs.map +1 -0
- package/dist/core/registry/ToolRegistry.d.ts +68 -0
- package/dist/core/registry/ToolRegistry.d.ts.map +1 -0
- package/dist/core/runtime/Budget.d.ts +63 -0
- package/dist/core/runtime/Budget.d.ts.map +1 -0
- package/dist/core/runtime/Evidence.d.ts +19 -0
- package/dist/core/runtime/Evidence.d.ts.map +1 -0
- package/dist/core/runtime/PTCRuntime.d.ts +124 -0
- package/dist/core/runtime/PTCRuntime.d.ts.map +1 -0
- package/dist/core/runtime/PTCRuntimeObservability.d.ts +26 -0
- package/dist/core/runtime/PTCRuntimeObservability.d.ts.map +1 -0
- package/dist/core/runtime/PTCRuntimePipeline.d.ts +69 -0
- package/dist/core/runtime/PTCRuntimePipeline.d.ts.map +1 -0
- package/dist/core/runtime/PolicyEngine.d.ts +67 -0
- package/dist/core/runtime/PolicyEngine.d.ts.map +1 -0
- package/dist/core/runtime/Retry.d.ts +33 -0
- package/dist/core/runtime/Retry.d.ts.map +1 -0
- package/dist/core/runtime/SchemaValidator.d.ts +42 -0
- package/dist/core/runtime/SchemaValidator.d.ts.map +1 -0
- package/dist/core/runtime/toolObservation.d.ts +7 -0
- package/dist/core/runtime/toolObservation.d.ts.map +1 -0
- package/dist/core/types/Events.d.ts +99 -0
- package/dist/core/types/Events.d.ts.map +1 -0
- package/dist/core/types/ToolIntent.d.ts +40 -0
- package/dist/core/types/ToolIntent.d.ts.map +1 -0
- package/dist/core/types/ToolResult.d.ts +44 -0
- package/dist/core/types/ToolResult.d.ts.map +1 -0
- package/dist/core/types/ToolSpec.d.ts +116 -0
- package/dist/core/types/ToolSpec.d.ts.map +1 -0
- package/dist/core/types/ToolTypeHandler.d.ts +88 -0
- package/dist/core/types/ToolTypeHandler.d.ts.map +1 -0
- package/dist/core/types/index.d.ts +7 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/index.cjs +399 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +394 -0
- package/dist/index.js.map +1 -0
- package/dist/observability/EventLog.d.ts +60 -0
- package/dist/observability/EventLog.d.ts.map +1 -0
- package/dist/observability/Logger.d.ts +33 -0
- package/dist/observability/Logger.d.ts.map +1 -0
- package/dist/observability/Metrics.d.ts +70 -0
- package/dist/observability/Metrics.d.ts.map +1 -0
- package/dist/observability/Tracing.d.ts +69 -0
- package/dist/observability/Tracing.d.ts.map +1 -0
- package/dist/sdk.cjs +493 -0
- package/dist/sdk.cjs.map +1 -0
- package/dist/sdk.d.ts +17 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +443 -0
- package/dist/sdk.js.map +1 -0
- package/dist/security/sandbox.d.ts +10 -0
- package/dist/security/sandbox.d.ts.map +1 -0
- package/dist/security/ssrf.d.ts +24 -0
- package/dist/security/ssrf.d.ts.map +1 -0
- package/dist/templates/mcp-server.js +48 -0
- package/dist/templates/n8n-invoker.js +11 -0
- package/dist/templates/skill-invoker.js +11 -0
- package/dist/templates/tool-index.js +9 -0
- package/dist/tools/discoveryFactory.d.ts +117 -0
- package/dist/tools/discoveryFactory.d.ts.map +1 -0
- package/dist/tools/function/index.d.ts +10 -0
- package/dist/tools/function/index.d.ts.map +1 -0
- package/dist/tools/function/scanner.d.ts +29 -0
- package/dist/tools/function/scanner.d.ts.map +1 -0
- package/dist/tools/function/schemaFromTs.d.ts +16 -0
- package/dist/tools/function/schemaFromTs.d.ts.map +1 -0
- package/dist/tools/function/types.d.ts +20 -0
- package/dist/tools/function/types.d.ts.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/langchain/LangChainLoader.d.ts +7 -0
- package/dist/tools/langchain/LangChainLoader.d.ts.map +1 -0
- package/dist/tools/langchain/directoryApply.d.ts +5 -0
- package/dist/tools/langchain/directoryApply.d.ts.map +1 -0
- package/dist/tools/langchain/directoryLoad.d.ts +13 -0
- package/dist/tools/langchain/directoryLoad.d.ts.map +1 -0
- package/dist/tools/langchain/index.d.ts +3 -0
- package/dist/tools/langchain/index.d.ts.map +1 -0
- package/dist/tools/langchain/scanner.d.ts +8 -0
- package/dist/tools/langchain/scanner.d.ts.map +1 -0
- package/dist/tools/langchain/types.d.ts +5 -0
- package/dist/tools/langchain/types.d.ts.map +1 -0
- package/dist/tools/mcp/MCPClientAdapter.d.ts +34 -0
- package/dist/tools/mcp/MCPClientAdapter.d.ts.map +1 -0
- package/dist/tools/mcp/MCPLoader.d.ts +8 -0
- package/dist/tools/mcp/MCPLoader.d.ts.map +1 -0
- package/dist/tools/mcp/MCPProcessManager.d.ts +29 -0
- package/dist/tools/mcp/MCPProcessManager.d.ts.map +1 -0
- package/dist/tools/mcp/connectMCP.d.ts +47 -0
- package/dist/tools/mcp/connectMCP.d.ts.map +1 -0
- package/dist/tools/mcp/directoryApply.d.ts +10 -0
- package/dist/tools/mcp/directoryApply.d.ts.map +1 -0
- package/dist/tools/mcp/index.d.ts +16 -0
- package/dist/tools/mcp/index.d.ts.map +1 -0
- package/dist/tools/mcp/mcpSpecToToolSpec.d.ts +8 -0
- package/dist/tools/mcp/mcpSpecToToolSpec.d.ts.map +1 -0
- package/dist/tools/mcp/registerMCPTools.d.ts +24 -0
- package/dist/tools/mcp/registerMCPTools.d.ts.map +1 -0
- package/dist/tools/mcp/scanner.d.ts +8 -0
- package/dist/tools/mcp/scanner.d.ts.map +1 -0
- package/dist/tools/mcp/support/types.d.ts +3 -0
- package/dist/tools/mcp/support/types.d.ts.map +1 -0
- package/dist/tools/n8n/N8nLoader.d.ts +25 -0
- package/dist/tools/n8n/N8nLoader.d.ts.map +1 -0
- package/dist/tools/n8n/directoryApply.d.ts +10 -0
- package/dist/tools/n8n/directoryApply.d.ts.map +1 -0
- package/dist/tools/n8n/index.d.ts +6 -0
- package/dist/tools/n8n/index.d.ts.map +1 -0
- package/dist/tools/n8n/scanN8n.d.ts +20 -0
- package/dist/tools/n8n/scanN8n.d.ts.map +1 -0
- package/dist/tools/n8n/types.d.ts +18 -0
- package/dist/tools/n8n/types.d.ts.map +1 -0
- package/dist/tools/scanPackage.d.ts +42 -0
- package/dist/tools/scanPackage.d.ts.map +1 -0
- package/dist/tools/skill/SkillLoader.d.ts +20 -0
- package/dist/tools/skill/SkillLoader.d.ts.map +1 -0
- package/dist/tools/skill/SkillManifest.d.ts +79 -0
- package/dist/tools/skill/SkillManifest.d.ts.map +1 -0
- package/dist/tools/skill/SkillMdParser.d.ts +31 -0
- package/dist/tools/skill/SkillMdParser.d.ts.map +1 -0
- package/dist/tools/skill/directoryApply.d.ts +10 -0
- package/dist/tools/skill/directoryApply.d.ts.map +1 -0
- package/dist/tools/skill/index.d.ts +8 -0
- package/dist/tools/skill/index.d.ts.map +1 -0
- package/dist/tools/skill/scanSkill.d.ts +20 -0
- package/dist/tools/skill/scanSkill.d.ts.map +1 -0
- package/dist/tools/skill/types.d.ts +19 -0
- package/dist/tools/skill/types.d.ts.map +1 -0
- package/dist/tools/util/canonicalCoreSchemas.d.ts +15 -0
- package/dist/tools/util/canonicalCoreSchemas.d.ts.map +1 -0
- package/dist/tools/util/index.d.ts +13 -0
- package/dist/tools/util/index.d.ts.map +1 -0
- package/dist/tools/util/resolveEntry.d.ts +6 -0
- package/dist/tools/util/resolveEntry.d.ts.map +1 -0
- package/dist/tools/util/scanUtil.d.ts +9 -0
- package/dist/tools/util/scanUtil.d.ts.map +1 -0
- package/dist/tools/util/toolConfig.d.ts +38 -0
- package/dist/tools/util/toolConfig.d.ts.map +1 -0
- package/dist/tools/util/toolDescriptor.d.ts +117 -0
- package/dist/tools/util/toolDescriptor.d.ts.map +1 -0
- package/dist/utils/cli/help.d.ts +2 -0
- package/dist/utils/cli/help.d.ts.map +1 -0
- package/dist/utils/cli/index.cjs +700 -0
- package/dist/utils/cli/index.cjs.map +1 -0
- package/dist/utils/cli/index.d.ts +9 -0
- package/dist/utils/cli/index.d.ts.map +1 -0
- package/dist/utils/cli/index.js +677 -0
- package/dist/utils/cli/index.js.map +1 -0
- package/dist/utils/cli/toolRuntime.d.ts +19 -0
- package/dist/utils/cli/toolRuntime.d.ts.map +1 -0
- package/dist/utils/log.d.ts +2 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/npmCache.d.ts +11 -0
- package/dist/utils/npmCache.d.ts.map +1 -0
- package/dist/utils/npmVersion.d.ts +10 -0
- package/dist/utils/npmVersion.d.ts.map +1 -0
- package/dist/utils/overrideWithConfig.d.ts +2 -0
- package/dist/utils/overrideWithConfig.d.ts.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Evidence, ToolError } from "./ToolResult.js";
|
|
2
|
+
/**
|
|
3
|
+
* Event types emitted by PTCRuntime and observability layer.
|
|
4
|
+
*/
|
|
5
|
+
export type ToolEventType = "TOOL_CALLED" | "TOOL_RESULT" | "POLICY_DENIED" | "HITL_APPROVAL_REQUESTED" | "HITL_APPROVAL_GRANTED" | "HITL_APPROVAL_DENIED" | "RETRY" | "TIMEOUT" | "BUDGET_EXCEEDED" | "JOB_SUBMITTED" | "JOB_COMPLETED" | "JOB_FAILED";
|
|
6
|
+
/**
|
|
7
|
+
* Base event structure for all tool events.
|
|
8
|
+
*/
|
|
9
|
+
export interface ToolEvent {
|
|
10
|
+
type: ToolEventType;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
requestId: string;
|
|
13
|
+
taskId: string;
|
|
14
|
+
toolName: string;
|
|
15
|
+
traceId?: string;
|
|
16
|
+
userId?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Emitted when a tool is called.
|
|
20
|
+
*/
|
|
21
|
+
export interface ToolCalledEvent extends ToolEvent {
|
|
22
|
+
type: "TOOL_CALLED";
|
|
23
|
+
argsSummary: string;
|
|
24
|
+
purpose: string;
|
|
25
|
+
idempotencyKey?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Emitted when a tool returns a result.
|
|
29
|
+
*/
|
|
30
|
+
export interface ToolResultEvent extends ToolEvent {
|
|
31
|
+
type: "TOOL_RESULT";
|
|
32
|
+
ok: boolean;
|
|
33
|
+
durationMs: number;
|
|
34
|
+
resultSummary: string;
|
|
35
|
+
evidence: Evidence[];
|
|
36
|
+
error?: ToolError;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Emitted when policy denies a tool invocation.
|
|
40
|
+
*/
|
|
41
|
+
export interface PolicyDeniedEvent extends ToolEvent {
|
|
42
|
+
type: "POLICY_DENIED";
|
|
43
|
+
reason: string;
|
|
44
|
+
missingCapabilities?: string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Emitted on retry.
|
|
48
|
+
*/
|
|
49
|
+
export interface RetryEvent extends ToolEvent {
|
|
50
|
+
type: "RETRY";
|
|
51
|
+
attempt: number;
|
|
52
|
+
maxRetries: number;
|
|
53
|
+
reason: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Emitted when human approval is requested (before execute for external_write/destructive).
|
|
57
|
+
*/
|
|
58
|
+
export interface HitlApprovalRequestedEvent extends ToolEvent {
|
|
59
|
+
type: "HITL_APPROVAL_REQUESTED";
|
|
60
|
+
sideEffect: string;
|
|
61
|
+
argsSummary?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Emitted when human approves the tool invocation.
|
|
65
|
+
*/
|
|
66
|
+
export interface HitlApprovalGrantedEvent extends ToolEvent {
|
|
67
|
+
type: "HITL_APPROVAL_GRANTED";
|
|
68
|
+
sideEffect: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Emitted when human denies the tool invocation.
|
|
72
|
+
*/
|
|
73
|
+
export interface HitlApprovalDeniedEvent extends ToolEvent {
|
|
74
|
+
type: "HITL_APPROVAL_DENIED";
|
|
75
|
+
sideEffect: string;
|
|
76
|
+
reason?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Async job events.
|
|
80
|
+
*/
|
|
81
|
+
export interface JobSubmittedEvent extends ToolEvent {
|
|
82
|
+
type: "JOB_SUBMITTED";
|
|
83
|
+
jobId: string;
|
|
84
|
+
}
|
|
85
|
+
export interface JobCompletedEvent extends ToolEvent {
|
|
86
|
+
type: "JOB_COMPLETED";
|
|
87
|
+
jobId: string;
|
|
88
|
+
durationMs: number;
|
|
89
|
+
}
|
|
90
|
+
export interface JobFailedEvent extends ToolEvent {
|
|
91
|
+
type: "JOB_FAILED";
|
|
92
|
+
jobId: string;
|
|
93
|
+
error: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Union type of all tool events.
|
|
97
|
+
*/
|
|
98
|
+
export type AnyToolEvent = ToolCalledEvent | ToolResultEvent | PolicyDeniedEvent | HitlApprovalRequestedEvent | HitlApprovalGrantedEvent | HitlApprovalDeniedEvent | RetryEvent | JobSubmittedEvent | JobCompletedEvent | JobFailedEvent;
|
|
99
|
+
//# sourceMappingURL=Events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Events.d.ts","sourceRoot":"","sources":["../../../src/core/types/Events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,aAAa,GACb,eAAe,GACf,yBAAyB,GACzB,uBAAuB,GACvB,sBAAsB,GACtB,OAAO,GACP,SAAS,GACT,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,YAAY,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB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AAkB,SAAQ,SAAS;IAClD,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,eAAe,GACf,eAAe,GACf,iBAAiB,GACjB,0BAA0B,GAC1B,wBAAwB,GACxB,uBAAuB,GACvB,UAAU,GACV,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Capability } from "./ToolSpec.js";
|
|
2
|
+
/**
|
|
3
|
+
* Budget constraints for a tool invocation.
|
|
4
|
+
*/
|
|
5
|
+
export interface BudgetConfig {
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
maxRetries?: number;
|
|
8
|
+
maxToolCalls?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Execution context passed from agent-orchestra.
|
|
12
|
+
* Contains permissions, budget, and observability context.
|
|
13
|
+
*/
|
|
14
|
+
export interface ExecContext {
|
|
15
|
+
requestId: string;
|
|
16
|
+
taskId: string;
|
|
17
|
+
/** Allowed capabilities for this invocation */
|
|
18
|
+
permissions: Capability[];
|
|
19
|
+
budget?: BudgetConfig;
|
|
20
|
+
/** OpenTelemetry-compatible trace ID */
|
|
21
|
+
traceId?: string;
|
|
22
|
+
userId?: string;
|
|
23
|
+
/** Optional: enable dry-run mode for two-phase commit */
|
|
24
|
+
dryRun?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tool invocation intent from agent-orchestra.
|
|
28
|
+
* Represents what the agent wants to do (untrusted input).
|
|
29
|
+
*/
|
|
30
|
+
export interface ToolIntent {
|
|
31
|
+
/** ToolSpec.name reference */
|
|
32
|
+
tool: string;
|
|
33
|
+
/** Untrusted input arguments */
|
|
34
|
+
args: unknown;
|
|
35
|
+
/** Human-readable purpose for audit trail */
|
|
36
|
+
purpose: string;
|
|
37
|
+
/** Idempotency key: recommended format requestId:taskId:tool */
|
|
38
|
+
idempotencyKey?: string;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=ToolIntent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolIntent.d.ts","sourceRoot":"","sources":["../../../src/core/types/ToolIntent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IAEf,+CAA+C;IAC/C,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evidence attached to a tool result for audit trail.
|
|
3
|
+
*/
|
|
4
|
+
export interface Evidence {
|
|
5
|
+
type: "tool" | "file" | "url" | "text" | "metric";
|
|
6
|
+
ref: string;
|
|
7
|
+
summary: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Known error kinds returned by PTC / tools so callers get structured feedback.
|
|
12
|
+
* Extensions may use createTaggedError(kind, message, details); pipeline maps to ToolError.
|
|
13
|
+
*/
|
|
14
|
+
export type ToolErrorKind = "TOOL_NOT_FOUND" | "INPUT_SCHEMA_INVALID" | "POLICY_DENIED" | "BUDGET_EXCEEDED" | "TIMEOUT" | "UPSTREAM_ERROR" | "OUTPUT_SCHEMA_INVALID" | "PATH_OUTSIDE_SANDBOX" | "FILE_TOO_LARGE" | "HTTP_DISALLOWED_HOST" | "HTTP_TIMEOUT" | "HTTP_TOO_LARGE" | "HITL_DENIED" | "EXEC_INVALID" | "EXEC_SPAWN_ERROR" | "DUCKDUCKGO_INVALID";
|
|
15
|
+
/**
|
|
16
|
+
* Error information in a tool result.
|
|
17
|
+
*/
|
|
18
|
+
export interface ToolError {
|
|
19
|
+
kind?: ToolErrorKind;
|
|
20
|
+
message: string;
|
|
21
|
+
details?: unknown;
|
|
22
|
+
}
|
|
23
|
+
export type ToolFeedbackStatus = "resolved" | "needs_retry" | "needs_input" | "blocked";
|
|
24
|
+
export interface ToolFeedback {
|
|
25
|
+
status: ToolFeedbackStatus;
|
|
26
|
+
message: string;
|
|
27
|
+
hint?: string;
|
|
28
|
+
suggested_intent_patch?: Record<string, unknown>;
|
|
29
|
+
suggested_tool_args?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Unified tool result returned to agent-orchestra.
|
|
33
|
+
* Always structured, never throws raw exceptions.
|
|
34
|
+
*/
|
|
35
|
+
export interface ToolResult {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
result?: unknown;
|
|
38
|
+
feedback?: ToolFeedback;
|
|
39
|
+
evidence: Evidence[];
|
|
40
|
+
error?: ToolError;
|
|
41
|
+
/** Raw response for debugging (can be disabled in production) */
|
|
42
|
+
raw?: unknown;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=ToolResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolResult.d.ts","sourceRoot":"","sources":["../../../src/core/types/ToolResult.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,sBAAsB,GACtB,eAAe,GACf,iBAAiB,GACjB,SAAS,GACT,gBAAgB,GAChB,uBAAuB,GACvB,sBAAsB,GACtB,gBAAgB,GAChB,sBAAsB,GACtB,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,kBAAkB,GAClB,oBAAoB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS,CAAC;AAExF,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjD,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,iEAAiE;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;CACf"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified tool kinds supported by the tools package.
|
|
3
|
+
*/
|
|
4
|
+
export type ToolKind = "mcp" | "langchain" | "n8n" | "comfyui" | "skill" | "function" | "core" | "example";
|
|
5
|
+
/**
|
|
6
|
+
* Capability declarations for tools.
|
|
7
|
+
* Used by PolicyEngine for permission gating.
|
|
8
|
+
*/
|
|
9
|
+
export type Capability = "read:web" | "read:fs" | "write:fs" | "read:db" | "write:db" | "network" | "gpu" | "workflow" | "danger:destructive" | "exec";
|
|
10
|
+
/**
|
|
11
|
+
* HITL (Human-in-the-Loop) side-effect classification.
|
|
12
|
+
* Used to gate execution: external_write / destructive require human approval when onApprovalRequired is set.
|
|
13
|
+
*/
|
|
14
|
+
export type HitlSideEffect = "none" | "local_write" | "external_write" | "destructive";
|
|
15
|
+
/**
|
|
16
|
+
* Cost hints for tools, used by Budget and routing.
|
|
17
|
+
*/
|
|
18
|
+
export interface CostHints {
|
|
19
|
+
latencyMsP50?: number;
|
|
20
|
+
latencyMsP95?: number;
|
|
21
|
+
isAsync?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Unified tool specification.
|
|
25
|
+
* All tool types (MCP, LangChain, n8n, SKILL) are described by this interface.
|
|
26
|
+
*
|
|
27
|
+
* Safety: each tool declares capabilities (permission gating) and _meta.hitl.sideEffect
|
|
28
|
+
* (HITL approval for external_write/destructive). Caller uses these to decide handling.
|
|
29
|
+
*/
|
|
30
|
+
export interface ToolSpec {
|
|
31
|
+
/** Globally unique name, recommended format: namespace/name */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Semver version */
|
|
34
|
+
version: string;
|
|
35
|
+
/** Tool kind determines which adapter handles execution */
|
|
36
|
+
kind: ToolKind;
|
|
37
|
+
description?: string;
|
|
38
|
+
tags?: string[];
|
|
39
|
+
/** JSON Schema for input validation */
|
|
40
|
+
inputSchema: object;
|
|
41
|
+
/** JSON Schema for output validation */
|
|
42
|
+
outputSchema: object;
|
|
43
|
+
/** Required capabilities for this tool (safety: PolicyEngine gates by ExecContext.permissions) */
|
|
44
|
+
capabilities: Capability[];
|
|
45
|
+
costHints?: CostHints;
|
|
46
|
+
/** HITL and adapter-specific metadata. Adapters may use _meta.sourcePath, _meta.exportName, _meta.projectPath (function), etc. */
|
|
47
|
+
_meta?: {
|
|
48
|
+
hitl?: {
|
|
49
|
+
sideEffect?: HitlSideEffect;
|
|
50
|
+
};
|
|
51
|
+
/** Function kind: path to source file relative to projectPath */
|
|
52
|
+
sourcePath?: string;
|
|
53
|
+
/** Function kind: export name of the handler */
|
|
54
|
+
exportName?: string;
|
|
55
|
+
/** Function/skill kind: project root for resolving sourcePath */
|
|
56
|
+
projectPath?: string;
|
|
57
|
+
/** Extension kind: package root for resolving sourcePath */
|
|
58
|
+
packageRoot?: string;
|
|
59
|
+
};
|
|
60
|
+
/** Adapter-specific: endpoint URL (MCP/n8n) */
|
|
61
|
+
endpoint?: string;
|
|
62
|
+
/** Adapter-specific: resource identifier (workflowId, promptId, etc.) */
|
|
63
|
+
resourceId?: string;
|
|
64
|
+
/** Adapter-specific: implementation reference (LangChain Tool instance, skill handler) */
|
|
65
|
+
impl?: unknown;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Normalize tool name: only [a-zA-Z0-9] and "." allowed; all other characters become ".".
|
|
69
|
+
* Consecutive dots are collapsed to one. Used for registry lookup and storage.
|
|
70
|
+
*/
|
|
71
|
+
export declare function normalizeToolName(name: string): string;
|
|
72
|
+
/** Default permissive input schema when not provided (framework supports auto-derived schema). */
|
|
73
|
+
export declare const DEFAULT_INPUT_SCHEMA: object;
|
|
74
|
+
/** Default permissive output schema when not provided (framework supports auto-derived schema). */
|
|
75
|
+
export declare const DEFAULT_OUTPUT_SCHEMA: object;
|
|
76
|
+
/**
|
|
77
|
+
* Minimal options to build a ToolSpec. Use with @effect in JSDoc for HITL sideEffect.
|
|
78
|
+
* Framework fills _meta.hitl.sideEffect from the sideEffect parameter (matches @effect annotation).
|
|
79
|
+
* inputSchema/outputSchema are optional: when omitted, permissive defaults are used (framework supports auto-derived schema at build time in scan/mcp-build).
|
|
80
|
+
*/
|
|
81
|
+
export interface CreateToolSpecOptions {
|
|
82
|
+
name: string;
|
|
83
|
+
version?: string;
|
|
84
|
+
kind: ToolKind;
|
|
85
|
+
description?: string;
|
|
86
|
+
tags?: string[];
|
|
87
|
+
/** Optional: when omitted, DEFAULT_INPUT_SCHEMA is used. Codegen can derive from handler params. */
|
|
88
|
+
inputSchema?: object;
|
|
89
|
+
/** Optional: when omitted, DEFAULT_OUTPUT_SCHEMA is used. Codegen can derive from handler return type. */
|
|
90
|
+
outputSchema?: object;
|
|
91
|
+
capabilities: Capability[];
|
|
92
|
+
costHints?: CostHints;
|
|
93
|
+
/** HITL: from @effect annotation (none | local_write | external_write | destructive). Default "none". */
|
|
94
|
+
sideEffect?: HitlSideEffect;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Build a ToolSpec from minimal options. Use @effect in handler JSDoc as annotation; pass same value as sideEffect.
|
|
98
|
+
* When inputSchema/outputSchema are omitted, permissive defaults are used (schema can be auto-derived at build time).
|
|
99
|
+
*/
|
|
100
|
+
export declare function createToolSpec(opts: CreateToolSpecOptions): ToolSpec;
|
|
101
|
+
/**
|
|
102
|
+
* Unified adapter interface.
|
|
103
|
+
* PTCRuntime looks up adapter by spec.kind and calls adapter.invoke(spec, args, ctx).
|
|
104
|
+
* spec.name is always the single canonical name (the long name); there is no short name.
|
|
105
|
+
*/
|
|
106
|
+
export interface ToolAdapter {
|
|
107
|
+
kind: ToolKind;
|
|
108
|
+
/** Optional: supports dynamic tool discovery */
|
|
109
|
+
listTools?(): Promise<ToolSpec[]>;
|
|
110
|
+
/** Execute the tool with validated args. spec.name is the canonical (long) name. */
|
|
111
|
+
invoke(spec: ToolSpec, args: unknown, ctx: import("./ToolIntent.js").ExecContext): Promise<{
|
|
112
|
+
result: unknown;
|
|
113
|
+
raw?: unknown;
|
|
114
|
+
}>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=ToolSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolSpec.d.ts","sourceRoot":"","sources":["../../../src/core/types/ToolSpec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAE3G;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,GACT,KAAK,GACL,UAAU,GACV,oBAAoB,GACpB,MAAM,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,aAAa,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3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;IACrB,0GAA0G;IAC1G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,yGAAyG;IACzG,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,QAAQ,CAepE;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,gDAAgD;IAChD,SAAS,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClC,oFAAoF;IACpF,MAAM,CACJ,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,OAAO,iBAAiB,EAAE,WAAW,GACzC,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic tool type handler: scan (discover), load (register), invoke (execute).
|
|
3
|
+
* Each tool kind has its own invoke path; PTCRuntime dispatches by spec.kind to the
|
|
4
|
+
* registered ToolAdapter for that kind.
|
|
5
|
+
*
|
|
6
|
+
* Invoke by kind:
|
|
7
|
+
* - core: handler map → runWithBuiltinContext(handler(args)) — CoreAdapter (builtin-tools)
|
|
8
|
+
* - example: handler map → runWithExampleContext(handler(args)) — ExampleAdapter (example-tools)
|
|
9
|
+
* - mcp: client.callTool({ name, arguments }) — MCPClientAdapter (src/tools/mcp)
|
|
10
|
+
* - function: dynamic import(spec._meta.sourcePath).then(m => m[exportName](args)) — in-repo adapter TBD; MCP build uses getHandler(name)(args)
|
|
11
|
+
* - skill: load skill handler from sourcePath, then run — in-repo adapter TBD; MCP build uses skill-invoker
|
|
12
|
+
* - n8n: HTTP to webhook or n8n API — in-repo adapter TBD; MCP build uses n8n-invoker
|
|
13
|
+
* - langchain: spec.impl.invoke(args) (LangChain Tool) — in-repo adapter TBD
|
|
14
|
+
*
|
|
15
|
+
* - scan: discover tools from a path. Optional if the kind does not support path-based discovery (e.g. MCP).
|
|
16
|
+
* - load: register tools into a registry and/or prepare for invoke. Optional if invoke is via external client.
|
|
17
|
+
* - invoke: execute the tool (same contract as ToolAdapter.invoke). Required.
|
|
18
|
+
*/
|
|
19
|
+
import type { ToolKind, ToolSpec } from "./ToolSpec.js";
|
|
20
|
+
import type { ToolAdapter } from "./ToolSpec.js";
|
|
21
|
+
import type { ExecContext } from "./ToolIntent.js";
|
|
22
|
+
/** Minimal registry interface for load(); avoids circular dependency on ToolRegistry. */
|
|
23
|
+
export interface ToolRegistryLike {
|
|
24
|
+
register(spec: ToolSpec): void;
|
|
25
|
+
bulkRegister(specs: ToolSpec[]): void;
|
|
26
|
+
}
|
|
27
|
+
/** Options for scanning a path for tools of a given kind. */
|
|
28
|
+
export interface ToolTypeScanOptions {
|
|
29
|
+
/** Project or package root path. */
|
|
30
|
+
projectPath?: string;
|
|
31
|
+
/** Glob patterns for files (e.g. ["**\/*.ts"]). Used by function kind. */
|
|
32
|
+
include?: string[];
|
|
33
|
+
/** Path to tsconfig.json. Used by function kind. */
|
|
34
|
+
tsconfigPath?: string;
|
|
35
|
+
/** Kind-specific options (e.g. includeN8n for scan). */
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
/** Result of scanning: unified ToolSpec[] and any errors/warnings. */
|
|
39
|
+
export interface ToolTypeScanResult {
|
|
40
|
+
specs: ToolSpec[];
|
|
41
|
+
errors: Array<{
|
|
42
|
+
file: string;
|
|
43
|
+
message: string;
|
|
44
|
+
}>;
|
|
45
|
+
warnings?: Array<{
|
|
46
|
+
file: string;
|
|
47
|
+
message: string;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
/** Options for loading (registering) tools of a given kind. */
|
|
51
|
+
export interface ToolTypeLoadOptions {
|
|
52
|
+
/** Namespace for registered tool names (e.g. "pkg"). */
|
|
53
|
+
namespace?: string;
|
|
54
|
+
/** Kind-specific options. */
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
/** Result of loading: how many registered and any errors. */
|
|
58
|
+
export interface ToolTypeLoadResult {
|
|
59
|
+
registered: number;
|
|
60
|
+
errors: Array<{
|
|
61
|
+
file: string;
|
|
62
|
+
message: string;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Generic tool type handler: scan, load, invoke.
|
|
67
|
+
* Extends ToolAdapter so a handler can be registered with PTCRuntime as the adapter for its kind.
|
|
68
|
+
*/
|
|
69
|
+
export interface ToolTypeHandler extends ToolAdapter {
|
|
70
|
+
readonly kind: ToolKind;
|
|
71
|
+
/**
|
|
72
|
+
* Discover tools from a path. Optional if this kind does not support path-based discovery.
|
|
73
|
+
*/
|
|
74
|
+
scan?(path: string, options?: ToolTypeScanOptions): Promise<ToolTypeScanResult> | ToolTypeScanResult;
|
|
75
|
+
/**
|
|
76
|
+
* Register tools into registry and/or prepare for invoke. Optional if this kind
|
|
77
|
+
* only supports invoke via an external client (e.g. MCP client already connected).
|
|
78
|
+
*/
|
|
79
|
+
load?(path: string, registry: ToolRegistryLike, options?: ToolTypeLoadOptions): Promise<ToolTypeLoadResult> | ToolTypeLoadResult;
|
|
80
|
+
/**
|
|
81
|
+
* Execute the tool. Same contract as ToolAdapter.invoke.
|
|
82
|
+
*/
|
|
83
|
+
invoke(spec: ToolSpec, args: unknown, ctx: ExecContext): Promise<{
|
|
84
|
+
result: unknown;
|
|
85
|
+
raw?: unknown;
|
|
86
|
+
}>;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=ToolTypeHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolTypeHandler.d.ts","sourceRoot":"","sources":["../../../src/core/types/ToolTypeHandler.ts"],"names":[],"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AI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAExB;;OAEG;IACH,IAAI,CAAC,CACH,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;IAEpD;;;OAGG;IACH,IAAI,CAAC,CACH,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;IAEpD;;OAEG;IACH,MAAM,CACJ,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,WAAW,GACf,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ToolKind, Capability, CostHints, ToolSpec, ToolAdapter, HitlSideEffect, CreateToolSpecOptions, } from "./ToolSpec.js";
|
|
2
|
+
export { createToolSpec, DEFAULT_INPUT_SCHEMA, DEFAULT_OUTPUT_SCHEMA, } from "./ToolSpec.js";
|
|
3
|
+
export type { BudgetConfig, ExecContext, ToolIntent, } from "./ToolIntent.js";
|
|
4
|
+
export type { Evidence, ToolError, ToolErrorKind, ToolResult, } from "./ToolResult.js";
|
|
5
|
+
export type { ToolEventType, ToolEvent, ToolCalledEvent, ToolResultEvent, PolicyDeniedEvent, RetryEvent, JobSubmittedEvent, JobCompletedEvent, JobFailedEvent, AnyToolEvent, } from "./Events.js";
|
|
6
|
+
export type { ToolTypeScanOptions, ToolTypeScanResult, ToolTypeLoadOptions, ToolTypeLoadResult, ToolRegistryLike, ToolTypeHandler, } from "./ToolTypeHandler.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,cAAc,EACd,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,sBAAsB,CAAC"}
|