@squidcloud/backend 1.0.496 → 1.0.498
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/backend/src/langgraph/index.d.ts +39 -0
- package/dist/backend/src/langgraph/langgraph-runner.d.ts +1 -0
- package/dist/backend/src/langgraph/squid-checkpointer.d.ts +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/langgraph.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/langgraph.js +1 -0
- package/dist/internal-common/src/public-types-backend/bundle-api.public-types.d.ts +1 -1
- package/dist/internal-common/src/public-types-backend/bundle-data.public-types.d.ts +1 -1
- package/dist/node_modules/@langchain/protocol/protocol.d.ts +760 -0
- package/package.json +24 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPassiveSquid as t,metadata as e}from"@squidcloud/backend";import{Command as a}from"@langchain/langgraph";import{BaseCheckpointSaver as n,WRITES_IDX_MAP as o,copyCheckpoint as i,getCheckpointId as r}from"@langchain/langgraph-checkpoint";let c=t=>new Error(t);function s(t,e,...a){t||function(t,...e){const a=function(t){return void 0===t?"":"string"==typeof t?t:t()}(t);if("object"==typeof a)throw a;throw c(a||"Assertion error",...e)}(e,...a)}const d=36e5;class h extends n{constructor(t){super(),this.graphId=t}async getTuple(t){const{threadId:e,checkpointNs:a,checkpointId:n}=p(t),{graphId:o}=this,i=n?await this.postUnlessNotFound("getCheckpoint",{graphId:o,threadId:e,checkpointId:n}):await this.postUnlessNotFound("getLatestCheckpoint",{graphId:o,threadId:e,checkpointNs:a});return i&&await this.toTuple(i)}async*list(t,e={}){const{threadId:a,checkpointNs:n}=p(t),{limit:o,before:i,filter:c}=e,s={graphId:this.graphId,threadId:a,checkpointNs:n,limit:c?void 0:o,beforeCheckpointId:i&&r(i)||void 0},{checkpoints:d}=await this.post("listCheckpoints",s);let h=o??1/0;for(const t of d){if(h<=0)return;const e=await this.toTuple(t),a=e.metadata??{};c&&!Object.entries(c).every(([t,e])=>a[t]===e)||(h--,yield e)}}async put(t,e,a,n){const{threadId:o,checkpointNs:r,checkpointId:c}=p(t),s={graphId:this.graphId,threadId:o,checkpointNs:r,checkpointId:e.id,checkpoint:await this.dump(i(e)),parentCheckpointId:c??null,metadata:await this.dump(a)};return await this.post("saveCheckpoint",s),{configurable:{thread_id:o,checkpoint_ns:r,checkpoint_id:e.id}}}async putWrites(t,e,a){const{threadId:n,checkpointNs:i,checkpointId:r}=p(t);s(r,"Failed to put writes: the config has no checkpoint_id");const c=await Promise.all(e.map(async([t,e],n)=>({channel:t,taskId:a,idx:o[t]??n,value:await this.dump(e)}))),d={graphId:this.graphId,threadId:n,checkpointNs:i,checkpointId:r,writes:c};await this.post("savePendingWrites",d)}async deleteThread(t){await this.post("deleteCheckpoints",{graphId:this.graphId,threadId:t})}async toTuple(t){const{threadId:e,checkpointNs:a,checkpointId:n,parentCheckpointId:o}=t,i=t=>({configurable:{thread_id:e,checkpoint_ns:a,checkpoint_id:t}}),r=await Promise.all(t.pendingWrites.map(async({taskId:t,channel:e,value:a})=>[t,e,await this.load(a)]));return{config:i(n),checkpoint:await this.load(t.checkpoint),metadata:t.metadata?await this.load(t.metadata):void 0,parentConfig:o?i(o):void 0,pendingWrites:r}}async dump(t){const[e,a]=await this.serde.dumpsTyped(t),n=[e,{__bytes__:Buffer.from(a).toString("base64")}];return JSON.stringify(n)}async load(t){const[e,{__bytes__:a}]=JSON.parse(t);return await this.serde.loadsTyped(e,Buffer.from(a,"base64"))}async post(e,a){return await t().rpcManager.post(`langgraph/${e}`,a)}async postUnlessNotFound(t,e){try{return await this.post(t,e)}catch(t){if(404===t.statusCode)return;throw t}}}function p(t){const e=t.configurable?.thread_id;s("string"==typeof e&&e,"The LangGraph config has no thread_id");const a=t.configurable?.checkpoint_ns;return{threadId:e,checkpointNs:"string"==typeof a?a:"",checkpointId:r(t)||void 0}}async function u(t,e){const{graphId:n,operation:o,input:i,resumePayload:r,timeoutMs:c}=e,s=new h(n),p=t.compile({checkpointer:s}),u=e.threadId??("function"==typeof globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})),l={configurable:{thread_id:u}};if("getState"!==o){const t="resume"===o&&await s.getTuple(l)?new a({resume:r}):i??{},e=AbortSignal.timeout(c??d);try{await p.invoke(t,{...l,signal:e})}catch(t){if(e.aborted)return{ok:!1,errorCode:"TIMEOUT",error:`The graph run did not finish within ${c??d} ms`};throw t}}const g=await p.getState(l),f=[...g.next],k=(I=g.values)&&"object"==typeof I?JSON.parse(JSON.stringify(I)):{};var I;return"getState"===o?{ok:!0,threadId:u,state:k,next:f}:{ok:!0,threadId:u,status:f.length?"interrupted":"completed",state:k,next:f}}function l(t,a={}){return function(n,o,i){e.langGraph(t,`${n.constructor.name}:${o}`,a.description);const r=function(t,e,...a){return s(t,e,...a),t}(i.value,()=>`@langGraph can only decorate a method: ${o}`);return i.value=function(...t){const[e]=t;return(a=e)&&"object"==typeof a&&!0===a.__squidLangGraphRun__?async function(t,e,a){const n=await t;return s(function(t){return"function"==typeof t?.compile}(n),()=>`@langGraph function '${e}' must return an uncompiled StateGraph, got ${function(t){return null===t?"null":"object"==typeof t?t.constructor?.name??"object":typeof t}(n)}`),await u(n,a)}(r.apply(this,[]),o,e):r.apply(this,[]);var a},i}}export{h as SquidCheckpointer,l as langGraph,u as runLangGraphRequest};
|
|
@@ -131,7 +131,7 @@ export interface QuotaLimitOptions {
|
|
|
131
131
|
/**
|
|
132
132
|
* Options for rate and quota limiting backend functions.
|
|
133
133
|
*
|
|
134
|
-
*
|
|
134
|
+
* It is not the type the developer defines in their code, which is LimiterConfig.
|
|
135
135
|
*/
|
|
136
136
|
export interface LimiterOptions {
|
|
137
137
|
/** Array of rate limit configurations, allowing different limits at different scopes. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Re-exported AI function types from public-types for backwards compatibility. */
|
|
2
|
-
export { AiFunctionAttributes, AiFunctionMetadata, AiFunctionParam, AiFunctionParamType, AiFunctionResponseWithFiles, FUNCTION_AFFINITY_SCOPES, FunctionAffinityScope, } from '@squidcloud/client';
|
|
2
|
+
export { AiFunctionAttributes, AiFunctionMetadata, AiFunctionParam, AiFunctionParamSchema, AiFunctionParamType, AiFunctionResponseWithFiles, FUNCTION_AFFINITY_SCOPES, FunctionAffinityScope, } from '@squidcloud/client';
|
|
3
3
|
/** The different types of actions that can be performed on a database. */
|
|
4
4
|
export type DatabaseActionType = 'read' | 'write' | 'update' | 'insert' | 'delete' | 'all';
|
|
5
5
|
/** The different types of actions that can be performed for storage. */
|