@zibby/skills 0.1.54 → 0.1.56

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,3 +1,4 @@
1
+ export function __clearEnsuredStores(): void;
1
2
  export namespace datasetStoreSkill {
2
3
  let id: string;
3
4
  let serverName: string;
@@ -49,6 +50,10 @@ export namespace datasetStoreSkill {
49
50
  limit?: undefined;
50
51
  since?: undefined;
51
52
  until?: undefined;
53
+ name?: undefined;
54
+ type?: undefined;
55
+ sql?: undefined;
56
+ params?: undefined;
52
57
  };
53
58
  required: string[];
54
59
  };
@@ -96,8 +101,79 @@ export namespace datasetStoreSkill {
96
101
  };
97
102
  record?: undefined;
98
103
  description?: undefined;
104
+ name?: undefined;
105
+ type?: undefined;
106
+ sql?: undefined;
107
+ params?: undefined;
99
108
  };
100
109
  required: any[];
101
110
  };
111
+ } | {
112
+ name: string;
113
+ description: string;
114
+ input_schema: {
115
+ type: string;
116
+ properties: {
117
+ name: {
118
+ type: string;
119
+ description: string;
120
+ };
121
+ type: {
122
+ type: string;
123
+ enum: string[];
124
+ description: string;
125
+ };
126
+ description: {
127
+ type: string;
128
+ description: string;
129
+ };
130
+ store?: undefined;
131
+ record?: undefined;
132
+ agent?: undefined;
133
+ select?: undefined;
134
+ where?: undefined;
135
+ groupBy?: undefined;
136
+ orderBy?: undefined;
137
+ limit?: undefined;
138
+ since?: undefined;
139
+ until?: undefined;
140
+ sql?: undefined;
141
+ params?: undefined;
142
+ };
143
+ required: string[];
144
+ };
145
+ } | {
146
+ name: string;
147
+ description: string;
148
+ input_schema: {
149
+ type: string;
150
+ properties: {
151
+ store: {
152
+ type: string;
153
+ description: string;
154
+ };
155
+ sql: {
156
+ type: string;
157
+ description: string;
158
+ };
159
+ params: {
160
+ type: string;
161
+ description: string;
162
+ };
163
+ record?: undefined;
164
+ description?: undefined;
165
+ agent?: undefined;
166
+ select?: undefined;
167
+ where?: undefined;
168
+ groupBy?: undefined;
169
+ orderBy?: undefined;
170
+ limit?: undefined;
171
+ since?: undefined;
172
+ until?: undefined;
173
+ name?: undefined;
174
+ type?: undefined;
175
+ };
176
+ required: string[];
177
+ };
102
178
  })[];
103
179
  }
