@oyasmi/pipiclaw 0.5.9 → 0.6.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.
Files changed (39) hide show
  1. package/dist/agent/channel-runner.d.ts +5 -0
  2. package/dist/agent/channel-runner.js +59 -15
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/memory/consolidation.js +11 -2
  6. package/dist/memory/session.js +2 -2
  7. package/dist/memory/sidecar-worker.d.ts +1 -0
  8. package/dist/memory/sidecar-worker.js +56 -1
  9. package/dist/paths.d.ts +1 -0
  10. package/dist/paths.js +1 -0
  11. package/dist/runtime/bootstrap.d.ts +1 -0
  12. package/dist/runtime/bootstrap.js +50 -11
  13. package/dist/runtime/delivery.js +56 -5
  14. package/dist/runtime/dingtalk.d.ts +2 -0
  15. package/dist/runtime/dingtalk.js +14 -4
  16. package/dist/runtime/events.d.ts +3 -0
  17. package/dist/runtime/events.js +30 -5
  18. package/dist/security/command-guard.js +4 -0
  19. package/dist/security/config.d.ts +6 -0
  20. package/dist/security/config.js +38 -6
  21. package/dist/security/path-guard.js +4 -0
  22. package/dist/security/platform.d.ts +1 -0
  23. package/dist/security/platform.js +3 -0
  24. package/dist/settings.d.ts +4 -1
  25. package/dist/settings.js +31 -6
  26. package/dist/shared/config-diagnostics.d.ts +7 -0
  27. package/dist/shared/config-diagnostics.js +3 -0
  28. package/dist/tools/config.d.ts +7 -0
  29. package/dist/tools/config.js +63 -7
  30. package/dist/tools/index.d.ts +3 -0
  31. package/dist/tools/index.js +2 -2
  32. package/dist/web/client.d.ts +1 -0
  33. package/dist/web/client.js +30 -18
  34. package/dist/web/config.d.ts +1 -0
  35. package/dist/web/config.js +1 -0
  36. package/dist/web/fetch.d.ts +1 -0
  37. package/dist/web/fetch.js +7 -5
  38. package/dist/web/search-providers.js +6 -3
  39. package/package.json +1 -1
package/dist/web/fetch.js CHANGED
@@ -22,7 +22,7 @@ function isHtmlContent(contentType, body) {
22
22
  .toLowerCase();
23
23
  return head.startsWith("<!doctype") || head.startsWith("<html");
24
24
  }
25
- async function tryFetchViaJina(context, url, maxChars, signal) {
25
+ async function tryFetchViaJina(context, url, maxChars, maxResponseBytes, signal) {
26
26
  const client = createWebHttpClient({
27
27
  webConfig: context.webConfig,
28
28
  securityConfig: context.securityConfig,
@@ -37,6 +37,7 @@ async function tryFetchViaJina(context, url, maxChars, signal) {
37
37
  url: `https://r.jina.ai/${url}`,
38
38
  headers,
39
39
  timeoutMs: context.webConfig.fetch.timeoutMs,
40
+ maxResponseBytes,
40
41
  signal,
41
42
  });
42
43
  if (response.status < 200 || response.status >= 300 || !data.data?.content) {
@@ -59,7 +60,7 @@ async function tryFetchViaJina(context, url, maxChars, signal) {
59
60
  },
60
61
  };
61
62
  }
62
- async function fetchDirect(context, url, extractMode, maxChars, maxImageBytes, signal) {
63
+ async function fetchDirect(context, url, extractMode, maxChars, maxImageBytes, maxResponseBytes, signal) {
63
64
  const client = createWebHttpClient({
64
65
  webConfig: context.webConfig,
65
66
  securityConfig: context.securityConfig,
@@ -69,6 +70,7 @@ async function fetchDirect(context, url, extractMode, maxChars, maxImageBytes, s
69
70
  const response = await client.request({
70
71
  url,
71
72
  timeoutMs: context.webConfig.fetch.timeoutMs,
73
+ maxResponseBytes,
72
74
  signal,
73
75
  });
74
76
  if (response.status < 200 || response.status >= 300) {
@@ -127,19 +129,19 @@ async function fetchDirect(context, url, extractMode, maxChars, maxImageBytes, s
127
129
  }
128
130
  export async function runWebFetch(context, request, signal) {
129
131
  if (request.preferJina) {
130
- const jinaResult = await tryFetchViaJina(context, request.url, request.maxChars, signal);
132
+ const jinaResult = await tryFetchViaJina(context, request.url, request.maxChars, request.maxResponseBytes, signal);
131
133
  if (jinaResult) {
132
134
  return jinaResult;
133
135
  }
134
136
  }
135
137
  try {
136
- return await fetchDirect(context, request.url, request.extractMode, request.maxChars, request.maxImageBytes, signal);
138
+ return await fetchDirect(context, request.url, request.extractMode, request.maxChars, request.maxImageBytes, request.maxResponseBytes, signal);
137
139
  }
138
140
  catch (error) {
139
141
  if (!request.enableJinaFallback) {
140
142
  throw error;
141
143
  }
142
- const jinaResult = await tryFetchViaJina(context, request.url, request.maxChars, signal);
144
+ const jinaResult = await tryFetchViaJina(context, request.url, request.maxChars, request.maxResponseBytes, signal);
143
145
  if (jinaResult) {
144
146
  return jinaResult;
145
147
  }
@@ -19,6 +19,9 @@ function normalizeResult(item) {
19
19
  snippet,
20
20
  };
21
21
  }
22
+ function isProviderConfigStatus(status) {
23
+ return status === 400 || status === 401 || status === 403 || status === 422 || status === 429;
24
+ }
22
25
  class BraveSearchProvider {
23
26
  constructor(context) {
24
27
  this.context = context;
@@ -38,7 +41,7 @@ class BraveSearchProvider {
38
41
  signal,
39
42
  });
40
43
  if (response.status < 200 || response.status >= 300) {
41
- throw new WebSearchProviderError("provider", `Brave search failed with HTTP ${response.status}`);
44
+ throw new WebSearchProviderError(isProviderConfigStatus(response.status) ? "config" : "provider", `Brave search failed with HTTP ${response.status}`);
42
45
  }
43
46
  return (data.web?.results ?? [])
44
47
  .map((item) => normalizeResult({
@@ -71,7 +74,7 @@ class TavilySearchProvider {
71
74
  signal,
72
75
  });
73
76
  if (response.status < 200 || response.status >= 300) {
74
- throw new WebSearchProviderError("provider", `Tavily search failed with HTTP ${response.status}`);
77
+ throw new WebSearchProviderError(isProviderConfigStatus(response.status) ? "config" : "provider", `Tavily search failed with HTTP ${response.status}`);
75
78
  }
76
79
  return (data.results ?? [])
77
80
  .map((item) => normalizeResult({
@@ -101,7 +104,7 @@ class JinaSearchProvider {
101
104
  signal,
102
105
  });
103
106
  if (response.status < 200 || response.status >= 300) {
104
- throw new WebSearchProviderError("provider", `Jina search failed with HTTP ${response.status}`);
107
+ throw new WebSearchProviderError(isProviderConfigStatus(response.status) ? "config" : "provider", `Jina search failed with HTTP ${response.status}`);
105
108
  }
106
109
  return (data.data ?? [])
107
110
  .map((item) => normalizeResult({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.5.9",
3
+ "version": "0.6.0",
4
4
  "description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
5
5
  "type": "module",
6
6
  "bin": {