opencode-gitlab-duo-agentic 0.1.11 → 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.
Files changed (2) hide show
  1. package/dist/index.js +3 -87
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  // src/constants.ts
2
- var PROVIDER_ID = "gitlab-duo-agentic";
2
+ var PROVIDER_ID = "gitlab";
3
3
  var MODEL_ID = "duo-agentic";
4
4
  var DEFAULT_INSTANCE_URL = "https://gitlab.com";
5
- var AUTH_KEY_PREFIX = "gitlab-duo-v1:";
6
- var NOT_IMPLEMENTED_MESSAGE = "gitlab-duo-agentic is configured, but the Duo Workflow runtime is not implemented yet.";
5
+ var NOT_IMPLEMENTED_MESSAGE = "GitLab Duo Agentic fallback model is configured, but the Duo Workflow runtime is not implemented yet.";
7
6
 
8
7
  // src/utils/url.ts
9
8
  function text(value) {
@@ -25,88 +24,6 @@ function normalizeInstanceUrl(value) {
25
24
  }
26
25
  }
27
26
 
28
- // src/plugin/auth.ts
29
- function encodeAuthKey(value) {
30
- const payload = Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
31
- return `${AUTH_KEY_PREFIX}${payload}`;
32
- }
33
- function decodeAuthKey(key) {
34
- if (!key.startsWith(AUTH_KEY_PREFIX)) {
35
- return { token: key };
36
- }
37
- try {
38
- const payload = key.slice(AUTH_KEY_PREFIX.length);
39
- const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
40
- return {
41
- token: text(parsed.token),
42
- instanceUrl: text(parsed.instanceUrl)
43
- };
44
- } catch {
45
- return { token: key };
46
- }
47
- }
48
- async function validateToken(instanceUrl, token) {
49
- const response = await fetch(`${instanceUrl}/api/v4/user`, {
50
- headers: {
51
- Authorization: `Bearer ${token}`
52
- }
53
- }).catch(() => void 0);
54
- return !!response?.ok;
55
- }
56
- function createAuthHook() {
57
- return {
58
- provider: PROVIDER_ID,
59
- loader: async (getAuth, provider) => {
60
- const auth = await getAuth();
61
- const decoded = auth?.type === "api" ? decodeAuthKey(auth.key) : {};
62
- const options = provider.options ?? {};
63
- const instanceUrl = normalizeInstanceUrl(decoded.instanceUrl ?? options.instanceUrl ?? envInstanceUrl());
64
- if (!decoded.token) {
65
- return {
66
- instanceUrl
67
- };
68
- }
69
- return {
70
- apiKey: decoded.token,
71
- instanceUrl
72
- };
73
- },
74
- methods: [
75
- {
76
- type: "api",
77
- label: "GitLab Personal Access Token",
78
- prompts: [
79
- {
80
- type: "text",
81
- key: "instanceUrl",
82
- message: "GitLab instance URL",
83
- placeholder: "https://gitlab.com",
84
- validate: (value) => text(value) ? void 0 : "Instance URL is required"
85
- },
86
- {
87
- type: "text",
88
- key: "token",
89
- message: "GitLab token",
90
- placeholder: "glpat-...",
91
- validate: (value) => text(value) ? void 0 : "Token is required"
92
- }
93
- ],
94
- authorize: async (inputs = {}) => {
95
- const token = text(inputs.token);
96
- if (!token) return { type: "failed" };
97
- const instanceUrl = normalizeInstanceUrl(inputs.instanceUrl ?? envInstanceUrl());
98
- const valid = await validateToken(instanceUrl, token);
99
- if (!valid) return { type: "failed" };
100
- return {
101
- type: "success",
102
- key: encodeAuthKey({ token, instanceUrl })
103
- };
104
- }
105
- }
106
- ]
107
- };
108
- }
109
-
110
27
  // src/plugin/config.ts
111
28
  function applyRuntimeConfig(config, moduleUrl) {
112
29
  config.provider ??= {};
@@ -141,8 +58,7 @@ function applyRuntimeConfig(config, moduleUrl) {
141
58
  // src/plugin/hooks.ts
142
59
  async function createPluginHooks(_input, moduleUrl) {
143
60
  return {
144
- config: async (config) => applyRuntimeConfig(config, moduleUrl),
145
- auth: createAuthHook()
61
+ config: async (config) => applyRuntimeConfig(config, moduleUrl)
146
62
  };
147
63
  }
148
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-gitlab-duo-agentic",
3
- "version": "0.1.11",
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",