@omp-provider-capabilities/kilo 0.0.0-stage → 0.2.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 +38 -2
- package/package.json +38 -4
- package/src/agent-sdk.ts +94 -0
- package/src/index.ts +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Enver Francisco
|
|
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
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @omp-provider-capabilities/kilo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Kilo Code harness adapter (ACP) and Kilo gateway (500+ models from 60+ providers)
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Kilo Code harness (ACP)
|
|
8
|
+
- Kilo gateway metadata
|
|
9
|
+
- 500+ model support
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install via OMP plugin manager:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
omp plugin install @omp-provider-capabilities/kilo
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Install from GitHub:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
omp plugin install https://github.com/blyzer/omp-provider-capabilities/tree/main/packages/kilo
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Link a local checkout:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
omp plugin link /path/to/omp-provider-capabilities/packages/kilo
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Load the extension source for one invocation:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
omp -e /path/to/omp-provider-capabilities/packages/kilo/src/index.ts
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omp-provider-capabilities/kilo",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Kilo provider extension: Kilo Code harness (ACP), Kilo gateway (500+ models)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"src/",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"omp": {
|
|
14
|
+
"extensions": [
|
|
15
|
+
"./src/index.ts"
|
|
16
|
+
],
|
|
17
|
+
"settings": {
|
|
18
|
+
"harness.enabled": {
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"default": true,
|
|
21
|
+
"description": "Enable Kilo Code harness"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"omp-package",
|
|
30
|
+
"omp-plugin",
|
|
31
|
+
"omp-extension",
|
|
32
|
+
"oh-my-pi",
|
|
33
|
+
"kilo"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@omp-provider-capabilities/core": "^0.1.0",
|
|
37
|
+
"@omp-provider-capabilities/harness": "^0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT"
|
|
40
|
+
}
|
package/src/agent-sdk.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kilo Agent SDK wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Wraps Kilo Code's gateway API for multi-turn agent loops via direct HTTP.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
AgentSDK,
|
|
9
|
+
AgentConfig,
|
|
10
|
+
AgentResult,
|
|
11
|
+
AgentMessage,
|
|
12
|
+
AgentTool,
|
|
13
|
+
} from "@omp-provider-capabilities/core";
|
|
14
|
+
|
|
15
|
+
export class KiloAgentSDK implements AgentSDK {
|
|
16
|
+
public provider = "kilo";
|
|
17
|
+
private apiKey: string;
|
|
18
|
+
|
|
19
|
+
constructor(apiKey: string) {
|
|
20
|
+
this.apiKey = apiKey;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
isAvailable(): boolean {
|
|
24
|
+
return !!this.apiKey;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async run(prompt: string, config: AgentConfig): Promise<AgentResult> {
|
|
28
|
+
const history: AgentMessage[] = [...(config.history || [])];
|
|
29
|
+
const maxTurns = config.maxTurns || 10;
|
|
30
|
+
let toolCallCount = 0;
|
|
31
|
+
|
|
32
|
+
const messages: Array<{ role: string; content: string }> = [
|
|
33
|
+
...(config.history || []).map((m) => ({ role: m.role, content: m.content })),
|
|
34
|
+
{ role: "user", content: prompt },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
if (config.instruction) {
|
|
38
|
+
messages.unshift({ role: "system", content: config.instruction });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
for (let turn = 0; turn < maxTurns; turn++) {
|
|
42
|
+
const response = await fetch("https://api.kilocode.ai/v1/chat/completions", {
|
|
43
|
+
method: "POST",
|
|
44
|
+
headers: {
|
|
45
|
+
"Content-Type": "application/json",
|
|
46
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
47
|
+
},
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
model: config.model || "kilo-gateway",
|
|
50
|
+
messages,
|
|
51
|
+
max_tokens: 4096,
|
|
52
|
+
tools: config.tools?.map((t) => ({
|
|
53
|
+
type: "function",
|
|
54
|
+
function: { name: t.name, description: t.description, parameters: t.parameters },
|
|
55
|
+
})),
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
const errorText = await response.text();
|
|
61
|
+
return { output: "", history, toolCallCount, error: `Kilo API error: ${response.status} ${errorText}` };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const data = await response.json();
|
|
65
|
+
const choices = data.choices || [];
|
|
66
|
+
if (choices.length === 0) break;
|
|
67
|
+
|
|
68
|
+
const message = choices[0].message;
|
|
69
|
+
if (message.tool_calls) {
|
|
70
|
+
toolCallCount += message.tool_calls.length;
|
|
71
|
+
for (const tc of message.tool_calls) {
|
|
72
|
+
messages.push({ role: "assistant", content: JSON.stringify(tc) });
|
|
73
|
+
const tool = config.tools?.find((t) => t.name === tc.function?.name);
|
|
74
|
+
let result = "Tool not found";
|
|
75
|
+
if (tool) {
|
|
76
|
+
try {
|
|
77
|
+
result = await tool.execute(tc.function?.arguments ? JSON.parse(tc.function.arguments) : {});
|
|
78
|
+
} catch (e) {
|
|
79
|
+
result = `Tool error: ${e instanceof Error ? e.message : String(e)}`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
messages.push({ role: "tool", content: result });
|
|
83
|
+
history.push({ role: "tool", content: result, toolCallId: tc.id, toolName: tc.function?.name });
|
|
84
|
+
}
|
|
85
|
+
} else if (message.content) {
|
|
86
|
+
messages.push({ role: "assistant", content: message.content });
|
|
87
|
+
history.push({ role: "assistant", content: message.content });
|
|
88
|
+
return { output: message.content, history, toolCallCount };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return { output: "", history, toolCallCount };
|
|
93
|
+
}
|
|
94
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kilo provider extension for OMPv1.
|
|
3
|
+
*
|
|
4
|
+
* Covers: Kilo Code harness (ACP), Kilo gateway (500+ models from 60+ providers).
|
|
5
|
+
*
|
|
6
|
+
* OMPv1 native: `kilo.kdl` catalog entry.
|
|
7
|
+
*/
|
|
8
|
+
import type { ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent";
|
|
9
|
+
import {
|
|
10
|
+
CredentialResolver,
|
|
11
|
+
} from "@omp-provider-capabilities/core";
|
|
12
|
+
import type { HarnessDriver } from "@omp-provider-capabilities/harness";
|
|
13
|
+
import { createKiloCodeAdapter } from "@omp-provider-capabilities/harness";
|
|
14
|
+
|
|
15
|
+
export const KILO_PROVIDER_ID = "kilo";
|
|
16
|
+
|
|
17
|
+
export interface KiloCapabilities {
|
|
18
|
+
/** Kilo Code harness adapter (ACP) */
|
|
19
|
+
kiloCode: HarnessDriver;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function kiloExtension(pi: ExtensionAPI) {
|
|
23
|
+
const credentialResolver = new CredentialResolver();
|
|
24
|
+
|
|
25
|
+
let kiloCodeAdapter: HarnessDriver | null = null;
|
|
26
|
+
|
|
27
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
28
|
+
pi.logger.debug("Kilo provider extension loaded");
|
|
29
|
+
const creds = await credentialResolver.resolveForProvider("kilo", ctx);
|
|
30
|
+
if (creds) {
|
|
31
|
+
kiloCodeAdapter = createKiloCodeAdapter();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
pi.registerTool({
|
|
36
|
+
name: "kilo_spawn",
|
|
37
|
+
label: "Kilo Code Spawn",
|
|
38
|
+
description: "Spawn a task via Kilo Code harness (ACP).",
|
|
39
|
+
parameters: pi.zod.object({
|
|
40
|
+
task: pi.zod.string().describe("Task description"),
|
|
41
|
+
}),
|
|
42
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
43
|
+
const p = params as { task: string };
|
|
44
|
+
if (!kiloCodeAdapter) {
|
|
45
|
+
return { content: [{ type: "text", text: "Kilo Code adapter not available." }], isError: true };
|
|
46
|
+
}
|
|
47
|
+
return { content: [{ type: "text", text: `Kilo Code adapter ready for: ${p.task}` }] };
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
pi.on("session_shutdown", async () => {
|
|
52
|
+
// cleanup
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export { KiloAgentSDK } from './agent-sdk';
|