@telvok/librarian-mcp 1.5.4 → 2.0.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 (119) hide show
  1. package/dist/library/errors.d.ts +48 -0
  2. package/dist/library/errors.js +80 -0
  3. package/dist/library/schemas.d.ts +6 -6
  4. package/dist/library/storage.d.ts +2 -2
  5. package/dist/library/storage.js +2 -2
  6. package/dist/library 2/embeddings.d.ts +21 -0
  7. package/dist/library 2/embeddings.js +86 -0
  8. package/dist/library 2/manager.d.ts +42 -0
  9. package/dist/library 2/manager.js +218 -0
  10. package/dist/library 2/parsers/cursor.d.ts +15 -0
  11. package/dist/library 2/parsers/cursor.js +168 -0
  12. package/dist/library 2/parsers/index.d.ts +6 -0
  13. package/dist/library 2/parsers/index.js +5 -0
  14. package/dist/library 2/parsers/json.d.ts +11 -0
  15. package/dist/library 2/parsers/json.js +95 -0
  16. package/dist/library 2/parsers/jsonl.d.ts +14 -0
  17. package/dist/library 2/parsers/jsonl.js +85 -0
  18. package/dist/library 2/parsers/markdown.d.ts +15 -0
  19. package/dist/library 2/parsers/markdown.js +77 -0
  20. package/dist/library 2/parsers/sqlite.d.ts +8 -0
  21. package/dist/library 2/parsers/sqlite.js +123 -0
  22. package/dist/library 2/parsers/types.d.ts +21 -0
  23. package/dist/library 2/parsers/types.js +4 -0
  24. package/dist/library 2/query.d.ts +26 -0
  25. package/dist/library 2/query.js +104 -0
  26. package/dist/library 2/schemas.d.ts +324 -0
  27. package/dist/library 2/schemas.js +79 -0
  28. package/dist/library 2/storage.d.ts +22 -0
  29. package/dist/library 2/storage.js +36 -0
  30. package/dist/library 2/vector-index.d.ts +55 -0
  31. package/dist/library 2/vector-index.js +160 -0
  32. package/dist/server 2.js +199 -0
  33. package/dist/server.d 2.ts +2 -0
  34. package/dist/server.js +102 -54
  35. package/dist/tools/adopt.d.ts +1 -0
  36. package/dist/tools/adopt.js +37 -10
  37. package/dist/tools/auth.d.ts +69 -0
  38. package/dist/tools/auth.js +379 -0
  39. package/dist/tools/bounty-claim.d.ts +28 -0
  40. package/dist/tools/bounty-claim.js +92 -0
  41. package/dist/tools/bounty-create.d.ts +47 -0
  42. package/dist/tools/bounty-create.js +118 -0
  43. package/dist/tools/bounty-list.d.ts +50 -0
  44. package/dist/tools/bounty-list.js +116 -0
  45. package/dist/tools/bounty-submit.d.ts +34 -0
  46. package/dist/tools/bounty-submit.js +94 -0
  47. package/dist/tools/brief.d.ts +94 -0
  48. package/dist/tools/brief.js +234 -15
  49. package/dist/tools/delete.d.ts +87 -0
  50. package/dist/tools/delete.js +266 -0
  51. package/dist/tools/feedback.d.ts +27 -0
  52. package/dist/tools/feedback.js +98 -0
  53. package/dist/tools/help.d.ts +22 -0
  54. package/dist/tools/help.js +482 -0
  55. package/dist/tools/import-memories.d.ts +1 -0
  56. package/dist/tools/import-memories.js +18 -13
  57. package/dist/tools/index.d.ts +11 -0
  58. package/dist/tools/index.js +12 -0
  59. package/dist/tools/library-buy.d.ts +31 -0
  60. package/dist/tools/library-buy.js +104 -0
  61. package/dist/tools/library-download.d.ts +27 -0
  62. package/dist/tools/library-download.js +177 -0
  63. package/dist/tools/library-publish.d.ts +112 -0
  64. package/dist/tools/library-publish.js +387 -0
  65. package/dist/tools/library-search.d.ts +110 -0
  66. package/dist/tools/library-search.js +132 -0
  67. package/dist/tools/mark-hit.d.ts +1 -0
  68. package/dist/tools/mark-hit.js +83 -5
  69. package/dist/tools/my-books.d.ts +51 -0
  70. package/dist/tools/my-books.js +115 -0
  71. package/dist/tools/my-bounties.d.ts +43 -0
  72. package/dist/tools/my-bounties.js +126 -0
  73. package/dist/tools/rate-book.d.ts +40 -0
  74. package/dist/tools/rate-book.js +147 -0
  75. package/dist/tools/rebuild-index.d.ts +1 -0
  76. package/dist/tools/rebuild-index.js +40 -8
  77. package/dist/tools/record.d.ts +18 -0
  78. package/dist/tools/record.js +30 -26
  79. package/dist/tools/seller-analytics.d.ts +53 -0
  80. package/dist/tools/seller-analytics.js +180 -0
  81. package/dist/tools/sync.d.ts +55 -0
  82. package/dist/tools/sync.js +304 -0
  83. package/dist/tools/unsubscribe.d.ts +48 -0
  84. package/dist/tools/unsubscribe.js +120 -0
  85. package/dist/tools 2/adopt.d.ts +24 -0
  86. package/dist/tools 2/adopt.js +154 -0
  87. package/dist/tools 2/auth.d.ts +35 -0
  88. package/dist/tools 2/auth.js +229 -0
  89. package/dist/tools 2/brief.d.ts +56 -0
  90. package/dist/tools 2/brief.js +414 -0
  91. package/dist/tools 2/help.d.ts +21 -0
  92. package/dist/tools 2/help.js +267 -0
  93. package/dist/tools 2/import-memories.d.ts +32 -0
  94. package/dist/tools 2/import-memories.js +231 -0
  95. package/dist/tools 2/index.d.ts +12 -0
  96. package/dist/tools 2/index.js +12 -0
  97. package/dist/tools 2/mark-hit.d.ts +20 -0
  98. package/dist/tools 2/mark-hit.js +71 -0
  99. package/dist/tools 2/marketplace-buy.d.ts +30 -0
  100. package/dist/tools 2/marketplace-buy.js +97 -0
  101. package/dist/tools 2/marketplace-download.d.ts +26 -0
  102. package/dist/tools 2/marketplace-download.js +160 -0
  103. package/dist/tools 2/marketplace-publish.d.ts +111 -0
  104. package/dist/tools 2/marketplace-publish.js +377 -0
  105. package/dist/tools 2/marketplace-search.d.ts +57 -0
  106. package/dist/tools 2/marketplace-search.js +96 -0
  107. package/dist/tools 2/my-books.d.ts +50 -0
  108. package/dist/tools 2/my-books.js +107 -0
  109. package/dist/tools 2/rate-book.d.ts +39 -0
  110. package/dist/tools 2/rate-book.js +139 -0
  111. package/dist/tools 2/rebuild-index.d.ts +23 -0
  112. package/dist/tools 2/rebuild-index.js +107 -0
  113. package/dist/tools 2/record.d.ts +40 -0
  114. package/dist/tools 2/record.js +205 -0
  115. package/dist/tools 2/seller-analytics.d.ts +35 -0
  116. package/dist/tools 2/seller-analytics.js +102 -0
  117. package/dist/tools 2/sync.d.ts +54 -0
  118. package/dist/tools 2/sync.js +298 -0
  119. package/package.json +1 -1
