beeos-claw 0.6.93 → 0.6.96

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.
@@ -1 +1 @@
1
- import{access,constants,readFile,stat}from"node:fs/promises";import{request as httpsRequest}from"node:https";import{createHash}from"node:crypto";import{basename,extname,resolve}from"node:path";import{HarnessProtocolError,RuntimeLeaseHttp,RuntimeOperationFiles,putPresignedUpload}from"@beeos-ai/cloud-harness-sdk";import{noteUploadedDeliverable}from"./delivery-ledger.js";const DEFAULT_TIMEOUT_MS=3e4,UPLOAD_REUSE_TTL_MS=18e5,MAX_REUSED_UPLOADS=256,completedUploads=new Map;let claimedCloudRuntimeInstanceId,_deps=null;export function setClaimedCloudRuntimeInstanceId(e){claimedCloudRuntimeInstanceId=e}export function setUploadDeps(e){_deps=e}export function getUploadDeps(){return _deps}export async function uploadLocalFile(e,t,r){if(void 0!==claimedCloudRuntimeInstanceId)throw new Error("native output file trusted tool capability required");await access(e,constants.R_OK);if(!(await stat(e)).isFile())throw new Error("not a regular file");const i=basename(e),a=r?.fileNameOverride??i,s=inferMimeType(a),n=await readFile(e);r?.signal?.throwIfAborted();const o=createHash("sha256").update(n).digest("hex"),p=JSON.stringify([t.baseUrl.origin,resolve(e),a,o]),d=Date.now();for(const[e,t]of completedUploads)t.expiresAt<=d&&completedUploads.delete(e);const l=completedUploads.get(p);if(l)return noteUploadedDeliverable(e),{...l.result};const c=AbortSignal.timeout(r?.timeoutMs??3e4),u=r?.signal?AbortSignal.any([r.signal,c]):c,m=await t.files.upload({fileName:a,mimeType:s,data:n,signal:u}),f={fileId:m.fileId,uri:m.uri,name:m.fileName,mimeType:m.mimeType,size:n.byteLength};if(!f.fileId)throw new Error("confirm returned no fileId");return completedUploads.size>=256&&completedUploads.delete(completedUploads.keys().next().value),completedUploads.set(p,{result:f,expiresAt:Date.now()+18e5}),noteUploadedDeliverable(e),{...f}}export class NativeOutputFilesError extends Error{category;detail;constructor(e,t,r){super(e),this.category=t,this.detail=r,this.name="NativeOutputFilesError"}}export async function uploadNativeOutputFile(e,t,r,i,a,s){r.assertAttempt(),await access(e,constants.R_OK);const n=await stat(e);if(!n.isFile()||n.size<=0||n.size>104857600)throw new Error("native output file size invalid");const o=await readFile(e);if(r.assertAttempt(),o.byteLength!==n.size)throw new Error("native output file changed while reading");const p=basename(e),d=inferMimeType(p),l=createHash("sha256").update(o).digest("hex"),c=createHash("sha256").update("beeos/native-output-file/v1\0"+r.operationId+"\0"+r.toolCallId+"\0"+i).digest("hex"),u=new URL(t);if(!["http:","https:"].includes(u.protocol)||u.username||u.password||"/"!==u.pathname||u.search||u.hash)throw new Error("native output Files origin invalid");const m=AbortSignal.any([r.signal,AbortSignal.timeout(s??3e4),...a?[a]:[]]),f={requestMessageId:r.requestMessageId,paramsHash:r.paramsHash,activeRunRegistrationId:r.activeRunRegistrationId,idempotencyKey:c},h=e=>!!e&&"object"==typeof e&&!Array.isArray(e),g=new RuntimeOperationFiles(new RuntimeLeaseHttp({origin:u.origin})),w=async(e,t)=>{r.assertAttempt();const i={runtimeLeaseCredential:r.getLease().runtimeLeaseCredential},a={...f,...t};let s;try{s="presign"===e?await g.presignOutput(i,r.operationId,a,m):await g.confirmOutput(i,r.operationId,a,m)}catch(t){if(t instanceof Error&&"runtime lease response origin changed"===t.message)throw new NativeOutputFilesError("native output Files response origin changed","control_response_origin",`stage=${e}`);if(!(t instanceof HarnessProtocolError))throw t;let r;const i=t.status??0;if(t.body)try{const e=JSON.parse(t.body);h(e)&&h(e.error)&&"string"==typeof e.error.code&&/^[A-Za-z0-9_.:-]{1,128}$/.test(e.error.code)&&(r=e.error.code)}catch(t){if(!(t instanceof SyntaxError))throw new NativeOutputFilesError("native output Files error decode failed","control_error_decode",`stage=${e} http_status=${i}`)}throw new NativeOutputFilesError("native output Files "+e+" failed ("+i+(r?","+r:"")+")","control_http_error",`stage=${e} http_status=${i} code=${r??"none"}`)}if(r.assertAttempt(),"string"==typeof s||void 0===s)throw new SyntaxError("native output Files response is not JSON");if(!h(n=s)||n.operationId!==r.operationId||n.requestMessageId!==f.requestMessageId||n.paramsHash!==f.paramsHash||n.activeRunRegistrationId!==f.activeRunRegistrationId)throw new NativeOutputFilesError("native output Files response binding invalid","control_response_binding",`stage=${e}`);var n;return s},y=await w("presign",{filename:p,content_type:d,size_bytes:o.byteLength,checksum_sha256:l}),v=y.upload,_=y.transferPolicy;if(!h(v)||!h(_)||"string"!=typeof _.allowedOrigin||"upload"!==v.direction||"PUT"!==v.http_method||"string"!=typeof v.file_id||!v.file_id||"string"!=typeof v.url||"string"!=typeof v.expires_at||!Number.isFinite(Date.parse(v.expires_at))||Date.parse(v.expires_at)<=Date.now()||v.content_type!==d||v.size_bytes!==o.byteLength||v.checksum_sha256!==l||!h(v.required_headers)||Object.values(v.required_headers).some(e=>"string"!=typeof e))throw new NativeOutputFilesError("native output Files transfer descriptor invalid","transfer_descriptor_invalid",descriptorDefect(v,_,d,o.byteLength,l));const b=new URL(v.url),x=new URL(_.allowedOrigin);if("https:"!==b.protocol||b.username||b.password||b.hash||"https:"!==x.protocol||x.username||x.password||"/"!==x.pathname||x.search||x.hash||x.origin!==_.allowedOrigin||b.origin!==x.origin)throw new NativeOutputFilesError("native output Files transfer origin invalid","transfer_origin_invalid",`target_matches_allowed=${b.origin===x.origin}`);r.assertAttempt();const I=v.required_headers,O=(await putPresignedUpload({url:b.toString(),allowedOrigin:x.origin,body:o,requiredHeaders:I,signal:m,fetchImpl:()=>putRequiredHeaders(b,I,o,m)})).status;if(r.assertAttempt(),O<200||O>=300)throw new NativeOutputFilesError("native output Files PUT failed ("+O+")","put_rejected",`http_status=${O} bytes=${o.byteLength} headers=${Object.keys(I).join(",")}`);let E;try{E=await w("confirm",{fileId:v.file_id,checksumSha256:l})}catch(e){if(r.assertAttempt(),m.throwIfAborted(),!(e instanceof TypeError||e instanceof SyntaxError))throw e;E=await w("confirm",{fileId:v.file_id,checksumSha256:l})}if(E.fileId!==v.file_id||E.fileName!==p||E.mimeType!==d||E.size!==o.byteLength)throw new NativeOutputFilesError("native output Files ready metadata mismatch","ready_metadata_mismatch",`fileId=${E.fileId===v.file_id} fileName=${E.fileName===p} mimeType=${E.mimeType===d} size=${E.size===o.byteLength}`);r.assertAttempt();const F={fileId:v.file_id,uri:"beeos-file://"+v.file_id,name:p,mimeType:d,size:o.byteLength};return noteUploadedDeliverable(e),F}function putRequiredHeaders(e,t,r,i){const a=Object.keys(t).find(e=>"content-length"===e.toLowerCase());if(void 0!==a&&t[a]!==String(r.byteLength))throw new NativeOutputFilesError("native output Files transfer descriptor invalid","transfer_descriptor_invalid",`field=required_headers.content-length bytes=${r.byteLength}`);return new Promise((a,s)=>{const n=e=>{s(e instanceof Error&&"AbortError"===e.name?e:new TypeError("fetch failed",{cause:e}))},o=httpsRequest(e,{method:"PUT",headers:t,signal:i},e=>{e.on("error",n),e.resume(),e.on("end",()=>a(new Response(null,{status:e.statusCode??0})))});o.on("error",n),o.end(r)})}function descriptorDefect(e,t,r,i,a){const s=e=>!!e&&"object"==typeof e&&!Array.isArray(e);if(!s(e))return"upload=absent";if(!s(t)||"string"!=typeof t.allowedOrigin)return"transferPolicy.allowedOrigin=invalid";const n=[["direction","upload"===e.direction],["http_method","PUT"===e.http_method],["file_id","string"==typeof e.file_id&&e.file_id.length>0],["url","string"==typeof e.url],["expires_at","string"==typeof e.expires_at&&Number.isFinite(Date.parse(e.expires_at))&&Date.parse(e.expires_at)>Date.now()],["content_type",e.content_type===r],["size_bytes",e.size_bytes===i],["checksum_sha256",e.checksum_sha256===a],["required_headers",s(e.required_headers)&&Object.values(e.required_headers).every(e=>"string"==typeof e)]];return`field=${n.find(([,e])=>!e)?.[0]??"none"} bytes=${i}`}function inferMimeType(e){switch(extname(e).toLowerCase()){case".txt":return"text/plain";case".md":return"text/markdown";case".json":return"application/json";case".html":return"text/html";case".css":return"text/css";case".js":case".mjs":case".cjs":return"text/javascript";case".ts":return"text/x.typescript";case".tsx":case".jsx":return"text/jsx";case".xml":return"application/xml";case".yaml":case".yml":return"application/yaml";case".toml":return"application/toml";case".pdf":return"application/pdf";case".doc":return"application/msword";case".docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case".xls":return"application/vnd.ms-excel";case".xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case".ppt":return"application/vnd.ms-powerpoint";case".pptx":return"application/vnd.openxmlformats-officedocument.presentationml.presentation";case".rtf":return"application/rtf";case".odt":return"application/vnd.oasis.opendocument.text";case".ods":return"application/vnd.oasis.opendocument.spreadsheet";case".odp":return"application/vnd.oasis.opendocument.presentation";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".svg":return"image/svg+xml";case".mp4":return"video/mp4";case".mov":return"video/quicktime";case".webm":return"video/webm";case".mkv":return"video/x-matroska";case".avi":return"video/x-msvideo";case".m4v":return"video/x-m4v";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".flac":return"audio/flac";case".aac":return"audio/aac";case".ogg":return"audio/ogg";case".m4a":return"audio/mp4";case".csv":return"text/csv";case".zip":return"application/zip";case".tar":return"application/x-tar";case".gz":case".tgz":return"application/gzip";default:return"application/octet-stream"}}
1
+ import{access,constants,readFile,realpath,stat}from"node:fs/promises";import{request as httpsRequest}from"node:https";import{createHash}from"node:crypto";import{basename,extname,isAbsolute,resolve,sep}from"node:path";import{HarnessProtocolError,RuntimeLeaseHttp,RuntimeOperationFiles,putPresignedUpload}from"@beeos-ai/cloud-harness-sdk";import{noteUploadedDeliverable}from"./delivery-ledger.js";const DEFAULT_TIMEOUT_MS=3e4,UPLOAD_REUSE_TTL_MS=18e5,MAX_REUSED_UPLOADS=256,completedUploads=new Map;let claimedCloudRuntimeInstanceId,_deps=null;export function setClaimedCloudRuntimeInstanceId(e){claimedCloudRuntimeInstanceId=e}export function setUploadDeps(e){_deps=e}export function getUploadDeps(){return _deps}export async function uploadLocalFile(e,t,r){if(void 0!==claimedCloudRuntimeInstanceId)throw new Error("native output file trusted tool capability required");await access(e,constants.R_OK);if(!(await stat(e)).isFile())throw new Error("not a regular file");const i=basename(e),a=r?.fileNameOverride??i,s=inferMimeType(a),n=await readFile(e);r?.signal?.throwIfAborted();const o=createHash("sha256").update(n).digest("hex"),p=JSON.stringify([t.baseUrl.origin,resolve(e),a,o]),l=Date.now();for(const[e,t]of completedUploads)t.expiresAt<=l&&completedUploads.delete(e);const c=completedUploads.get(p);if(c)return noteUploadedDeliverable(e),{...c.result};const d=AbortSignal.timeout(r?.timeoutMs??3e4),u=r?.signal?AbortSignal.any([r.signal,d]):d,m=await t.files.upload({fileName:a,mimeType:s,data:n,signal:u}),f={fileId:m.fileId,uri:m.uri,name:m.fileName,mimeType:m.mimeType,size:n.byteLength};if(!f.fileId)throw new Error("confirm returned no fileId");return completedUploads.size>=256&&completedUploads.delete(completedUploads.keys().next().value),completedUploads.set(p,{result:f,expiresAt:Date.now()+18e5}),noteUploadedDeliverable(e),{...f}}export class NativeOutputFilesError extends Error{category;detail;constructor(e,t,r){super(e),this.category=t,this.detail=r,this.name="NativeOutputFilesError"}}export async function nativeOutputPathWithinWorkspace(e,t){if(!t||!isAbsolute(t))throw new Error("native output workspace unavailable");const r=await realpath(t),i=isAbsolute(e)?e:resolve(r,e),a=await realpath(i);if(a!==r&&!a.startsWith(r+sep))throw new Error("native output file is outside this run's workspace");return a}export async function uploadNativeOutputFile(e,t,r,i,a,s){r.assertAttempt(),await access(e,constants.R_OK);const n=await stat(e);if(!n.isFile()||n.size<=0||n.size>104857600)throw new Error("native output file size invalid");const o=await readFile(e);if(r.assertAttempt(),o.byteLength!==n.size)throw new Error("native output file changed while reading");const p=basename(e),l=inferMimeType(p),c=createHash("sha256").update(o).digest("hex"),d=createHash("sha256").update("beeos/native-output-file/v1\0"+r.operationId+"\0"+r.toolCallId+"\0"+i).digest("hex"),u=new URL(t);if(!["http:","https:"].includes(u.protocol)||u.username||u.password||"/"!==u.pathname||u.search||u.hash)throw new Error("native output Files origin invalid");const m=AbortSignal.any([r.signal,AbortSignal.timeout(s??3e4),...a?[a]:[]]),f={requestMessageId:r.requestMessageId,paramsHash:r.paramsHash,activeRunRegistrationId:r.activeRunRegistrationId,idempotencyKey:d},h=e=>!!e&&"object"==typeof e&&!Array.isArray(e),g=new RuntimeOperationFiles(new RuntimeLeaseHttp({origin:u.origin})),w=async(e,t)=>{r.assertAttempt();const i={runtimeLeaseCredential:r.getLease().runtimeLeaseCredential},a={...f,...t};let s;try{s="presign"===e?await g.presignOutput(i,r.operationId,a,m):await g.confirmOutput(i,r.operationId,a,m)}catch(t){if(t instanceof Error&&"runtime lease response origin changed"===t.message)throw new NativeOutputFilesError("native output Files response origin changed","control_response_origin",`stage=${e}`);if(!(t instanceof HarnessProtocolError))throw t;let r;const i=t.status??0;if(t.body)try{const e=JSON.parse(t.body);h(e)&&h(e.error)&&"string"==typeof e.error.code&&/^[A-Za-z0-9_.:-]{1,128}$/.test(e.error.code)&&(r=e.error.code)}catch(t){if(!(t instanceof SyntaxError))throw new NativeOutputFilesError("native output Files error decode failed","control_error_decode",`stage=${e} http_status=${i}`)}throw new NativeOutputFilesError("native output Files "+e+" failed ("+i+(r?","+r:"")+")","control_http_error",`stage=${e} http_status=${i} code=${r??"none"}`)}if(r.assertAttempt(),"string"==typeof s||void 0===s)throw new SyntaxError("native output Files response is not JSON");if(!h(n=s)||n.operationId!==r.operationId||n.requestMessageId!==f.requestMessageId||n.paramsHash!==f.paramsHash||n.activeRunRegistrationId!==f.activeRunRegistrationId)throw new NativeOutputFilesError("native output Files response binding invalid","control_response_binding",`stage=${e}`);var n;return s},v=await w("presign",{filename:p,content_type:l,size_bytes:o.byteLength,checksum_sha256:c}),y=v.upload,_=v.transferPolicy;if(!h(y)||!h(_)||"string"!=typeof _.allowedOrigin||"upload"!==y.direction||"PUT"!==y.http_method||"string"!=typeof y.file_id||!y.file_id||"string"!=typeof y.url||"string"!=typeof y.expires_at||!Number.isFinite(Date.parse(y.expires_at))||Date.parse(y.expires_at)<=Date.now()||y.content_type!==l||y.size_bytes!==o.byteLength||y.checksum_sha256!==c||!h(y.required_headers)||Object.values(y.required_headers).some(e=>"string"!=typeof e))throw new NativeOutputFilesError("native output Files transfer descriptor invalid","transfer_descriptor_invalid",descriptorDefect(y,_,l,o.byteLength,c));const b=new URL(y.url),x=new URL(_.allowedOrigin);if("https:"!==b.protocol||b.username||b.password||b.hash||"https:"!==x.protocol||x.username||x.password||"/"!==x.pathname||x.search||x.hash||x.origin!==_.allowedOrigin||b.origin!==x.origin)throw new NativeOutputFilesError("native output Files transfer origin invalid","transfer_origin_invalid",`target_matches_allowed=${b.origin===x.origin}`);r.assertAttempt();const E=y.required_headers,I=(await putPresignedUpload({url:b.toString(),allowedOrigin:x.origin,body:o,requiredHeaders:E,signal:m,fetchImpl:()=>putRequiredHeaders(b,E,o,m)})).status;if(r.assertAttempt(),I<200||I>=300)throw new NativeOutputFilesError("native output Files PUT failed ("+I+")","put_rejected",`http_status=${I} bytes=${o.byteLength} headers=${Object.keys(E).join(",")}`);let O;try{O=await w("confirm",{fileId:y.file_id,checksumSha256:c})}catch(e){if(r.assertAttempt(),m.throwIfAborted(),!(e instanceof TypeError||e instanceof SyntaxError))throw e;O=await w("confirm",{fileId:y.file_id,checksumSha256:c})}if(O.fileId!==y.file_id||O.fileName!==p||O.mimeType!==l||O.size!==o.byteLength)throw new NativeOutputFilesError("native output Files ready metadata mismatch","ready_metadata_mismatch",`fileId=${O.fileId===y.file_id} fileName=${O.fileName===p} mimeType=${O.mimeType===l} size=${O.size===o.byteLength}`);r.assertAttempt();const F={fileId:y.file_id,uri:"beeos-file://"+y.file_id,name:p,mimeType:l,size:o.byteLength};return noteUploadedDeliverable(e),F}function putRequiredHeaders(e,t,r,i){const a=Object.keys(t).find(e=>"content-length"===e.toLowerCase());if(void 0!==a&&t[a]!==String(r.byteLength))throw new NativeOutputFilesError("native output Files transfer descriptor invalid","transfer_descriptor_invalid",`field=required_headers.content-length bytes=${r.byteLength}`);return new Promise((a,s)=>{const n=e=>{s(e instanceof Error&&"AbortError"===e.name?e:new TypeError("fetch failed",{cause:e}))},o=httpsRequest(e,{method:"PUT",headers:t,signal:i},e=>{e.on("error",n),e.resume(),e.on("end",()=>a(new Response(null,{status:e.statusCode??0})))});o.on("error",n),o.end(r)})}function descriptorDefect(e,t,r,i,a){const s=e=>!!e&&"object"==typeof e&&!Array.isArray(e);if(!s(e))return"upload=absent";if(!s(t)||"string"!=typeof t.allowedOrigin)return"transferPolicy.allowedOrigin=invalid";const n=[["direction","upload"===e.direction],["http_method","PUT"===e.http_method],["file_id","string"==typeof e.file_id&&e.file_id.length>0],["url","string"==typeof e.url],["expires_at","string"==typeof e.expires_at&&Number.isFinite(Date.parse(e.expires_at))&&Date.parse(e.expires_at)>Date.now()],["content_type",e.content_type===r],["size_bytes",e.size_bytes===i],["checksum_sha256",e.checksum_sha256===a],["required_headers",s(e.required_headers)&&Object.values(e.required_headers).every(e=>"string"==typeof e)]];return`field=${n.find(([,e])=>!e)?.[0]??"none"} bytes=${i}`}function inferMimeType(e){switch(extname(e).toLowerCase()){case".txt":return"text/plain";case".md":return"text/markdown";case".json":return"application/json";case".html":return"text/html";case".css":return"text/css";case".js":case".mjs":case".cjs":return"text/javascript";case".ts":return"text/x.typescript";case".tsx":case".jsx":return"text/jsx";case".xml":return"application/xml";case".yaml":case".yml":return"application/yaml";case".toml":return"application/toml";case".pdf":return"application/pdf";case".doc":return"application/msword";case".docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case".xls":return"application/vnd.ms-excel";case".xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case".ppt":return"application/vnd.ms-powerpoint";case".pptx":return"application/vnd.openxmlformats-officedocument.presentationml.presentation";case".rtf":return"application/rtf";case".odt":return"application/vnd.oasis.opendocument.text";case".ods":return"application/vnd.oasis.opendocument.spreadsheet";case".odp":return"application/vnd.oasis.opendocument.presentation";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".svg":return"image/svg+xml";case".mp4":return"video/mp4";case".mov":return"video/quicktime";case".webm":return"video/webm";case".mkv":return"video/x-matroska";case".avi":return"video/x-msvideo";case".m4v":return"video/x-m4v";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".flac":return"audio/flac";case".aac":return"audio/aac";case".ogg":return"audio/ogg";case".m4a":return"audio/mp4";case".csv":return"text/csv";case".zip":return"application/zip";case".tar":return"application/x-tar";case".gz":case".tgz":return"application/gzip";default:return"application/octet-stream"}}
@@ -18,6 +18,10 @@
18
18
  "beeos_discover_agents",
