@llm4ts/core 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/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/AgentSession.d.ts +66 -0
- package/dist/AgentSession.d.ts.map +1 -0
- package/dist/AgentSession.js +53 -0
- package/dist/AgentSession.js.map +1 -0
- package/dist/Capability.d.ts +101 -0
- package/dist/Capability.d.ts.map +1 -0
- package/dist/Capability.js +210 -0
- package/dist/Capability.js.map +1 -0
- package/dist/Connector.d.ts +69 -0
- package/dist/Connector.d.ts.map +1 -0
- package/dist/Connector.js +86 -0
- package/dist/Connector.js.map +1 -0
- package/dist/ConnectorConfig.d.ts +70 -0
- package/dist/ConnectorConfig.d.ts.map +1 -0
- package/dist/ConnectorConfig.js +110 -0
- package/dist/ConnectorConfig.js.map +1 -0
- package/dist/ConnectorRegistry.d.ts +28 -0
- package/dist/ConnectorRegistry.d.ts.map +1 -0
- package/dist/ConnectorRegistry.js +87 -0
- package/dist/ConnectorRegistry.js.map +1 -0
- package/dist/ContextManagement.d.ts +78 -0
- package/dist/ContextManagement.d.ts.map +1 -0
- package/dist/ContextManagement.js +221 -0
- package/dist/ContextManagement.js.map +1 -0
- package/dist/Conversation.d.ts +18 -0
- package/dist/Conversation.d.ts.map +1 -0
- package/dist/Conversation.js +17 -0
- package/dist/Conversation.js.map +1 -0
- package/dist/Errors.d.ts +64 -0
- package/dist/Errors.d.ts.map +1 -0
- package/dist/Errors.js +76 -0
- package/dist/Errors.js.map +1 -0
- package/dist/HttpClient.d.ts +43 -0
- package/dist/HttpClient.d.ts.map +1 -0
- package/dist/HttpClient.js +99 -0
- package/dist/HttpClient.js.map +1 -0
- package/dist/LlmService.d.ts +24 -0
- package/dist/LlmService.d.ts.map +1 -0
- package/dist/LlmService.js +4 -0
- package/dist/LlmService.js.map +1 -0
- package/dist/Models.d.ts +138 -0
- package/dist/Models.d.ts.map +1 -0
- package/dist/Models.js +209 -0
- package/dist/Models.js.map +1 -0
- package/dist/ProcessExecutor.d.ts +57 -0
- package/dist/ProcessExecutor.d.ts.map +1 -0
- package/dist/ProcessExecutor.js +71 -0
- package/dist/ProcessExecutor.js.map +1 -0
- package/dist/RateLimiter.d.ts +44 -0
- package/dist/RateLimiter.d.ts.map +1 -0
- package/dist/RateLimiter.js +155 -0
- package/dist/RateLimiter.js.map +1 -0
- package/dist/Streaming.d.ts +17 -0
- package/dist/Streaming.d.ts.map +1 -0
- package/dist/Streaming.js +65 -0
- package/dist/Streaming.js.map +1 -0
- package/dist/StructuredOutput.d.ts +10 -0
- package/dist/StructuredOutput.d.ts.map +1 -0
- package/dist/StructuredOutput.js +97 -0
- package/dist/StructuredOutput.js.map +1 -0
- package/dist/TemporaryFiles.d.ts +20 -0
- package/dist/TemporaryFiles.d.ts.map +1 -0
- package/dist/TemporaryFiles.js +18 -0
- package/dist/TemporaryFiles.js.map +1 -0
- package/dist/UsageLimits.d.ts +5 -0
- package/dist/UsageLimits.d.ts.map +1 -0
- package/dist/UsageLimits.js +187 -0
- package/dist/UsageLimits.js.map +1 -0
- package/dist/eval/Checks.d.ts +6 -0
- package/dist/eval/Checks.d.ts.map +1 -0
- package/dist/eval/Checks.js +39 -0
- package/dist/eval/Checks.js.map +1 -0
- package/dist/eval/Eval.d.ts +57 -0
- package/dist/eval/Eval.d.ts.map +1 -0
- package/dist/eval/Eval.js +91 -0
- package/dist/eval/Eval.js.map +1 -0
- package/dist/eval/EvalSuite.d.ts +21 -0
- package/dist/eval/EvalSuite.d.ts.map +1 -0
- package/dist/eval/EvalSuite.js +30 -0
- package/dist/eval/EvalSuite.js.map +1 -0
- package/dist/eval/Evaluator.d.ts +10 -0
- package/dist/eval/Evaluator.d.ts.map +1 -0
- package/dist/eval/Evaluator.js +14 -0
- package/dist/eval/Evaluator.js.map +1 -0
- package/dist/eval/Judge.d.ts +15 -0
- package/dist/eval/Judge.d.ts.map +1 -0
- package/dist/eval/Judge.js +73 -0
- package/dist/eval/Judge.js.map +1 -0
- package/dist/observability/MeteredLlmService.d.ts +16 -0
- package/dist/observability/MeteredLlmService.d.ts.map +1 -0
- package/dist/observability/MeteredLlmService.js +66 -0
- package/dist/observability/MeteredLlmService.js.map +1 -0
- package/dist/observability/Metrics.d.ts +71 -0
- package/dist/observability/Metrics.d.ts.map +1 -0
- package/dist/observability/Metrics.js +147 -0
- package/dist/observability/Metrics.js.map +1 -0
- package/dist/observability/Redaction.d.ts +8 -0
- package/dist/observability/Redaction.d.ts.map +1 -0
- package/dist/observability/Redaction.js +38 -0
- package/dist/observability/Redaction.js.map +1 -0
- package/dist/observability/StreamRecorder.d.ts +9 -0
- package/dist/observability/StreamRecorder.d.ts.map +1 -0
- package/dist/observability/StreamRecorder.js +10 -0
- package/dist/observability/StreamRecorder.js.map +1 -0
- package/dist/observability/StructuredLogger.d.ts +31 -0
- package/dist/observability/StructuredLogger.d.ts.map +1 -0
- package/dist/observability/StructuredLogger.js +34 -0
- package/dist/observability/StructuredLogger.js.map +1 -0
- package/dist/observability/Tracing.d.ts +38 -0
- package/dist/observability/Tracing.d.ts.map +1 -0
- package/dist/observability/Tracing.js +75 -0
- package/dist/observability/Tracing.js.map +1 -0
- package/dist/providers/AnthropicModels.d.ts +95 -0
- package/dist/providers/AnthropicModels.d.ts.map +1 -0
- package/dist/providers/AnthropicModels.js +83 -0
- package/dist/providers/AnthropicModels.js.map +1 -0
- package/dist/providers/AnthropicProvider.d.ts +13 -0
- package/dist/providers/AnthropicProvider.d.ts.map +1 -0
- package/dist/providers/AnthropicProvider.js +177 -0
- package/dist/providers/AnthropicProvider.js.map +1 -0
- package/dist/providers/AntigravityConnector.d.ts +7 -0
- package/dist/providers/AntigravityConnector.d.ts.map +1 -0
- package/dist/providers/AntigravityConnector.js +52 -0
- package/dist/providers/AntigravityConnector.js.map +1 -0
- package/dist/providers/ClaudeAgentSession.d.ts +11 -0
- package/dist/providers/ClaudeAgentSession.d.ts.map +1 -0
- package/dist/providers/ClaudeAgentSession.js +158 -0
- package/dist/providers/ClaudeAgentSession.js.map +1 -0
- package/dist/providers/ClaudeCliConnector.d.ts +9 -0
- package/dist/providers/ClaudeCliConnector.d.ts.map +1 -0
- package/dist/providers/ClaudeCliConnector.js +123 -0
- package/dist/providers/ClaudeCliConnector.js.map +1 -0
- package/dist/providers/CliSupport.d.ts +21 -0
- package/dist/providers/CliSupport.d.ts.map +1 -0
- package/dist/providers/CliSupport.js +62 -0
- package/dist/providers/CliSupport.js.map +1 -0
- package/dist/providers/CodexConnector.d.ts +12 -0
- package/dist/providers/CodexConnector.d.ts.map +1 -0
- package/dist/providers/CodexConnector.js +175 -0
- package/dist/providers/CodexConnector.js.map +1 -0
- package/dist/providers/ConnectorFactories.d.ts +15 -0
- package/dist/providers/ConnectorFactories.d.ts.map +1 -0
- package/dist/providers/ConnectorFactories.js +74 -0
- package/dist/providers/ConnectorFactories.js.map +1 -0
- package/dist/providers/CopilotConnector.d.ts +6 -0
- package/dist/providers/CopilotConnector.d.ts.map +1 -0
- package/dist/providers/CopilotConnector.js +35 -0
- package/dist/providers/CopilotConnector.js.map +1 -0
- package/dist/providers/CursorConnector.d.ts +8 -0
- package/dist/providers/CursorConnector.d.ts.map +1 -0
- package/dist/providers/CursorConnector.js +82 -0
- package/dist/providers/CursorConnector.js.map +1 -0
- package/dist/providers/GeminiApiProvider.d.ts +9 -0
- package/dist/providers/GeminiApiProvider.d.ts.map +1 -0
- package/dist/providers/GeminiApiProvider.js +181 -0
- package/dist/providers/GeminiApiProvider.js.map +1 -0
- package/dist/providers/GeminiCliProvider.d.ts +106 -0
- package/dist/providers/GeminiCliProvider.d.ts.map +1 -0
- package/dist/providers/GeminiCliProvider.js +596 -0
- package/dist/providers/GeminiCliProvider.js.map +1 -0
- package/dist/providers/GeminiModels.d.ts +92 -0
- package/dist/providers/GeminiModels.d.ts.map +1 -0
- package/dist/providers/GeminiModels.js +80 -0
- package/dist/providers/GeminiModels.js.map +1 -0
- package/dist/providers/GrokCliConnector.d.ts +8 -0
- package/dist/providers/GrokCliConnector.d.ts.map +1 -0
- package/dist/providers/GrokCliConnector.js +82 -0
- package/dist/providers/GrokCliConnector.js.map +1 -0
- package/dist/providers/LmStudioModels.d.ts +114 -0
- package/dist/providers/LmStudioModels.d.ts.map +1 -0
- package/dist/providers/LmStudioModels.js +102 -0
- package/dist/providers/LmStudioModels.js.map +1 -0
- package/dist/providers/LmStudioProvider.d.ts +13 -0
- package/dist/providers/LmStudioProvider.d.ts.map +1 -0
- package/dist/providers/LmStudioProvider.js +158 -0
- package/dist/providers/LmStudioProvider.js.map +1 -0
- package/dist/providers/MockProvider.d.ts +6 -0
- package/dist/providers/MockProvider.d.ts.map +1 -0
- package/dist/providers/MockProvider.js +271 -0
- package/dist/providers/MockProvider.js.map +1 -0
- package/dist/providers/OllamaModels.d.ts +68 -0
- package/dist/providers/OllamaModels.d.ts.map +1 -0
- package/dist/providers/OllamaModels.js +59 -0
- package/dist/providers/OllamaModels.js.map +1 -0
- package/dist/providers/OllamaProvider.d.ts +7 -0
- package/dist/providers/OllamaProvider.d.ts.map +1 -0
- package/dist/providers/OllamaProvider.js +134 -0
- package/dist/providers/OllamaProvider.js.map +1 -0
- package/dist/providers/OpenAIModels.d.ts +139 -0
- package/dist/providers/OpenAIModels.d.ts.map +1 -0
- package/dist/providers/OpenAIModels.js +123 -0
- package/dist/providers/OpenAIModels.js.map +1 -0
- package/dist/providers/OpenAIProvider.d.ts +9 -0
- package/dist/providers/OpenAIProvider.d.ts.map +1 -0
- package/dist/providers/OpenAIProvider.js +185 -0
- package/dist/providers/OpenAIProvider.js.map +1 -0
- package/dist/providers/OpenCodeCliConnector.d.ts +8 -0
- package/dist/providers/OpenCodeCliConnector.d.ts.map +1 -0
- package/dist/providers/OpenCodeCliConnector.js +93 -0
- package/dist/providers/OpenCodeCliConnector.js.map +1 -0
- package/dist/providers/OpenCodeModels.d.ts +61 -0
- package/dist/providers/OpenCodeModels.d.ts.map +1 -0
- package/dist/providers/OpenCodeModels.js +53 -0
- package/dist/providers/OpenCodeModels.js.map +1 -0
- package/dist/providers/OpenCodeProvider.d.ts +10 -0
- package/dist/providers/OpenCodeProvider.d.ts.map +1 -0
- package/dist/providers/OpenCodeProvider.js +154 -0
- package/dist/providers/OpenCodeProvider.js.map +1 -0
- package/dist/providers/PiConnector.d.ts +8 -0
- package/dist/providers/PiConnector.d.ts.map +1 -0
- package/dist/providers/PiConnector.js +99 -0
- package/dist/providers/PiConnector.js.map +1 -0
- package/dist/tools/Tool.d.ts +83 -0
- package/dist/tools/Tool.d.ts.map +1 -0
- package/dist/tools/Tool.js +278 -0
- package/dist/tools/Tool.js.map +1 -0
- package/dist/tools/ToolCallingExecutor.d.ts +18 -0
- package/dist/tools/ToolCallingExecutor.d.ts.map +1 -0
- package/dist/tools/ToolCallingExecutor.js +64 -0
- package/dist/tools/ToolCallingExecutor.js.map +1 -0
- package/dist/tools/ToolRegistry.d.ts +45 -0
- package/dist/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/tools/ToolRegistry.js +133 -0
- package/dist/tools/ToolRegistry.js.map +1 -0
- package/package.json +105 -0
- package/src/.gitkeep +1 -0
- package/src/AgentSession.ts +69 -0
- package/src/Capability.ts +240 -0
- package/src/Connector.ts +220 -0
- package/src/ConnectorConfig.ts +146 -0
- package/src/ConnectorRegistry.ts +184 -0
- package/src/ContextManagement.ts +372 -0
- package/src/Conversation.ts +21 -0
- package/src/Errors.ts +87 -0
- package/src/HttpClient.ts +202 -0
- package/src/LlmService.ts +45 -0
- package/src/Models.ts +250 -0
- package/src/ProcessExecutor.ts +157 -0
- package/src/RateLimiter.ts +238 -0
- package/src/Streaming.ts +164 -0
- package/src/StructuredOutput.ts +138 -0
- package/src/TemporaryFiles.ts +51 -0
- package/src/UsageLimits.ts +242 -0
- package/src/eval/Checks.ts +68 -0
- package/src/eval/Eval.ts +112 -0
- package/src/eval/EvalSuite.ts +63 -0
- package/src/eval/Evaluator.ts +31 -0
- package/src/eval/Judge.ts +92 -0
- package/src/observability/MeteredLlmService.ts +156 -0
- package/src/observability/Metrics.ts +195 -0
- package/src/observability/Redaction.ts +55 -0
- package/src/observability/StreamRecorder.ts +32 -0
- package/src/observability/StructuredLogger.ts +62 -0
- package/src/observability/Tracing.ts +141 -0
- package/src/providers/AnthropicModels.ts +96 -0
- package/src/providers/AnthropicProvider.ts +320 -0
- package/src/providers/AntigravityConnector.ts +77 -0
- package/src/providers/ClaudeAgentSession.ts +226 -0
- package/src/providers/ClaudeCliConnector.ts +201 -0
- package/src/providers/CliSupport.ts +100 -0
- package/src/providers/CodexConnector.ts +251 -0
- package/src/providers/ConnectorFactories.ts +142 -0
- package/src/providers/CopilotConnector.ts +47 -0
- package/src/providers/CursorConnector.ts +120 -0
- package/src/providers/GeminiApiProvider.ts +337 -0
- package/src/providers/GeminiCliProvider.ts +793 -0
- package/src/providers/GeminiModels.ts +97 -0
- package/src/providers/GrokCliConnector.ts +117 -0
- package/src/providers/LmStudioModels.ts +117 -0
- package/src/providers/LmStudioProvider.ts +260 -0
- package/src/providers/MockProvider.ts +322 -0
- package/src/providers/OllamaModels.ts +64 -0
- package/src/providers/OllamaProvider.ts +236 -0
- package/src/providers/OpenAIModels.ts +152 -0
- package/src/providers/OpenAIProvider.ts +331 -0
- package/src/providers/OpenCodeCliConnector.ts +135 -0
- package/src/providers/OpenCodeModels.ts +60 -0
- package/src/providers/OpenCodeProvider.ts +278 -0
- package/src/providers/PiConnector.ts +142 -0
- package/src/tools/Tool.ts +379 -0
- package/src/tools/ToolCallingExecutor.ts +106 -0
- package/src/tools/ToolRegistry.ts +224 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Riccardo Merolla
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @llm4ts/core
|
|
2
|
+
|
|
3
|
+
Effect-native LLM contracts: backend-neutral messages, responses, streaming
|
|
4
|
+
chunks, usage, health, structured output, tools, evaluation, and the connector
|
|
5
|
+
registry. This is the foundation package of [llm4ts](https://github.com/riccardomerolla/llm4ts).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @llm4ts/core effect
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Node.js >= 22. `effect` is a peer dependency pinned to the Effect 4
|
|
14
|
+
beta line.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
The package exposes explicit subpath exports — import the module you need:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { LlmServiceShape } from "@llm4ts/core/LlmService"
|
|
22
|
+
import { Message, LlmResponse, ConnectorIds } from "@llm4ts/core/Models"
|
|
23
|
+
import { ApiConnectorConfig } from "@llm4ts/core/ConnectorConfig"
|
|
24
|
+
import { collect } from "@llm4ts/core/Streaming"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Connectors for OpenAI, Anthropic, Gemini, LM Studio, Ollama, and CLI coding
|
|
28
|
+
agents (Claude, Codex, Gemini CLI, and more) live under
|
|
29
|
+
`@llm4ts/core/providers/*`. A deterministic mock connector
|
|
30
|
+
(`@llm4ts/core/providers/MockProvider`) works with zero configuration and no
|
|
31
|
+
credentials.
|
|
32
|
+
|
|
33
|
+
Most applications should start from
|
|
34
|
+
[`@llm4ts/runner`](https://www.npmjs.com/package/@llm4ts/runner) (Node
|
|
35
|
+
composition and flows) or
|
|
36
|
+
[`@llm4ts/js`](https://www.npmjs.com/package/@llm4ts/js) (Promise-based facade)
|
|
37
|
+
rather than wiring core services directly.
|
|
38
|
+
|
|
39
|
+
## Documentation
|
|
40
|
+
|
|
41
|
+
- [Repository and full documentation](https://github.com/riccardomerolla/llm4ts)
|
|
42
|
+
- [API overview](https://github.com/riccardomerolla/llm4ts/blob/main/docs/api.md)
|
|
43
|
+
- [Provider capabilities](https://github.com/riccardomerolla/llm4ts/blob/main/docs/provider-capabilities.md)
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type * as Stream from "effect/Stream";
|
|
4
|
+
import type { LlmError } from "./Errors.ts";
|
|
5
|
+
import { TokenUsage } from "./Models.ts";
|
|
6
|
+
declare const SessionTextDelta_base: Schema.Class<SessionTextDelta, Schema.TaggedStruct<"TextDelta", {
|
|
7
|
+
readonly text: Schema.String;
|
|
8
|
+
}>, {}>;
|
|
9
|
+
export declare class SessionTextDelta extends SessionTextDelta_base {
|
|
10
|
+
}
|
|
11
|
+
declare const SessionToolUse_base: Schema.Class<SessionToolUse, Schema.TaggedStruct<"ToolUse", {
|
|
12
|
+
readonly tool: Schema.String;
|
|
13
|
+
readonly rawInput: Schema.String;
|
|
14
|
+
readonly id: Schema.String;
|
|
15
|
+
}>, {}>;
|
|
16
|
+
export declare class SessionToolUse extends SessionToolUse_base {
|
|
17
|
+
}
|
|
18
|
+
declare const SessionToolResult_base: Schema.Class<SessionToolResult, Schema.TaggedStruct<"ToolResult", {
|
|
19
|
+
readonly id: Schema.String;
|
|
20
|
+
readonly status: Schema.String;
|
|
21
|
+
readonly content: Schema.String;
|
|
22
|
+
}>, {}>;
|
|
23
|
+
export declare class SessionToolResult extends SessionToolResult_base {
|
|
24
|
+
}
|
|
25
|
+
declare const SessionAskUser_base: Schema.Class<SessionAskUser, Schema.TaggedStruct<"AskUser", {
|
|
26
|
+
readonly question: Schema.String;
|
|
27
|
+
}>, {}>;
|
|
28
|
+
export declare class SessionAskUser extends SessionAskUser_base {
|
|
29
|
+
}
|
|
30
|
+
declare const SessionApprovalRequest_base: Schema.Class<SessionApprovalRequest, Schema.TaggedStruct<"ApprovalRequest", {
|
|
31
|
+
readonly tool: Schema.String;
|
|
32
|
+
readonly rawInput: Schema.String;
|
|
33
|
+
readonly id: Schema.String;
|
|
34
|
+
}>, {}>;
|
|
35
|
+
export declare class SessionApprovalRequest extends SessionApprovalRequest_base {
|
|
36
|
+
}
|
|
37
|
+
declare const SessionUsage_base: Schema.Class<SessionUsage, Schema.TaggedStruct<"Usage", {
|
|
38
|
+
readonly usage: typeof TokenUsage;
|
|
39
|
+
readonly model: Schema.optionalKey<Schema.String>;
|
|
40
|
+
}>, {}>;
|
|
41
|
+
export declare class SessionUsage extends SessionUsage_base {
|
|
42
|
+
}
|
|
43
|
+
declare const SessionDone_base: Schema.Class<SessionDone, Schema.TaggedStruct<"Done", {
|
|
44
|
+
readonly result: Schema.String;
|
|
45
|
+
}>, {}>;
|
|
46
|
+
export declare class SessionDone extends SessionDone_base {
|
|
47
|
+
}
|
|
48
|
+
export declare const SessionEvent: Schema.Union<readonly [typeof SessionTextDelta, typeof SessionToolUse, typeof SessionToolResult, typeof SessionAskUser, typeof SessionApprovalRequest, typeof SessionUsage, typeof SessionDone]>;
|
|
49
|
+
export type SessionEvent = typeof SessionEvent.Type;
|
|
50
|
+
declare const SessionResult_base: Schema.Class<SessionResult, Schema.Struct<{
|
|
51
|
+
readonly text: Schema.String;
|
|
52
|
+
readonly usage: Schema.optionalKey<typeof TokenUsage>;
|
|
53
|
+
readonly model: Schema.optionalKey<Schema.String>;
|
|
54
|
+
}>, {}>;
|
|
55
|
+
export declare class SessionResult extends SessionResult_base {
|
|
56
|
+
}
|
|
57
|
+
export interface AgentSessionShape {
|
|
58
|
+
readonly events: Stream.Stream<SessionEvent, LlmError>;
|
|
59
|
+
readonly sendUserMessage: (text: string) => Effect.Effect<void, LlmError>;
|
|
60
|
+
readonly respondToAsk: (answer: string) => Effect.Effect<void, LlmError>;
|
|
61
|
+
readonly respondToApproval: (id: string, approved: boolean) => Effect.Effect<void, LlmError>;
|
|
62
|
+
readonly awaitResult: Effect.Effect<SessionResult, LlmError>;
|
|
63
|
+
readonly cancel: Effect.Effect<void>;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=AgentSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSession.d.ts","sourceRoot":"","sources":["../src/AgentSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;;;;AAExC,qBAAa,gBAAiB,SAAQ,qBAEpC;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", {
|
|
4
|
+
text: Schema.String
|
|
5
|
+
}) {
|
|
6
|
+
}
|
|
7
|
+
export class SessionToolUse extends Schema.TaggedClass()("ToolUse", {
|
|
8
|
+
tool: Schema.String,
|
|
9
|
+
rawInput: Schema.String,
|
|
10
|
+
id: Schema.String
|
|
11
|
+
}) {
|
|
12
|
+
}
|
|
13
|
+
export class SessionToolResult extends Schema.TaggedClass()("ToolResult", {
|
|
14
|
+
id: Schema.String,
|
|
15
|
+
status: Schema.String,
|
|
16
|
+
content: Schema.String
|
|
17
|
+
}) {
|
|
18
|
+
}
|
|
19
|
+
export class SessionAskUser extends Schema.TaggedClass()("AskUser", {
|
|
20
|
+
question: Schema.String
|
|
21
|
+
}) {
|
|
22
|
+
}
|
|
23
|
+
export class SessionApprovalRequest extends Schema.TaggedClass()("ApprovalRequest", {
|
|
24
|
+
tool: Schema.String,
|
|
25
|
+
rawInput: Schema.String,
|
|
26
|
+
id: Schema.String
|
|
27
|
+
}) {
|
|
28
|
+
}
|
|
29
|
+
export class SessionUsage extends Schema.TaggedClass()("Usage", {
|
|
30
|
+
usage: TokenUsage,
|
|
31
|
+
model: Schema.optionalKey(Schema.String)
|
|
32
|
+
}) {
|
|
33
|
+
}
|
|
34
|
+
export class SessionDone extends Schema.TaggedClass()("Done", {
|
|
35
|
+
result: Schema.String
|
|
36
|
+
}) {
|
|
37
|
+
}
|
|
38
|
+
export const SessionEvent = Schema.Union([
|
|
39
|
+
SessionTextDelta,
|
|
40
|
+
SessionToolUse,
|
|
41
|
+
SessionToolResult,
|
|
42
|
+
SessionAskUser,
|
|
43
|
+
SessionApprovalRequest,
|
|
44
|
+
SessionUsage,
|
|
45
|
+
SessionDone
|
|
46
|
+
]);
|
|
47
|
+
export class SessionResult extends Schema.Class("SessionResult")({
|
|
48
|
+
text: Schema.String,
|
|
49
|
+
usage: Schema.optionalKey(TokenUsage),
|
|
50
|
+
model: Schema.optionalKey(Schema.String)
|
|
51
|
+
}) {
|
|
52
|
+
}
|
|
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W,CAAC,MAAM,CAAC,MAAM,CAAC;CACzC,CAAC;CAAG;AAEL,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,EAAe,CAAC,MAAM,EAAE;IACzE,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;IACvC,gBAAgB;IAChB,cAAc;IACd,iBAAiB;IACjB,cAAc;IACd,sBAAsB;IACtB,YAAY;IACZ,WAAW;CACZ,CAAC,CAAA;AAGF,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,KAAK,CAAgB,eAAe,CAAC,CAAC;IAC9E,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;CACzC,CAAC;CAAG"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
declare const GitRead_base: Schema.Class<GitRead, Schema.TaggedStruct<"GitRead", {}>, {}>;
|
|
4
|
+
export declare class GitRead extends GitRead_base {
|
|
5
|
+
}
|
|
6
|
+
declare const GitWrite_base: Schema.Class<GitWrite, Schema.TaggedStruct<"GitWrite", {}>, {}>;
|
|
7
|
+
export declare class GitWrite extends GitWrite_base {
|
|
8
|
+
}
|
|
9
|
+
declare const GitPush_base: Schema.Class<GitPush, Schema.TaggedStruct<"GitPush", {}>, {}>;
|
|
10
|
+
export declare class GitPush extends GitPush_base {
|
|
11
|
+
}
|
|
12
|
+
declare const GhRead_base: Schema.Class<GhRead, Schema.TaggedStruct<"GhRead", {}>, {}>;
|
|
13
|
+
export declare class GhRead extends GhRead_base {
|
|
14
|
+
}
|
|
15
|
+
declare const GhWrite_base: Schema.Class<GhWrite, Schema.TaggedStruct<"GhWrite", {}>, {}>;
|
|
16
|
+
export declare class GhWrite extends GhWrite_base {
|
|
17
|
+
}
|
|
18
|
+
declare const AdoRead_base: Schema.Class<AdoRead, Schema.TaggedStruct<"AdoRead", {}>, {}>;
|
|
19
|
+
export declare class AdoRead extends AdoRead_base {
|
|
20
|
+
}
|
|
21
|
+
declare const AdoWrite_base: Schema.Class<AdoWrite, Schema.TaggedStruct<"AdoWrite", {}>, {}>;
|
|
22
|
+
export declare class AdoWrite extends AdoWrite_base {
|
|
23
|
+
}
|
|
24
|
+
declare const Exec_base: Schema.Class<Exec, Schema.TaggedStruct<"Exec", {
|
|
25
|
+
readonly command: Schema.String;
|
|
26
|
+
}>, {}>;
|
|
27
|
+
export declare class Exec extends Exec_base {
|
|
28
|
+
}
|
|
29
|
+
declare const UseCoder_base: Schema.Class<UseCoder, Schema.TaggedStruct<"UseCoder", {}>, {}>;
|
|
30
|
+
export declare class UseCoder extends UseCoder_base {
|
|
31
|
+
}
|
|
32
|
+
declare const UseReasoning_base: Schema.Class<UseReasoning, Schema.TaggedStruct<"UseReasoning", {}>, {}>;
|
|
33
|
+
export declare class UseReasoning extends UseReasoning_base {
|
|
34
|
+
}
|
|
35
|
+
declare const Declassify_base: Schema.Class<Declassify, Schema.TaggedStruct<"Declassify", {}>, {}>;
|
|
36
|
+
export declare class Declassify extends Declassify_base {
|
|
37
|
+
}
|
|
38
|
+
export declare const Capability: Schema.Union<readonly [typeof GitRead, typeof GitWrite, typeof GitPush, typeof GhRead, typeof GhWrite, typeof AdoRead, typeof AdoWrite, typeof Exec, typeof UseCoder, typeof UseReasoning, typeof Declassify]>;
|
|
39
|
+
export type Capability = typeof Capability.Type;
|
|
40
|
+
export declare const Capabilities: Readonly<{
|
|
41
|
+
Schema: Schema.Union<readonly [typeof GitRead, typeof GitWrite, typeof GitPush, typeof GhRead, typeof GhWrite, typeof AdoRead, typeof AdoWrite, typeof Exec, typeof UseCoder, typeof UseReasoning, typeof Declassify]>;
|
|
42
|
+
GitRead: GitRead;
|
|
43
|
+
GitWrite: GitWrite;
|
|
44
|
+
GitPush: GitPush;
|
|
45
|
+
GhRead: GhRead;
|
|
46
|
+
GhWrite: GhWrite;
|
|
47
|
+
AdoRead: AdoRead;
|
|
48
|
+
AdoWrite: AdoWrite;
|
|
49
|
+
Exec: (command: string) => Exec;
|
|
50
|
+
UseCoder: UseCoder;
|
|
51
|
+
UseReasoning: UseReasoning;
|
|
52
|
+
Declassify: Declassify;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const GrantLevel: Schema.Literals<readonly ["None", "Read", "Write", "Push"]>;
|
|
55
|
+
export type GrantLevel = typeof GrantLevel.Type;
|
|
56
|
+
declare const ExecDenied_base: Schema.Class<ExecDenied, Schema.TaggedStruct<"Denied", {}>, {}>;
|
|
57
|
+
export declare class ExecDenied extends ExecDenied_base {
|
|
58
|
+
}
|
|
59
|
+
declare const ExecAllow_base: Schema.Class<ExecAllow, Schema.TaggedStruct<"Allow", {
|
|
60
|
+
readonly commands: Schema.$ReadonlySet<Schema.String>;
|
|
61
|
+
}>, {}>;
|
|
62
|
+
export declare class ExecAllow extends ExecAllow_base {
|
|
63
|
+
}
|
|
64
|
+
declare const ExecAll_base: Schema.Class<ExecAll, Schema.TaggedStruct<"All", {}>, {}>;
|
|
65
|
+
export declare class ExecAll extends ExecAll_base {
|
|
66
|
+
}
|
|
67
|
+
export declare const ExecGrant: Schema.Union<readonly [typeof ExecDenied, typeof ExecAllow, typeof ExecAll]>;
|
|
68
|
+
export type ExecGrant = typeof ExecGrant.Type;
|
|
69
|
+
export declare const ExecGrants: Readonly<{
|
|
70
|
+
Denied: ExecDenied;
|
|
71
|
+
All: ExecAll;
|
|
72
|
+
}>;
|
|
73
|
+
export declare const allowExec: (commands: Iterable<string>) => ExecAllow;
|
|
74
|
+
declare const Grants_base: Schema.Class<Grants, Schema.Struct<{
|
|
75
|
+
readonly git: Schema.Literals<readonly ["None", "Read", "Write", "Push"]>;
|
|
76
|
+
readonly gh: Schema.Literals<readonly ["None", "Read", "Write", "Push"]>;
|
|
77
|
+
readonly ado: Schema.Literals<readonly ["None", "Read", "Write", "Push"]>;
|
|
78
|
+
readonly exec: Schema.Union<readonly [typeof ExecDenied, typeof ExecAllow, typeof ExecAll]>;
|
|
79
|
+
readonly coder: Schema.Boolean;
|
|
80
|
+
readonly reasoning: Schema.Boolean;
|
|
81
|
+
readonly declassify: Schema.Boolean;
|
|
82
|
+
}>, {}>;
|
|
83
|
+
export declare class Grants extends Grants_base {
|
|
84
|
+
}
|
|
85
|
+
export declare const allGrants: Grants;
|
|
86
|
+
export declare const noneGrants: Grants;
|
|
87
|
+
export declare const intersectGrants: (first: Grants, second: Grants) => Grants;
|
|
88
|
+
export declare const unionGrants: (first: Grants, second: Grants) => Grants;
|
|
89
|
+
export declare const allows: (grants: Grants, capability: Capability) => boolean;
|
|
90
|
+
export declare const currentGrants: Effect.Effect<Grants>;
|
|
91
|
+
export declare const restricted: (grants: Grants) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
92
|
+
declare const CapabilityDenied_base: Schema.Class<CapabilityDenied, Schema.TaggedStruct<"CapabilityDenied", {
|
|
93
|
+
readonly required: Schema.$Array<Schema.Union<readonly [typeof GitRead, typeof GitWrite, typeof GitPush, typeof GhRead, typeof GhWrite, typeof AdoRead, typeof AdoWrite, typeof Exec, typeof UseCoder, typeof UseReasoning, typeof Declassify]>>;
|
|
94
|
+
readonly granted: typeof Grants;
|
|
95
|
+
}>, import("effect/Cause").YieldableError>;
|
|
96
|
+
export declare class CapabilityDenied extends CapabilityDenied_base {
|
|
97
|
+
get message(): string;
|
|
98
|
+
}
|
|
99
|
+
export declare const requireCapabilities: (required: ReadonlyArray<Capability>) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | CapabilityDenied, R>;
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=Capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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;;;;;;AA4BhD,qBAAa,MAAO,SAAQ,WAQ1B;CAAG;AAEL,eAAO,MAAM,SAAS,QAQpB,CAAA;AAEF,eAAO,MAAM,UAAU,QAQrB,CAAA;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,MAS5D,CAAA;AAEJ,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,MASxD,CAAA;AAaJ,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,EAAE,YAAY,UAAU,KAAG,OAyB/D,CAAA;AAMD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAiD,CAAA;AAEjG,eAAO,MAAM,UAAU,GACpB,QAAQ,MAAM,MACd,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAG7D,CAAA;;;;;AAEL,qBAAa,gBAAiB,SAAQ,qBAMrC;IACC,IAAI,OAAO,IAAI,MAAM,CAKpB;CACF;AAED,eAAO,MAAM,mBAAmB,GAC7B,UAAU,aAAa,CAAC,UAAU,CAAC,MACnC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAC,CAM/E,CAAA"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
export class GitRead extends Schema.TaggedClass()("GitRead", {}) {
|
|
5
|
+
}
|
|
6
|
+
export class GitWrite extends Schema.TaggedClass()("GitWrite", {}) {
|
|
7
|
+
}
|
|
8
|
+
export class GitPush extends Schema.TaggedClass()("GitPush", {}) {
|
|
9
|
+
}
|
|
10
|
+
export class GhRead extends Schema.TaggedClass()("GhRead", {}) {
|
|
11
|
+
}
|
|
12
|
+
export class GhWrite extends Schema.TaggedClass()("GhWrite", {}) {
|
|
13
|
+
}
|
|
14
|
+
export class AdoRead extends Schema.TaggedClass()("AdoRead", {}) {
|
|
15
|
+
}
|
|
16
|
+
export class AdoWrite extends Schema.TaggedClass()("AdoWrite", {}) {
|
|
17
|
+
}
|
|
18
|
+
export class Exec extends Schema.TaggedClass()("Exec", {
|
|
19
|
+
command: Schema.String
|
|
20
|
+
}) {
|
|
21
|
+
}
|
|
22
|
+
export class UseCoder extends Schema.TaggedClass()("UseCoder", {}) {
|
|
23
|
+
}
|
|
24
|
+
export class UseReasoning extends Schema.TaggedClass()("UseReasoning", {}) {
|
|
25
|
+
}
|
|
26
|
+
export class Declassify extends Schema.TaggedClass()("Declassify", {}) {
|
|
27
|
+
}
|
|
28
|
+
export const Capability = Schema.Union([
|
|
29
|
+
GitRead,
|
|
30
|
+
GitWrite,
|
|
31
|
+
GitPush,
|
|
32
|
+
GhRead,
|
|
33
|
+
GhWrite,
|
|
34
|
+
AdoRead,
|
|
35
|
+
AdoWrite,
|
|
36
|
+
Exec,
|
|
37
|
+
UseCoder,
|
|
38
|
+
UseReasoning,
|
|
39
|
+
Declassify
|
|
40
|
+
]);
|
|
41
|
+
export const Capabilities = Object.freeze({
|
|
42
|
+
Schema: Capability,
|
|
43
|
+
GitRead: new GitRead(),
|
|
44
|
+
GitWrite: new GitWrite(),
|
|
45
|
+
GitPush: new GitPush(),
|
|
46
|
+
GhRead: new GhRead(),
|
|
47
|
+
GhWrite: new GhWrite(),
|
|
48
|
+
AdoRead: new AdoRead(),
|
|
49
|
+
AdoWrite: new AdoWrite(),
|
|
50
|
+
Exec: (command) => new Exec({ command }),
|
|
51
|
+
UseCoder: new UseCoder(),
|
|
52
|
+
UseReasoning: new UseReasoning(),
|
|
53
|
+
Declassify: new Declassify()
|
|
54
|
+
});
|
|
55
|
+
export const GrantLevel = Schema.Literals(["None", "Read", "Write", "Push"]);
|
|
56
|
+
const levelRank = (level) => {
|
|
57
|
+
switch (level) {
|
|
58
|
+
case "None":
|
|
59
|
+
return 0;
|
|
60
|
+
case "Read":
|
|
61
|
+
return 1;
|
|
62
|
+
case "Write":
|
|
63
|
+
return 2;
|
|
64
|
+
case "Push":
|
|
65
|
+
return 3;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const minLevel = (first, second) => levelRank(first) <= levelRank(second) ? first : second;
|
|
69
|
+
const maxLevel = (first, second) => levelRank(first) >= levelRank(second) ? first : second;
|
|
70
|
+
export class ExecDenied extends Schema.TaggedClass()("Denied", {}) {
|
|
71
|
+
}
|
|
72
|
+
export class ExecAllow extends Schema.TaggedClass()("Allow", {
|
|
73
|
+
commands: Schema.ReadonlySet(Schema.String)
|
|
74
|
+
}) {
|
|
75
|
+
}
|
|
76
|
+
export class ExecAll extends Schema.TaggedClass()("All", {}) {
|
|
77
|
+
}
|
|
78
|
+
export const ExecGrant = Schema.Union([ExecDenied, ExecAllow, ExecAll]);
|
|
79
|
+
export const ExecGrants = Object.freeze({
|
|
80
|
+
Denied: new ExecDenied(),
|
|
81
|
+
All: new ExecAll()
|
|
82
|
+
});
|
|
83
|
+
export const allowExec = (commands) => new ExecAllow({ commands: new Set(commands) });
|
|
84
|
+
const intersectExec = (first, second) => {
|
|
85
|
+
if (first._tag === "Denied" || second._tag === "Denied") {
|
|
86
|
+
return ExecGrants.Denied;
|
|
87
|
+
}
|
|
88
|
+
if (first._tag === "All") {
|
|
89
|
+
return second;
|
|
90
|
+
}
|
|
91
|
+
if (second._tag === "All") {
|
|
92
|
+
return first;
|
|
93
|
+
}
|
|
94
|
+
return allowExec([...first.commands].filter((command) => second.commands.has(command)));
|
|
95
|
+
};
|
|
96
|
+
const unionExec = (first, second) => {
|
|
97
|
+
if (first._tag === "All" || second._tag === "All") {
|
|
98
|
+
return ExecGrants.All;
|
|
99
|
+
}
|
|
100
|
+
if (first._tag === "Denied") {
|
|
101
|
+
return second;
|
|
102
|
+
}
|
|
103
|
+
if (second._tag === "Denied") {
|
|
104
|
+
return first;
|
|
105
|
+
}
|
|
106
|
+
return allowExec(new Set([...first.commands, ...second.commands]));
|
|
107
|
+
};
|
|
108
|
+
export class Grants extends Schema.Class("Grants")({
|
|
109
|
+
git: GrantLevel,
|
|
110
|
+
gh: GrantLevel,
|
|
111
|
+
ado: GrantLevel,
|
|
112
|
+
exec: ExecGrant,
|
|
113
|
+
coder: Schema.Boolean,
|
|
114
|
+
reasoning: Schema.Boolean,
|
|
115
|
+
declassify: Schema.Boolean
|
|
116
|
+
}) {
|
|
117
|
+
}
|
|
118
|
+
export const allGrants = new Grants({
|
|
119
|
+
git: "Push",
|
|
120
|
+
gh: "Write",
|
|
121
|
+
ado: "Write",
|
|
122
|
+
exec: ExecGrants.All,
|
|
123
|
+
coder: true,
|
|
124
|
+
reasoning: true,
|
|
125
|
+
declassify: true
|
|
126
|
+
});
|
|
127
|
+
export const noneGrants = new Grants({
|
|
128
|
+
git: "None",
|
|
129
|
+
gh: "None",
|
|
130
|
+
ado: "None",
|
|
131
|
+
exec: ExecGrants.Denied,
|
|
132
|
+
coder: false,
|
|
133
|
+
reasoning: false,
|
|
134
|
+
declassify: false
|
|
135
|
+
});
|
|
136
|
+
export const intersectGrants = (first, second) => new Grants({
|
|
137
|
+
git: minLevel(first.git, second.git),
|
|
138
|
+
gh: minLevel(first.gh, second.gh),
|
|
139
|
+
ado: minLevel(first.ado, second.ado),
|
|
140
|
+
exec: intersectExec(first.exec, second.exec),
|
|
141
|
+
coder: first.coder && second.coder,
|
|
142
|
+
reasoning: first.reasoning && second.reasoning,
|
|
143
|
+
declassify: first.declassify && second.declassify
|
|
144
|
+
});
|
|
145
|
+
export const unionGrants = (first, second) => new Grants({
|
|
146
|
+
git: maxLevel(first.git, second.git),
|
|
147
|
+
gh: maxLevel(first.gh, second.gh),
|
|
148
|
+
ado: maxLevel(first.ado, second.ado),
|
|
149
|
+
exec: unionExec(first.exec, second.exec),
|
|
150
|
+
coder: first.coder || second.coder,
|
|
151
|
+
reasoning: first.reasoning || second.reasoning,
|
|
152
|
+
declassify: first.declassify || second.declassify
|
|
153
|
+
});
|
|
154
|
+
const execAllows = (grant, command) => {
|
|
155
|
+
switch (grant._tag) {
|
|
156
|
+
case "Denied":
|
|
157
|
+
return false;
|
|
158
|
+
case "Allow":
|
|
159
|
+
return grant.commands.has(command);
|
|
160
|
+
case "All":
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
export const allows = (grants, capability) => {
|
|
165
|
+
switch (capability._tag) {
|
|
166
|
+
case "GitRead":
|
|
167
|
+
return levelRank(grants.git) >= levelRank("Read");
|
|
168
|
+
case "GitWrite":
|
|
169
|
+
return levelRank(grants.git) >= levelRank("Write");
|
|
170
|
+
case "GitPush":
|
|
171
|
+
return levelRank(grants.git) >= levelRank("Push");
|
|
172
|
+
case "GhRead":
|
|
173
|
+
return levelRank(grants.gh) >= levelRank("Read");
|
|
174
|
+
case "GhWrite":
|
|
175
|
+
return levelRank(grants.gh) >= levelRank("Write");
|
|
176
|
+
case "AdoRead":
|
|
177
|
+
return levelRank(grants.ado) >= levelRank("Read");
|
|
178
|
+
case "AdoWrite":
|
|
179
|
+
return levelRank(grants.ado) >= levelRank("Write");
|
|
180
|
+
case "Exec":
|
|
181
|
+
return execAllows(grants.exec, capability.command);
|
|
182
|
+
case "UseCoder":
|
|
183
|
+
return grants.coder;
|
|
184
|
+
case "UseReasoning":
|
|
185
|
+
return grants.reasoning;
|
|
186
|
+
case "Declassify":
|
|
187
|
+
return grants.declassify;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const CurrentGrants = Context.Reference("@llm4ts/core/CurrentGrants", {
|
|
191
|
+
defaultValue: () => allGrants
|
|
192
|
+
});
|
|
193
|
+
export const currentGrants = Effect.map(CurrentGrants, (grants) => grants);
|
|
194
|
+
export const restricted = (grants) => (effect) => Effect.flatMap(CurrentGrants, (current) => Effect.provideService(effect, CurrentGrants, intersectGrants(current, grants)));
|
|
195
|
+
export class CapabilityDenied extends Schema.TaggedErrorClass()("CapabilityDenied", {
|
|
196
|
+
required: Schema.Array(Capability),
|
|
197
|
+
granted: Grants
|
|
198
|
+
}) {
|
|
199
|
+
get message() {
|
|
200
|
+
const names = this.required.map((capability) => capability._tag === "Exec" ? `Exec(${capability.command})` : capability._tag);
|
|
201
|
+
return `missing required capabilities: ${names.join(", ")}`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
export const requireCapabilities = (required) => (effect) => Effect.flatMap(CurrentGrants, (granted) => {
|
|
205
|
+
const missing = required.filter((capability) => !allows(granted, capability));
|
|
206
|
+
return missing.length === 0
|
|
207
|
+
? effect
|
|
208
|
+
: Effect.fail(new CapabilityDenied({ required: missing, granted }));
|
|
209
|
+
});
|
|
210
|
+
//# sourceMappingURL=Capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Capability.js","sourceRoot":"","sources":["../src/Capability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,EAAW,CAAC,SAAS,EAAE,EAAE,CAAC;CAAG;AAC5E,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,WAAW,EAAY,CAAC,UAAU,EAAE,EAAE,CAAC;CAAG;AAC/E,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,EAAW,CAAC,SAAS,EAAE,EAAE,CAAC;CAAG;AAC5E,MAAM,OAAO,MAAO,SAAQ,MAAM,CAAC,WAAW,EAAU,CAA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B,EAA6C,EAAE,CACrF,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAA6C,EAAE;IACnF,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;IAC7E,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC;QACzB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;AACvE,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type * as Stream from "effect/Stream";
|
|
4
|
+
import { type LlmError } from "./Errors.ts";
|
|
5
|
+
import type { LlmServiceShape, StructuredResult } from "./LlmService.ts";
|
|
6
|
+
import { ConnectorCapabilities, HealthStatus, type ConnectorId, type ConnectorKind, type InteractionSupport, type JsonSchema, type LlmChunk, type Message, type ToolCallResponse, type ToolDefinition } from "./Models.ts";
|
|
7
|
+
import type { ProcessExecutorShape } from "./ProcessExecutor.ts";
|
|
8
|
+
export interface ConnectorShape extends LlmServiceShape {
|
|
9
|
+
readonly id: ConnectorId;
|
|
10
|
+
readonly kind: ConnectorKind;
|
|
11
|
+
readonly healthCheck: Effect.Effect<HealthStatus, LlmError>;
|
|
12
|
+
readonly capabilities: ConnectorCapabilities;
|
|
13
|
+
}
|
|
14
|
+
export interface ApiConnectorShape extends ConnectorShape {
|
|
15
|
+
readonly kind: "Api";
|
|
16
|
+
}
|
|
17
|
+
declare const CliContext_base: Schema.Class<CliContext, Schema.Struct<{
|
|
18
|
+
readonly worktreePath: Schema.String;
|
|
19
|
+
readonly repoPath: Schema.String;
|
|
20
|
+
readonly envVars: Schema.withConstructorDefault<Schema.$Record<Schema.String, Schema.String>>;
|
|
21
|
+
readonly sandbox: Schema.optionalKey<Schema.Union<readonly [typeof import("./ConnectorConfig.ts").DockerSandbox, typeof import("./ConnectorConfig.ts").PodmanSandbox, typeof import("./ConnectorConfig.ts").SeatbeltMacOsSandbox, typeof import("./ConnectorConfig.ts").RunscSandbox, typeof import("./ConnectorConfig.ts").LxcSandbox]>>;
|
|
22
|
+
readonly turnLimit: Schema.optionalKey<Schema.Int>;
|
|
23
|
+
}>, {}>;
|
|
24
|
+
export declare class CliContext extends CliContext_base {
|
|
25
|
+
}
|
|
26
|
+
export interface CliConnectorShape extends ConnectorShape {
|
|
27
|
+
readonly kind: "Cli";
|
|
28
|
+
readonly interactionSupport: InteractionSupport;
|
|
29
|
+
readonly buildArgv: (prompt: string, context: CliContext) => ReadonlyArray<string>;
|
|
30
|
+
readonly buildInteractiveArgv: (context: CliContext) => ReadonlyArray<string>;
|
|
31
|
+
readonly complete: (prompt: string) => Effect.Effect<string, LlmError>;
|
|
32
|
+
readonly completeStream: (prompt: string) => Stream.Stream<LlmChunk, LlmError>;
|
|
33
|
+
}
|
|
34
|
+
export declare const apiConnectorCapabilities: () => ConnectorCapabilities;
|
|
35
|
+
export declare const timedHealthCheck: (isAvailable: Effect.Effect<boolean>) => Effect.Effect<HealthStatus, LlmError>;
|
|
36
|
+
export interface ApiConnectorPrimitives {
|
|
37
|
+
readonly id: ConnectorId;
|
|
38
|
+
readonly executeStream: (prompt: string) => Stream.Stream<LlmChunk, LlmError>;
|
|
39
|
+
readonly executeStreamWithHistory: (messages: ReadonlyArray<Message>) => Stream.Stream<LlmChunk, LlmError>;
|
|
40
|
+
readonly executeWithTools: (prompt: string, tools: ReadonlyArray<ToolDefinition>) => Effect.Effect<ToolCallResponse, LlmError>;
|
|
41
|
+
readonly executeStructuredWithUsage: <A, E, RD, RE>(prompt: string, schema: Schema.ConstraintCodec<A, E, RD, RE>, jsonSchema: JsonSchema) => Effect.Effect<StructuredResult<A>, LlmError, RD>;
|
|
42
|
+
readonly isAvailable: Effect.Effect<boolean>;
|
|
43
|
+
readonly capabilities?: ConnectorCapabilities;
|
|
44
|
+
}
|
|
45
|
+
export declare const makeApiConnector: (primitives: ApiConnectorPrimitives) => ApiConnectorShape;
|
|
46
|
+
export declare const cliConnectorCapabilities: (interactionSupport: InteractionSupport) => ConnectorCapabilities;
|
|
47
|
+
export declare const flattenHistory: (messages: ReadonlyArray<Message>) => string;
|
|
48
|
+
export interface CliVersionProbe {
|
|
49
|
+
readonly executor: ProcessExecutorShape;
|
|
50
|
+
readonly binary: string;
|
|
51
|
+
readonly versionArgs?: ReadonlyArray<string>;
|
|
52
|
+
readonly cwd?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare const cliVersionProbeHealthCheck: (probe: CliVersionProbe) => Effect.Effect<HealthStatus, LlmError>;
|
|
55
|
+
export interface CliConnectorPrimitives {
|
|
56
|
+
readonly id: ConnectorId;
|
|
57
|
+
readonly interactionSupport: InteractionSupport;
|
|
58
|
+
readonly buildArgv: (prompt: string, context: CliContext) => ReadonlyArray<string>;
|
|
59
|
+
readonly buildInteractiveArgv: (context: CliContext) => ReadonlyArray<string>;
|
|
60
|
+
readonly complete: (prompt: string) => Effect.Effect<string, LlmError>;
|
|
61
|
+
readonly completeStream: (prompt: string) => Stream.Stream<LlmChunk, LlmError>;
|
|
62
|
+
readonly versionProbe?: CliVersionProbe;
|
|
63
|
+
readonly healthCheck?: Effect.Effect<HealthStatus, LlmError>;
|
|
64
|
+
readonly isAvailable?: Effect.Effect<boolean>;
|
|
65
|
+
readonly capabilities?: ConnectorCapabilities;
|
|
66
|
+
}
|
|
67
|
+
export declare const makeCliConnector: (primitives: CliConnectorPrimitives) => CliConnectorShape;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=Connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../src/Connector.ts"],"names":[],"mappings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