opencode-gitlab-duo-agentic 0.1.0 → 0.1.1

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.d.ts CHANGED
@@ -18,6 +18,7 @@ type GitLabDuoAgenticProviderOptions = {
18
18
  systemRules?: string;
19
19
  };
20
20
 
21
- declare function createGitLabDuoAgentic(options: GitLabDuoAgenticProviderOptions): ProviderV2;
21
+ type GitLabDuoAgenticProviderInput = Partial<GitLabDuoAgenticProviderOptions>;
22
+ declare function createGitLabDuoAgentic(options?: GitLabDuoAgenticProviderInput): ProviderV2;
22
23
 
23
24
  export { GitLabDuoAgenticPlugin, createGitLabDuoAgentic, GitLabDuoAgenticPlugin as default };
package/dist/index.js CHANGED
@@ -77,8 +77,8 @@ async function configHook(input) {
77
77
  const existing = input.provider[GITLAB_DUO_PROVIDER_ID];
78
78
  const existingOptions = existing?.options ?? {};
79
79
  const providerNpm = typeof existing?.npm === "string" && existing.npm.trim() ? existing.npm : GITLAB_DUO_PROVIDER_NPM_ENTRY;
80
- const apiKey = typeof existingOptions.apiKey === "string" ? existingOptions.apiKey : process.env.GITLAB_TOKEN || "";
81
- const instanceUrl = typeof existingOptions.instanceUrl === "string" ? existingOptions.instanceUrl : process.env.GITLAB_INSTANCE_URL || "https://gitlab.com";
80
+ const apiKey = typeof existingOptions.apiKey === "string" && existingOptions.apiKey.trim() ? existingOptions.apiKey.trim() : process.env.GITLAB_TOKEN || "";
81
+ const instanceUrl = typeof existingOptions.instanceUrl === "string" && existingOptions.instanceUrl.trim() ? existingOptions.instanceUrl.trim() : process.env.GITLAB_INSTANCE_URL?.trim() || "https://gitlab.com";
82
82
  const systemRules = typeof existingOptions.systemRules === "string" ? existingOptions.systemRules : "";
83
83
  const systemRulesPath = typeof existingOptions.systemRulesPath === "string" ? existingOptions.systemRulesPath : "";
84
84
  const modelsPath = typeof existingOptions.modelsPath === "string" ? existingOptions.modelsPath : void 0;
@@ -2334,24 +2334,54 @@ function assertDependencies() {
2334
2334
  );
2335
2335
  }
2336
2336
  }
2337
+ function resolveInstanceUrl(value) {
2338
+ if (typeof value === "string" && value.trim()) {
2339
+ const normalized = value.trim();
2340
+ assertInstanceUrl(normalized);
2341
+ return normalized;
2342
+ }
2343
+ const fromEnv = process.env.GITLAB_INSTANCE_URL?.trim();
2344
+ if (fromEnv) {
2345
+ assertInstanceUrl(fromEnv);
2346
+ return fromEnv;
2347
+ }
2348
+ return "https://gitlab.com";
2349
+ }
2337
2350
  function assertInstanceUrl(value) {
2338
2351
  try {
2339
2352
  new URL(value);
2340
2353
  } catch {
2341
- throw new Error(`Invalid instanceUrl: "${value}"`);
2354
+ throw new Error(
2355
+ `Invalid instanceUrl: "${value}". Expected an absolute URL (for example https://gitlab.com).`
2356
+ );
2342
2357
  }
2343
2358
  }
2344
- function createGitLabDuoAgentic(options) {
2359
+ function resolveApiKey(value) {
2360
+ if (typeof value === "string" && value.trim()) return value.trim();
2361
+ return process.env.GITLAB_TOKEN || "";
2362
+ }
2363
+ function createGitLabDuoAgentic(options = {}) {
2345
2364
  assertDependencies();
2346
- assertInstanceUrl(options.instanceUrl);
2365
+ const resolvedOptions = {
2366
+ instanceUrl: resolveInstanceUrl(options.instanceUrl),
2367
+ apiKey: resolveApiKey(options.apiKey),
2368
+ sendSystemContext: typeof options.sendSystemContext === "boolean" ? options.sendSystemContext : true,
2369
+ enableMcp: typeof options.enableMcp === "boolean" ? options.enableMcp : true,
2370
+ systemRules: typeof options.systemRules === "string" ? options.systemRules : void 0
2371
+ };
2372
+ if (!resolvedOptions.apiKey) {
2373
+ console.warn(
2374
+ "[gitlab-duo] GITLAB_TOKEN is empty for the OpenCode process. Ensure it is exported in the same shell."
2375
+ );
2376
+ }
2347
2377
  const container = createRuntimeContainer();
2348
2378
  const dependencies = container.resolve(
2349
2379
  RUNTIME_TOKENS.runtimeDependencies
2350
2380
  );
2351
- const sharedRuntime = new GitLabAgenticRuntime(options, dependencies);
2381
+ const sharedRuntime = new GitLabAgenticRuntime(resolvedOptions, dependencies);
2352
2382
  return {
2353
2383
  languageModel(modelId) {
2354
- return new GitLabDuoAgenticLanguageModel(modelId, options, sharedRuntime);
2384
+ return new GitLabDuoAgenticLanguageModel(modelId, resolvedOptions, sharedRuntime);
2355
2385
  },
2356
2386
  textEmbeddingModel() {
2357
2387
  throw new Error("GitLab Duo Agentic does not support text embedding models");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-gitlab-duo-agentic",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "OpenCode plugin and provider for GitLab Duo Agentic workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",