n8n-nodes-opencode-ai 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 +190 -0
- package/dist/assets/opencode.svg +6 -0
- package/dist/credentials/OpenCodeApi.credentials.d.ts +8 -0
- package/dist/credentials/OpenCodeApi.credentials.js +50 -0
- package/dist/credentials/OpenCodeApi.credentials.js.map +1 -0
- package/dist/nodes/OpenCode/OpenCode.node.d.ts +13 -0
- package/dist/nodes/OpenCode/OpenCode.node.js +787 -0
- package/dist/nodes/OpenCode/OpenCode.node.js.map +1 -0
- package/dist/nodes/OpenCode/actions/config/getProviders.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/config/getProviders.js +19 -0
- package/dist/nodes/OpenCode/actions/config/getProviders.js.map +1 -0
- package/dist/nodes/OpenCode/actions/config/index.d.ts +4 -0
- package/dist/nodes/OpenCode/actions/config/index.js +15 -0
- package/dist/nodes/OpenCode/actions/config/index.js.map +1 -0
- package/dist/nodes/OpenCode/actions/index.d.ts +5 -0
- package/dist/nodes/OpenCode/actions/index.js +26 -0
- package/dist/nodes/OpenCode/actions/index.js.map +1 -0
- package/dist/nodes/OpenCode/actions/message/command.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/message/command.js +102 -0
- package/dist/nodes/OpenCode/actions/message/command.js.map +1 -0
- package/dist/nodes/OpenCode/actions/message/getMessage.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/message/getMessage.js +21 -0
- package/dist/nodes/OpenCode/actions/message/getMessage.js.map +1 -0
- package/dist/nodes/OpenCode/actions/message/index.d.ts +9 -0
- package/dist/nodes/OpenCode/actions/message/index.js +35 -0
- package/dist/nodes/OpenCode/actions/message/index.js.map +1 -0
- package/dist/nodes/OpenCode/actions/message/list.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/message/list.js +37 -0
- package/dist/nodes/OpenCode/actions/message/list.js.map +1 -0
- package/dist/nodes/OpenCode/actions/message/send.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/message/send.js +124 -0
- package/dist/nodes/OpenCode/actions/message/send.js.map +1 -0
- package/dist/nodes/OpenCode/actions/message/sendAsync.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/message/sendAsync.js +88 -0
- package/dist/nodes/OpenCode/actions/message/sendAsync.js.map +1 -0
- package/dist/nodes/OpenCode/actions/message/shell.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/message/shell.js +102 -0
- package/dist/nodes/OpenCode/actions/message/shell.js.map +1 -0
- package/dist/nodes/OpenCode/actions/session/abort.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/session/abort.js +24 -0
- package/dist/nodes/OpenCode/actions/session/abort.js.map +1 -0
- package/dist/nodes/OpenCode/actions/session/create.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/session/create.js +21 -0
- package/dist/nodes/OpenCode/actions/session/create.js.map +1 -0
- package/dist/nodes/OpenCode/actions/session/delete.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/session/delete.js +24 -0
- package/dist/nodes/OpenCode/actions/session/delete.js.map +1 -0
- package/dist/nodes/OpenCode/actions/session/get.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/session/get.js +20 -0
- package/dist/nodes/OpenCode/actions/session/get.js.map +1 -0
- package/dist/nodes/OpenCode/actions/session/index.d.ts +9 -0
- package/dist/nodes/OpenCode/actions/session/index.js +35 -0
- package/dist/nodes/OpenCode/actions/session/index.js.map +1 -0
- package/dist/nodes/OpenCode/actions/session/list.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/session/list.js +18 -0
- package/dist/nodes/OpenCode/actions/session/list.js.map +1 -0
- package/dist/nodes/OpenCode/actions/session/status.d.ts +2 -0
- package/dist/nodes/OpenCode/actions/session/status.js +19 -0
- package/dist/nodes/OpenCode/actions/session/status.js.map +1 -0
- package/dist/nodes/OpenCode/helpers/api.d.ts +13 -0
- package/dist/nodes/OpenCode/helpers/api.js +62 -0
- package/dist/nodes/OpenCode/helpers/api.js.map +1 -0
- package/dist/nodes/OpenCode/opencode.svg +6 -0
- package/dist/nodes/OpenCode/types/index.d.ts +100 -0
- package/dist/nodes/OpenCode/types/index.js +3 -0
- package/dist/nodes/OpenCode/types/index.js.map +1 -0
- package/dist/nodes/OpenCodeChatModel/ChatOpenCode.d.ts +57 -0
- package/dist/nodes/OpenCodeChatModel/ChatOpenCode.js +270 -0
- package/dist/nodes/OpenCodeChatModel/ChatOpenCode.js.map +1 -0
- package/dist/nodes/OpenCodeChatModel/OpenCodeChatModel.node.d.ts +11 -0
- package/dist/nodes/OpenCodeChatModel/OpenCodeChatModel.node.js +217 -0
- package/dist/nodes/OpenCodeChatModel/OpenCodeChatModel.node.js.map +1 -0
- package/dist/nodes/OpenCodeChatModel/opencode.svg +6 -0
- package/dist/nodes/OpenCodeTool/OpenCodeTool.node.d.ts +11 -0
- package/dist/nodes/OpenCodeTool/OpenCodeTool.node.js +319 -0
- package/dist/nodes/OpenCodeTool/OpenCodeTool.node.js.map +1 -0
- package/dist/nodes/OpenCodeTool/opencode.svg +6 -0
- package/package.json +67 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeShell = void 0;
|
|
4
|
+
const api_1 = require("../../helpers/api");
|
|
5
|
+
async function executeShell(itemIndex) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7
|
+
const credentials = await (0, api_1.getCredentials)(this);
|
|
8
|
+
const sessionMode = this.getNodeParameter('sessionMode', itemIndex, 'existing');
|
|
9
|
+
const shellCommand = this.getNodeParameter('shellCommand', itemIndex);
|
|
10
|
+
const agent = this.getNodeParameter('shellAgent', itemIndex);
|
|
11
|
+
const model = this.getNodeParameter('model', itemIndex, '');
|
|
12
|
+
const simpleResponse = this.getNodeParameter('simpleResponse', itemIndex, false);
|
|
13
|
+
const options = this.getNodeParameter('options', itemIndex, {});
|
|
14
|
+
// Extract options with defaults
|
|
15
|
+
const timeout = (_a = options.timeout) !== null && _a !== void 0 ? _a : 300000;
|
|
16
|
+
const trimResponse = (_b = options.trimResponse) !== null && _b !== void 0 ? _b : true;
|
|
17
|
+
const responseKey = options.responseKey || 'response';
|
|
18
|
+
// Determine session ID based on mode
|
|
19
|
+
let sessionId;
|
|
20
|
+
let shouldDeleteSession = false;
|
|
21
|
+
if (sessionMode === 'temporary') {
|
|
22
|
+
const tempSessionTitle = this.getNodeParameter('tempSessionTitle', itemIndex, 'Temporary Chat Session');
|
|
23
|
+
sessionId = await (0, api_1.createSession)(this, credentials, tempSessionTitle);
|
|
24
|
+
shouldDeleteSession = true;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
sessionId = this.getNodeParameter('sessionId', itemIndex);
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
// Build payload
|
|
31
|
+
const payload = {
|
|
32
|
+
command: shellCommand,
|
|
33
|
+
agent,
|
|
34
|
+
};
|
|
35
|
+
// model format: "providerID::modelID"
|
|
36
|
+
if (model && model.includes('::')) {
|
|
37
|
+
const [providerID, modelID] = model.split('::');
|
|
38
|
+
payload.model = { providerID, modelID };
|
|
39
|
+
}
|
|
40
|
+
const response = (await api_1.openCodeApiRequest.call(this, credentials, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
endpoint: `/session/${sessionId}/shell`,
|
|
43
|
+
body: payload,
|
|
44
|
+
timeout,
|
|
45
|
+
}));
|
|
46
|
+
// Extract shell output from tool parts
|
|
47
|
+
// Shell response has parts with type 'tool' and state.output containing the command output
|
|
48
|
+
let shellOutput = '';
|
|
49
|
+
const parts = response.parts || [];
|
|
50
|
+
for (const part of parts) {
|
|
51
|
+
if (part.type === 'tool' && part.state) {
|
|
52
|
+
// Try to get output from state.output or state.metadata.output
|
|
53
|
+
const output = part.state.output || ((_c = part.state.metadata) === null || _c === void 0 ? void 0 : _c.output) || '';
|
|
54
|
+
if (output) {
|
|
55
|
+
shellOutput += output;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Apply trim if enabled
|
|
60
|
+
if (trimResponse) {
|
|
61
|
+
shellOutput = shellOutput.trim();
|
|
62
|
+
}
|
|
63
|
+
// Simple response - return only the shell output
|
|
64
|
+
if (simpleResponse) {
|
|
65
|
+
return [
|
|
66
|
+
{
|
|
67
|
+
json: {
|
|
68
|
+
[responseKey]: shellOutput,
|
|
69
|
+
},
|
|
70
|
+
pairedItem: { item: itemIndex },
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
// Full response with metadata
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
json: {
|
|
78
|
+
messageId: (_d = response.info) === null || _d === void 0 ? void 0 : _d.id,
|
|
79
|
+
sessionId: ((_e = response.info) === null || _e === void 0 ? void 0 : _e.sessionID) || sessionId,
|
|
80
|
+
model: (_f = response.info) === null || _f === void 0 ? void 0 : _f.modelID,
|
|
81
|
+
provider: (_g = response.info) === null || _g === void 0 ? void 0 : _g.providerID,
|
|
82
|
+
tokens: (_h = response.info) === null || _h === void 0 ? void 0 : _h.tokens,
|
|
83
|
+
cost: (_j = response.info) === null || _j === void 0 ? void 0 : _j.cost,
|
|
84
|
+
command: shellCommand,
|
|
85
|
+
agent,
|
|
86
|
+
wasTemporarySession: shouldDeleteSession,
|
|
87
|
+
[responseKey]: shellOutput,
|
|
88
|
+
parts: response.parts,
|
|
89
|
+
},
|
|
90
|
+
pairedItem: { item: itemIndex },
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
// Delete temporary session after use
|
|
96
|
+
if (shouldDeleteSession) {
|
|
97
|
+
await (0, api_1.deleteSession)(this, credentials, sessionId);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.executeShell = executeShell;
|
|
102
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,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|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.abortSession = void 0;
|
|
4
|
+
const api_1 = require("../../helpers/api");
|
|
5
|
+
async function abortSession(itemIndex) {
|
|
6
|
+
const credentials = await (0, api_1.getCredentials)(this);
|
|
7
|
+
const sessionId = this.getNodeParameter('sessionId', itemIndex);
|
|
8
|
+
const response = await api_1.openCodeApiRequest.call(this, credentials, {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
endpoint: `/session/${sessionId}/abort`,
|
|
11
|
+
});
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
json: response || {
|
|
15
|
+
success: true,
|
|
16
|
+
message: `Session ${sessionId} aborted`,
|
|
17
|
+
sessionId,
|
|
18
|
+
},
|
|
19
|
+
pairedItem: { item: itemIndex },
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
exports.abortSession = abortSession;
|
|
24
|
+
//# sourceMappingURL=abort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../../../../src/nodes/OpenCode/actions/session/abort.ts"],"names":[],"mappings":";;;AACA,2CAAuE;AAEhE,KAAK,UAAU,YAAY,CAEjC,SAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,IAAA,oBAAc,EAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,SAAS,CAAW,CAAC;IAE1E,MAAM,QAAQ,GAAG,MAAM,wBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;QACjE,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,YAAY,SAAS,QAAQ;KACvC,CAAC,CAAC;IAEH,OAAO;QACN;YACC,IAAI,EAAG,QAAwB,IAAI;gBAClC,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,WAAW,SAAS,UAAU;gBACvC,SAAS;aACT;YACD,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAC/B;KACD,CAAC;AACH,CAAC;AAtBD,oCAsBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSession = void 0;
|
|
4
|
+
const api_1 = require("../../helpers/api");
|
|
5
|
+
async function createSession(itemIndex) {
|
|
6
|
+
const credentials = await (0, api_1.getCredentials)(this);
|
|
7
|
+
const title = this.getNodeParameter('title', itemIndex, 'New Session');
|
|
8
|
+
const response = await api_1.openCodeApiRequest.call(this, credentials, {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
endpoint: '/session',
|
|
11
|
+
body: { title },
|
|
12
|
+
});
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
json: response,
|
|
16
|
+
pairedItem: { item: itemIndex },
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
exports.createSession = createSession;
|
|
21
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../../src/nodes/OpenCode/actions/session/create.ts"],"names":[],"mappings":";;;AACA,2CAAuE;AAEhE,KAAK,UAAU,aAAa,CAElC,SAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,IAAA,oBAAc,EAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAW,CAAC;IAEjF,MAAM,QAAQ,GAAG,MAAM,wBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;QACjE,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,EAAE,KAAK,EAAE;KACf,CAAC,CAAC;IAEH,OAAO;QACN;YACC,IAAI,EAAE,QAAuB;YAC7B,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAC/B;KACD,CAAC;AACH,CAAC;AAnBD,sCAmBC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteSession = void 0;
|
|
4
|
+
const api_1 = require("../../helpers/api");
|
|
5
|
+
async function deleteSession(itemIndex) {
|
|
6
|
+
const credentials = await (0, api_1.getCredentials)(this);
|
|
7
|
+
const sessionId = this.getNodeParameter('sessionId', itemIndex);
|
|
8
|
+
await api_1.openCodeApiRequest.call(this, credentials, {
|
|
9
|
+
method: 'DELETE',
|
|
10
|
+
endpoint: `/session/${sessionId}`,
|
|
11
|
+
});
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
json: {
|
|
15
|
+
success: true,
|
|
16
|
+
message: `Session ${sessionId} deleted successfully`,
|
|
17
|
+
sessionId,
|
|
18
|
+
},
|
|
19
|
+
pairedItem: { item: itemIndex },
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
exports.deleteSession = deleteSession;
|
|
24
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../../src/nodes/OpenCode/actions/session/delete.ts"],"names":[],"mappings":";;;AACA,2CAAuE;AAEhE,KAAK,UAAU,aAAa,CAElC,SAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,IAAA,oBAAc,EAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,SAAS,CAAW,CAAC;IAE1E,MAAM,wBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;QAChD,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,YAAY,SAAS,EAAE;KACjC,CAAC,CAAC;IAEH,OAAO;QACN;YACC,IAAI,EAAE;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,WAAW,SAAS,uBAAuB;gBACpD,SAAS;aACT;YACD,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAC/B;KACD,CAAC;AACH,CAAC;AAtBD,sCAsBC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSession = void 0;
|
|
4
|
+
const api_1 = require("../../helpers/api");
|
|
5
|
+
async function getSession(itemIndex) {
|
|
6
|
+
const credentials = await (0, api_1.getCredentials)(this);
|
|
7
|
+
const sessionId = this.getNodeParameter('sessionId', itemIndex);
|
|
8
|
+
const response = await api_1.openCodeApiRequest.call(this, credentials, {
|
|
9
|
+
method: 'GET',
|
|
10
|
+
endpoint: `/session/${sessionId}`,
|
|
11
|
+
});
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
json: response,
|
|
15
|
+
pairedItem: { item: itemIndex },
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
exports.getSession = getSession;
|
|
20
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../src/nodes/OpenCode/actions/session/get.ts"],"names":[],"mappings":";;;AACA,2CAAuE;AAEhE,KAAK,UAAU,UAAU,CAE/B,SAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,IAAA,oBAAc,EAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,SAAS,CAAW,CAAC;IAE1E,MAAM,QAAQ,GAAG,MAAM,wBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;QACjE,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,YAAY,SAAS,EAAE;KACjC,CAAC,CAAC;IAEH,OAAO;QACN;YACC,IAAI,EAAE,QAAuB;YAC7B,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAC/B;KACD,CAAC;AACH,CAAC;AAlBD,gCAkBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
import { listSessions } from './list';
|
|
3
|
+
import { getSession } from './get';
|
|
4
|
+
import { createSession } from './create';
|
|
5
|
+
import { deleteSession } from './delete';
|
|
6
|
+
import { abortSession } from './abort';
|
|
7
|
+
import { getSessionStatus } from './status';
|
|
8
|
+
export declare function executeSessionAction(this: IExecuteFunctions, operation: string, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
9
|
+
export { listSessions, getSession, createSession, deleteSession, abortSession, getSessionStatus };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSessionStatus = exports.abortSession = exports.deleteSession = exports.createSession = exports.getSession = exports.listSessions = exports.executeSessionAction = void 0;
|
|
4
|
+
const list_1 = require("./list");
|
|
5
|
+
Object.defineProperty(exports, "listSessions", { enumerable: true, get: function () { return list_1.listSessions; } });
|
|
6
|
+
const get_1 = require("./get");
|
|
7
|
+
Object.defineProperty(exports, "getSession", { enumerable: true, get: function () { return get_1.getSession; } });
|
|
8
|
+
const create_1 = require("./create");
|
|
9
|
+
Object.defineProperty(exports, "createSession", { enumerable: true, get: function () { return create_1.createSession; } });
|
|
10
|
+
const delete_1 = require("./delete");
|
|
11
|
+
Object.defineProperty(exports, "deleteSession", { enumerable: true, get: function () { return delete_1.deleteSession; } });
|
|
12
|
+
const abort_1 = require("./abort");
|
|
13
|
+
Object.defineProperty(exports, "abortSession", { enumerable: true, get: function () { return abort_1.abortSession; } });
|
|
14
|
+
const status_1 = require("./status");
|
|
15
|
+
Object.defineProperty(exports, "getSessionStatus", { enumerable: true, get: function () { return status_1.getSessionStatus; } });
|
|
16
|
+
async function executeSessionAction(operation, itemIndex) {
|
|
17
|
+
switch (operation) {
|
|
18
|
+
case 'list':
|
|
19
|
+
return list_1.listSessions.call(this, itemIndex);
|
|
20
|
+
case 'get':
|
|
21
|
+
return get_1.getSession.call(this, itemIndex);
|
|
22
|
+
case 'create':
|
|
23
|
+
return create_1.createSession.call(this, itemIndex);
|
|
24
|
+
case 'delete':
|
|
25
|
+
return delete_1.deleteSession.call(this, itemIndex);
|
|
26
|
+
case 'abort':
|
|
27
|
+
return abort_1.abortSession.call(this, itemIndex);
|
|
28
|
+
case 'status':
|
|
29
|
+
return status_1.getSessionStatus.call(this, itemIndex);
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(`Unknown session operation: ${operation}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.executeSessionAction = executeSessionAction;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/nodes/OpenCode/actions/session/index.ts"],"names":[],"mappings":";;;AACA,iCAAsC;AA8B7B,6FA9BA,mBAAY,OA8BA;AA7BrB,+BAAmC;AA6BZ,2FA7Bd,gBAAU,OA6Bc;AA5BjC,qCAAyC;AA4BN,8FA5B1B,sBAAa,OA4B0B;AA3BhD,qCAAyC;AA2BS,8FA3BzC,sBAAa,OA2ByC;AA1B/D,mCAAuC;AA0B0B,6FA1BxD,oBAAY,OA0BwD;AAzB7E,qCAA4C;AAyBmC,iGAzBtE,yBAAgB,OAyBsE;AAvBxF,KAAK,UAAU,oBAAoB,CAEzC,SAAiB,EACjB,SAAiB;IAEjB,QAAQ,SAAS,EAAE,CAAC;QACnB,KAAK,MAAM;YACV,OAAO,mBAAY,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC3C,KAAK,KAAK;YACT,OAAO,gBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACzC,KAAK,QAAQ;YACZ,OAAO,sBAAa,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC5C,KAAK,QAAQ;YACZ,OAAO,sBAAa,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC5C,KAAK,OAAO;YACX,OAAO,oBAAY,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC3C,KAAK,QAAQ;YACZ,OAAO,yBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/C;YACC,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,EAAE,CAAC,CAAC;IAC7D,CAAC;AACF,CAAC;AArBD,oDAqBC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listSessions = void 0;
|
|
4
|
+
const api_1 = require("../../helpers/api");
|
|
5
|
+
async function listSessions(itemIndex) {
|
|
6
|
+
const credentials = await (0, api_1.getCredentials)(this);
|
|
7
|
+
const response = await api_1.openCodeApiRequest.call(this, credentials, {
|
|
8
|
+
method: 'GET',
|
|
9
|
+
endpoint: '/session',
|
|
10
|
+
});
|
|
11
|
+
const sessions = Array.isArray(response) ? response : [response];
|
|
12
|
+
return sessions.map((session) => ({
|
|
13
|
+
json: session,
|
|
14
|
+
pairedItem: { item: itemIndex },
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
exports.listSessions = listSessions;
|
|
18
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../../src/nodes/OpenCode/actions/session/list.ts"],"names":[],"mappings":";;;AACA,2CAAuE;AAEhE,KAAK,UAAU,YAAY,CAEjC,SAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,IAAA,oBAAc,EAAC,IAAI,CAAC,CAAC;IAE/C,MAAM,QAAQ,GAAG,MAAM,wBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;QACjE,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,UAAU;KACpB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAEjE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACjC,IAAI,EAAE,OAAsB;QAC5B,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/B,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,oCAiBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSessionStatus = void 0;
|
|
4
|
+
const api_1 = require("../../helpers/api");
|
|
5
|
+
async function getSessionStatus(itemIndex) {
|
|
6
|
+
const credentials = await (0, api_1.getCredentials)(this);
|
|
7
|
+
const response = await api_1.openCodeApiRequest.call(this, credentials, {
|
|
8
|
+
method: 'GET',
|
|
9
|
+
endpoint: '/session/status',
|
|
10
|
+
});
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
json: response,
|
|
14
|
+
pairedItem: { item: itemIndex },
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
exports.getSessionStatus = getSessionStatus;
|
|
19
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../../src/nodes/OpenCode/actions/session/status.ts"],"names":[],"mappings":";;;AACA,2CAAuE;AAEhE,KAAK,UAAU,gBAAgB,CAErC,SAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,IAAA,oBAAc,EAAC,IAAI,CAAC,CAAC;IAE/C,MAAM,QAAQ,GAAG,MAAM,wBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;QACjE,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,iBAAiB;KAC3B,CAAC,CAAC;IAEH,OAAO;QACN;YACC,IAAI,EAAE,QAAuB;YAC7B,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAC/B;KACD,CAAC;AACH,CAAC;AAjBD,4CAiBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IExecuteFunctions, IHttpRequestMethods, IDataObject } from 'n8n-workflow';
|
|
2
|
+
import { IOpenCodeCredentials } from '../types';
|
|
3
|
+
export interface IApiRequestOptions {
|
|
4
|
+
method: IHttpRequestMethods;
|
|
5
|
+
endpoint: string;
|
|
6
|
+
body?: IDataObject;
|
|
7
|
+
qs?: IDataObject;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function openCodeApiRequest(this: IExecuteFunctions, credentials: IOpenCodeCredentials, options: IApiRequestOptions): Promise<IDataObject | IDataObject[]>;
|
|
11
|
+
export declare function getCredentials(execute: IExecuteFunctions): Promise<IOpenCodeCredentials>;
|
|
12
|
+
export declare function createSession(execute: IExecuteFunctions, credentials: IOpenCodeCredentials, title: string): Promise<string>;
|
|
13
|
+
export declare function deleteSession(execute: IExecuteFunctions, credentials: IOpenCodeCredentials, sessionId: string): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteSession = exports.createSession = exports.getCredentials = exports.openCodeApiRequest = void 0;
|
|
4
|
+
async function openCodeApiRequest(credentials, options) {
|
|
5
|
+
const { method, endpoint, body, qs, timeout } = options;
|
|
6
|
+
const requestOptions = {
|
|
7
|
+
method,
|
|
8
|
+
url: `${credentials.baseUrl}${endpoint}`,
|
|
9
|
+
headers: {
|
|
10
|
+
'Content-Type': 'application/json',
|
|
11
|
+
},
|
|
12
|
+
body,
|
|
13
|
+
qs,
|
|
14
|
+
json: true,
|
|
15
|
+
timeout: timeout !== null && timeout !== void 0 ? timeout : 300000, // Default: 5 minutes timeout
|
|
16
|
+
// Basic Auth
|
|
17
|
+
auth: {
|
|
18
|
+
username: credentials.username,
|
|
19
|
+
password: credentials.password,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
const response = await this.helpers.httpRequest(requestOptions);
|
|
24
|
+
return response;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
const errorMessage = error.message || 'Unknown error';
|
|
28
|
+
throw new Error(`OpenCode API request failed: ${errorMessage}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.openCodeApiRequest = openCodeApiRequest;
|
|
32
|
+
async function getCredentials(execute) {
|
|
33
|
+
const credentials = await execute.getCredentials('openCodeApi');
|
|
34
|
+
return {
|
|
35
|
+
baseUrl: credentials.baseUrl,
|
|
36
|
+
username: credentials.username,
|
|
37
|
+
password: credentials.password,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.getCredentials = getCredentials;
|
|
41
|
+
async function createSession(execute, credentials, title) {
|
|
42
|
+
const response = await openCodeApiRequest.call(execute, credentials, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
endpoint: '/session',
|
|
45
|
+
body: { title },
|
|
46
|
+
});
|
|
47
|
+
return response.id;
|
|
48
|
+
}
|
|
49
|
+
exports.createSession = createSession;
|
|
50
|
+
async function deleteSession(execute, credentials, sessionId) {
|
|
51
|
+
try {
|
|
52
|
+
await openCodeApiRequest.call(execute, credentials, {
|
|
53
|
+
method: 'DELETE',
|
|
54
|
+
endpoint: `/session/${sessionId}`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error(`Failed to delete session ${sessionId}:`, error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.deleteSession = deleteSession;
|
|
62
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/nodes/OpenCode/helpers/api.ts"],"names":[],"mappings":";;;AAgBO,KAAK,UAAU,kBAAkB,CAEvC,WAAiC,EACjC,OAA2B;IAE3B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAExD,MAAM,cAAc,GAAwB;QAC3C,MAAM;QACN,GAAG,EAAE,GAAG,WAAW,CAAC,OAAO,GAAG,QAAQ,EAAE;QACxC,OAAO,EAAE;YACR,cAAc,EAAE,kBAAkB;SAClC;QACD,IAAI;QACJ,EAAE;QACF,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,MAAM,EAAE,6BAA6B;QACzD,aAAa;QACb,IAAI,EAAE;YACL,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,QAAQ,EAAE,WAAW,CAAC,QAAQ;SAC9B;KACD,CAAC;IAEF,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAChE,OAAO,QAAuC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,YAAY,GAAI,KAAe,CAAC,OAAO,IAAI,eAAe,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,gCAAgC,YAAY,EAAE,CAAC,CAAC;IACjE,CAAC;AACF,CAAC;AA/BD,gDA+BC;AAEM,KAAK,UAAU,cAAc,CACnC,OAA0B;IAE1B,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAChE,OAAO;QACN,OAAO,EAAE,WAAW,CAAC,OAAiB;QACtC,QAAQ,EAAE,WAAW,CAAC,QAAkB;QACxC,QAAQ,EAAE,WAAW,CAAC,QAAkB;KACxC,CAAC;AACH,CAAC;AATD,wCASC;AAEM,KAAK,UAAU,aAAa,CAClC,OAA0B,EAC1B,WAAiC,EACjC,KAAa;IAEb,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE;QACpE,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,EAAE,KAAK,EAAE;KACf,CAAgB,CAAC;IAClB,OAAO,QAAQ,CAAC,EAAY,CAAC;AAC9B,CAAC;AAXD,sCAWC;AAEM,KAAK,UAAU,aAAa,CAClC,OAA0B,EAC1B,WAAiC,EACjC,SAAiB;IAEjB,IAAI,CAAC;QACJ,MAAM,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE;YACnD,MAAM,EAAE,QAAQ;YAChB,QAAQ,EAAE,YAAY,SAAS,EAAE;SACjC,CAAC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,4BAA4B,SAAS,GAAG,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;AACF,CAAC;AAbD,sCAaC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" fill="none">
|
|
2
|
+
<rect width="60" height="60" rx="8" fill="#1a1a2e"/>
|
|
3
|
+
<path d="M20 22L12 30L20 38" stroke="#00d9ff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M40 22L48 30L40 38" stroke="#00d9ff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<path d="M35 16L25 44" stroke="#ff6b6b" stroke-width="3" stroke-linecap="round"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { IDataObject, IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
export interface IOpenCodeCredentials {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
username: string;
|
|
5
|
+
password: string;
|
|
6
|
+
}
|
|
7
|
+
export interface INodeContext {
|
|
8
|
+
execute: IExecuteFunctions;
|
|
9
|
+
credentials: IOpenCodeCredentials;
|
|
10
|
+
itemIndex: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ISession {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt?: string;
|
|
17
|
+
messages?: IMessage[];
|
|
18
|
+
}
|
|
19
|
+
export interface IMessage {
|
|
20
|
+
id: string;
|
|
21
|
+
sessionID: string;
|
|
22
|
+
role: 'user' | 'assistant';
|
|
23
|
+
parts: IMessagePart[];
|
|
24
|
+
info?: IMessageInfo;
|
|
25
|
+
createdAt?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IMessagePart {
|
|
28
|
+
type: 'text' | 'tool_use' | 'tool_result' | 'tool';
|
|
29
|
+
text?: string;
|
|
30
|
+
toolName?: string;
|
|
31
|
+
toolInput?: IDataObject;
|
|
32
|
+
toolResult?: string;
|
|
33
|
+
id?: string;
|
|
34
|
+
messageID?: string;
|
|
35
|
+
sessionID?: string;
|
|
36
|
+
tool?: string;
|
|
37
|
+
callID?: string;
|
|
38
|
+
state?: {
|
|
39
|
+
status?: string;
|
|
40
|
+
time?: {
|
|
41
|
+
start?: number;
|
|
42
|
+
end?: number;
|
|
43
|
+
};
|
|
44
|
+
input?: IDataObject;
|
|
45
|
+
output?: string;
|
|
46
|
+
metadata?: {
|
|
47
|
+
output?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface IMessageInfo {
|
|
53
|
+
id: string;
|
|
54
|
+
sessionID: string;
|
|
55
|
+
modelID: string;
|
|
56
|
+
providerID: string;
|
|
57
|
+
tokens: {
|
|
58
|
+
input: number;
|
|
59
|
+
output: number;
|
|
60
|
+
};
|
|
61
|
+
cost: {
|
|
62
|
+
input: number;
|
|
63
|
+
output: number;
|
|
64
|
+
total: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export interface IProvider {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
models: IModel[];
|
|
71
|
+
}
|
|
72
|
+
export interface IModel {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ISendMessageRequest {
|
|
78
|
+
parts: IMessagePart[];
|
|
79
|
+
model?: string;
|
|
80
|
+
agent?: string;
|
|
81
|
+
system?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface ISendMessageResponse {
|
|
84
|
+
info: IMessageInfo;
|
|
85
|
+
parts: IMessagePart[];
|
|
86
|
+
}
|
|
87
|
+
export interface ISessionStatus {
|
|
88
|
+
[sessionId: string]: {
|
|
89
|
+
status: 'idle' | 'running' | 'error';
|
|
90
|
+
lastActivity?: string;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export type ResourceType = 'session' | 'message' | 'config';
|
|
94
|
+
export type SessionOperation = 'list' | 'get' | 'create' | 'delete' | 'abort' | 'status';
|
|
95
|
+
export type MessageOperation = 'send' | 'sendAsync' | 'list' | 'get' | 'command' | 'shell';
|
|
96
|
+
export type ConfigOperation = 'getProviders';
|
|
97
|
+
export interface IActionResult {
|
|
98
|
+
json: IDataObject;
|
|
99
|
+
binary?: IDataObject;
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nodes/OpenCode/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseChatModel, type BaseChatModelParams, type BaseChatModelCallOptions } from '@langchain/core/language_models/chat_models';
|
|
2
|
+
import { type BaseMessage } from '@langchain/core/messages';
|
|
3
|
+
import { type ChatResult } from '@langchain/core/outputs';
|
|
4
|
+
import { type CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
|
|
5
|
+
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
6
|
+
import type { RunnableToolLike } from '@langchain/core/runnables';
|
|
7
|
+
export interface ChatOpenCodeInput extends BaseChatModelParams {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
username: string;
|
|
10
|
+
password: string;
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
model?: string;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
useTemporarySession?: boolean;
|
|
15
|
+
tempSessionTitle?: string;
|
|
16
|
+
}
|
|
17
|
+
interface ToolDefinition {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
schema?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export interface ChatOpenCodeCallOptions extends BaseChatModelCallOptions {
|
|
23
|
+
tools?: ToolDefinition[];
|
|
24
|
+
}
|
|
25
|
+
export declare class ChatOpenCode extends BaseChatModel<ChatOpenCodeCallOptions> {
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
username: string;
|
|
28
|
+
password: string;
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
model?: string;
|
|
31
|
+
timeout: number;
|
|
32
|
+
useTemporarySession: boolean;
|
|
33
|
+
tempSessionTitle: string;
|
|
34
|
+
boundTools?: ToolDefinition[];
|
|
35
|
+
static lc_name(): string;
|
|
36
|
+
constructor(fields: ChatOpenCodeInput & {
|
|
37
|
+
boundTools?: ToolDefinition[];
|
|
38
|
+
});
|
|
39
|
+
_llmType(): string;
|
|
40
|
+
private getAuthHeader;
|
|
41
|
+
private createSession;
|
|
42
|
+
private deleteSession;
|
|
43
|
+
/**
|
|
44
|
+
* Bind tools to the model for function calling support
|
|
45
|
+
*/
|
|
46
|
+
bindTools(tools: (StructuredToolInterface | RunnableToolLike | ToolDefinition)[]): ChatOpenCode;
|
|
47
|
+
/**
|
|
48
|
+
* Format tools as a system prompt for models that don't have native tool support
|
|
49
|
+
*/
|
|
50
|
+
private formatToolsAsPrompt;
|
|
51
|
+
/**
|
|
52
|
+
* Parse tool calls from the response text
|
|
53
|
+
*/
|
|
54
|
+
private parseToolCalls;
|
|
55
|
+
_generate(messages: BaseMessage[], options: this['ParsedCallOptions'], _runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
56
|
+
}
|
|
57
|
+
export {};
|