@cachly-dev/mcp-server 0.10.0 → 0.10.2

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/src/index.ts CHANGED
@@ -52,22 +52,19 @@ import { Redis } from 'ioredis';
52
52
  const API_URL = process.env.CACHLY_API_URL ?? 'https://api.cachly.dev';
53
53
  let JWT = process.env.CACHLY_JWT ?? '';
54
54
  const EMBED_MODEL = process.env.CACHLY_EMBED_MODEL ?? '';
55
- const CURRENT_VERSION = '0.10.0';
55
+ const CURRENT_VERSION = '0.9.17';
56
56
 
57
57
  // ── Default Instance Resolution (for Smithery & single-credential setups) ────
58
58
  // When CACHLY_BRAIN_INSTANCE_ID is set, tools can omit the instance_id parameter.
59
59
  // When neither is set, we auto-fetch the first running instance once per process.
60
60
  let _defaultInstanceId: string = process.env.CACHLY_BRAIN_INSTANCE_ID ?? '';
61
- // Timestamp of last failed fetch — retries after 30 s (not permanently blocked).
62
- let _defaultInstanceLastAttempt = 0;
61
+ let _defaultInstanceFetched = false;
63
62
 
64
63
  async function resolveDefaultInstanceId(): Promise<string> {
65
64
  if (_defaultInstanceId) return _defaultInstanceId;
65
+ if (_defaultInstanceFetched) return '';
66
+ _defaultInstanceFetched = true;
66
67
  if (!JWT) return '';
67
- // Cooldown: don't hammer the API on every tool call after a transient failure.
68
- const now = Date.now();
69
- if (_defaultInstanceLastAttempt > 0 && now - _defaultInstanceLastAttempt < 30_000) return '';
70
- _defaultInstanceLastAttempt = now;
71
68
  try {
72
69
  const res = await fetch(`${API_URL}/api/v1/instances`, {
73
70
  headers: { Authorization: `Bearer ${JWT}`, Accept: 'application/json' },
@@ -75,15 +72,9 @@ async function resolveDefaultInstanceId(): Promise<string> {
75
72
  });
76
73
  if (!res.ok) return '';
77
74
  const data = await res.json() as { data?: Array<{ id: string; status: string }> };
78
- const instances = (data?.data ?? []) as Array<{ id: string; status: string }>;
79
- // Prefer running, fall back to provisioning so the ID is resolved even during startup.
80
- const best = instances.find(i => i.status === 'running') ?? instances.find(i => i.status === 'provisioning');
81
- if (best) {
82
- _defaultInstanceId = best.id;
83
- _defaultInstanceLastAttempt = 0;
84
- return _defaultInstanceId;
85
- }
86
- } catch { /* transient error — will retry after cooldown */ }
75
+ const running = (data?.data ?? []).filter(i => i.status === 'running');
76
+ if (running.length > 0) { _defaultInstanceId = running[0].id; return _defaultInstanceId; }
77
+ } catch { /* non-fatal — caller will surface missing instance_id error */ }
87
78
  return '';
88
79
  }
89
80
 
@@ -158,55 +149,24 @@ async function pollDeviceFlow(flow: DeviceFlowState): Promise<'pending' | 'expir
158
149
  JWT = apiKey;
159
150
  setEmbedJwt(apiKey); // keep embeddings.ts in sync
160
151
  _deviceFlow = null;
161
- // Auto-provision: find or create the user's brain instance.
162
- _defaultInstanceLastAttempt = 0;
152
+ // Auto-provision instance
153
+ _defaultInstanceFetched = false;
163
154
  await resolveDefaultInstanceId();