19
19
  "beeos_call_agent",
20
20
  "beeos_get_task",
21
+ "beeos_memory_remember",
22
+ "beeos_memory_recall",
23
+ "beeos_memory_revise",
24
+ "beeos_memory_forget",
21
25
  "beeos_automation_create",
22
26
  "beeos_automation_create_webhook",
23
27
  "beeos_automation_capabilities",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beeos-claw",
3
- "version": "0.6.93",
3
+ "version": "0.6.96",
4
4
  "description": "OpenClaw plugin that bridges the BeeOS platform with the local OpenClaw Gateway, providing file transfer, ACP bridge, and observability.",
5
5
  "license": "MIT",
6
6
  "author": "BeeOS <dev@beeos.ai>",
@@ -88,7 +88,10 @@
88
88
  "overrides": {
89
89
  "fast-uri": ">=3.1.4",
90
90
  "brace-expansion": ">=5.0.9",
91
- "@beeos-ai/beeos-types": "$@beeos-ai/beeos-types"
91
+ "@beeos-ai/beeos-types": "$@beeos-ai/beeos-types",
92
+ "body-parser": "2.4.0",
93
+ "zod": "4.6.7",
94
+ "qs": "6.16.1"
92
95
  },
93
- "gitHead": "278210cc10bb594c61ebef419bb16481d9fcab4c"
96
+ "gitHead": "bd6b67b59ecf8110733d116b6221110088733fbd"
94
97
  }