@@ -1,4 +1,4 @@
1
- import{existsSync as c,readFileSync as u}from"node:fs";import{homedir as p}from"node:os";import{join as l,dirname as y,resolve as m}from"node:path";import{fileURLToPath as f}from"node:url";function g(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let r=y(f(import.meta.url)),t=m(r,"..","bin","mcp-skill.mjs");return c(t)?t:null}function h(){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 r=l(p(),".zibby","config.json");return c(r)&&JSON.parse(u(r,"utf-8")).sessionToken||null}catch{return null}}function O(){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 b(){return(typeof process.env.WORKFLOW_TYPE=="string"?process.env.WORKFLOW_TYPE.trim():"")||"agent"}function _(){let r={};for(let[t,e]of Object.entries(process.env)){let o=/^ZIBBY_STORE__(.+)$/.exec(t);if(!o)continue;let n=typeof e=="string"?e.trim():"";n&&(r[o[1]]=n)}return r}function i(r){let t=_(),e=Object.keys(t),o=typeof r=="string"?r.trim():"";return o?Object.prototype.hasOwnProperty.call(t,o)?{storeId:t[o],name:o}:{error:`unknown store '${o}'; available: ${e.join(", ")}`}:e.length===1?{storeId:t[e[0]],name:e[0]}:e.length===0?{error:"no stores bound to this agent"}:{error:`multiple stores are bound; pass \`store\` (one of: ${e.join(", ")})`}}async function a(r,t,e){let o=h();if(!o)throw new Error("No backend credential (PROJECT_API_TOKEN). Dataset store is only available inside a Zibby run.");let n=`${O()}/datasets/stores/${encodeURIComponent(r)}/${t}`,s=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok){let d=await s.text().catch(()=>"");throw new Error(`Store ${t} failed (${s.status}): ${d.slice(0,300)}`)}return s.json()}var T={id:"dataset-store",serverName:"dataset_store",allowedTools:["mcp__dataset_store__*"],description:"Dataset store \u2014 a durable, queryable store for structured JSON records; append rows now, run SQL-style aggregations/reports later",promptFragment:`## Dataset Store (durable, queryable structured-record store)
1
+ import{existsSync as p,readFileSync as m}from"node:fs";import{homedir as f}from"node:os";import{join as h,dirname as E,resolve as g}from"node:path";import{fileURLToPath as T}from"node:url";function S(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let r=E(T(import.meta.url)),t=g(r,"..","bin","mcp-skill.mjs");return p(t)?t:null}function l(){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 r=h(f(),".zibby","config.json");return p(r)&&JSON.parse(m(r,"utf-8")).sessionToken||null}catch{return null}}function u(){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 d(){return(typeof process.env.WORKFLOW_TYPE=="string"?process.env.WORKFLOW_TYPE.trim():"")||"agent"}function O(){let r={};for(let[t,e]of Object.entries(process.env)){let o=/^ZIBBY_STORE__(.+)$/.exec(t);if(!o)continue;let n=typeof e=="string"?e.trim():"";n&&(r[o[1]]=n)}return r}var a={};function I(){for(let r of Object.keys(a))delete a[r]}function i(r){let t={...O(),...a},e=Object.keys(t),o=typeof r=="string"?r.trim():"";return o?Object.prototype.hasOwnProperty.call(t,o)?{storeId:t[o],name:o}:{error:`unknown store '${o}'; available: ${e.join(", ")}`}:e.length===1?{storeId:t[e[0]],name:e[0]}:e.length===0?{error:"no stores bound to this agent"}:{error:`multiple stores are bound; pass \`store\` (one of: ${e.join(", ")})`}}async function b(r){let t=l();if(!t)throw new Error("No backend credential (PROJECT_API_TOKEN). Stores are only available inside a Zibby run.");let e=await fetch(`${u()}/datasets/stores/ensure`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(r)});if(!e.ok){let o=await e.text().catch(()=>"");throw new Error(`ensure_store failed (${e.status}): ${o.slice(0,300)}`)}return e.json()}async function c(r,t,e){let o=l();if(!o)throw new Error("No backend credential (PROJECT_API_TOKEN). Dataset store is only available inside a Zibby run.");let n=`${u()}/datasets/stores/${encodeURIComponent(r)}/${t}`,s=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok){let y=await s.text().catch(()=>"");throw new Error(`Store ${t} failed (${s.status}): ${y.slice(0,300)}`)}return s.json()}var L={id:"dataset-store",serverName:"dataset_store",allowedTools:["mcp__dataset_store__*"],description:"Dataset store \u2014 a durable, queryable store for structured JSON records; append rows now, run SQL-style aggregations/reports later",promptFragment:`## Dataset Store (durable, queryable structured-record store)
2
2
  You have one or more durable stores for STRUCTURED records that survive across
3
3
  your stateless runs. Unlike key-value memory (for picking up where you left
4
4
  off), this is for accumulating DATA you want to QUERY and AGGREGATE later \u2014 e.g.
@@ -11,9 +11,27 @@ omit \`store\` and it defaults to that one. You can ONLY write to a bound store
11
11
  name; any other name is rejected. Each appended record is an arbitrary JSON
12
12
  object, auto-tagged with YOUR agent type so you can later filter to your writes.
13
13
 
14
+ There are TWO kinds of bound store (shown as TYPE in AVAILABLE STORES):
15
+ \u2022 dataset \u2014 append-only structured records you QUERY/AGGREGATE later (analytics).
16
+ \u2022 sqlite \u2014 a real, MUTABLE relational database (a SQLite file per store): CREATE
17
+ TABLE on the fly, INSERT/UPDATE/DELETE, SELECT. Schema + data persist across
18
+ runs. Use this when you need to UPDATE rows / track changing state (e.g. a
19
+ queue with a status column), not just append.
20
+
21
+ You can also CREATE your own store on demand (no deploy needed) with
22
+ ensure_store \u2014 e.g. an agent that needs a private sqlite DB to track drafts/
23
+ state creates it at the start of the run and reuses it every run.
24
+
14
25
  Tools:
15
- - dataset_append: Append ONE structured JSON \`record\` to a store (by \`store\`
16
- name). Use to durably persist a row of data each run (e.g. {repo, stars, ts}).
17
- - dataset_query: Run a SQL-style query over a store \u2014 select/aggregate
18
- (count|sum|avg|min|max), filter (where), group (groupBy), order, limit, and
19
- bound by month (since/until). Use to compute reports from what you've stored.`,resolve(){let r=g();if(!r)return{command:null,args:[],env:{},description:this.description};let t={};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]&&(t[e]=process.env[e]);for(let e of Object.keys(process.env))/^ZIBBY_STORE__.+$/.test(e)&&process.env[e]&&(t[e]=process.env[e]);return{type:"stdio",command:"node",args:[r,"../dist/datasetStore.js","datasetStoreSkill"],env:t,description:this.description,alwaysLoad:!1}},async handleToolCall(r,t){try{switch(r){case"dataset_append":{if(t?.record==null||typeof t.record!="object"||Array.isArray(t.record))return JSON.stringify({error:"record is required (a JSON object)"});let e=i(t?.store);if(e.error)return JSON.stringify({error:e.error});let o=typeof t?.agent=="string"&&t.agent.trim()?t.agent.trim():b(),n={record:t.record,agent:o};typeof t?.description=="string"&&t.description.trim()&&(n.description=t.description.trim());let s=await a(e.storeId,"append",n);return JSON.stringify({...s,store:e.name,storeId:e.storeId})}case"dataset_query":{let e=i(t?.store);if(e.error)return JSON.stringify({error:e.error});let o={};for(let s of["select","where","groupBy","orderBy","limit","since","until","agent"])t?.[s]!=null&&(o[s]=t[s]);let n=await a(e.storeId,"query",o);return JSON.stringify({...n,store:e.name,storeId:e.storeId})}default:return JSON.stringify({error:`Unknown tool: ${r}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"dataset_append",description:"Append ONE structured JSON record to a bound store, durably. Records persist across your stateless runs and are auto-tagged with your agent type so you can filter to your own writes later. Use to accumulate data you will query/aggregate (e.g. per-run metrics, processed items). Append ONE record per call.",input_schema:{type:"object",properties:{store:{type:"string",description:'The logical store NAME to write to (e.g. "scorecards"), taken from the AVAILABLE STORES list \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this and it defaults to that store; you can ONLY write to a bound store name.'},record:{type:"object",description:'An arbitrary JSON object \u2014 one row of data. Its keys become queryable fields (e.g. {"repo":"owner/x","stars":1200}). One record per call.'},description:{type:"string",description:"Optional, informational note about this write. The store already exists from deploy, so this is not required and does not create anything."},agent:{type:"string",description:"Optional writing-agent tag. Defaults to your own agent type \u2014 leave unset to auto-tag."}},required:["record"]}},{name:"dataset_query",description:"Run a SQL-style query over a bound store to build reports: select/aggregate (count|sum|avg|min|max), filter, group, order, limit, and bound by month. Returns { columns, rows }. Use this to compute summaries/aggregations from records you appended earlier.",input_schema:{type:"object",properties:{store:{type:"string",description:'The logical store NAME to query (e.g. "scorecards"), taken from the AVAILABLE STORES list \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this and it defaults to that store.'},select:{type:"array",description:"Columns to return. Each item is { field?, agg?, as? }. agg \u2208 count|sum|avg|min|max; omit field for count(*). Omit `select` entirely to return raw rows."},where:{type:"array",description:"Filters, ANDed. Each item is { field, op, value }; op \u2208 eq|ne|gt|gte|lt|lte|like. `field` is a JSON key of the stored record."},groupBy:{type:"array",description:"Field names to group by (array of strings) for aggregation."},orderBy:{type:"array",description:"Sort spec. Each item is { field|as, dir }; dir \u2208 asc|desc."},limit:{type:"number",description:"Maximum number of rows to return."},since:{type:"string",description:"Inclusive lower bound month, 'yyyy-MM' (e.g. '2026-01')."},until:{type:"string",description:"Inclusive upper bound month, 'yyyy-MM' (e.g. '2026-06')."},agent:{type:"string",description:"Filter to records written by one agent namespace. Omit to query across all writers."}},required:[]}}]};export{T as datasetStoreSkill};
26
+ - ensure_store: Create/reuse a store ON DEMAND for this agent (idempotent by
27
+ name). Use when you need a store not bound at deploy. Then use its name with
28
+ the tools below.
29
+ - dataset_append: (dataset stores) Append ONE structured JSON \`record\`.
30
+ - dataset_query: (dataset stores) SQL-style select/aggregate over appended records.
31
+ - sqlite_exec: (sqlite stores) Run SQL that CHANGES data \u2014 CREATE TABLE / INSERT /
32
+ UPDATE / DELETE (one or more statements). Idempotent DDL: use CREATE TABLE IF
33
+ NOT EXISTS. Returns { rowsModified, wrote }.
34
+ - sqlite_query: (sqlite stores) Run a SELECT (optionally with \`params\` for safe
35
+ binding). Returns { columns, rows }. Read-only \u2014 never changes data.
36
+ Pick the tool that matches the store's TYPE; using a dataset tool on a sqlite
37
+ store (or vice-versa) is rejected.`,resolve(){let r=S();if(!r)return{command:null,args:[],env:{},description:this.description};let t={};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]&&(t[e]=process.env[e]);for(let e of Object.keys(process.env))/^ZIBBY_STORE__.+$/.test(e)&&process.env[e]&&(t[e]=process.env[e]);return{type:"stdio",command:"node",args:[r,"../dist/datasetStore.js","datasetStoreSkill"],env:t,description:this.description,alwaysLoad:!1}},async handleToolCall(r,t){try{switch(r){case"dataset_append":{if(t?.record==null||typeof t.record!="object"||Array.isArray(t.record))return JSON.stringify({error:"record is required (a JSON object)"});let e=i(t?.store);if(e.error)return JSON.stringify({error:e.error});let o=typeof t?.agent=="string"&&t.agent.trim()?t.agent.trim():d(),n={record:t.record,agent:o};typeof t?.description=="string"&&t.description.trim()&&(n.description=t.description.trim());let s=await c(e.storeId,"append",n);return JSON.stringify({...s,store:e.name,storeId:e.storeId})}case"dataset_query":{let e=i(t?.store);if(e.error)return JSON.stringify({error:e.error});let o={};for(let s of["select","where","groupBy","orderBy","limit","since","until","agent"])t?.[s]!=null&&(o[s]=t[s]);let n=await c(e.storeId,"query",o);return JSON.stringify({...n,store:e.name,storeId:e.storeId})}case"ensure_store":{let e=typeof t?.name=="string"?t.name.trim():"";if(!e)return JSON.stringify({error:"name is required"});let o=typeof t?.type=="string"&&t.type.trim()?t.type.trim().toLowerCase():"sqlite",n=typeof t?.description=="string"?t.description.trim():"",s=await b({name:e,type:o,description:n,namespace:d()});return s?.storeId&&(a[e]=s.storeId),JSON.stringify({...s,store:e})}case"sqlite_exec":case"sqlite_query":{let e=i(t?.store);if(e.error)return JSON.stringify({error:e.error});if(typeof t?.sql!="string"||!t.sql.trim())return JSON.stringify({error:"sql is required (a non-empty SQL string)"});let o={sql:t.sql};Array.isArray(t?.params)&&(o.params=t.params);let n=await c(e.storeId,"sql",o);return JSON.stringify({...n,store:e.name,storeId:e.storeId})}default:return JSON.stringify({error:`Unknown tool: ${r}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"dataset_append",description:"Append ONE structured JSON record to a bound store, durably. Records persist across your stateless runs and are auto-tagged with your agent type so you can filter to your own writes later. Use to accumulate data you will query/aggregate (e.g. per-run metrics, processed items). Append ONE record per call.",input_schema:{type:"object",properties:{store:{type:"string",description:'The logical store NAME to write to (e.g. "scorecards"), taken from the AVAILABLE STORES list \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this and it defaults to that store; you can ONLY write to a bound store name.'},record:{type:"object",description:'An arbitrary JSON object \u2014 one row of data. Its keys become queryable fields (e.g. {"repo":"owner/x","stars":1200}). One record per call.'},description:{type:"string",description:"Optional, informational note about this write. The store already exists from deploy, so this is not required and does not create anything."},agent:{type:"string",description:"Optional writing-agent tag. Defaults to your own agent type \u2014 leave unset to auto-tag."}},required:["record"]}},{name:"dataset_query",description:"Run a SQL-style query over a bound store to build reports: select/aggregate (count|sum|avg|min|max), filter, group, order, limit, and bound by month. Returns { columns, rows }. Use this to compute summaries/aggregations from records you appended earlier.",input_schema:{type:"object",properties:{store:{type:"string",description:'The logical store NAME to query (e.g. "scorecards"), taken from the AVAILABLE STORES list \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this and it defaults to that store.'},select:{type:"array",description:"Columns to return. Each item is { field?, agg?, as? }. agg \u2208 count|sum|avg|min|max; omit field for count(*). Omit `select` entirely to return raw rows."},where:{type:"array",description:"Filters, ANDed. Each item is { field, op, value }; op \u2208 eq|ne|gt|gte|lt|lte|like. `field` is a JSON key of the stored record."},groupBy:{type:"array",description:"Field names to group by (array of strings) for aggregation."},orderBy:{type:"array",description:"Sort spec. Each item is { field|as, dir }; dir \u2208 asc|desc."},limit:{type:"number",description:"Maximum number of rows to return."},since:{type:"string",description:"Inclusive lower bound month, 'yyyy-MM' (e.g. '2026-01')."},until:{type:"string",description:"Inclusive upper bound month, 'yyyy-MM' (e.g. '2026-06')."},agent:{type:"string",description:"Filter to records written by one agent namespace. Omit to query across all writers."}},required:[]}},{name:"ensure_store",description:'Create (or reuse) a store ON DEMAND for THIS agent \u2014 use when you need a store that was NOT declared/bound at deploy. Idempotent by name and private to this agent: calling again with the same name returns the SAME store (safe to call at the start of every run). Returns { storeId }. For type "sqlite" you then define schema with sqlite_exec (CREATE TABLE IF NOT EXISTS) and read/write via sqlite_exec/sqlite_query using this name.',input_schema:{type:"object",properties:{name:{type:"string",description:'A short logical name for the store (e.g. "linkedin_posts"). Letters, digits, _ and - only.'},type:{type:"string",enum:["sqlite","dataset"],description:'Store type. "sqlite" (default) = a mutable relational DB whose schema YOU define with SQL. "dataset" = append-only JSON records for later aggregation/analytics.'},description:{type:"string",description:"What this store is for (shown in the Storage UI)."}},required:["name"]}},{name:"sqlite_exec",description:"For SQLITE-type stores: run SQL that CHANGES data \u2014 CREATE TABLE (use IF NOT EXISTS), INSERT, UPDATE, DELETE (one or more statements in one call). The store is a real, mutable SQLite database that persists across your stateless runs. Returns { rowsModified, wrote }. Use this to build schema on the fly and to update rows / track changing state (e.g. a queue with a status column).",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a sqlite-type store from AVAILABLE STORES) \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this."},sql:{type:"string",description:'The SQL to run. May contain multiple statements separated by ";". Prefer CREATE TABLE IF NOT EXISTS for idempotent schema.'},params:{type:"array",description:'Optional positional bind params for a SINGLE parameterized statement (safe binding of values), e.g. sql "UPDATE t SET s=? WHERE id=?" with params ["done", 1].'}},required:["sql"]}},{name:"sqlite_query",description:"For SQLITE-type stores: run a read-only SELECT (optionally with `params` for safe binding) against the store's SQLite database. Returns { columns, rows }. Never changes data. Use to read back rows/state you stored earlier.",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a sqlite-type store from AVAILABLE STORES) \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this."},sql:{type:"string",description:"A single SELECT statement. Use ? placeholders + `params` for any values."},params:{type:"array",description:'Optional positional bind params for the SELECT, e.g. ["linkedin_personal"].'}},required:["sql"]}}]};export{I as __clearEnsuredStores,L as datasetStoreSkill};