164
155
  if (!_defaultInstanceId) {
156
+ // Try auto-provision
165
157
  try {
166
158
  const autoRes = await fetch(`${API_URL}/api/v1/instances/auto`, {
167
159
  method: 'POST',
168
160
  headers: { Authorization: `Bearer ${JWT}`, 'Content-Type': 'application/json' },
169
- signal: AbortSignal.timeout(12000),
161
+ signal: AbortSignal.timeout(10000),
170
162
  });
171
163
  if (autoRes.ok) {
172
- const body = await autoRes.json() as {
173
- instance?: { id: string; status?: string };
174
- instance_id?: string;
175
- status?: string;
176
- };
164
+ const body = await autoRes.json() as { instance?: { id: string }; instance_id?: string };
177
165
  const id = body.instance?.id ?? body.instance_id;
178
166
  if (id) _defaultInstanceId = id;
179
167
  }
180
168
  } catch { /* non-fatal */ }
181
169
  }
182
- // Give a provisioning instance a head-start so getConnection's wait is shorter.
183
- // The instance is almost always ready by the time the user's tool re-enters.
184
- if (_defaultInstanceId) {
185
- try {
186
- const checkRes = await fetch(`${API_URL}/api/v1/instances/${_defaultInstanceId}`, {
187
- headers: { Authorization: `Bearer ${JWT}`, Accept: 'application/json' },
188
- signal: AbortSignal.timeout(4000),
189
- });
190
- if (checkRes.ok) {
191
- const checkInst = await checkRes.json() as { status?: string };
192
- if (checkInst.status === 'provisioning') {
193
- // Wait up to 20s here so the re-entered tool call lands on a running instance.
194
- const pDeadline = Date.now() + 20_000;
195
- while (checkInst.status === 'provisioning' && Date.now() < pDeadline) {
196
- await new Promise(r => setTimeout(r, 3000));
197
- const rr = await fetch(`${API_URL}/api/v1/instances/${_defaultInstanceId}`, {
198
- headers: { Authorization: `Bearer ${JWT}`, Accept: 'application/json' },
199
- signal: AbortSignal.timeout(4000),
200
- }).catch(() => null);
201
- if (rr?.ok) {
202
- const ri = await rr.json() as { status?: string };
203
- (checkInst as { status?: string }).status = ri.status;
204
- } else { break; }
205
- }
206
- }
207
- }
208
- } catch { /* non-fatal — getConnection will handle the wait if still provisioning */ }
209
- }
210
170
  return 'done';
211
171
  }
212
172
  if (data.error === 'slow_down') flow.pollInterval = Math.min(flow.pollInterval + 2000, 15000);
