@tiny-fish/cli 0.35.1-next.290 → 0.35.1-next.291
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/lib/client.d.ts +1 -0
- package/dist/lib/client.js +13 -10
- package/package.json +1 -1
package/dist/lib/client.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type ConnectMap = Record<string, {
|
|
|
4
4
|
attempt_id: string;
|
|
5
5
|
}> | undefined;
|
|
6
6
|
export declare function buildConnectHeaders(connect: ConnectMap, caller: string | null): Record<string, string>;
|
|
7
|
+
export declare function resolveClientName(env?: Record<string, string | undefined>): string;
|
|
7
8
|
export declare function runSync(req: CliAgentRunParams, apiKey: string): Promise<AgentRunResponse>;
|
|
8
9
|
export declare function runAsync(req: CliAgentRunParams, apiKey: string): Promise<AgentRunAsyncResponse>;
|
|
9
10
|
export declare function runStream(req: CliAgentRunParams, apiKey: string, signal?: AbortSignal): AsyncGenerator<AgentRunWithStreamingResponse>;
|
package/dist/lib/client.js
CHANGED
|
@@ -29,6 +29,18 @@ function connectHeadersFor(client, attemptId) {
|
|
|
29
29
|
'X-TF-Connect-Attempt-Id': attemptId,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
// Forwarded explicitly: the pinned published SDK may predate TF_CLIENT_* support.
|
|
33
|
+
// Non-printable chars make fetch throw; 128 is the server cap (client_name varchar(128)).
|
|
34
|
+
const sanitize = (value) => (value ?? '')
|
|
35
|
+
.replace(/[^\x20-\x7E]/g, '')
|
|
36
|
+
.trim()
|
|
37
|
+
.slice(0, 128);
|
|
38
|
+
// An explicit TF_CLIENT_NAME always wins over auto-detection, preserving the
|
|
39
|
+
// env-var forwarding contract added in PR #3781; otherwise fingerprint the
|
|
40
|
+
// calling harness so cli usage can be split by client (PF-3168).
|
|
41
|
+
export function resolveClientName(env = process.env) {
|
|
42
|
+
return sanitize(env['TF_CLIENT_NAME']) || sanitize(detectHarness(env) ?? undefined);
|
|
43
|
+
}
|
|
32
44
|
class TinyFishCliClient extends TinyFish {
|
|
33
45
|
_buildHeaders() {
|
|
34
46
|
const base = super._buildHeaders();
|
|
@@ -37,16 +49,7 @@ class TinyFishCliClient extends TinyFish {
|
|
|
37
49
|
'X-TF-Request-Origin': CLI_AGENT_IDENTITY,
|
|
38
50
|
'User-Agent': `${base['User-Agent'] ?? ''} @tiny-fish/cli/${CLI_VERSION}`.trim(),
|
|
39
51
|
};
|
|
40
|
-
|
|
41
|
-
// Non-printable chars make fetch throw; 128 is the server cap (client_name varchar(128)).
|
|
42
|
-
const sanitize = (value) => (value ?? '')
|
|
43
|
-
.replace(/[^\x20-\x7E]/g, '')
|
|
44
|
-
.trim()
|
|
45
|
-
.slice(0, 128);
|
|
46
|
-
// An explicit TF_CLIENT_NAME always wins over auto-detection, preserving the
|
|
47
|
-
// env-var forwarding contract added in PR #3781; otherwise fingerprint the
|
|
48
|
-
// calling harness so cli usage can be split by client (PF-3168).
|
|
49
|
-
const clientName = sanitize(process.env['TF_CLIENT_NAME']) || sanitize(detectHarness() ?? undefined);
|
|
52
|
+
const clientName = resolveClientName();
|
|
50
53
|
const clientVersion = sanitize(process.env['TF_CLIENT_VERSION']);
|
|
51
54
|
if (clientName)
|
|
52
55
|
headers['X-TF-Client-Name'] = clientName;
|