@@ -0,0 +1,118 @@
1
+ // ============================================================================
2
+ // Bounty Create Tool
3
+ // Create a bounty on the Telvok marketplace
4
+ // ============================================================================
5
+ import { loadApiKey } from './auth.js';
6
+ const TELVOK_API_URL = process.env.TELVOK_API_URL || 'https://telvok.com';
7
+ // ============================================================================
8
+ // Tool Definition
9
+ // ============================================================================
10
+ export const bountyCreateTool = {
11
+ name: 'bounty_create',
12
+ title: 'Create Bounty',
13
+ description: `Create a knowledge bounty when you need specific expertise.
14
+
15
+ USE THIS TOOL WHEN:
16
+ - User needs knowledge that doesn't exist in marketplace
17
+ - User says "I'd pay for someone to explain X"
18
+ - Searching shows no results for a topic user needs
19
+
20
+ Sellers claim bounties, publish relevant books, and get paid when you approve.
21
+ Bounty held in escrow until approval. Platform fee: 20%. Minimum: $5 (500 cents)
22
+
23
+ TRIGGER PATTERNS:
24
+ - Need expertise that doesn't exist → bounty_create({ title: "...", amount_cents: 2000 })
25
+ - "I'd pay for auth patterns" → bounty_create({ title: "Auth best practices", amount_cents: 2000 })
26
+
27
+ Examples:
28
+ - bounty_create({ title: "Stripe webhook patterns", amount_cents: 2000 })
29
+ - bounty_create({ title: "Auth best practices", description: "Need JWT refresh patterns", amount_cents: 5000, tags: ["auth", "jwt"] })`,
30
+ inputSchema: {
31
+ type: 'object',
32
+ properties: {
33
+ title: {
34
+ type: 'string',
35
+ description: 'What knowledge you need (3+ characters)',
36
+ },
37
+ description: {
38
+ type: 'string',
39
+ description: 'Additional details about what you need',
40
+ },
41
+ amount_cents: {
42
+ type: 'number',
43
+ description: 'Bounty amount in cents (minimum 500 = $5)',
44
+ },
45
+ tags: {
46
+ type: 'array',
47
+ items: { type: 'string' },
48
+ description: 'Tags to help sellers find your bounty',
49
+ },
50
+ expires_days: {
51
+ type: 'number',
52
+ description: 'Days until bounty expires (default: 30)',
53
+ },
54
+ },
55
+ required: ['title', 'amount_cents'],
56
+ },
57
+ async handler(args) {
58
+ const { title, description, amount_cents, tags, expires_days } = args;
59
+ // Validate inputs
60
+ if (!title || typeof title !== 'string' || title.length < 3) {
61
+ return {
62
+ success: false,
63
+ message: 'Title must be at least 3 characters',
64
+ };
65
+ }
66
+ if (!amount_cents || typeof amount_cents !== 'number' || amount_cents < 500) {
67
+ return {
68
+ success: false,
69
+ message: 'Minimum bounty amount is $5 (500 cents)',
70
+ };
71
+ }
72
+ // Check authentication
73
+ const apiKey = await loadApiKey();
74
+ if (!apiKey) {
75
+ return {
76
+ success: false,
77
+ message: 'Not authenticated. Run auth({ action: "login" }) to connect your Telvok account first.',
78
+ };
79
+ }
80
+ try {
81
+ const response = await fetch(`${TELVOK_API_URL}/api/bounties`, {
82
+ method: 'POST',
83
+ headers: {
84
+ 'Authorization': `Bearer ${apiKey}`,
85
+ 'Content-Type': 'application/json',
86
+ },
87
+ body: JSON.stringify({
88
+ title,
89
+ description,
90
+ amount_cents,
91
+ tags,
92
+ expires_days,
93
+ }),
94
+ });
95
+ const data = await response.json();
96
+ if (!response.ok) {
97
+ return {
98
+ success: false,
99
+ message: data.error || `Failed to create bounty: HTTP ${response.status}`,
100
+ };
101
+ }
102
+ const amount = `$${(amount_cents / 100).toFixed(2)}`;
103
+ return {
104
+ success: true,
105
+ bounty: data.bounty,
106
+ checkout_url: data.checkout_url,
107
+ message: `Bounty created! Complete payment to activate:\n\n${data.checkout_url}\n\nBounty: "${title}" (${amount})`,
108
+ };
109
+ }
110
+ catch (error) {
111
+ const message = error instanceof Error ? error.message : String(error);
112
+ return {
113
+ success: false,
114
+ message: `Failed to create bounty: ${message}`,
115
+ };
116
+ }
117
+ },
118
+ };
@@ -0,0 +1,50 @@
1
+ interface BountyItem {
2
+ id: string;
3
+ title: string;
4
+ description: string | null;
5
+ amount: string;
6
+ amount_cents: number;
7
+ tags: string[] | null;
8
+ status: string;
9
+ created_at: string;
10
+ expires_at: string;
11
+ }
12
+ interface BountyListResult {
13
+ success: boolean;
14
+ message: string;
15
+ bounties: BountyItem[];
16
+ total: number;
17
+ }
18
+ export declare const bountyListTool: {
19
+ name: string;
20
+ title: string;
21
+ description: string;
22
+ inputSchema: {
23
+ type: "object";
24
+ properties: {
25
+ query: {
26
+ type: string;
27
+ description: string;
28
+ };
29
+ status: {
30
+ type: string;
31
+ enum: string[];
32
+ description: string;
33
+ };
34
+ tags: {
35
+ type: string;
36
+ items: {
37
+ type: string;
38
+ };
39
+ description: string;
40
+ };
41
+ limit: {
42
+ type: string;
43
+ description: string;
44
+ };
45
+ };
46
+ required: never[];
47
+ };
48
+ handler(args: unknown): Promise<BountyListResult>;
49
+ };
50
+ export {};
@@ -0,0 +1,116 @@
1
+ // ============================================================================
2
+ // Bounty List Tool
3
+ // List open bounties on the Telvok marketplace
4
+ // ============================================================================
5
+ const TELVOK_API_URL = process.env.TELVOK_API_URL || 'https://telvok.com';
6
+ // ============================================================================
7
+ // Tool Definition
8
+ // ============================================================================
9
+ export const bountyListTool = {
10
+ name: 'bounty_list',
11
+ title: 'List Bounties',
12
+ description: `Browse bounties to find knowledge requests you can fulfill.
13
+
14
+ USE THIS TOOL WHEN:
15
+ - User wants to earn by sharing expertise
16
+ - Looking for topics people will pay for
17
+ - User asks "what bounties are available"
18
+
19
+ Claim a bounty → publish relevant book → get paid when approved.
20
+
21
+ TRIGGER PATTERNS:
22
+ - "What bounties can I fulfill?" → bounty_list()
23
+ - Looking for earning opportunities → bounty_list({ query: "<user expertise>" })
24
+ - "Show stripe bounties" → bounty_list({ query: "stripe" })
25
+
26
+ Examples:
27
+ - bounty_list() - Show all open bounties
28
+ - bounty_list({ query: "stripe" }) - Search for Stripe-related bounties
29
+ - bounty_list({ tags: ["auth", "security"] }) - Filter by tags`,
30
+ inputSchema: {
31
+ type: 'object',
32
+ properties: {
33
+ query: {
34
+ type: 'string',
35
+ description: 'Search terms to filter bounties',
36
+ },
37
+ status: {
38
+ type: 'string',
39
+ enum: ['open', 'all'],
40
+ description: 'Filter by status (default: open)',
41
+ },
42
+ tags: {
43
+ type: 'array',
44
+ items: { type: 'string' },
45
+ description: 'Filter by tags',
46
+ },
47
+ limit: {
48
+ type: 'number',
49
+ description: 'Maximum results (default: 20, max: 50)',
50
+ },
51
+ },
52
+ required: [],
53
+ },
54
+ async handler(args) {
55
+ const { query, status = 'open', tags, limit = 20 } = (args || {});
56
+ try {
57
+ // Build query params
58
+ const params = new URLSearchParams();
59
+ params.set('status', status);
60
+ params.set('limit', String(Math.min(limit, 50)));
61
+ if (query) {
62
+ params.set('query', query);
63
+ }
64
+ if (tags && tags.length > 0) {
65
+ params.set('tags', tags.join(','));
66
+ }
67
+ const response = await fetch(`${TELVOK_API_URL}/api/bounties?${params}`, {
68
+ method: 'GET',
69
+ headers: {
70
+ 'Content-Type': 'application/json',
71
+ },
72
+ });
73
+ const data = await response.json();
74
+ if (!response.ok) {
75
+ return {
76
+ success: false,
77
+ message: data.error || `Failed to fetch bounties: HTTP ${response.status}`,
78
+ bounties: [],
79
+ total: 0,
80
+ };
81
+ }
82
+ const bounties = data.bounties || [];
83
+ const total = data.total || 0;
84
+ if (bounties.length === 0) {
85
+ const queryMsg = query ? ` for "${query}"` : '';
86
+ return {
87
+ success: true,
88
+ message: `No open bounties found${queryMsg}. Check back later or try different search terms.`,
89
+ bounties: [],
90
+ total: 0,
91
+ };
92
+ }
93
+ // Format summary
94
+ const summary = bounties.map((b, i) => {
95
+ const tagsStr = b.tags?.length ? ` [${b.tags.join(', ')}]` : '';
96
+ return `${i + 1}. **${b.title}** - ${b.amount}${tagsStr}\n ${b.description?.slice(0, 100) || 'No description'}${(b.description?.length || 0) > 100 ? '...' : ''}`;
97
+ }).join('\n');
98
+ const queryMsg = query ? ` for "${query}"` : '';
99
+ return {
100
+ success: true,
101
+ bounties,
102
+ total,
103
+ message: `Found ${total} bounty(s)${queryMsg}:\n\n${summary}\n\nUse bounty_claim({ bounty_id: "..." }) to claim a bounty.`,
104
+ };
105
+ }
106
+ catch (error) {
107
+ const message = error instanceof Error ? error.message : String(error);
108
+ return {
109
+ success: false,
110
+ message: `Failed to fetch bounties: ${message}`,
111
+ bounties: [],
112
+ total: 0,
113
+ };
114
+ }
115
+ },
116
+ };
@@ -0,0 +1,34 @@
1
+ interface BountySubmitResult {
2
+ success: boolean;
3
+ message: string;
4
+ bounty?: {
5
+ id: string;
6
+ title: string;
7
+ status: string;
8
+ };
9
+ library?: {
10
+ slug: string;
11
+ name: string;
12
+ };
13
+ }
14
+ export declare const bountySubmitTool: {
15
+ name: string;
16
+ title: string;
17
+ description: string;
18
+ inputSchema: {
19
+ type: "object";
20
+ properties: {
21
+ bounty_id: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ library_slug: {
26
+ type: string;
27
+ description: string;
28
+ };
29
+ };
30
+ required: string[];
31
+ };
32
+ handler(args: unknown): Promise<BountySubmitResult>;
33
+ };
34
+ export {};
@@ -0,0 +1,94 @@
1
+ // ============================================================================
2
+ // Bounty Submit Tool
3
+ // Submit a book to fulfill a claimed bounty
4
+ // ============================================================================
5
+ import { loadApiKey } from './auth.js';
6
+ const TELVOK_API_URL = process.env.TELVOK_API_URL || 'https://telvok.com';
7
+ // ============================================================================
8
+ // Tool Definition
9
+ // ============================================================================
10
+ export const bountySubmitTool = {
11
+ name: 'bounty_submit',
12
+ title: 'Submit Bounty',
13
+ description: `Submit your published book to fulfill a claimed bounty.
14
+
15
+ USE THIS TOOL WHEN:
16
+ - User has claimed a bounty AND published a book to fulfill it
17
+ - User says "submit my book for the bounty"
18
+
19
+ The bounty creator reviews and approves (releasing payment) or rejects.
20
+
21
+ TRIGGER PATTERNS:
22
+ - After library_publish() for a bounty → bounty_submit({ bounty_id: "...", library_slug: "..." })
23
+ - "Submit my book for the bounty" → bounty_submit({ bounty_id: "...", library_slug: "..." })
24
+
25
+ Example:
26
+ - bounty_submit({ bounty_id: "abc123", library_slug: "my-webhook-patterns" })`,
27
+ inputSchema: {
28
+ type: 'object',
29
+ properties: {
30
+ bounty_id: {
31
+ type: 'string',
32
+ description: 'ID of the bounty you claimed',
33
+ },
34
+ library_slug: {
35
+ type: 'string',
36
+ description: 'Slug of your published book that fulfills the bounty',
37
+ },
38
+ },
39
+ required: ['bounty_id', 'library_slug'],
40
+ },
41
+ async handler(args) {
42
+ const { bounty_id, library_slug } = args;
43
+ if (!bounty_id || typeof bounty_id !== 'string') {
44
+ return {
45
+ success: false,
46
+ message: 'bounty_id is required',
47
+ };
48
+ }
49
+ if (!library_slug || typeof library_slug !== 'string') {
50
+ return {
51
+ success: false,
52
+ message: 'library_slug is required. Publish a book first with library_publish().',
53
+ };
54
+ }
55
+ // Check authentication
56
+ const apiKey = await loadApiKey();
57
+ if (!apiKey) {
58
+ return {
59
+ success: false,
60
+ message: 'Not authenticated. Run auth({ action: "login" }) to connect your Telvok account first.',
61
+ };
62
+ }
63
+ try {
64
+ const response = await fetch(`${TELVOK_API_URL}/api/bounties/${bounty_id}/submit`, {
65
+ method: 'POST',
66
+ headers: {
67
+ 'Authorization': `Bearer ${apiKey}`,
68
+ 'Content-Type': 'application/json',
69
+ },
70
+ body: JSON.stringify({ library_slug }),
71
+ });
72
+ const data = await response.json();
73
+ if (!response.ok) {
74
+ return {
75
+ success: false,
76
+ message: data.error || `Failed to submit: HTTP ${response.status}`,
77
+ };
78
+ }
79
+ return {
80
+ success: true,
81
+ bounty: data.bounty,
82
+ library: data.library,
83
+ message: data.message || `Submitted "${library_slug}" for bounty review. The creator will approve or reject your submission.`,
84
+ };
85
+ }
86
+ catch (error) {
87
+ const message = error instanceof Error ? error.message : String(error);
88
+ return {
89
+ success: false,
90
+ message: `Failed to submit: ${message}`,
91
+ };
92
+ }
93
+ },
94
+ };
@@ -7,15 +7,31 @@ export interface BriefEntry {
7
7
  created: string;
8
8
  hits: number;
9
9
  last_hit: string | null;
10
+ source?: 'local' | 'cloud' | 'packages';
11
+ book_name?: string;
12
+ book_slug?: string;
13
+ }
14
+ export interface MarketplaceBook {
15
+ slug: string;
16
+ name: string;
17
+ description: string;
18
+ pricing: string;
19
+ price: string;
20
+ entries: number;
10
21
  }
