@zeulewan/glueclaw-provider 1.3.0 → 1.4.0
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 +12 -0
- package/index.ts +23 -2
- package/package.json +1 -1
- package/src/stream.ts +8 -4
package/README.md
CHANGED
|
@@ -50,6 +50,18 @@ The only way this breaks is if Anthropic changes how `--system-prompt` or `--out
|
|
|
50
50
|
|
|
51
51
|
Switch in TUI: `/model glueclaw/glueclaw-opus`
|
|
52
52
|
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
| Env var | Default | Description |
|
|
56
|
+
| ----------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `GLUECLAW_REQUEST_TIMEOUT_MS` | `120000` | Maximum time (in milliseconds) to wait for the Claude CLI subprocess to complete a single request before it is terminated. Increase if long-running tool calls or extensive reasoning trip the default 120s limit. Invalid or non-positive values fall back to the default. |
|
|
58
|
+
|
|
59
|
+
Example (10 minute timeout):
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
export GLUECLAW_REQUEST_TIMEOUT_MS=600000
|
|
63
|
+
```
|
|
64
|
+
|
|
53
65
|
## Notes
|
|
54
66
|
|
|
55
67
|
- Tested with Telegram and OpenClaw TUI
|
package/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
1
2
|
import {
|
|
2
3
|
definePluginEntry,
|
|
3
4
|
type OpenClawPluginApi,
|
|
4
5
|
} from "openclaw/plugin-sdk/plugin-entry";
|
|
5
6
|
import { createClaudeCliStreamFn } from "./src/stream.js";
|
|
6
7
|
import { MODEL_CATALOG } from "./src/catalog.js";
|
|
8
|
+
import { resolveSessionKey } from "./src/session-key.js";
|
|
7
9
|
|
|
8
10
|
const PROVIDER_ID = "glueclaw";
|
|
9
11
|
const PROVIDER_LABEL = "GlueClaw";
|
|
@@ -18,6 +20,17 @@ const MODEL_MAP: Readonly<Record<string, string>> = {
|
|
|
18
20
|
"glueclaw-haiku": "claude-haiku-4-5",
|
|
19
21
|
};
|
|
20
22
|
|
|
23
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 120_000;
|
|
24
|
+
|
|
25
|
+
function resolveRequestTimeoutMs(): number {
|
|
26
|
+
const raw = process.env.GLUECLAW_REQUEST_TIMEOUT_MS;
|
|
27
|
+
if (raw === undefined || raw === "") return DEFAULT_REQUEST_TIMEOUT_MS;
|
|
28
|
+
const parsed = Number(raw);
|
|
29
|
+
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
30
|
+
return DEFAULT_REQUEST_TIMEOUT_MS;
|
|
31
|
+
return parsed;
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
export default definePluginEntry({
|
|
22
35
|
register(api: OpenClawPluginApi): void {
|
|
23
36
|
const authProfile = () =>
|
|
@@ -69,11 +82,19 @@ export default definePluginEntry({
|
|
|
69
82
|
},
|
|
70
83
|
}),
|
|
71
84
|
},
|
|
72
|
-
createStreamFn: (ctx: {
|
|
85
|
+
createStreamFn: (ctx: {
|
|
86
|
+
modelId: string;
|
|
87
|
+
agentDir?: string;
|
|
88
|
+
sessionId?: string;
|
|
89
|
+
sessionKey?: string;
|
|
90
|
+
}) => {
|
|
73
91
|
const realModel = MODEL_MAP[ctx.modelId] ?? ctx.modelId;
|
|
92
|
+
const agentId = ctx.agentDir ? basename(ctx.agentDir) : undefined;
|
|
74
93
|
return createClaudeCliStreamFn({
|
|
75
|
-
sessionKey: ctx
|
|
94
|
+
sessionKey: resolveSessionKey(ctx),
|
|
95
|
+
agentId,
|
|
76
96
|
modelOverride: realModel,
|
|
97
|
+
requestTimeoutMs: resolveRequestTimeoutMs(),
|
|
77
98
|
});
|
|
78
99
|
},
|
|
79
100
|
resolveSyntheticAuth: () => ({
|
package/package.json
CHANGED
package/src/stream.ts
CHANGED
|
@@ -170,6 +170,7 @@ function evictSessions(): void {
|
|
|
170
170
|
export function createClaudeCliStreamFn(opts: {
|
|
171
171
|
claudeBin?: string;
|
|
172
172
|
sessionKey?: string;
|
|
173
|
+
agentId?: string;
|
|
173
174
|
modelOverride?: string;
|
|
174
175
|
requestTimeoutMs?: number;
|
|
175
176
|
}): StreamFn {
|
|
@@ -194,14 +195,17 @@ export function createClaudeCliStreamFn(opts: {
|
|
|
194
195
|
"--verbose",
|
|
195
196
|
"--include-partial-messages",
|
|
196
197
|
];
|
|
197
|
-
// Resume session for multi-turn conversation memory
|
|
198
|
+
// Resume session for multi-turn conversation memory.
|
|
199
|
+
// Always re-inject the system prompt — on resumptions the CLI would
|
|
200
|
+
// otherwise stick to whatever identity was used on the first turn,
|
|
201
|
+
// leaving no way for callers to reinforce or correct an agent's
|
|
202
|
+
// identity across turns.
|
|
198
203
|
const sessionKey = `glueclaw:${opts.sessionKey ?? "default"}`;
|
|
199
204
|
const existingSessionId = sessionMap.get(sessionKey);
|
|
200
205
|
if (existingSessionId) {
|
|
201
206
|
args.push("--resume", existingSessionId);
|
|
202
|
-
} else {
|
|
203
|
-
if (cleanPrompt) args.push("--system-prompt", cleanPrompt);
|
|
204
207
|
}
|
|
208
|
+
if (cleanPrompt) args.push("--system-prompt", cleanPrompt);
|
|
205
209
|
if (resolvedModel) args.push("--model", resolvedModel);
|
|
206
210
|
|
|
207
211
|
// Debug: log args for resume troubleshooting
|
|
@@ -233,7 +237,7 @@ export function createClaudeCliStreamFn(opts: {
|
|
|
233
237
|
args.push("--strict-mcp-config", "--mcp-config", mcp.path);
|
|
234
238
|
env.OPENCLAW_MCP_TOKEN = loopback.token;
|
|
235
239
|
env.OPENCLAW_MCP_SESSION_KEY = opts.sessionKey ?? "";
|
|
236
|
-
env.OPENCLAW_MCP_AGENT_ID = "main";
|
|
240
|
+
env.OPENCLAW_MCP_AGENT_ID = opts.agentId ?? "main";
|
|
237
241
|
env.OPENCLAW_MCP_ACCOUNT_ID = "";
|
|
238
242
|
env.OPENCLAW_MCP_MESSAGE_CHANNEL = "";
|
|
239
243
|
}
|