opencode-gateway 0.2.1 → 0.2.2
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 +2 -1
- package/dist/cli/templates.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/config/gateway.js +3 -2
- package/dist/config/memory.d.ts +1 -1
- package/dist/config/memory.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -93,5 +93,6 @@ Memory rules:
|
|
|
93
93
|
- `inject_markdown_contents = true` recursively injects `*.md` and `*.markdown`
|
|
94
94
|
- `globs` are relative to the configured directory and may match other UTF-8
|
|
95
95
|
text files
|
|
96
|
-
- relative paths are resolved from `opencode-gateway
|
|
96
|
+
- relative paths are resolved from `opencode-gateway-workspace`
|
|
97
|
+
- absolute paths are still allowed
|
|
97
98
|
- memory is injected only into gateway-managed sessions
|
package/dist/cli/templates.js
CHANGED
|
@@ -21,7 +21,7 @@ export function buildGatewayConfigTemplate(stateDbPath) {
|
|
|
21
21
|
"allowed_users = []",
|
|
22
22
|
"",
|
|
23
23
|
"# Optional long-lived memory sources injected into gateway-managed sessions.",
|
|
24
|
-
"# Relative paths are resolved from
|
|
24
|
+
"# Relative paths are resolved from opencode-gateway-workspace.",
|
|
25
25
|
"#",
|
|
26
26
|
"# [[memory.entries]]",
|
|
27
27
|
'# path = "memory/project.md"',
|
package/dist/cli.js
CHANGED
|
@@ -401,7 +401,7 @@ function buildGatewayConfigTemplate(stateDbPath) {
|
|
|
401
401
|
"allowed_users = []",
|
|
402
402
|
"",
|
|
403
403
|
"# Optional long-lived memory sources injected into gateway-managed sessions.",
|
|
404
|
-
"# Relative paths are resolved from
|
|
404
|
+
"# Relative paths are resolved from opencode-gateway-workspace.",
|
|
405
405
|
"#",
|
|
406
406
|
"# [[memory.entries]]",
|
|
407
407
|
'# path = "memory/project.md"',
|
package/dist/config/gateway.js
CHANGED
|
@@ -7,6 +7,7 @@ import { defaultGatewayStateDbPath, resolveGatewayConfigPath, resolveGatewayWork
|
|
|
7
7
|
import { parseTelegramConfig } from "./telegram";
|
|
8
8
|
export async function loadGatewayConfig(env = process.env) {
|
|
9
9
|
const configPath = resolveGatewayConfigPath(env);
|
|
10
|
+
const workspaceDirPath = resolveGatewayWorkspacePath(configPath);
|
|
10
11
|
const rawConfig = await readGatewayConfigFile(configPath);
|
|
11
12
|
const stateDbValue = rawConfig?.gateway?.state_db;
|
|
12
13
|
if (stateDbValue !== undefined && typeof stateDbValue !== "string") {
|
|
@@ -17,12 +18,12 @@ export async function loadGatewayConfig(env = process.env) {
|
|
|
17
18
|
configPath,
|
|
18
19
|
stateDbPath,
|
|
19
20
|
mediaRootPath: resolveMediaRootPath(stateDbPath),
|
|
20
|
-
workspaceDirPath
|
|
21
|
+
workspaceDirPath,
|
|
21
22
|
logLevel: parseGatewayLogLevel(rawConfig?.gateway?.log_level, "gateway.log_level"),
|
|
22
23
|
hasLegacyGatewayTimezone: rawConfig?.gateway?.timezone !== undefined,
|
|
23
24
|
legacyGatewayTimezone: readLegacyGatewayTimezone(rawConfig?.gateway?.timezone),
|
|
24
25
|
mailbox: parseMailboxConfig(rawConfig?.gateway?.mailbox),
|
|
25
|
-
memory: await parseMemoryConfig(rawConfig?.memory,
|
|
26
|
+
memory: await parseMemoryConfig(rawConfig?.memory, workspaceDirPath),
|
|
26
27
|
cron: parseCronConfig(rawConfig?.cron),
|
|
27
28
|
telegram: parseTelegramConfig(rawConfig?.channels?.telegram, env),
|
|
28
29
|
};
|
package/dist/config/memory.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ export type GatewayMemoryEntryConfig = {
|
|
|
15
15
|
injectMarkdownContents: boolean;
|
|
16
16
|
globs: string[];
|
|
17
17
|
};
|
|
18
|
-
export declare function parseMemoryConfig(value: unknown,
|
|
18
|
+
export declare function parseMemoryConfig(value: unknown, workspaceDirPath: string): Promise<GatewayMemoryConfig>;
|
package/dist/config/memory.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { stat } from "node:fs/promises";
|
|
2
|
-
import {
|
|
3
|
-
export async function parseMemoryConfig(value,
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
export async function parseMemoryConfig(value, workspaceDirPath) {
|
|
4
4
|
const table = readMemoryTable(value);
|
|
5
|
-
const entries = await readMemoryEntries(table.entries,
|
|
5
|
+
const entries = await readMemoryEntries(table.entries, workspaceDirPath);
|
|
6
6
|
return { entries };
|
|
7
7
|
}
|
|
8
8
|
function readMemoryTable(value) {
|
|
@@ -14,16 +14,16 @@ function readMemoryTable(value) {
|
|
|
14
14
|
}
|
|
15
15
|
return value;
|
|
16
16
|
}
|
|
17
|
-
async function readMemoryEntries(value,
|
|
17
|
+
async function readMemoryEntries(value, workspaceDirPath) {
|
|
18
18
|
if (value === undefined) {
|
|
19
19
|
return [];
|
|
20
20
|
}
|
|
21
21
|
if (!Array.isArray(value)) {
|
|
22
22
|
throw new Error("memory.entries must be an array when present");
|
|
23
23
|
}
|
|
24
|
-
return await Promise.all(value.map((entry, index) => readMemoryEntry(entry, index,
|
|
24
|
+
return await Promise.all(value.map((entry, index) => readMemoryEntry(entry, index, workspaceDirPath)));
|
|
25
25
|
}
|
|
26
|
-
async function readMemoryEntry(value, index,
|
|
26
|
+
async function readMemoryEntry(value, index, workspaceDirPath) {
|
|
27
27
|
const field = `memory.entries[${index}]`;
|
|
28
28
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
29
29
|
throw new Error(`${field} must be a table`);
|
|
@@ -31,7 +31,7 @@ async function readMemoryEntry(value, index, configPath) {
|
|
|
31
31
|
const entry = value;
|
|
32
32
|
const displayPath = readRequiredString(entry.path, `${field}.path`);
|
|
33
33
|
const description = readRequiredString(entry.description, `${field}.description`);
|
|
34
|
-
const resolvedPath = resolve(
|
|
34
|
+
const resolvedPath = resolve(workspaceDirPath, displayPath);
|
|
35
35
|
const metadata = await statPath(resolvedPath, `${field}.path`);
|
|
36
36
|
if (metadata.isFile()) {
|
|
37
37
|
ensureDirectoryOnlyFieldIsAbsent(entry.inject_markdown_contents, `${field}.inject_markdown_contents`);
|