teamcopilot 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -26
- package/dist/frontend/assets/{cssMode-BDT3WbVs.js → cssMode-BBJnYJ3k.js} +1 -1
- package/dist/frontend/assets/{freemarker2-C7-hEgID.js → freemarker2-D_OsaDj3.js} +1 -1
- package/dist/frontend/assets/{handlebars-4cwTkPir.js → handlebars-OZHda73C.js} +1 -1
- package/dist/frontend/assets/{html-YNfE1Q0A.js → html-CdGHj-sb.js} +1 -1
- package/dist/frontend/assets/{htmlMode-opTQ1HoB.js → htmlMode-DmOnHDtb.js} +1 -1
- package/dist/frontend/assets/index-CnBE4Efj.css +1 -0
- package/dist/frontend/assets/{index-DWyaVa1h.js → index-DNOGp3R4.js} +133 -133
- package/dist/frontend/assets/{javascript-BEwGzk7T.js → javascript--es-Ez5N.js} +1 -1
- package/dist/frontend/assets/{jsonMode-CGhIS5Al.js → jsonMode-C3d51Wej.js} +1 -1
- package/dist/frontend/assets/{liquid-QekTGCGJ.js → liquid-D2JYL9PO.js} +1 -1
- package/dist/frontend/assets/{mdx-BAVDaB7v.js → mdx-Ch04DugU.js} +1 -1
- package/dist/frontend/assets/{python-BQlHw7XO.js → python-D-iNySlZ.js} +1 -1
- package/dist/frontend/assets/{razor-Be3Wwc2E.js → razor-Bq45_Fpy.js} +1 -1
- package/dist/frontend/assets/{tsMode-CIBFoN3z.js → tsMode-CC8kGhhz.js} +1 -1
- package/dist/frontend/assets/{typescript-BuV9wEIE.js → typescript-CtgyIznM.js} +1 -1
- package/dist/frontend/assets/{xml-DcDKYaM4.js → xml-D5joow3e.js} +1 -1
- package/dist/frontend/assets/{yaml-CuBNmOuI.js → yaml-BsRI11pd.js} +1 -1
- package/dist/frontend/index.html +2 -2
- package/dist/opencode-auth/index.js +26 -3
- package/dist/opencode-server.js +2 -0
- package/dist/utils/opencode-auth.js +112 -0
- package/dist/utils/workspace-sync.js +7 -0
- package/package.json +1 -1
- package/dist/frontend/assets/index-lXrsgeTF.css +0 -1
|
@@ -5,14 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getConfiguredModelProviderId = getConfiguredModelProviderId;
|
|
7
7
|
exports.initializeOpencodeAuthStorage = initializeOpencodeAuthStorage;
|
|
8
|
+
exports.isServiceManagedProvider = isServiceManagedProvider;
|
|
9
|
+
exports.hasRuntimeProviderCredentials = hasRuntimeProviderCredentials;
|
|
8
10
|
exports.getRuntimeProviderAuth = getRuntimeProviderAuth;
|
|
9
11
|
exports.setRuntimeProviderAuth = setRuntimeProviderAuth;
|
|
12
|
+
exports.syncManagedProviderConfiguration = syncManagedProviderConfiguration;
|
|
10
13
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
11
14
|
const path_1 = __importDefault(require("path"));
|
|
12
15
|
const assert_1 = require("./assert");
|
|
13
16
|
const workspace_sync_1 = require("./workspace-sync");
|
|
14
17
|
const WORKSPACE_OPENCODE_DIR = ".opencode";
|
|
15
18
|
const WORKSPACE_AUTH_FILE = "auth.json";
|
|
19
|
+
const WORKSPACE_CONFIG_FILE = "opencode.json";
|
|
16
20
|
const RUNTIME_DATA_HOME_DIR = "xdg-data";
|
|
17
21
|
function getWorkspaceOpencodeDir() {
|
|
18
22
|
return path_1.default.join((0, workspace_sync_1.getWorkspaceDirFromEnv)(), WORKSPACE_OPENCODE_DIR);
|
|
@@ -23,6 +27,9 @@ function getRuntimeDataHomePath() {
|
|
|
23
27
|
function getRuntimeAuthPath() {
|
|
24
28
|
return path_1.default.join(getRuntimeDataHomePath(), "opencode", WORKSPACE_AUTH_FILE);
|
|
25
29
|
}
|
|
30
|
+
function getWorkspaceOpencodeConfigPath() {
|
|
31
|
+
return path_1.default.join(getWorkspaceOpencodeDir(), WORKSPACE_CONFIG_FILE);
|
|
32
|
+
}
|
|
26
33
|
function normalizeProviderId(providerId) {
|
|
27
34
|
return providerId.replace(/\/+$/, "");
|
|
28
35
|
}
|
|
@@ -80,6 +87,35 @@ async function writeAuthRecord(filepath, data) {
|
|
|
80
87
|
await promises_1.default.rename(tempPath, filepath);
|
|
81
88
|
await promises_1.default.chmod(filepath, 0o600).catch(() => { });
|
|
82
89
|
}
|
|
90
|
+
async function readOpencodeConfig(filepath) {
|
|
91
|
+
try {
|
|
92
|
+
const content = await promises_1.default.readFile(filepath, "utf-8");
|
|
93
|
+
const parsed = JSON.parse(content);
|
|
94
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
95
|
+
throw new Error("Invalid opencode config");
|
|
96
|
+
}
|
|
97
|
+
return parsed;
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
const nodeError = err;
|
|
101
|
+
if (nodeError.code === "ENOENT") {
|
|
102
|
+
return {
|
|
103
|
+
$schema: "https://opencode.ai/config.json",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function writeOpencodeConfig(filepath, data) {
|
|
110
|
+
await promises_1.default.mkdir(path_1.default.dirname(filepath), { recursive: true });
|
|
111
|
+
const tempPath = `${filepath}.tmp-${process.pid}-${Date.now()}`;
|
|
112
|
+
await promises_1.default.writeFile(tempPath, `${JSON.stringify(data, null, 2)}\n`, {
|
|
113
|
+
encoding: "utf-8",
|
|
114
|
+
mode: 0o600,
|
|
115
|
+
});
|
|
116
|
+
await promises_1.default.rename(tempPath, filepath);
|
|
117
|
+
await promises_1.default.chmod(filepath, 0o600).catch(() => { });
|
|
118
|
+
}
|
|
83
119
|
function getConfiguredModelProviderId() {
|
|
84
120
|
const model = (0, assert_1.assertEnv)("OPENCODE_MODEL");
|
|
85
121
|
const [providerId, ...parts] = model.split("/");
|
|
@@ -88,6 +124,14 @@ function getConfiguredModelProviderId() {
|
|
|
88
124
|
}
|
|
89
125
|
return providerId;
|
|
90
126
|
}
|
|
127
|
+
function getConfiguredModelId() {
|
|
128
|
+
const model = (0, assert_1.assertEnv)("OPENCODE_MODEL");
|
|
129
|
+
const [providerId, ...parts] = model.split("/");
|
|
130
|
+
if (!providerId || parts.length === 0) {
|
|
131
|
+
throw new Error("OPENCODE_MODEL must be in the format <provider>/<model>");
|
|
132
|
+
}
|
|
133
|
+
return parts.join("/");
|
|
134
|
+
}
|
|
91
135
|
function configureOpencodeDataHome() {
|
|
92
136
|
const runtimeDataHome = getRuntimeDataHomePath();
|
|
93
137
|
process.env.XDG_DATA_HOME = runtimeDataHome;
|
|
@@ -112,6 +156,40 @@ function getAuthForProvider(record, providerId) {
|
|
|
112
156
|
const normalizedProviderId = normalizeProviderId(providerId);
|
|
113
157
|
return record[providerId] || record[normalizedProviderId] || record[`${normalizedProviderId}/`];
|
|
114
158
|
}
|
|
159
|
+
function isAzureCustomProvider(providerId) {
|
|
160
|
+
return normalizeProviderId(providerId).toLowerCase() === "azure-openai";
|
|
161
|
+
}
|
|
162
|
+
function isServiceManagedProvider(providerId) {
|
|
163
|
+
return isAzureCustomProvider(providerId);
|
|
164
|
+
}
|
|
165
|
+
function normalizeAzureEndpoint(endpoint) {
|
|
166
|
+
return endpoint.trim().replace(/\/+$/, "");
|
|
167
|
+
}
|
|
168
|
+
function hasRequiredAzureEnvironment() {
|
|
169
|
+
return isNonEmptyString(process.env.AZURE_API_KEY)
|
|
170
|
+
&& isNonEmptyString(process.env.AZURE_OPENAI_ENDPOINT)
|
|
171
|
+
&& isNonEmptyString(process.env.AZURE_OPENAI_API_VERSION);
|
|
172
|
+
}
|
|
173
|
+
async function hasAzureProviderConfiguration(providerId) {
|
|
174
|
+
const deployment = getConfiguredModelId().trim();
|
|
175
|
+
const config = await readOpencodeConfig(getWorkspaceOpencodeConfigPath());
|
|
176
|
+
const provider = config.provider?.[normalizeProviderId(providerId)];
|
|
177
|
+
if (!provider || provider.npm !== "@ai-sdk/azure") {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
const models = provider.models;
|
|
181
|
+
if (!models || typeof models !== "object" || Array.isArray(models)) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const deploymentConfig = models[deployment];
|
|
185
|
+
return Boolean(deploymentConfig && typeof deploymentConfig === "object" && !Array.isArray(deploymentConfig));
|
|
186
|
+
}
|
|
187
|
+
async function hasRuntimeProviderCredentials(providerId) {
|
|
188
|
+
if (isAzureCustomProvider(providerId)) {
|
|
189
|
+
return hasRequiredAzureEnvironment() && await hasAzureProviderConfiguration(providerId);
|
|
190
|
+
}
|
|
191
|
+
return Boolean(await getRuntimeProviderAuth(providerId));
|
|
192
|
+
}
|
|
115
193
|
async function getRuntimeProviderAuth(providerId) {
|
|
116
194
|
const record = await readAuthRecord(getRuntimeAuthPath());
|
|
117
195
|
return getAuthForProvider(record, providerId);
|
|
@@ -124,3 +202,37 @@ async function setRuntimeProviderAuth(providerId, info) {
|
|
|
124
202
|
runtimeRecord[normalizedProviderId] = info;
|
|
125
203
|
await writeAuthRecord(getRuntimeAuthPath(), runtimeRecord);
|
|
126
204
|
}
|
|
205
|
+
async function syncManagedProviderConfiguration() {
|
|
206
|
+
const providerId = getConfiguredModelProviderId();
|
|
207
|
+
if (!isAzureCustomProvider(providerId) || !hasRequiredAzureEnvironment()) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const endpoint = normalizeAzureEndpoint((0, assert_1.assertEnv)("AZURE_OPENAI_ENDPOINT"));
|
|
211
|
+
const apiVersion = (0, assert_1.assertEnv)("AZURE_OPENAI_API_VERSION").trim();
|
|
212
|
+
const deployment = getConfiguredModelId().trim();
|
|
213
|
+
const normalizedProviderId = normalizeProviderId(providerId);
|
|
214
|
+
const configPath = getWorkspaceOpencodeConfigPath();
|
|
215
|
+
const configRecord = await readOpencodeConfig(configPath);
|
|
216
|
+
const providerRecord = configRecord.provider ?? {};
|
|
217
|
+
const existingProviderConfig = providerRecord[normalizedProviderId];
|
|
218
|
+
configRecord.provider = {
|
|
219
|
+
...providerRecord,
|
|
220
|
+
[normalizedProviderId]: {
|
|
221
|
+
...(existingProviderConfig ?? {}),
|
|
222
|
+
npm: "@ai-sdk/azure",
|
|
223
|
+
name: "Azure OpenAI",
|
|
224
|
+
models: {
|
|
225
|
+
[deployment]: {
|
|
226
|
+
name: deployment,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
options: {
|
|
230
|
+
...(existingProviderConfig?.options ?? {}),
|
|
231
|
+
baseURL: `${endpoint}/openai`,
|
|
232
|
+
apiVersion,
|
|
233
|
+
useDeploymentBasedUrls: true,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
await writeOpencodeConfig(configPath, configRecord);
|
|
238
|
+
}
|
|
@@ -21,6 +21,7 @@ const WORKSPACE_DB_DIRECTORY = ".sqlite";
|
|
|
21
21
|
const WORKSPACE_DB_FILENAME = "data.db";
|
|
22
22
|
const HONEYTOKEN_UUID = "1f9f0b72-5f9f-4c9b-aef1-2fb2e0f6d8c4";
|
|
23
23
|
const HONEYTOKEN_FILE_NAME = `honeytoken-${HONEYTOKEN_UUID}.txt`;
|
|
24
|
+
const WORKSPACE_AZURE_PROVIDER_VERSION = "3.0.48";
|
|
24
25
|
function getWorkspaceDirFromEnv() {
|
|
25
26
|
let workspaceDir = (0, assert_1.assertEnv)("WORKSPACE_DIR");
|
|
26
27
|
if (!path_1.default.isAbsolute(workspaceDir)) {
|
|
@@ -178,6 +179,9 @@ function syncTemplateDirectory(sourceDirectory, targetDirectory, relativePath, i
|
|
|
178
179
|
mergeGitignoreFile(sourceEntryPath, targetEntryPath);
|
|
179
180
|
continue;
|
|
180
181
|
}
|
|
182
|
+
if (relativeEntryPath === ".opencode/opencode.json" && fs_1.default.existsSync(targetEntryPath)) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
181
185
|
if (entry.name === "package.json") {
|
|
182
186
|
mergePackageJsonFile(sourceEntryPath, targetEntryPath);
|
|
183
187
|
continue;
|
|
@@ -195,6 +199,9 @@ async function initializeWorkspaceNodeDependencies(workspaceDir) {
|
|
|
195
199
|
...(existingPackageJson.dependencies ?? {}),
|
|
196
200
|
"opencode-ai": "1.1.65",
|
|
197
201
|
};
|
|
202
|
+
if ((0, assert_1.assertEnv)("OPENCODE_MODEL").startsWith("azure-openai/")) {
|
|
203
|
+
dependencies["@ai-sdk/azure"] = WORKSPACE_AZURE_PROVIDER_VERSION;
|
|
204
|
+
}
|
|
198
205
|
const workspacePackageJson = {
|
|
199
206
|
...existingPackageJson,
|
|
200
207
|
dependencies,
|