@@ -256,48 +216,18 @@ interface SemanticSearchResponse {
256
216
  const pool = new Map<string, Redis>();
257
217
 
258
218
  async function getConnection(instance_id: string): Promise<Redis> {
259
- if (!instance_id) {
260
- throw new McpError(
261
- ErrorCode.InvalidRequest,
262
- 'No instance_id provided and no running instance could be resolved automatically.\n\n' +
263
- '• Set CACHLY_BRAIN_INSTANCE_ID in your MCP config, or\n' +
264
- '• Pass instance_id explicitly to the tool, or\n' +
265
- '• Run `list_instances` to see your available instances.'
266
- );
267
- }
268
-
269
219
  if (pool.has(instance_id)) return pool.get(instance_id)!;
270
220
 
271
- // Fetch instance, waiting up to 25 s if it is still provisioning.
272
- // This covers the zero-friction path: device-flow auth → auto-provision → first tool call
273
- // all happen in quick succession and the instance isn't running yet.
274
- let inst = await apiFetch<Instance>(`/api/v1/instances/${instance_id}`);
275
- if (inst.status === 'provisioning') {
276
- const deadline = Date.now() + 25_000;
277
- while (inst.status === 'provisioning' && Date.now() < deadline) {
278
- await new Promise(r => setTimeout(r, 3000));
279
- inst = await apiFetch<Instance>(`/api/v1/instances/${instance_id}`);
280
- }
281
- }
282
-
221
+ const inst = await apiFetch<Instance>(`/api/v1/instances/${instance_id}`);
283
222
  if (inst.status !== 'running') {
284
- // Telemetry: unreachable instance so the team can proactively investigate
285
- void fetch(`${API_URL}/api/v1/telemetry/mcp`, {
286
- method: 'POST',
287
- headers: { 'Content-Type': 'application/json', ...(JWT ? { Authorization: `Bearer ${JWT}` } : {}) },
288
- body: JSON.stringify({ event: 'instance_not_reachable', instance_id, status: inst.status, version: CURRENT_VERSION }),
289
- signal: AbortSignal.timeout(3000),
290
- }).catch(() => {});
291
- const hint = inst.status === 'provisioning'
292
- ? `⏳ Brain instance "${inst.name}" is still starting up.\n\nThis usually finishes within 30 seconds. Please try again in a moment.`
293
- : `Brain instance "${inst.name}" is not reachable (status: ${inst.status}).\n\n` +
294
- `• View your instance at: https://cachly.dev/instances\n` +
295
- `• Run \`get_api_status\` for a full diagnostic.`;
296
- throw new McpError(ErrorCode.InvalidRequest, hint);
223
+ throw new McpError(
224
+ ErrorCode.InvalidRequest,
225
+ `Instance "${inst.name}" is not running (status: ${inst.status}). ` +
226
+ `It may still be provisioning or awaiting payment.`
227
+ );
297
228
  }
298
229
  if (!inst.host || !inst.port) {
299
- throw new McpError(ErrorCode.InternalError,
300
- `Instance "${inst.name}" is running but has no host/port — contact support@cachly.dev.`);
230
+ throw new McpError(ErrorCode.InternalError, `Instance "${inst.name}" has no host/port yet.`);
301
231
  }
302
232
 
303
233
  // Fetch connection details (includes password) from the dedicated endpoint.
@@ -310,7 +240,7 @@ async function getConnection(instance_id: string): Promise<Redis> {
310
240
  password = conn.password ?? undefined;
311
241
  tlsEnabled = conn.tls_enabled !== false;
312
242
  } catch {
313
- // Fallback: use TLS flag from instance metadata
243
+ // Fallback: no password, use TLS default from instance
314
244
  }
315
245
 
316
246
  const client = new Redis({
@@ -318,33 +248,26 @@ async function getConnection(instance_id: string): Promise<Redis> {
318
248
  port: inst.port,
319
249
  password: password || undefined,
320
250
  ...(tlsEnabled ? { tls: {} } : {}),
321
- lazyConnect: true,
251
+ lazyConnect: true, // don't auto-connect — we connect explicitly below
322
252
  enableReadyCheck: true,
323
- connectTimeout: 8000,
253
+ connectTimeout: 5000,
324
254
  retryStrategy: () => null, // fail fast, no reconnect loops in MCP context
325
255
  });
326
256
 
327
- const evict = () => pool.delete(instance_id);
328
- client.on('error', evict);
329
- client.on('end', evict);
257
+ client.on('error', () => {
258
+ pool.delete(instance_id); // remove stale connection on error
259
+ });
330
260
 
261
+ // Connect explicitly so we can catch connection errors as a proper rejected
262
+ // Promise instead of an unhandled 'error' event that would kill the process.
331
263
  try {
332
264
  await client.connect();
333
265
  } catch (err: unknown) {
334
266
  client.disconnect();
335
267
  const msg = err instanceof Error ? err.message : String(err);
336
- void fetch(`${API_URL}/api/v1/telemetry/mcp`, {
337
- method: 'POST',
338
- headers: { 'Content-Type': 'application/json', ...(JWT ? { Authorization: `Bearer ${JWT}` } : {}) },
339
- body: JSON.stringify({ event: 'redis_connect_failed', instance_id, host: inst.host, port: inst.port, error: msg, version: CURRENT_VERSION }),
340
- signal: AbortSignal.timeout(3000),
341
- }).catch(() => {});
342
268
  throw new McpError(
343
269
  ErrorCode.InternalError,
344
- `Could not reach Brain instance "${inst.name}" (${inst.host}:${inst.port}).\n\n` +
345
- `• Check your network connection\n` +
346
- `• Run \`get_api_status\` to verify instance status\n` +
347
- `• Technical detail: ${msg}`
270
+ `Could not connect to instance "${inst.name}" (${inst.host}:${inst.port}): ${msg}`
348
271
  );
349
272
  }
350
273
 
@@ -460,6 +383,61 @@ async function sendAnonymousTelemetry(toolName: string): Promise<void> {
460
383
  }
461
384
 
462
385
  async function handleTool(name: string, args: Record<string, unknown>): Promise<string> {
386
+ // ── sign_in: explicit device-flow trigger — works even without JWT ────────
387
+ if (name === 'sign_in') {
388
+ if (JWT) {
389
+ return '✅ **Already signed in.** Your cachly AI Brain is ready — all 63 tools available.';
390
+ }
391
+ // Poll if flow already in progress
392
+ if (_deviceFlow) {
393
+ const result = await pollDeviceFlow(_deviceFlow);
394
+ if (result === 'done') {
395
+ return [
396
+ '✅ **Sign-in complete!** Your cachly AI Brain is ready.',
397
+ '',
398
+ 'All 63 brain tools are now available. Start with `session_start` to load context from your last session.',
399
+ ].join('\n');
400
+ }
401
+ if (result === 'expired') {
402
+ _deviceFlow = null;
403
+ // fall through to start a new flow
404
+ } else {
405
+ return [
406
+ '⏳ **Waiting for you to approve in the browser...**',
407
+ '',
408
+ `Sign in at: **${_deviceFlow.verifyUrl}**`,
409
+ `Code: **${_deviceFlow.userCode}**`,
410
+ '',
411
+ 'After approving, call `sign_in` again — it will complete automatically.',
412
+ ].join('\n');
413
+ }
414
+ }
415
+ const flow = await startDeviceFlow();
416
+ if (flow) {
417
+ _deviceFlow = flow;
418
+ return [
419
+ '🧠 **cachly AI Brain — One-click sign in**',
420
+ '',
421
+ '1. Open this URL (it may open automatically):',
422
+ ` **${flow.verifyUrl}**`,
423
+ '',
424
+ `2. If prompted for a code, enter: **${flow.userCode}**`,
425
+ '',
426
+ '3. After approving in your browser, call `sign_in` again — it will complete automatically.',
427
+ '',
428
+ '✨ Free tier: 1 Brain instance · persistent memory · 63 MCP tools · no credit card required.',
429
+ ].join('\n');
430
+ }
431
+ return [
432
+ '🧠 **cachly AI Brain — Setup required**',
433
+ '',
434
+ 'Run once in your terminal:',
435
+ ' `npx @cachly-dev/mcp-server@latest setup`',
436
+ '',
437
+ 'Or sign up at: https://cachly.dev/setup-ai',
438
+ ].join('\n');
439
+ }
440
+
463
441
  // Guard: if no JWT, return actionable onboarding message instead of HTTP 401
464
442
  if (!JWT) {
465
443
  void sendAnonymousTelemetry(name);
@@ -614,44 +592,6 @@ async function handleTool(name: string, args: Record<string, unknown>): Promise<
614
592
  authInfo = '❌ JWT decode failed – check CACHLY_JWT format';
615
593
  }
616
594
 
617
- // List instances + connectivity
618
- let instanceInfo = '';
619
- try {
620
- const listRes = await apiFetch<{ data: Instance[] }>('/api/v1/instances');
621
- const instances = listRes.data ?? [];
622
- if (instances.length === 0) {
623
- instanceInfo = '\n\n🧠 **Brain Instances:** none — create one at https://cachly.dev/instances';
624
- } else {
625
- const lines: string[] = ['\n\n🧠 **Brain Instances:**'];
626
- for (const inst of instances) {
627
- const badge = inst.status === 'running' ? '🟢' : inst.status === 'provisioning' ? '🟡' : '🔴';
628
- const defaultMark = inst.id === _defaultInstanceId ? ' ← active' : '';
629
- lines.push(` ${badge} **${inst.name}** (\`${inst.id}\`) · ${inst.status}${defaultMark}`);
630
- if (inst.status === 'running' && inst.host) {
631
- // Try a quick ping on the cached connection
632
- const pooled = pool.get(inst.id);
633
- if (pooled) {
634
- try {
635
- await pooled.ping();
636
- lines.push(` 💓 Redis: connected`);
637
- } catch {
638
- lines.push(` ⚠️ Redis: pooled but ping failed — will reconnect on next use`);
639
- }
640
- } else {
641
- lines.push(` 💤 Redis: not connected yet (connects on first tool use)`);
642
- }
643
- } else if (inst.status === 'provisioning') {
644
- lines.push(` ⏳ Still provisioning — check back in ~30 s`);
645
- } else if (inst.status !== 'running') {
646
- lines.push(` ❌ Not reachable (status: ${inst.status})`);
647
- }
648
- }
649
- instanceInfo = lines.join('\n');
650
- }
651
- } catch (e) {
652
- instanceInfo = `\n\n🧠 **Brain Instances:** could not fetch — ${(e as Error).message}`;
653
- }
654
-
655
595
  return [
656
596
  `📡 **cachly API Status**`,
657
597
  ``,
@@ -660,7 +600,6 @@ async function handleTool(name: string, args: Record<string, unknown>): Promise<
660
600
  ``,
661
601
  `🔑 **Auth:**`,
662
602
  authInfo,
663
- instanceInfo,
664
603
  ].join('\n');
665
604
  }
666
605
 
@@ -674,7 +613,15 @@ const server = new Server(
674
613
  { capabilities: { tools: {} } }
675
614
  );
676
615
 
677
- server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
616
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
617
+ if (!JWT) {
618
+ // Surface sign_in as the only prominent tool when not authenticated,
619
+ // so AI assistants proactively call it before attempting any brain tool.
620
+ const signInTool = TOOLS.find(t => t.name === 'sign_in');
621
+ return { tools: signInTool ? [signInTool] : TOOLS };
622
+ }
623
+ return { tools: TOOLS };
624
+ });
678
625
 
679
626
  // ── Auto-session management ───────────────────────────────────────────────────
680
627
  // Transparently starts a Brain session on the first tool call of a process
@@ -698,9 +645,8 @@ async function autoStartSession(instanceId: string): Promise<void> {
698
645
  _autoSessionInstanceId = instanceId;
699
646
  try {
700
647
  await handleTool('session_start', { instance_id: instanceId, focus: 'auto (MCP session)' });
701
- } catch { /* non-fatal — session tracking is a best-effort feature */ } finally {
702
- _autoSessionStarting = null;
703
- }
648
+ } catch { /* non-fatal — session tracking is a best-effort feature */ }
649
+ _autoSessionStarting = null;
704
650
  })();
