@aliou/pi-linkup 0.6.1 → 0.6.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @aliou/pi-linkup
2
2
 
3
+ ## 0.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - f591230: fix: forward abort signal to HTTP requests so cancellation propagates
8
+
3
9
  ## 0.6.1
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliou/pi-linkup",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/aliou/pi-linkup"
package/src/client.ts CHANGED
@@ -28,9 +28,11 @@ export class LinkupClient {
28
28
  private async request<T>(
29
29
  endpoint: string,
30
30
  options: RequestInit = {},
31
+ signal?: AbortSignal,
31
32
  ): Promise<T> {
32
33
  const response = await fetch(`${BASE_URL}${endpoint}`, {
33
34
  ...options,
35
+ signal,
34
36
  headers: {
35
37
  Authorization: `Bearer ${this.apiKey}`,
36
38
  "Content-Type": "application/json",
@@ -54,28 +56,38 @@ export class LinkupClient {
54
56
  query: string;
55
57
  depth: SearchDepthType;
56
58
  outputType: "searchResults" | "sourcedAnswer";
59
+ signal?: AbortSignal;
57
60
  }): Promise<LinkupSearchResponse | LinkupSourcedAnswerResponse> {
58
- return this.request("/search", {
59
- method: "POST",
60
- body: JSON.stringify({
61
- q: params.query,
62
- depth: params.depth,
63
- outputType: params.outputType,
64
- }),
65
- });
61
+ return this.request(
62
+ "/search",
63
+ {
64
+ method: "POST",
65
+ body: JSON.stringify({
66
+ q: params.query,
67
+ depth: params.depth,
68
+ outputType: params.outputType,
69
+ }),
70
+ },
71
+ params.signal,
72
+ );
66
73
  }
67
74
 
68
75
  async fetch(params: {
69
76
  url: string;
70
77
  renderJs?: boolean;
78
+ signal?: AbortSignal;
71
79
  }): Promise<LinkupFetchResponse> {
72
- return this.request("/fetch", {
73
- method: "POST",
74
- body: JSON.stringify({
75
- url: params.url,
76
- renderJs: params.renderJs ?? true,
77
- }),
78
- });
80
+ return this.request(
81
+ "/fetch",
82
+ {
83
+ method: "POST",
84
+ body: JSON.stringify({
85
+ url: params.url,
86
+ renderJs: params.renderJs ?? true,
87
+ }),
88
+ },
89
+ params.signal,
90
+ );
79
91
  }
80
92
 
81
93
  async getBalance(): Promise<LinkupBalanceResponse> {
@@ -26,7 +26,7 @@ export function registerWebAnswerTool(pi: ExtensionAPI) {
26
26
  depth: Type.Optional(SearchDepth),
27
27
  }),
28
28
 
29
- async execute(_toolCallId, params, _signal, onUpdate, _ctx) {
29
+ async execute(_toolCallId, params, signal, onUpdate, _ctx) {
30
30
  const client = getClient();
31
31
 
32
32
  try {
@@ -44,6 +44,7 @@ export function registerWebAnswerTool(pi: ExtensionAPI) {
44
44
  query: params.query,
45
45
  depth: (params.depth ?? "standard") as SearchDepthType,
46
46
  outputType: "sourcedAnswer",
47
+ signal,
47
48
  })) as LinkupSourcedAnswerResponse;
48
49
 
49
50
  let content = `${response.answer}\n\n`;
@@ -28,7 +28,7 @@ export function registerWebFetchTool(pi: ExtensionAPI) {
28
28
  ),
29
29
  }),
30
30
 
31
- async execute(_toolCallId, params, _signal, onUpdate, _ctx) {
31
+ async execute(_toolCallId, params, signal, onUpdate, _ctx) {
32
32
  const client = getClient();
33
33
 
34
34
  try {
@@ -45,6 +45,7 @@ export function registerWebFetchTool(pi: ExtensionAPI) {
45
45
  const response = await client.fetch({
46
46
  url: params.url,
47
47
  renderJs: params.renderJs,
48
+ signal,
48
49
  });
49
50
 
50
51
  return {
@@ -25,7 +25,7 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
25
25
  depth: Type.Optional(SearchDepth),
26
26
  }),
27
27
 
28
- async execute(_toolCallId, params, _signal, onUpdate, _ctx) {
28
+ async execute(_toolCallId, params, signal, onUpdate, _ctx) {
29
29
  const client = getClient();
30
30
 
31
31
  try {
@@ -43,6 +43,7 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
43
43
  query: params.query,
44
44
  depth: (params.depth ?? "standard") as SearchDepthType,
45
45
  outputType: "searchResults",
46
+ signal,
46
47
  })) as LinkupSearchResponse;
47
48
 
48
49
  let content = `Found ${response.results.length} result(s):\n\n`;