nemo-fabric-adapters-opencode 0.5.0-beta.3 → 0.5.0-rc.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/README.md +14 -2
- package/dist/configuration.js +4 -16
- package/opencode.fabric-adapter.json +12 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -41,8 +41,20 @@ The adapter supports the following configuration:
|
|
|
41
41
|
### Model Endpoints
|
|
42
42
|
|
|
43
43
|
`models.<role>.base_url` must point to an OpenAI-compatible Chat Completions
|
|
44
|
-
endpoint, not an OpenCode server.
|
|
45
|
-
|
|
44
|
+
endpoint, not an OpenCode server.
|
|
45
|
+
|
|
46
|
+
HTTPS is required by default, except for loopback HTTP. For a trusted Docker or Kubernetes gateway, set `harness.settings.insecure_http_model_hosts` to the exact hostnames that can receive HTTP model requests. Entries contain only hostnames or IPv4 addresses, without schemes, ports, paths, or wildcards. Matching ignores case and a trailing DNS dot, and permits any port or path on the listed host. The adapter does not resolve DNS to infer trust. Allowlisted HTTP endpoints receive model credentials and prompt content over an unencrypted connection. This setting applies only to model endpoints; MCP endpoint restrictions are unchanged.
|
|
47
|
+
|
|
48
|
+
For example, allow the gateway hosts used by your deployment:
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
harness:
|
|
52
|
+
settings:
|
|
53
|
+
insecure_http_model_hosts:
|
|
54
|
+
- host.docker.internal
|
|
55
|
+
- release-nhx-api
|
|
56
|
+
- gateway.namespace.svc.cluster.local
|
|
57
|
+
```
|
|
46
58
|
|
|
47
59
|
`temperature` and `top_p` are supported only with `base_url`. The adapter removes
|
|
48
60
|
OpenCode's `prompt_cache_key` extension for compatibility with providers that
|
package/dist/configuration.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { LifecycleError } from "nemo-fabric-adapters-common";
|
|
3
|
+
import { LifecycleError, insecureHttpModelHosts, modelEndpointAllowed } from "nemo-fabric-adapters-common";
|
|
4
4
|
const ENVIRONMENT_VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/u;
|
|
5
|
-
function loopbackHostname(hostname) {
|
|
6
|
-
return hostname === "localhost" || hostname === "::1" || hostname === "[::1]" || /^127(?:\.\d{1,3}){3}$/u.test(hostname);
|
|
7
|
-
}
|
|
8
|
-
function validEndpoint(value) {
|
|
9
|
-
try {
|
|
10
|
-
const url = new URL(value);
|
|
11
|
-
return url.protocol === "https:" || (url.protocol === "http:" && loopbackHostname(url.hostname));
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
5
|
function sampling(model, baseUrl) {
|
|
18
6
|
if (model.max_tokens !== undefined && model.max_tokens !== null) {
|
|
19
7
|
throw new LifecycleError("opencode_max_tokens_unsupported", "OpenCode does not support models.max_tokens");
|
|
@@ -39,7 +27,7 @@ function sampling(model, baseUrl) {
|
|
|
39
27
|
...(typeof model.top_p === "number" ? { topP: model.top_p } : {}),
|
|
40
28
|
};
|
|
41
29
|
}
|
|
42
|
-
function validModel(model) {
|
|
30
|
+
function validModel(model, insecureHosts) {
|
|
43
31
|
if (typeof model.provider !== "string" ||
|
|
44
32
|
model.provider.length === 0 ||
|
|
45
33
|
typeof model.model !== "string" ||
|
|
@@ -50,7 +38,7 @@ function validModel(model) {
|
|
|
50
38
|
}
|
|
51
39
|
if (model.base_url !== undefined &&
|
|
52
40
|
model.base_url !== null &&
|
|
53
|
-
(typeof model.base_url !== "string" || !
|
|
41
|
+
(typeof model.base_url !== "string" || !modelEndpointAllowed(model.base_url, insecureHosts))) {
|
|
54
42
|
throw new LifecycleError("opencode_invalid_model", "OpenCode model configuration does not match the adapter schema");
|
|
55
43
|
}
|
|
56
44
|
const baseUrl = typeof model.base_url === "string" ? model.base_url : undefined;
|
|
@@ -72,7 +60,7 @@ export function selectModel(config) {
|
|
|
72
60
|
if (selected === undefined) {
|
|
73
61
|
throw new LifecycleError("opencode_model_ambiguous", "Configure a default model role when the OpenCode adapter receives multiple models");
|
|
74
62
|
}
|
|
75
|
-
return validModel(selected);
|
|
63
|
+
return validModel(selected, insecureHttpModelHosts(config.harness?.settings, "opencode_invalid_settings"));
|
|
76
64
|
}
|
|
77
65
|
export function selectSystemInstruction(config) {
|
|
78
66
|
const instruction = config.instructions?.system;
|
|
@@ -50,6 +50,18 @@
|
|
|
50
50
|
}
|
|
51
51
|
]
|
|
52
52
|
},
|
|
53
|
+
"settings_schema": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"properties": {
|
|
56
|
+
"insecure_http_model_hosts": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"items": {"type": "string", "maxLength": 253, "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$"},
|
|
59
|
+
"uniqueItems": true,
|
|
60
|
+
"description": "Explicitly trusted HTTP model endpoint hostnames, without schemes, ports, paths, or wildcards."
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"additionalProperties": false
|
|
64
|
+
},
|
|
53
65
|
"capabilities": {
|
|
54
66
|
"streaming": false,
|
|
55
67
|
"cancellation": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nemo-fabric-adapters-opencode",
|
|
3
|
-
"version": "0.5.0-
|
|
3
|
+
"version": "0.5.0-rc.1",
|
|
4
4
|
"description": "OpenCode v2 SDK harness adapter for NVIDIA NeMo Fabric.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"bun": ">=1.4.2"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"nemo-fabric-adapter-contract": "0.5.0-
|
|
46
|
-
"nemo-fabric-adapters-common": "0.5.0-
|
|
45
|
+
"nemo-fabric-adapter-contract": "0.5.0-rc.1",
|
|
46
|
+
"nemo-fabric-adapters-common": "0.5.0-rc.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@opencode/core": "2.0.23",
|