opencode-gitlab-duo-agentic 0.1.10 → 0.1.12

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
@@ -1,5 +1,9 @@
1
- import { Plugin } from '@opencode-ai/plugin';
1
+ import { ProviderV2 } from '@ai-sdk/provider';
2
+ import { Plugin, PluginInput, Hooks } from '@opencode-ai/plugin';
2
3
 
4
+ type EntryInput = PluginInput | Record<string, unknown>;
5
+ type EntryOutput = Promise<Hooks> | ProviderV2;
6
+ declare const createGitLabDuoAgentic: (input: EntryInput) => EntryOutput;
3
7
  declare const GitLabDuoAgenticPlugin: Plugin;
4
8
 
5
- export { GitLabDuoAgenticPlugin, GitLabDuoAgenticPlugin as default };
9
+ export { GitLabDuoAgenticPlugin, createGitLabDuoAgentic, GitLabDuoAgenticPlugin as default };
package/dist/index.js CHANGED
@@ -1,14 +1,16 @@
1
1
  // src/constants.ts
2
- var PROVIDER_ID = "gitlab-duo-agentic";
2
+ var PROVIDER_ID = "gitlab";
3
+ var MODEL_ID = "duo-agentic";
3
4
  var DEFAULT_INSTANCE_URL = "https://gitlab.com";
5
+ var NOT_IMPLEMENTED_MESSAGE = "GitLab Duo Agentic fallback model is configured, but the Duo Workflow runtime is not implemented yet.";
4
6
 
5
- // src/gitlab.ts
7
+ // src/utils/url.ts
6
8
  function text(value) {
7
9
  if (typeof value !== "string") return void 0;
8
10
  const trimmed = value.trim();
9
11
  return trimmed.length > 0 ? trimmed : void 0;
10
12
  }