705
651
  await _autoSessionStarting;
706
652
 
@@ -749,9 +695,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
749
695
  // Skip session management tools to avoid recursion.
750
696
  const sessionTools = new Set(['session_start', 'session_end', 'auto_learn_session']);
751
697
  if (!sessionTools.has(name) && !_autoSessionStarted && !_autoSessionStarting) {
752
- const instanceId = ((args as Record<string, unknown>)?.instance_id as string | undefined)
753
- || _defaultInstanceId
754
- || process.env.CACHLY_BRAIN_INSTANCE_ID;
698
+ const instanceId = (args as Record<string, unknown>)?.instance_id as string | undefined;
755
699
  if (instanceId) {
756
700
  await autoStartSession(instanceId).catch(() => undefined);
757
701
  }
package/src/tools.ts CHANGED
@@ -3,6 +3,18 @@
3
3
  // ── Tools ─────────────────────────────────────────────────────────────────────
4
4
 
5
5
  const TOOLS = [
6
+ // ── Auth / Onboarding ────────────────────────────────────────────────────
7
+ {
8
+ name: 'sign_in',
9
+ description:
10
+ 'Sign in to cachly AI Brain. Call this FIRST if no CACHLY_JWT is configured. ' +
11
+ 'Starts an OAuth 2.0 Device Flow: you visit a short URL in your browser, approve in one click, ' +
12
+ 'and the brain is ready instantly — no copy-paste, no dashboard required. ' +
13
+ 'After sign-in, a free Brain instance is auto-provisioned if you don\'t have one yet. ' +
14
+ 'Once authenticated, all 63 brain tools become available. ' +
15
+ 'IMPORTANT: AI assistants should call this tool proactively at session start when CACHLY_JWT is not set.',
16
+ inputSchema: { type: 'object', properties: {}, required: [] },
17
+ },
6
18
  // ── Instance Management ──────────────────────────────────────────────────
7
19
  {
8
20
  name: 'list_instances',
@@ -437,11 +449,10 @@ const TOOLS = [
437
449
  {
438
450
  name: 'get_api_status',
439
451
  description:
440
- 'Full diagnostic for your cachly Brain — call this FIRST whenever anything is not working. ' +
441
- 'Returns: API reachability, JWT validity + expiry, your user ID, ' +
442
- 'all Brain instances with live status (🟢 running / 🟡 provisioning / 🔴 stopped), ' +
443
- 'Redis ping on the active connection, and actionable fix steps for every issue found. ' +
444
- 'Workflow: run get_api_status → read the issue it flags → fix it → retry your tool.',
452
+ 'Check the cachly API health and your authentication status. ' +
453
+ 'Returns whether the JWT is valid, your user ID (sub claim), ' +
454
+ 'token expiry, and the auth provider (keycloak). ' +
455
+ 'Use this to debug connection issues or verify your CACHLY_JWT is correct.',
445
456
  inputSchema: { type: 'object', properties: {}, required: [] },
446
457
  },
447
458
  // ── Thinking/Context Cache (for AI assistants) ────────────────────────────
@@ -1,42 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- workflow_dispatch:
7
-
8
- jobs:
9
- publish:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v4
13
-
14
- - uses: actions/setup-node@v4
15
- with:
16
- node-version: '20'
17
- registry-url: 'https://registry.npmjs.org'
18
-
19
- - name: Install dependencies
20
- run: npm install --ignore-scripts
21
-
22
- - name: Build
23
- run: npm run build
24
-
25
- - name: Check if version is already published
26
- id: version_check
27
- run: |
28
- PKG_VERSION=$(node -p "require('./package.json').version")
29
- echo "version=$PKG_VERSION" >> $GITHUB_OUTPUT
30
- if npm view "@cachly-dev/mcp-server@$PKG_VERSION" version &>/dev/null; then
31
- echo "skip=true" >> $GITHUB_OUTPUT
32
- echo "Version $PKG_VERSION already published — skipping."
33
- else
34
- echo "skip=false" >> $GITHUB_OUTPUT
35
- echo "Version $PKG_VERSION is new — will publish."
36
- fi
37
-
38
- - name: Publish
39
- if: steps.version_check.outputs.skip == 'false'
40
- run: npm publish --access public
41
- env:
42
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/LICENSE DELETED
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
package/dist/utils.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function safeJsonParse<T>(raw: string | null | undefined, fallback: T): T;
package/dist/utils.js DELETED
@@ -1,13 +0,0 @@
1
- // Safely parses a JSON string. Returns `fallback` on null, empty, or malformed
2
- // input instead of throwing a SyntaxError that would fail the entire tool call.
3
- export function safeJsonParse(raw, fallback) {
4
- if (!raw)
5
- return fallback;
6
- try {
7
- return JSON.parse(raw);
8
- }
9
- catch {
10
- return fallback;
11
- }
12
- }
13
- //# sourceMappingURL=utils.js.map