@termfleet/core 0.1.2 → 0.1.4
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 +11 -2
- package/dist/local-tunnel.js +5 -2
- package/dist/provider-client.d.ts +4 -4
- package/dist/provider-client.js +3 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,7 +55,8 @@ const session = readLocalAgentSession({
|
|
|
55
55
|
sessionId: "claude:0f9c…", // or "codex:…", "gemini:…", or a bare Claude uuid
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
console.log(session.
|
|
58
|
+
console.log(session.sessionId); // "claude:0f9c…" (prefixed)
|
|
59
|
+
console.log(session.agentSessionId); // "0f9c…" (bare id, no prefix)
|
|
59
60
|
console.log(session.lastAssistantText);
|
|
60
61
|
console.log(session.endOfTurn); // is the turn finished?
|
|
61
62
|
for (const item of session.timeline) {
|
|
@@ -101,10 +102,18 @@ const off = client.onSnapshot((snapshot) => { /* … */ });
|
|
|
101
102
|
|
|
102
103
|
// create a fresh agent window (boot a claude/codex/gemini session)
|
|
103
104
|
await client.createAgentWindow({ /* AgentWindowCreateOptions */ });
|
|
105
|
+
|
|
106
|
+
// terminals + files: capture/send, and read/write through the provider filesystem
|
|
107
|
+
const { content } = await client.captureTerminal("term-1", 40);
|
|
108
|
+
await client.sendTerminalInput("term-1", "echo hi\n", { breakGlass: true });
|
|
109
|
+
const bytes = await client.readFile("term-1", "/path/file"); // Uint8Array (browser-safe)
|
|
110
|
+
const text = new TextDecoder().decode(bytes); // node: or Buffer.from(bytes)
|
|
104
111
|
```
|
|
105
112
|
|
|
106
113
|
Pass `{ authToken }` for an authenticated/shared provider, or a `urlResolver`
|
|
107
|
-
when proxying through a console; omit both for a direct connection.
|
|
114
|
+
when proxying through a console; omit both for a direct connection. `readFile`
|
|
115
|
+
returns a `Uint8Array` (not a node `Buffer`, since this client also runs in the
|
|
116
|
+
browser) — decode with `new TextDecoder().decode(bytes)` or `Buffer.from(bytes)`.
|
|
108
117
|
|
|
109
118
|
## What's inside
|
|
110
119
|
|
package/dist/local-tunnel.js
CHANGED
|
@@ -84,9 +84,12 @@ function startLocalTunnel(src, options) {
|
|
|
84
84
|
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
85
85
|
throw new Error(`Cannot tunnel iframe URL with invalid local port: ${src.href}`);
|
|
86
86
|
}
|
|
87
|
-
const bin = process.env.TERMFLEET_LOCAL_TUNNEL_BIN
|
|
87
|
+
const bin = process.env.TERMFLEET_LOCAL_TUNNEL_BIN;
|
|
88
|
+
if (!bin) {
|
|
89
|
+
throw new Error("Tunneling requires a tunnel client. Set TERMFLEET_LOCAL_TUNNEL_BIN to your tunnel client binary (or use a standalone tunnel like ngrok/cloudflared — see the README).");
|
|
90
|
+
}
|
|
88
91
|
if (!commandExists(bin)) {
|
|
89
|
-
throw new Error(`
|
|
92
|
+
throw new Error(`Tunnel client "${bin}" (TERMFLEET_LOCAL_TUNNEL_BIN) is not on PATH.`);
|
|
90
93
|
}
|
|
91
94
|
const tunnelServerUrl = process.env.TUNNEL_SERVER_URL ?? process.env.TERMFLEET_TUNNEL_SERVER_URL;
|
|
92
95
|
if (!tunnelServerUrl) {
|
|
@@ -120,15 +120,15 @@ export declare class ProviderClient {
|
|
|
120
120
|
}): Promise<CommandAck<T>>;
|
|
121
121
|
listDirectory(terminalId: string, path: string): Promise<ProviderDirectoryList>;
|
|
122
122
|
listDirectoryByFilesystem(filesystemId: string, path: string): Promise<ProviderDirectoryList>;
|
|
123
|
-
readFile(terminalId: string, path: string): Promise<
|
|
124
|
-
readFileByFilesystem(filesystemId: string, path: string): Promise<
|
|
123
|
+
readFile(terminalId: string, path: string): Promise<Uint8Array>;
|
|
124
|
+
readFileByFilesystem(filesystemId: string, path: string): Promise<Uint8Array>;
|
|
125
125
|
statFile(terminalId: string, path: string): Promise<ProviderFileStat>;
|
|
126
126
|
statFileByFilesystem(filesystemId: string, path: string): Promise<ProviderFileStat>;
|
|
127
|
-
writeFile(terminalId: string, path: string, data:
|
|
127
|
+
writeFile(terminalId: string, path: string, data: Uint8Array, options?: {
|
|
128
128
|
mkdirs?: boolean;
|
|
129
129
|
mode?: string;
|
|
130
130
|
}): Promise<ProviderFileWriteResult>;
|
|
131
|
-
writeFileByFilesystem(filesystemId: string, path: string, data:
|
|
131
|
+
writeFileByFilesystem(filesystemId: string, path: string, data: Uint8Array, options?: {
|
|
132
132
|
mkdirs?: boolean;
|
|
133
133
|
mode?: string;
|
|
134
134
|
}): Promise<ProviderFileWriteResult>;
|
package/dist/provider-client.js
CHANGED
|
@@ -385,6 +385,9 @@ export class ProviderClient {
|
|
|
385
385
|
}
|
|
386
386
|
return await response.json();
|
|
387
387
|
}
|
|
388
|
+
// Returns raw bytes as a Uint8Array (browser-safe — this client also runs in the
|
|
389
|
+
// browser, where node's Buffer is absent). Node consumers decode with
|
|
390
|
+
// `Buffer.from(bytes)` or `new TextDecoder().decode(bytes)`.
|
|
388
391
|
async readFile(terminalId, path) {
|
|
389
392
|
const url = new URL(`${this.apiBase}/api/files`);
|
|
390
393
|
url.searchParams.set("terminalId", terminalId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@termfleet/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Termfleet core: contracts, the provider SDK, and the agent-transcript/session library (Claude Code / Codex / Gemini). The reusable layer, usable beyond the console.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsc -p tsconfig.json",
|
|
40
|
-
"
|
|
40
|
+
"prepack": "tsc -p tsconfig.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"socket.io-client": "^4.8.3",
|