@ycodium-ai/agent-opencode 0.2.2898 → 0.2.2900
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/dist/index.js +62 -68
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -59,15 +59,15 @@ var require_windows = __commonJS({
|
|
|
59
59
|
}
|
|
60
60
|
return false;
|
|
61
61
|
}
|
|
62
|
-
function checkStat(
|
|
63
|
-
if (!
|
|
62
|
+
function checkStat(stat, path, options) {
|
|
63
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
return checkPathExt(path, options);
|
|
67
67
|
}
|
|
68
68
|
function isexe(path, options, cb) {
|
|
69
|
-
fs.stat(path, function(er,
|
|
70
|
-
cb(er, er ? false : checkStat(
|
|
69
|
+
fs.stat(path, function(er, stat) {
|
|
70
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
function sync(path, options) {
|
|
@@ -83,20 +83,20 @@ var require_mode = __commonJS({
|
|
|
83
83
|
isexe.sync = sync;
|
|
84
84
|
var fs = __require("fs");
|
|
85
85
|
function isexe(path, options, cb) {
|
|
86
|
-
fs.stat(path, function(er,
|
|
87
|
-
cb(er, er ? false : checkStat(
|
|
86
|
+
fs.stat(path, function(er, stat) {
|
|
87
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
function sync(path, options) {
|
|
91
91
|
return checkStat(fs.statSync(path), options);
|
|
92
92
|
}
|
|
93
|
-
function checkStat(
|
|
94
|
-
return
|
|
93
|
+
function checkStat(stat, options) {
|
|
94
|
+
return stat.isFile() && checkMode(stat, options);
|
|
95
95
|
}
|
|
96
|
-
function checkMode(
|
|
97
|
-
var mod =
|
|
98
|
-
var uid =
|
|
99
|
-
var gid =
|
|
96
|
+
function checkMode(stat, options) {
|
|
97
|
+
var mod = stat.mode;
|
|
98
|
+
var uid = stat.uid;
|
|
99
|
+
var gid = stat.gid;
|
|
100
100
|
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
101
101
|
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
102
102
|
var u = parseInt("100", 8);
|
|
@@ -1058,26 +1058,6 @@ async function persistProducedBytes(input) {
|
|
|
1058
1058
|
return null;
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
|
-
async function readLocalFileAttachment(input) {
|
|
1062
|
-
const name = input.name ?? NodePath.basename(input.absolutePath);
|
|
1063
|
-
const mimeType = mimeTypeForFileName(name);
|
|
1064
|
-
try {
|
|
1065
|
-
const info = await NodeFSP.stat(input.absolutePath);
|
|
1066
|
-
if (!info.isFile()) return null;
|
|
1067
|
-
if (info.size > maxBytesForMime(mimeType)) return null;
|
|
1068
|
-
const bytes = await NodeFSP.readFile(input.absolutePath);
|
|
1069
|
-
if (bytes.byteLength > maxBytesForMime(mimeType)) return null;
|
|
1070
|
-
return persistProducedBytes({
|
|
1071
|
-
attachmentsApi: input.attachmentsApi,
|
|
1072
|
-
threadId: input.threadId,
|
|
1073
|
-
name,
|
|
1074
|
-
mimeType,
|
|
1075
|
-
bytes
|
|
1076
|
-
});
|
|
1077
|
-
} catch {
|
|
1078
|
-
return null;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
1061
|
async function readUrlAttachment(input) {
|
|
1082
1062
|
const mimeType = input.mimeType ?? mimeTypeForFileName(input.name);
|
|
1083
1063
|
const limit = maxBytesForMime(mimeType);
|
|
@@ -1091,15 +1071,6 @@ async function readUrlAttachment(input) {
|
|
|
1091
1071
|
bytes: Buffer.from(parsed.base64, "base64")
|
|
1092
1072
|
});
|
|
1093
1073
|
}
|
|
1094
|
-
if (input.url.startsWith("file://") || input.url.startsWith("/")) {
|
|
1095
|
-
const absolutePath = input.url.startsWith("/") ? input.url : decodeURIComponent(new URL(input.url).pathname);
|
|
1096
|
-
return readLocalFileAttachment({
|
|
1097
|
-
attachmentsApi: input.attachmentsApi,
|
|
1098
|
-
threadId: input.threadId,
|
|
1099
|
-
absolutePath,
|
|
1100
|
-
name: input.name
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
1074
|
let sameOrigin = false;
|
|
1104
1075
|
if (input.allowedOrigin !== void 0) {
|
|
1105
1076
|
try {
|
|
@@ -8128,6 +8099,55 @@ function emitEvent(events, context, type3, payload, extra) {
|
|
|
8128
8099
|
events.push(event);
|
|
8129
8100
|
}
|
|
8130
8101
|
|
|
8102
|
+
// src/producedFiles.ts
|
|
8103
|
+
import * as NodePath6 from "node:path";
|
|
8104
|
+
import * as NodeURL2 from "node:url";
|
|
8105
|
+
function fileNameFromUrl(url) {
|
|
8106
|
+
try {
|
|
8107
|
+
const parsed = new URL(url);
|
|
8108
|
+
const base = parsed.pathname.split("/").findLast(Boolean);
|
|
8109
|
+
if (base && base.length > 0) return decodeURIComponent(base);
|
|
8110
|
+
} catch {
|
|
8111
|
+
const base = url.split("/").findLast(Boolean);
|
|
8112
|
+
if (base && base.length > 0) return base;
|
|
8113
|
+
}
|
|
8114
|
+
return "file";
|
|
8115
|
+
}
|
|
8116
|
+
function localPathOf(url) {
|
|
8117
|
+
if (url.startsWith("file:")) {
|
|
8118
|
+
try {
|
|
8119
|
+
return NodeURL2.fileURLToPath(url);
|
|
8120
|
+
} catch {
|
|
8121
|
+
return null;
|
|
8122
|
+
}
|
|
8123
|
+
}
|
|
8124
|
+
return NodePath6.isAbsolute(url) ? url : null;
|
|
8125
|
+
}
|
|
8126
|
+
async function emitProducedFile(events, context, file) {
|
|
8127
|
+
const filename = file.filename?.trim();
|
|
8128
|
+
const path = localPathOf(file.url);
|
|
8129
|
+
if (path !== null) {
|
|
8130
|
+
const artifact = {
|
|
8131
|
+
path,
|
|
8132
|
+
...filename ? { name: filename } : {},
|
|
8133
|
+
...file.mime ? { mimeType: file.mime } : {}
|
|
8134
|
+
};
|
|
8135
|
+
emitEvent(events, context, "assistant.artifact.produced", { artifacts: [artifact] });
|
|
8136
|
+
return;
|
|
8137
|
+
}
|
|
8138
|
+
const attachment = await readUrlAttachment({
|
|
8139
|
+
attachmentsApi: context.attachmentsApi,
|
|
8140
|
+
threadId: context.threadId,
|
|
8141
|
+
url: file.url,
|
|
8142
|
+
name: filename || fileNameFromUrl(file.url),
|
|
8143
|
+
mimeType: file.mime,
|
|
8144
|
+
allowedOrigin: context.server.url
|
|
8145
|
+
});
|
|
8146
|
+
if (attachment) {
|
|
8147
|
+
emitEvent(events, context, "assistant.attachment.produced", { attachments: [attachment] });
|
|
8148
|
+
}
|
|
8149
|
+
}
|
|
8150
|
+
|
|
8131
8151
|
// src/textMerge.ts
|
|
8132
8152
|
function commonPrefixLength(left, right) {
|
|
8133
8153
|
let index = 0;
|
|
@@ -8291,32 +8311,6 @@ function openCodeEventSessionId(event) {
|
|
|
8291
8311
|
}
|
|
8292
8312
|
return void 0;
|
|
8293
8313
|
}
|
|
8294
|
-
function fileNameFromUrl(url) {
|
|
8295
|
-
try {
|
|
8296
|
-
const parsed = new URL(url);
|
|
8297
|
-
const base = parsed.pathname.split("/").filter(Boolean).at(-1);
|
|
8298
|
-
if (base && base.length > 0) return decodeURIComponent(base);
|
|
8299
|
-
} catch {
|
|
8300
|
-
const base = url.split("/").filter(Boolean).at(-1);
|
|
8301
|
-
if (base && base.length > 0) return base;
|
|
8302
|
-
}
|
|
8303
|
-
return "file";
|
|
8304
|
-
}
|
|
8305
|
-
async function emitAssistantFileAttachment(events, context, part) {
|
|
8306
|
-
const name = part.filename?.trim() || fileNameFromUrl(part.url) || "file";
|
|
8307
|
-
const attachment = await readUrlAttachment({
|
|
8308
|
-
attachmentsApi: context.attachmentsApi,
|
|
8309
|
-
threadId: context.threadId,
|
|
8310
|
-
url: part.url,
|
|
8311
|
-
name,
|
|
8312
|
-
mimeType: part.mime,
|
|
8313
|
-
allowedOrigin: context.server.url
|
|
8314
|
-
});
|
|
8315
|
-
if (!attachment) return;
|
|
8316
|
-
emitEvent(events, context, "assistant.attachment.produced", {
|
|
8317
|
-
attachments: [attachment]
|
|
8318
|
-
});
|
|
8319
|
-
}
|
|
8320
8314
|
function emitAssistantTextDelta(events, context, part) {
|
|
8321
8315
|
const previous = context.assistantTextByPartId.get(part.id);
|
|
8322
8316
|
const { latestText, deltaToEmit } = mergeOpenCodeAssistantText(previous, part.text);
|
|
@@ -8718,7 +8712,7 @@ async function handleSubscribedEvent(input) {
|
|
|
8718
8712
|
return;
|
|
8719
8713
|
}
|
|
8720
8714
|
if (part.type === "file") {
|
|
8721
|
-
await
|
|
8715
|
+
await emitProducedFile(events, context, part);
|
|
8722
8716
|
return;
|
|
8723
8717
|
}
|
|
8724
8718
|
if (part.type === "tool") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-opencode",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2900",
|
|
4
4
|
"description": "OpenCode executor: OpenCode CLI via @opencode-ai/sdk/v2.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@types/node": "24.12.4",
|
|
25
25
|
"esbuild": "0.28.1",
|
|
26
26
|
"vite-plus": "0.2.2",
|
|
27
|
-
"
|
|
27
|
+
"ycodium-executor-testing": "0.0.0",
|
|
28
28
|
"ycodium-fetch-ports": "0.0.0",
|
|
29
|
-
"ycodium-
|
|
29
|
+
"@ycodium-ai/plugin-api": "0.2.2900"
|
|
30
30
|
},
|
|
31
31
|
"ycodium": {
|
|
32
32
|
"plugin": "./dist/index.js",
|