@a1hvdy/cc-openclaw 0.8.0 → 0.9.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/dist/src/index.d.ts +10 -1
- package/dist/src/index.js +47 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/config-service.d.ts +106 -0
- package/dist/src/lib/config-service.js +217 -0
- package/dist/src/lib/config-service.js.map +1 -0
- package/dist/src/lib/config.d.ts +33 -14
- package/dist/src/lib/config.js +147 -34
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/index.d.ts +1 -1
- package/dist/src/lib/index.js +4 -1
- package/dist/src/lib/index.js.map +1 -1
- package/dist/src/openai-compat/message-extractor.d.ts +79 -0
- package/dist/src/openai-compat/message-extractor.js +134 -0
- package/dist/src/openai-compat/message-extractor.js.map +1 -0
- package/dist/src/openai-compat/mode-flags.d.ts +34 -0
- package/dist/src/openai-compat/mode-flags.js +44 -0
- package/dist/src/openai-compat/mode-flags.js.map +1 -0
- package/dist/src/openai-compat/non-streaming-handler.d.ts +26 -0
- package/dist/src/openai-compat/non-streaming-handler.js +108 -0
- package/dist/src/openai-compat/non-streaming-handler.js.map +1 -0
- package/dist/src/openai-compat/openai-compat.d.ts +15 -166
- package/dist/src/openai-compat/openai-compat.js +59 -849
- package/dist/src/openai-compat/openai-compat.js.map +1 -1
- package/dist/src/openai-compat/prompts.d.ts +47 -0
- package/dist/src/openai-compat/prompts.js +119 -0
- package/dist/src/openai-compat/prompts.js.map +1 -0
- package/dist/src/openai-compat/response-formatter.d.ts +33 -0
- package/dist/src/openai-compat/response-formatter.js +74 -0
- package/dist/src/openai-compat/response-formatter.js.map +1 -0
- package/dist/src/openai-compat/session-key-resolver.d.ts +41 -0
- package/dist/src/openai-compat/session-key-resolver.js +78 -0
- package/dist/src/openai-compat/session-key-resolver.js.map +1 -0
- package/dist/src/openai-compat/status-reporter.d.ts +30 -0
- package/dist/src/openai-compat/status-reporter.js +81 -0
- package/dist/src/openai-compat/status-reporter.js.map +1 -0
- package/dist/src/openai-compat/streaming-handler.d.ts +41 -0
- package/dist/src/openai-compat/streaming-handler.js +294 -0
- package/dist/src/openai-compat/streaming-handler.js.map +1 -0
- package/dist/src/openai-compat/tool-calls-parser.d.ts +34 -0
- package/dist/src/openai-compat/tool-calls-parser.js +93 -0
- package/dist/src/openai-compat/tool-calls-parser.js.map +1 -0
- package/dist/src/openai-compat/tool-results-serializer.d.ts +60 -0
- package/dist/src/openai-compat/tool-results-serializer.js +56 -0
- package/dist/src/openai-compat/tool-results-serializer.js.map +1 -0
- package/dist/src/session-bootstrap/cwd-patch.js +20 -13
- package/dist/src/session-bootstrap/cwd-patch.js.map +1 -1
- package/dist/src/types/index.d.ts +15 -0
- package/dist/src/types/index.js +16 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/route.d.ts +41 -0
- package/dist/src/types/route.js +12 -0
- package/dist/src/types/route.js.map +1 -0
- package/dist/src/types/runtime-config.d.ts +161 -0
- package/dist/src/types/runtime-config.js +118 -0
- package/dist/src/types/runtime-config.js.map +1 -0
- package/dist/src/types/session.d.ts +48 -0
- package/dist/src/types/session.js +20 -0
- package/dist/src/types/session.js.map +1 -0
- package/dist/src/types/sse.d.ts +38 -0
- package/dist/src/types/sse.js +12 -0
- package/dist/src/types/sse.js.map +1 -0
- package/dist/src/types/tool-bridge.d.ts +81 -0
- package/dist/src/types/tool-bridge.js +34 -0
- package/dist/src/types/tool-bridge.js.map +1 -0
- package/dist/src/types/upstream.d.ts +652 -0
- package/dist/src/types/upstream.js +145 -0
- package/dist/src/types/upstream.js.map +1 -0
- package/package.json +3 -2
- package/dist/src/lib/route-flag.d.ts +0 -49
- package/dist/src/lib/route-flag.js +0 -52
- package/dist/src/lib/route-flag.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster A — Session boundary types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the session vocabulary already established in the root
|
|
5
|
+
* `src/types.ts` module. New aliases (`SessionStartConfig`, `SessionMeta`)
|
|
6
|
+
* preview Cluster B's `SessionService` boundary without yet introducing
|
|
7
|
+
* a new shape — they're typed wrappers over today's `SessionConfig` /
|
|
8
|
+
* `ActiveSession`.
|
|
9
|
+
*
|
|
10
|
+
* `SessionName` is the branded type that Cluster D's `SessionRegistry`
|
|
11
|
+
* will use to enforce the `'openai-'` prefix routing discriminant
|
|
12
|
+
* (cwd-patch.ts:489 gates CWD redirect, tools restoration, CLAUDE.md
|
|
13
|
+
* injection on this prefix).
|
|
14
|
+
*
|
|
15
|
+
* NOT consumed yet — Cluster A first commit establishes the vocabulary.
|
|
16
|
+
*/
|
|
17
|
+
export type { SessionConfig as SessionStartConfig, SessionStats, ActiveSession, SessionInfo, SessionSendOptions, StreamCallbacks, StreamEvent, SendResult, SendOptions, TurnResult, CostBreakdown, ISession, EngineType, PermissionMode, EffortLevel, PluginConfig, HookConfig, CustomEngineConfig, } from '../types.js';
|
|
18
|
+
/**
|
|
19
|
+
* Branded session-name type. Prevents raw string from being passed where
|
|
20
|
+
* the `'openai-'` prefix is load-bearing. Use the constructors below to
|
|
21
|
+
* mint or strip the prefix — never construct directly.
|
|
22
|
+
*/
|
|
23
|
+
export type SessionName = string & {
|
|
24
|
+
readonly __brand: 'SessionName';
|
|
25
|
+
};
|
|
26
|
+
export declare const sessionNameFromKey: (key: string) => SessionName;
|
|
27
|
+
export declare const isOpenAiBridgeName: (name: SessionName) => boolean;
|
|
28
|
+
export declare const stripOpenAiPrefix: (name: SessionName) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Cluster B/D will fold this into `SessionRegistry.SessionEntry`. For
|
|
31
|
+
* Cluster A it's a typed preview — the shape Cluster D will persist,
|
|
32
|
+
* declared here so other clusters can compile against the contract.
|
|
33
|
+
*/
|
|
34
|
+
export interface SessionMeta {
|
|
35
|
+
readonly name: SessionName;
|
|
36
|
+
readonly claudeSessionId: string | null;
|
|
37
|
+
readonly pid: number | null;
|
|
38
|
+
readonly cachedSysPromptHash: string;
|
|
39
|
+
readonly skipPersistence: boolean;
|
|
40
|
+
readonly createdAt: number;
|
|
41
|
+
readonly updatedAt: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Input shape Cluster B's `SessionService.send()` accepts.
|
|
45
|
+
* Today's call sites pass either a string or an array of content blocks;
|
|
46
|
+
* this interface preserves both without yet committing to a tighter shape.
|
|
47
|
+
*/
|
|
48
|
+
export type SendInput = string | ReadonlyArray<unknown>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster A — Session boundary types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the session vocabulary already established in the root
|
|
5
|
+
* `src/types.ts` module. New aliases (`SessionStartConfig`, `SessionMeta`)
|
|
6
|
+
* preview Cluster B's `SessionService` boundary without yet introducing
|
|
7
|
+
* a new shape — they're typed wrappers over today's `SessionConfig` /
|
|
8
|
+
* `ActiveSession`.
|
|
9
|
+
*
|
|
10
|
+
* `SessionName` is the branded type that Cluster D's `SessionRegistry`
|
|
11
|
+
* will use to enforce the `'openai-'` prefix routing discriminant
|
|
12
|
+
* (cwd-patch.ts:489 gates CWD redirect, tools restoration, CLAUDE.md
|
|
13
|
+
* injection on this prefix).
|
|
14
|
+
*
|
|
15
|
+
* NOT consumed yet — Cluster A first commit establishes the vocabulary.
|
|
16
|
+
*/
|
|
17
|
+
export const sessionNameFromKey = (key) => `openai-${key}`;
|
|
18
|
+
export const isOpenAiBridgeName = (name) => name.startsWith('openai-');
|
|
19
|
+
export const stripOpenAiPrefix = (name) => name.replace(/^openai-/, '');
|
|
20
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/types/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA8BH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAe,EAAE,CAC7D,UAAU,GAAG,EAAiB,CAAC;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAiB,EAAW,EAAE,CAC/D,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAE7B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAiB,EAAU,EAAE,CAC7D,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster A — SSE wire-format types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the SSE types currently inline in `openai-compat.ts` and the
|
|
5
|
+
* Anthropic event types from `cli-stream-parser.ts` under a single import
|
|
6
|
+
* surface. Cluster B's `sse-translator.ts` already lives at
|
|
7
|
+
* `src/openai-compat/sse-translator.ts` — this module is its typed contract.
|
|
8
|
+
*
|
|
9
|
+
* NOT consumed yet — Cluster A first commit establishes the vocabulary.
|
|
10
|
+
*/
|
|
11
|
+
export type { OpenAIChatCompletionChunk as SseChunk, OpenAIToolCall, } from '../openai-compat/openai-compat.js';
|
|
12
|
+
export type { AnthropicEvent, AnthropicMessage, MessageUsage, MessageDeltaBody, ContentBlockStart, ContentBlockDelta, ParsedEvent, CliStreamParser, } from '../openai-compat/cli-stream-parser.js';
|
|
13
|
+
/**
|
|
14
|
+
* OpenAI `finish_reason` values cc-openclaw emits after mapping from
|
|
15
|
+
* Anthropic `stop_reason`:
|
|
16
|
+
* end_turn / stop_sequence → 'stop'
|
|
17
|
+
* tool_use → 'tool_calls'
|
|
18
|
+
* max_tokens → 'length'
|
|
19
|
+
* (cancelled / abort) → null (no finish_reason chunk)
|
|
20
|
+
*/
|
|
21
|
+
export type FinishReason = 'stop' | 'tool_calls' | 'length' | null;
|
|
22
|
+
/**
|
|
23
|
+
* One delta in an OpenAI streaming chunk. Cluster B will tighten this when
|
|
24
|
+
* `sse-translator.ts` is extracted into the typed boundary.
|
|
25
|
+
*/
|
|
26
|
+
export interface OpenAIDelta {
|
|
27
|
+
readonly role?: 'assistant' | 'system' | 'user' | 'tool';
|
|
28
|
+
readonly content?: string;
|
|
29
|
+
readonly tool_calls?: ReadonlyArray<{
|
|
30
|
+
readonly index: number;
|
|
31
|
+
readonly id?: string;
|
|
32
|
+
readonly type?: 'function';
|
|
33
|
+
readonly function?: {
|
|
34
|
+
readonly name?: string;
|
|
35
|
+
readonly arguments?: string;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster A — SSE wire-format types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the SSE types currently inline in `openai-compat.ts` and the
|
|
5
|
+
* Anthropic event types from `cli-stream-parser.ts` under a single import
|
|
6
|
+
* surface. Cluster B's `sse-translator.ts` already lives at
|
|
7
|
+
* `src/openai-compat/sse-translator.ts` — this module is its typed contract.
|
|
8
|
+
*
|
|
9
|
+
* NOT consumed yet — Cluster A first commit establishes the vocabulary.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=sse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../../src/types/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster A — Tool bridge contract.
|
|
3
|
+
*
|
|
4
|
+
* Declares the interface Cluster B's three tool-mode strategies will
|
|
5
|
+
* implement (`EmbeddedToolsBridge`, `PerMessageToolsBridge`,
|
|
6
|
+
* `NativeToolStreamBridge`). Lives in `src/types/` — pure type
|
|
7
|
+
* declaration, no runtime code, zero implementation yet.
|
|
8
|
+
*
|
|
9
|
+
* The mode → bridge selection in Cluster B is one-way: `bridges/factory.ts`
|
|
10
|
+
* imports from this module; `system-prompt-builder.ts` (the other
|
|
11
|
+
* potentially-circular dependency) accepts a `ToolMode` arg from the
|
|
12
|
+
* bridge rather than importing the factory. See PRP §11 Decision Log.
|
|
13
|
+
*
|
|
14
|
+
* NOT consumed yet — Cluster A first commit establishes the vocabulary.
|
|
15
|
+
*/
|
|
16
|
+
import type { OpenAIToolCall } from './route.js';
|
|
17
|
+
import type { OpenAIDelta } from './sse.js';
|
|
18
|
+
/**
|
|
19
|
+
* Three tool-handling modes documented in ARCHITECTURE.md §5.3:
|
|
20
|
+
*
|
|
21
|
+
* - Embedded — default. Tools embedded in session system prompt at
|
|
22
|
+
* create-time; NOT re-injected per turn; cacheable.
|
|
23
|
+
* - PerMessage — legacy `OPENAI_COMPAT_TOOLS_PER_MESSAGE=1`. Tool block
|
|
24
|
+
* prepended to every user message; defeats prompt caching;
|
|
25
|
+
* allows mutating tool list mid-session.
|
|
26
|
+
* - NativeStream — `CC_OPENCLAW_TOOL_STREAM=1`. Tools forwarded as
|
|
27
|
+
* `--tools` allowlist; native `tool_use` events flow
|
|
28
|
+
* through; SSE translator emits inline `delta.tool_calls`.
|
|
29
|
+
*/
|
|
30
|
+
export declare enum ToolMode {
|
|
31
|
+
Embedded = "embedded",
|
|
32
|
+
PerMessage = "per-message",
|
|
33
|
+
NativeStream = "native-stream"
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The tool definition shape OpenClaw's `createOpenClawCodingTools` produces
|
|
37
|
+
* and that callers send in `request.tools`. Shape mirrors the OpenAI tool
|
|
38
|
+
* definition. Cluster B will tighten when bridge implementations land.
|
|
39
|
+
*/
|
|
40
|
+
export interface ToolDefinition {
|
|
41
|
+
readonly type: 'function';
|
|
42
|
+
readonly function: {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly description?: string;
|
|
45
|
+
readonly parameters?: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Result of translating a single Anthropic `tool_use` event from the
|
|
50
|
+
* Claude CLI stream into an OpenAI streaming chunk delta. `null` means
|
|
51
|
+
* the bridge consumed the event but emitted nothing (e.g. mid-block
|
|
52
|
+
* input_json_delta accumulation).
|
|
53
|
+
*/
|
|
54
|
+
export type TranslatedToolUseDelta = OpenAIDelta | null;
|
|
55
|
+
/**
|
|
56
|
+
* The contract every tool-mode bridge must satisfy. Cluster B's three
|
|
57
|
+
* strategy classes live at `src/openai-compat/bridges/{embedded-tools,
|
|
58
|
+
* per-message,native-stream}.ts`. Each is constructed once per route
|
|
59
|
+
* request and discarded after the response is written.
|
|
60
|
+
*/
|
|
61
|
+
export interface IToolBridge {
|
|
62
|
+
readonly mode: ToolMode;
|
|
63
|
+
/**
|
|
64
|
+
* Build the system-prompt fragment that advertises the tool list to
|
|
65
|
+
* the model. Pure function — no I/O. Empty string when the bridge
|
|
66
|
+
* does not embed tools in the prompt (NativeStream).
|
|
67
|
+
*/
|
|
68
|
+
buildToolPreamble(tools: ReadonlyArray<ToolDefinition> | undefined): string;
|
|
69
|
+
/**
|
|
70
|
+
* Translate one parsed Anthropic event into an OpenAI delta if it
|
|
71
|
+
* represents a tool_use boundary. Returns `null` for events the
|
|
72
|
+
* bridge does not surface as tool_calls deltas.
|
|
73
|
+
*/
|
|
74
|
+
translateToolUse(event: unknown): TranslatedToolUseDelta;
|
|
75
|
+
/**
|
|
76
|
+
* Serialize an OpenAI tool_call result back into the format the
|
|
77
|
+
* bridge sends to Claude CLI on the next turn. Embedded + PerMessage
|
|
78
|
+
* use `<tool_result>` XML; NativeStream uses native blocks.
|
|
79
|
+
*/
|
|
80
|
+
serializeToolResult(call: OpenAIToolCall, result: string): string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster A — Tool bridge contract.
|
|
3
|
+
*
|
|
4
|
+
* Declares the interface Cluster B's three tool-mode strategies will
|
|
5
|
+
* implement (`EmbeddedToolsBridge`, `PerMessageToolsBridge`,
|
|
6
|
+
* `NativeToolStreamBridge`). Lives in `src/types/` — pure type
|
|
7
|
+
* declaration, no runtime code, zero implementation yet.
|
|
8
|
+
*
|
|
9
|
+
* The mode → bridge selection in Cluster B is one-way: `bridges/factory.ts`
|
|
10
|
+
* imports from this module; `system-prompt-builder.ts` (the other
|
|
11
|
+
* potentially-circular dependency) accepts a `ToolMode` arg from the
|
|
12
|
+
* bridge rather than importing the factory. See PRP §11 Decision Log.
|
|
13
|
+
*
|
|
14
|
+
* NOT consumed yet — Cluster A first commit establishes the vocabulary.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Three tool-handling modes documented in ARCHITECTURE.md §5.3:
|
|
18
|
+
*
|
|
19
|
+
* - Embedded — default. Tools embedded in session system prompt at
|
|
20
|
+
* create-time; NOT re-injected per turn; cacheable.
|
|
21
|
+
* - PerMessage — legacy `OPENAI_COMPAT_TOOLS_PER_MESSAGE=1`. Tool block
|
|
22
|
+
* prepended to every user message; defeats prompt caching;
|
|
23
|
+
* allows mutating tool list mid-session.
|
|
24
|
+
* - NativeStream — `CC_OPENCLAW_TOOL_STREAM=1`. Tools forwarded as
|
|
25
|
+
* `--tools` allowlist; native `tool_use` events flow
|
|
26
|
+
* through; SSE translator emits inline `delta.tool_calls`.
|
|
27
|
+
*/
|
|
28
|
+
export var ToolMode;
|
|
29
|
+
(function (ToolMode) {
|
|
30
|
+
ToolMode["Embedded"] = "embedded";
|
|
31
|
+
ToolMode["PerMessage"] = "per-message";
|
|
32
|
+
ToolMode["NativeStream"] = "native-stream";
|
|
33
|
+
})(ToolMode || (ToolMode = {}));
|
|
34
|
+
//# sourceMappingURL=tool-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-bridge.js","sourceRoot":"","sources":["../../../src/types/tool-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH;;;;;;;;;;;GAWG;AACH,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,sCAA0B,CAAA;IAC1B,0CAA8B,CAAA;AAChC,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB"}
|