@agimon-ai/po-claude-bridge 0.1.1-alpha.21 → 0.1.1-alpha.211
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 +32 -7
- package/dist/index.d.mts +10 -1
- package/dist/index.mjs +1800 -1494
- package/package.json +14 -12
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Standalone Pi extension that runs Claude Code through the Claude Agent SDK. It
|
|
|
4
4
|
registers the `claude-bridge` model provider and an optional `AskClaude` delegation
|
|
5
5
|
tool. It does not register a Po runtime extension or HTTP service.
|
|
6
6
|
|
|
7
|
+
Requires Node.js 24+, `@earendil-works/pi-ai`, `@earendil-works/pi-coding-agent`, and `@earendil-works/pi-tui` (all `^1.0.0`), `typebox@^1.3.27`, and `zod@^4.6.7`.
|
|
8
|
+
|
|
7
9
|
## Install from npm
|
|
8
10
|
|
|
9
11
|
```sh
|
|
@@ -76,7 +78,8 @@ Bridge diagnostics use the existing LogSink OTLP transport, under service
|
|
|
76
78
|
as usual. No collector is started by this package.
|
|
77
79
|
|
|
78
80
|
Without a collector, standalone Pi continues normally without writing fallback
|
|
79
|
-
log files. Diagnostic events export numeric and boolean metadata
|
|
81
|
+
log files. Diagnostic events export numeric and boolean metadata by default, plus
|
|
82
|
+
validated cache fingerprints, opaque query IDs, and fixed session-sync paths.
|
|
80
83
|
`CLAUDE_BRIDGE_DEBUG=1` enables debug events and SDK stderr capture. Add
|
|
81
84
|
`AGENT_OTEL_REDACT=0` only when you explicitly want verbose content, which may
|
|
82
85
|
include prompts, tool results, paths, and credentials, sent to the collector.
|
|
@@ -85,10 +88,36 @@ include prompts, tool results, paths, and credentials, sent to the collector.
|
|
|
85
88
|
when an agent settles or its session shuts down. The shared transport closes when
|
|
86
89
|
the process exits. `CLAUDE_BRIDGE_DEBUG_PATH` is no longer used.
|
|
87
90
|
|
|
91
|
+
Cache diagnostics work without debug mode or disabling redaction:
|
|
92
|
+
|
|
93
|
+
- `claude_bridge.cache_query`: a fresh provider query's `queryId`, `syncPath`
|
|
94
|
+
(`clean-start`, `empty-rebuild`, `reuse`, `append`, `rebuild`), SHA-256
|
|
95
|
+
`hostPromptHash` and `toolsHash`, change flags, and the gap between comparable
|
|
96
|
+
query starts. Comparisons require an explicit session owner and stay within
|
|
97
|
+
that owner, project, and model.
|
|
98
|
+
- `claude_bridge.cache_query_reuse`: tool results delivered to an existing SDK
|
|
99
|
+
query, rather than a new process. It carries the same `queryId`.
|
|
100
|
+
- `claude_bridge.cache_usage`: SDK query totals, emitted once on its result,
|
|
101
|
+
including standard `gen_ai.usage.*` input/output and cache-read/write counters,
|
|
102
|
+
available 5m/1h write counts, and
|
|
103
|
+
`cacheHitPercent = read / (input + read + write) * 100`.
|
|
104
|
+
AskClaude delegation emits this event with `askClaude: true`.
|
|
105
|
+
|
|
106
|
+
`requestedTtlSeconds` is 300 or 3600 for explicit short/long retention, otherwise
|
|
107
|
+
zero (automatic or disabled). `environmentTtlSeconds` records a recognized SDK
|
|
108
|
+
TTL environment override, otherwise zero. These are configuration inputs, not
|
|
109
|
+
proof of the effective TTL, which can also depend on Claude settings and account
|
|
110
|
+
policy. `cacheDisabled` records the child environment's disable switch.
|
|
111
|
+
|
|
112
|
+
Join query and usage events by `queryId`. Query totals overlap Pi's per-turn
|
|
113
|
+
usage: do not sum the two sources. A changed host fingerprint is a candidate for
|
|
114
|
+
cache invalidation, not proof: the SDK-rendered preset and actual API prefix are
|
|
115
|
+
not captured. Prompt snapshots and forwarding behavior remain unchanged.
|
|
116
|
+
|
|
88
117
|
Query from this repository:
|
|
89
118
|
|
|
90
119
|
```sh
|
|
91
|
-
pnpm --filter @agimon-ai/po-
|
|
120
|
+
pnpm --filter @agimon-ai/po-logsink exec po-logsink logs query --global --service po-claude-bridge --limit 20
|
|
92
121
|
```
|
|
93
122
|
|
|
94
123
|
Older collectors may still write `~/.log-sink-mcp/global/session.db`. Query that
|
|
@@ -101,13 +130,9 @@ does not migrate or restart the collector.
|
|
|
101
130
|
pnpm nx run-many -p @agimon-ai/po-claude-bridge -t build,typecheck,lint,test
|
|
102
131
|
```
|
|
103
132
|
|
|
104
|
-
Tests
|
|
133
|
+
Tests run with Vitest. They use scripted SDK queries, temporary session files, an
|
|
105
134
|
in-process MCP client, and Pi's extension loader. They do not verify live Claude
|
|
106
135
|
Code authentication or subscription billing.
|
|
107
|
-
|
|
108
|
-
Bun's matcher typings declare `.rejects` assertions as `void`, so the test-only
|
|
109
|
-
lint override permits awaiting them. Production type-aware lint remains enabled.
|
|
110
|
-
|
|
111
136
|
The imported implementation and tests remain at the package root and in `test/`
|
|
112
137
|
to retain their standalone structure. Runtime dependencies stay external to the
|
|
113
138
|
ESM build; Pi supplies the peer dependencies.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Context } from "@earendil-works/pi-ai";
|
|
2
2
|
import { SettingSource, query } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
import "cc-session-io";
|
|
3
4
|
import { ExtensionAPI, ExtensionUIContext } from "@earendil-works/pi-coding-agent";
|
|
4
5
|
//#region config.d.ts
|
|
5
6
|
interface Config {
|
|
@@ -40,7 +41,9 @@ interface SessionState {
|
|
|
40
41
|
}
|
|
41
42
|
interface SyncResult {
|
|
42
43
|
sessionId: string | null;
|
|
44
|
+
path: 'clean-start' | 'empty-rebuild' | 'reuse' | 'append' | 'rebuild';
|
|
43
45
|
}
|
|
46
|
+
type SyncDiagnostics = Record<string, string | number | boolean>;
|
|
44
47
|
type NotifyFn = (message: string, level: 'warning' | 'error') => void;
|
|
45
48
|
declare class SessionStore {
|
|
46
49
|
private state;
|
|
@@ -49,6 +52,8 @@ declare class SessionStore {
|
|
|
49
52
|
private inputHashes;
|
|
50
53
|
private inputPolicy;
|
|
51
54
|
private stagedHashes;
|
|
55
|
+
/** Why the last sync took its path; cache diagnostics only, never content. */
|
|
56
|
+
lastSyncDiagnostics: SyncDiagnostics;
|
|
52
57
|
constructor(notify?: NotifyFn);
|
|
53
58
|
get current(): SessionState | null;
|
|
54
59
|
clear(): void;
|
|
@@ -64,6 +69,8 @@ declare class SessionStore {
|
|
|
64
69
|
private policy;
|
|
65
70
|
matchesPrefix(messages: Context['messages'], map?: Map<string, string>, model?: string, cwd?: string | undefined, owner?: string | undefined): boolean;
|
|
66
71
|
private matchesHashes;
|
|
72
|
+
/** Which matchesHashes condition failed, checked in the same order. */
|
|
73
|
+
private mismatchReason;
|
|
67
74
|
/** Tail not yet handled by the live query (including busy steering). */
|
|
68
75
|
unacceptedTail(messages: Context['messages']): Context['messages'];
|
|
69
76
|
accept(messages: Context['messages'], map?: Map<string, string>, model?: string): void;
|
|
@@ -87,6 +94,8 @@ interface BridgeRuntime {
|
|
|
87
94
|
}
|
|
88
95
|
//#endregion
|
|
89
96
|
//#region index.d.ts
|
|
90
|
-
export declare function registerClaudeBridge(pi: ExtensionAPI
|
|
97
|
+
export declare function registerClaudeBridge(pi: ExtensionAPI, options?: {
|
|
98
|
+
cwd?: string;
|
|
99
|
+
}): BridgeRuntime;
|
|
91
100
|
//#endregion
|
|
92
101
|
export { registerClaudeBridge as default };
|