11
22
  export interface BriefResult {
12
23
  entries: BriefEntry[];
13
24
  total: number;
14
25
  message: string;
15
26
  libraryPath: string;
27
+ library?: {
28
+ books: MarketplaceBook[];
29
+ total: number;
30
+ };
16
31
  }
17
32
  export declare const briefTool: {
18
33
  name: string;
34
+ title: string;
19
35
  description: string;
20
36
  inputSchema: {
21
37
  type: "object";
@@ -29,8 +45,86 @@ export declare const briefTool: {
29
45
  description: string;
30
46
  default: number;
31
47
  };
48
+ include_library: {
49
+ type: string;
50
+ description: string;
51
+ default: boolean;
52
+ };
32
53
  };
33
54
  required: never[];
34
55
  };
56
+ outputSchema: {
57
+ type: "object";
58
+ properties: {
59
+ entries: {
60
+ type: string;
61
+ items: {
62
+ type: string;
63
+ properties: {
64
+ title: {
65
+ type: string;
66
+ };
67
+ preview: {
68
+ type: string;
69
+ };
70
+ path: {
71
+ type: string;
72
+ };
73
+ hits: {
74
+ type: string;
75
+ };
76
+ source: {
77
+ type: string;
78
+ enum: string[];
79
+ };
80
+ book_name: {
81
+ type: string;
82
+ };
83
+ };
84
+ };
85
+ };
86
+ total: {
87
+ type: string;
88
+ };
89
+ message: {
90
+ type: string;
91
+ };
92
+ libraryPath: {
93
+ type: string;
94
+ };
95
+ library: {
96
+ type: string;
97
+ properties: {
98
+ books: {
99
+ type: string;
100
+ items: {
101
+ type: string;
102
+ properties: {
103
+ slug: {
104
+ type: string;
105
+ };
106
+ name: {
107
+ type: string;
108
+ };
109
+ description: {
110
+ type: string;
111
+ };
112
+ pricing: {
113
+ type: string;
114
+ };
115
+ entries: {
116
+ type: string;
117
+ };
118
+ };
119
+ };
120
+ };
121
+ total: {
122
+ type: string;
123
+ };
124
+ };
125
+ };
126
+ };
127
+ required: string[];
128
+ };
35
129
  handler(args: unknown): Promise<BriefResult>;
36
130
  };