11
- function instanceFromEnv() {
13
+ function envInstanceUrl() {
12
14
  return process.env.GITLAB_INSTANCE_URL ?? process.env.GITLAB_URL ?? process.env.GITLAB_BASE_URL;
13
15
  }
14
16
  function normalizeInstanceUrl(value) {
@@ -21,91 +23,101 @@ function normalizeInstanceUrl(value) {
21
23
  return DEFAULT_INSTANCE_URL;
22
24
  }
23
25
  }
24
- async function validateToken(instanceUrl, token) {
25
- const response = await fetch(`${instanceUrl}/api/v4/user`, {
26
- headers: {
27
- Authorization: `Bearer ${token}`
28
- }
29
- }).catch(() => void 0);
30
- return !!response?.ok;
31
- }
32
- async function persistInstanceUrl(input, instanceUrl) {
33
- await input.client.config.update({
34
- query: {
35
- directory: input.directory
36
- },
37
- body: {
38
- provider: {
39
- [PROVIDER_ID]: {
40
- options: {
41
- instanceUrl
42
- }
43
- }
44
- }
45
- }
46
- }).catch(() => void 0);
47
- }
48
- function applyGitLabConfig(config) {
26
+
27
+ // src/plugin/config.ts
28
+ function applyRuntimeConfig(config, moduleUrl) {
49
29
  config.provider ??= {};
50
30
  const current = config.provider[PROVIDER_ID] ?? {};
51
31
  const options = current.options ?? {};
52
- const instanceUrl = normalizeInstanceUrl(options.instanceUrl ?? instanceFromEnv());
32
+ const models = current.models ?? {};
33
+ const instanceUrl = normalizeInstanceUrl(options.instanceUrl ?? envInstanceUrl());
53
34
  config.provider[PROVIDER_ID] = {
54
35
  ...current,
36
+ name: current.name ?? "GitLab Duo Agentic",
37
+ npm: current.npm ?? moduleUrl,
38
+ env: current.env ?? ["GITLAB_TOKEN", "GITLAB_INSTANCE_URL"],
55
39
  options: {
56
40
  ...options,
57
41
  instanceUrl
42
+ },
43
+ models: Object.keys(models).length > 0 ? models : {
44
+ [MODEL_ID]: {
45
+ id: MODEL_ID,
46
+ name: "GitLab Duo Agentic (fallback)"
47
+ }
58
48
  }
59
49
  };
50
+ if (Array.isArray(config.disabled_providers)) {
51
+ config.disabled_providers = config.disabled_providers.filter((id) => id !== PROVIDER_ID);
52
+ }
53
+ if (Array.isArray(config.enabled_providers) && !config.enabled_providers.includes(PROVIDER_ID)) {
54
+ config.enabled_providers = [...config.enabled_providers, PROVIDER_ID];
55
+ }
56
+ }
57
+
58
+ // src/plugin/hooks.ts
59
+ async function createPluginHooks(_input, moduleUrl) {
60
+ return {
61
+ config: async (config) => applyRuntimeConfig(config, moduleUrl)
62
+ };
63
+ }
64
+
65
+ // src/provider/index.ts
66
+ import { NoSuchModelError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
67
+ function notImplemented() {
68
+ return new UnsupportedFunctionalityError({
69
+ functionality: "gitlab-duo-workflow-runtime",
70
+ message: NOT_IMPLEMENTED_MESSAGE
71
+ });
60
72
  }
61
- function createGitLabAuthHook(input) {
73
+ function fallbackModel(modelId) {
62
74
  return {
75
+ specificationVersion: "v2",
63
76
  provider: PROVIDER_ID,
64
- methods: [
65
- {
66
- type: "api",
67
- label: "GitLab Personal Access Token",
68
- prompts: [
69
- {
70
- type: "text",
71
- key: "instanceUrl",
72
- message: "GitLab instance URL",
73
- placeholder: "https://gitlab.com",
74
- validate: (value) => text(value) ? void 0 : "Instance URL is required"
75
- },
76
- {
77
- type: "text",
78
- key: "token",
79
- message: "GitLab token",
80
- placeholder: "glpat-...",
81
- validate: (value) => text(value) ? void 0 : "Token is required"
82
- }
83
- ],
84
- authorize: async (inputs = {}) => {
85
- const token = text(inputs.token);
86
- if (!token) return { type: "failed" };
87
- const instanceUrl = normalizeInstanceUrl(inputs.instanceUrl ?? instanceFromEnv());
88
- const valid = await validateToken(instanceUrl, token);
89
- if (!valid) return { type: "failed" };
90
- process.env.GITLAB_INSTANCE_URL = instanceUrl;
91
- await persistInstanceUrl(input, instanceUrl);
92
- return {
93
- type: "success",
94
- key: token
95
- };
96
- }
77
+ modelId,
78
+ supportedUrls: {},
79
+ async doGenerate(_options) {
80
+ throw notImplemented();
81
+ },
82
+ async doStream(_options) {
83
+ throw notImplemented();
84
+ }
85
+ };
86
+ }
87
+ function createFallbackProvider() {
88
+ return {
89
+ languageModel(modelId) {
90
+ if (modelId !== MODEL_ID) {
91
+ throw new NoSuchModelError({ modelId, modelType: "languageModel" });
97
92
  }
98
- ]
93
+ return fallbackModel(modelId);
94
+ },
95
+ textEmbeddingModel(modelId) {
96
+ throw new NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
97
+ },
98
+ imageModel(modelId) {
99
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
100
+ }
99
101
  };
100
102
  }
101
103
 
102
104
  // src/index.ts
103
- var GitLabDuoAgenticPlugin = async (input) => ({
104
- config: async (config) => applyGitLabConfig(config),
105
- auth: createGitLabAuthHook(input)
106
- });
105
+ function isPluginInput(value) {
106
+ if (!value || typeof value !== "object") return false;
107
+ const input = value;
108
+ return "client" in input && "project" in input && "directory" in input && "worktree" in input && "serverUrl" in input;
109
+ }
110
+ var entry = (input) => {
111
+ if (isPluginInput(input)) {
112
+ return createPluginHooks(input, import.meta.url);
113
+ }
114
+ return createFallbackProvider();
115
+ };
116
+ var createGitLabDuoAgentic = entry;
117
+ var GitLabDuoAgenticPlugin = entry;
107
118
  var src_default = GitLabDuoAgenticPlugin;
108
119
  export {
109
120
  GitLabDuoAgenticPlugin,
121
+ createGitLabDuoAgentic,
110
122
  src_default as default
111
123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-gitlab-duo-agentic",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "OpenCode plugin and provider for GitLab Duo Agentic workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",