@zibby/skills 0.1.84 → 0.1.85
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/gbrain.d.ts +115 -0
- package/dist/gbrain.js +12 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +144 -133
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/gbrain.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export namespace gbrainSkill {
|
|
2
|
+
let id: string;
|
|
3
|
+
let serverName: string;
|
|
4
|
+
let allowedTools: string[];
|
|
5
|
+
let meta: any;
|
|
6
|
+
let description: string;
|
|
7
|
+
let promptFragment: string;
|
|
8
|
+
/**
|
|
9
|
+
* Spawn the GENERIC skill MCP server (bin/mcp-skill.mjs) pointing at this
|
|
10
|
+
* module's gbrainSkill export — same FIXED pattern as datasetStore. Forwards
|
|
11
|
+
* the backend-auth env + every bound-store mapping the spawned process needs.
|
|
12
|
+
*/
|
|
13
|
+
function resolve(): {
|
|
14
|
+
command: any;
|
|
15
|
+
args: any[];
|
|
16
|
+
env: {};
|
|
17
|
+
description: string;
|
|
18
|
+
type?: undefined;
|
|
19
|
+
alwaysLoad?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
type: string;
|
|
22
|
+
command: string;
|
|
23
|
+
args: any[];
|
|
24
|
+
env: {};
|
|
25
|
+
description: string;
|
|
26
|
+
alwaysLoad: boolean;
|
|
27
|
+
};
|
|
28
|
+
function handleToolCall(name: any, args: any): Promise<string>;
|
|
29
|
+
let tools: ({
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
input_schema: {
|
|
33
|
+
type: string;
|
|
34
|
+
properties: {
|
|
35
|
+
docs: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
items: {
|
|
39
|
+
type: string;
|
|
40
|
+
properties: {
|
|
41
|
+
sourceId: {
|
|
42
|
+
type: string;
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
markdown: {
|
|
46
|
+
type: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
deleted: {
|
|
50
|
+
type: string;
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
required: string[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
store: {
|
|
58
|
+
type: string;
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
61
|
+
query?: undefined;
|
|
62
|
+
topK?: undefined;
|
|
63
|
+
sourceIds?: undefined;
|
|
64
|
+
};
|
|
65
|
+
required: string[];
|
|
66
|
+
};
|
|
67
|
+
} | {
|
|
68
|
+
name: string;
|
|
69
|
+
description: string;
|
|
70
|
+
input_schema: {
|
|
71
|
+
type: string;
|
|
72
|
+
properties: {
|
|
73
|
+
query: {
|
|
74
|
+
type: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
topK: {
|
|
78
|
+
type: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
store: {
|
|
82
|
+
type: string;
|
|
83
|
+
description: string;
|
|
84
|
+
};
|
|
85
|
+
docs?: undefined;
|
|
86
|
+
sourceIds?: undefined;
|
|
87
|
+
};
|
|
88
|
+
required: string[];
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
name: string;
|
|
92
|
+
description: string;
|
|
93
|
+
input_schema: {
|
|
94
|
+
type: string;
|
|
95
|
+
properties: {
|
|
96
|
+
sourceIds: {
|
|
97
|
+
type: string;
|
|
98
|
+
description: string;
|
|
99
|
+
items: {
|
|
100
|
+
type: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
store: {
|
|
104
|
+
type: string;
|
|
105
|
+
description: string;
|
|
106
|
+
};
|
|
107
|
+
docs?: undefined;
|
|
108
|
+
query?: undefined;
|
|
109
|
+
topK?: undefined;
|
|
110
|
+
};
|
|
111
|
+
required: string[];
|
|
112
|
+
};
|
|
113
|
+
})[];
|
|
114
|
+
}
|
|
115
|
+
export default gbrainSkill;
|
package/dist/gbrain.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{existsSync as f,readFileSync as b}from"node:fs";import{homedir as h}from"node:os";import{join as I,dirname as _,resolve as S}from"node:path";import{fileURLToPath as O}from"node:url";import{SKILL_META as E}from"@zibby/skill-ids";var T=3e4,p=1;function w(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let o=_(O(import.meta.url)),r=S(o,"..","bin","mcp-skill.mjs");return f(r)?r:null}function A(){if(process.env.PROJECT_API_TOKEN)return process.env.PROJECT_API_TOKEN;if(process.env.ZIBBY_USER_TOKEN)return process.env.ZIBBY_USER_TOKEN;try{let o=I(h(),".zibby","config.json");return f(o)&&JSON.parse(b(o,"utf-8")).sessionToken||null}catch{return null}}function k(){return process.env.ZIBBY_ACCOUNT_API_URL?process.env.ZIBBY_ACCOUNT_API_URL.replace(/\/$/,""):(process.env.ZIBBY_ENV||"prod")==="local"?"http://localhost:3001":process.env.ZIBBY_PROD_ACCOUNT_API_URL||"https://api-prod.zibby.app"}function v(){let o={};for(let[r,e]of Object.entries(process.env)){let t=/^ZIBBY_STORE__(.+)$/.exec(r);if(!t)continue;let n=typeof e=="string"?e.trim():"";n&&(o[t[1]]=n)}return o}function l(o){let r=v(),e=Object.keys(r),t=typeof o=="string"?o.trim():"";return t?Object.prototype.hasOwnProperty.call(r,t)?{storeId:r[t],name:t}:{error:`unknown store '${t}'; available: ${e.join(", ")}`}:e.length===1?{storeId:r[e[0]],name:e[0]}:e.length===0?{error:"no knowledge-base store is bound to this agent"}:{error:`multiple stores are bound; pass \`store\` (one of: ${e.join(", ")})`}}async function m(o,r,e){let t=A();if(!t)throw new Error("No backend credential (PROJECT_API_TOKEN). The knowledge base is only available inside a Zibby run.");let n=`${k()}/datasets/stores/${encodeURIComponent(o)}/${r}`,s={Authorization:`Bearer ${t}`,"Content-Type":"application/json"},u=JSON.stringify(e),i;for(let c=0;c<=p;c++){let y=new AbortController,g=setTimeout(()=>y.abort(),T);try{let a=await fetch(n,{method:"POST",headers:s,body:u,signal:y.signal}),d=await a.text().catch(()=>"");if(a.status>=500&&c<p){i=new Error(`store ${a.status}`);continue}if(!a.ok)throw new Error(`gbrain ${r} failed (${a.status}): ${d.slice(0,300)}`);try{return JSON.parse(d)}catch{throw new Error(`store returned non-JSON: ${d.slice(0,200)}`)}}catch(a){if(i=a,!((a?.name==="AbortError"||a?.code==="ECONNREFUSED"||/fetch failed|network/i.test(String(a?.message)))&&c<p))break}finally{clearTimeout(g)}}throw i||new Error(`gbrain ${r} request failed`)}var N={id:"gbrain",serverName:"gbrain",allowedTools:["mcp__gbrain__*"],meta:E.gbrain,description:"Knowledge base (GBrain) \u2014 ingest source documents into, semantically query, and prune a per-tenant Postgres/pgvector brain (a `postgres`-type store, brokered by the control-plane)",promptFragment:`## Knowledge Base (GBrain \u2014 per-tenant document brain)
|
|
2
|
+
You have a per-tenant KNOWLEDGE BASE (a Postgres + pgvector "brain"), bound as a
|
|
3
|
+
\`postgres\`-type store in the "AVAILABLE STORES" block below. Ingested documents
|
|
4
|
+
are addressed by a STABLE \`sourceId\` so re-ingesting the same source UPSERTS
|
|
5
|
+
(updates in place) rather than duplicating, and a source can be removed. If
|
|
6
|
+
exactly one store is bound you may omit \`store\`; otherwise pass its NAME.
|
|
7
|
+
Tools:
|
|
8
|
+
- gbrain_ingest({ docs, store? }): upsert an array of { sourceId, markdown, deleted? }.
|
|
9
|
+
Pass deleted:true to remove a source that no longer exists upstream.
|
|
10
|
+
- gbrain_query({ query, topK, store? }): semantic search; returns the topK most
|
|
11
|
+
relevant document chunks with their sourceId and relevance score.
|
|
12
|
+
- gbrain_delete({ sourceIds, store? }): remove documents by their stable sourceId(s).`,resolve(){let o=w();if(!o)return{command:null,args:[],env:{},description:this.description};let r={};for(let e of["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV","ZIBBY_PROD_ACCOUNT_API_URL","ZIBBY_USER_TOKEN","WORKFLOW_TYPE"])process.env[e]&&(r[e]=process.env[e]);for(let e of Object.keys(process.env))/^ZIBBY_STORE__.+$/.test(e)&&process.env[e]&&(r[e]=process.env[e]);return{type:"stdio",command:"node",args:[o,"../dist/gbrain.js","gbrainSkill"],env:r,description:this.description,alwaysLoad:!0}},async handleToolCall(o,r){try{switch(o){case"gbrain_ingest":{let e=Array.isArray(r?.docs)?r.docs:null;if(!e)return JSON.stringify({error:"docs is required (array of { sourceId, markdown, deleted? })"});if(e.length===0)return JSON.stringify({ok:!0,upserted:0,deleted:0,chunks:0,note:"empty docs \u2014 nothing to ingest"});if(e.find(i=>!i||typeof i.sourceId!="string"||!i.sourceId.trim())!==void 0)return JSON.stringify({error:"every doc requires a non-empty string sourceId"});let n=e.find(i=>i.deleted!==!0&&(typeof i.markdown!="string"||!i.markdown.length));if(n!==void 0)return JSON.stringify({error:`doc "${n.sourceId}" has no markdown (required unless deleted:true)`});let s=l(r?.store);if(s.error)return JSON.stringify({error:s.error});let u=await m(s.storeId,"ingest",{docs:e});return JSON.stringify({...u,store:s.name,storeId:s.storeId})}case"gbrain_query":{let e=typeof r?.query=="string"?r.query.trim():"";if(!e)return JSON.stringify({error:"query is required"});let t=l(r?.store);if(t.error)return JSON.stringify({error:t.error});let n={query:e};Number.isInteger(r?.topK)&&r.topK>0&&(n.topK=Math.min(r.topK,50));let s=await m(t.storeId,"query",n);return JSON.stringify({...s,store:t.name,storeId:t.storeId})}case"gbrain_delete":{let e=Array.isArray(r?.sourceIds)?r.sourceIds.filter(s=>typeof s=="string"&&s.trim()):null;if(!e||e.length===0)return JSON.stringify({error:"sourceIds is required (non-empty array of strings)"});let t=l(r?.store);if(t.error)return JSON.stringify({error:t.error});let n=await m(t.storeId,"delete",{sourceIds:e});return JSON.stringify({...n,store:t.name,storeId:t.storeId})}default:return JSON.stringify({error:`Unknown tool: ${o}`})}}catch(e){return JSON.stringify({error:String(e?.message||e)})}},tools:[{name:"gbrain_ingest",description:'Upsert documents into the knowledge base. Each doc is { sourceId, markdown, deleted? }; sourceId is a STABLE id (e.g. "owner/repo#docs/x.md" or a Lark doc token) so re-ingesting the same source UPDATES in place instead of duplicating. Set deleted:true to remove a source.',input_schema:{type:"object",properties:{docs:{type:"array",description:"Documents to upsert.",items:{type:"object",properties:{sourceId:{type:"string",description:"Stable source id \u2014 the upsert/delete key."},markdown:{type:"string",description:"The normalized markdown content of the document."},deleted:{type:"boolean",description:"When true, remove this sourceId from the brain (markdown ignored)."}},required:["sourceId"]}},store:{type:"string",description:"The bound knowledge-base store NAME (from AVAILABLE STORES). Omit if exactly one store is bound."}},required:["docs"]}},{name:"gbrain_query",description:"Semantic-search the knowledge base and return the most relevant document chunks (each with its sourceId and relevance score).",input_schema:{type:"object",properties:{query:{type:"string",description:"Natural-language query."},topK:{type:"integer",description:"How many chunks to return (default 8, max 50)."},store:{type:"string",description:"The bound knowledge-base store NAME (from AVAILABLE STORES). Omit if exactly one store is bound."}},required:["query"]}},{name:"gbrain_delete",description:"Remove documents from the knowledge base by their stable sourceId(s).",input_schema:{type:"object",properties:{sourceIds:{type:"array",description:"Stable source ids to delete.",items:{type:"string"}},store:{type:"string",description:"The bound knowledge-base store NAME (from AVAILABLE STORES). Omit if exactly one store is bound."}},required:["sourceIds"]}}]},U=N;export{U as default,N as gbrainSkill};
|
package/dist/index.d.ts
CHANGED
|
@@ -27,11 +27,12 @@ import { chartRenderSkill } from './chartRender.js';
|
|
|
27
27
|
import { socialCardSkill } from './socialCard.js';
|
|
28
28
|
import { codeScanSkill } from './code-scan.js';
|
|
29
29
|
import { codebaseMemorySkill } from './codebaseMemory.js';
|
|
30
|
+
import { gbrainSkill } from './gbrain.js';
|
|
30
31
|
import { testRunnerSkill } from './test-runner.js';
|
|
31
32
|
import { skillInstallerSkill } from './skill-installer.js';
|
|
32
33
|
import { coreToolsSkill } from './core-tools.js';
|
|
33
34
|
import { workflowBuilderSkill } from './workflow-builder.js';
|
|
34
|
-
export { browserSkill, jiraSkill, githubSkill, gitlabSkill, figmaSkill, hubspotSkill, linearSkill, planeSkill, opendesignSkill, gitSkill, gitWriteSkill, slackSkill, larkSkill, discordSkill, notionSkill, linkedinSkill, googleDocsSkill, larkDocsSkill, chatNotifySkill, sentrySkill, memorySkill, chatMemorySkill, kvMemorySkill, datasetStoreSkill, chartRenderSkill, socialCardSkill, codeScanSkill, codebaseMemorySkill, testRunnerSkill, testRunnerSkill as runnerSkill, skillInstallerSkill, coreToolsSkill, workflowBuilderSkill };
|
|
35
|
+
export { browserSkill, jiraSkill, githubSkill, gitlabSkill, figmaSkill, hubspotSkill, linearSkill, planeSkill, opendesignSkill, gitSkill, gitWriteSkill, slackSkill, larkSkill, discordSkill, notionSkill, linkedinSkill, googleDocsSkill, larkDocsSkill, chatNotifySkill, sentrySkill, memorySkill, chatMemorySkill, kvMemorySkill, datasetStoreSkill, chartRenderSkill, socialCardSkill, codeScanSkill, codebaseMemorySkill, gbrainSkill, testRunnerSkill, testRunnerSkill as runnerSkill, skillInstallerSkill, coreToolsSkill, workflowBuilderSkill };
|
|
35
36
|
export { openaiBillingSkill, anthropicBillingSkill, cursorAdminSkill, fetchOpenAICosts, fetchOpenAIProjects, fetchAnthropicCosts, fetchAnthropicWorkspaces, fetchCursorSpend, fetchAllProviders, groupByKey, meanStddev } from "./llm-billing.js";
|
|
36
37
|
export { reportObjectSchema, reportToBlockKit, reportToLarkCard, reportToNotionBlocks, reportToMarkdown, SEVERITIES as REPORT_SEVERITIES } from "./report.js";
|
|
37
38
|
export { skill, functionSkill } from "./function-skill.js";
|