@agllama/mcp 0.7.2 → 0.10.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.
- package/README.md +68 -18
- package/dist/__tests__/api-client.dispatch.test.d.ts +2 -0
- package/dist/__tests__/api-client.dispatch.test.d.ts.map +1 -0
- package/dist/__tests__/api-client.dispatch.test.js +243 -0
- package/dist/__tests__/api-client.dispatch.test.js.map +1 -0
- package/dist/api-client.d.ts +161 -9
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +203 -56
- package/dist/api-client.js.map +1 -1
- package/dist/hosted/__tests__/context.test.d.ts +2 -0
- package/dist/hosted/__tests__/context.test.d.ts.map +1 -0
- package/dist/hosted/__tests__/context.test.js +77 -0
- package/dist/hosted/__tests__/context.test.js.map +1 -0
- package/dist/hosted/__tests__/toolSurface.test.d.ts +2 -0
- package/dist/hosted/__tests__/toolSurface.test.d.ts.map +1 -0
- package/dist/hosted/__tests__/toolSurface.test.js +20 -0
- package/dist/hosted/__tests__/toolSurface.test.js.map +1 -0
- package/dist/hosted/context.d.ts +11 -0
- package/dist/hosted/context.d.ts.map +1 -0
- package/dist/hosted/context.js +39 -0
- package/dist/hosted/context.js.map +1 -0
- package/dist/hosted/toolSurface.d.ts +21 -0
- package/dist/hosted/toolSurface.d.ts.map +1 -0
- package/dist/hosted/toolSurface.js +51 -0
- package/dist/hosted/toolSurface.js.map +1 -0
- package/dist/lib/__tests__/resolve-org-project.test.d.ts +2 -0
- package/dist/lib/__tests__/resolve-org-project.test.d.ts.map +1 -0
- package/dist/lib/__tests__/resolve-org-project.test.js +114 -0
- package/dist/lib/__tests__/resolve-org-project.test.js.map +1 -0
- package/dist/lib/resolve-org-project.d.ts +28 -0
- package/dist/lib/resolve-org-project.d.ts.map +1 -0
- package/dist/lib/resolve-org-project.js +16 -0
- package/dist/lib/resolve-org-project.js.map +1 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +32 -118
- package/dist/server.js.map +1 -1
- package/dist/tools/__tests__/connect.test.d.ts +2 -0
- package/dist/tools/__tests__/connect.test.d.ts.map +1 -0
- package/dist/tools/__tests__/connect.test.js +57 -0
- package/dist/tools/__tests__/connect.test.js.map +1 -0
- package/dist/tools/__tests__/help.test.d.ts +2 -0
- package/dist/tools/__tests__/help.test.d.ts.map +1 -0
- package/dist/tools/__tests__/help.test.js +25 -0
- package/dist/tools/__tests__/help.test.js.map +1 -0
- package/dist/tools/__tests__/issuePlanLinks.test.d.ts +2 -0
- package/dist/tools/__tests__/issuePlanLinks.test.d.ts.map +1 -0
- package/dist/tools/__tests__/issuePlanLinks.test.js +294 -0
- package/dist/tools/__tests__/issuePlanLinks.test.js.map +1 -0
- package/dist/tools/__tests__/plans.test.d.ts +2 -0
- package/dist/tools/__tests__/plans.test.d.ts.map +1 -0
- package/dist/tools/__tests__/plans.test.js +359 -0
- package/dist/tools/__tests__/plans.test.js.map +1 -0
- package/dist/tools/__tests__/prScorer.test.js +7 -0
- package/dist/tools/__tests__/prScorer.test.js.map +1 -1
- package/dist/tools/__tests__/session.test.js +165 -1
- package/dist/tools/__tests__/session.test.js.map +1 -1
- package/dist/tools/__tests__/skills.createSkill.hosted.test.d.ts +2 -0
- package/dist/tools/__tests__/skills.createSkill.hosted.test.d.ts.map +1 -0
- package/dist/tools/__tests__/skills.createSkill.hosted.test.js +102 -0
- package/dist/tools/__tests__/skills.createSkill.hosted.test.js.map +1 -0
- package/dist/tools/__tests__/specs.test.d.ts +2 -0
- package/dist/tools/__tests__/specs.test.d.ts.map +1 -0
- package/dist/tools/__tests__/specs.test.js +262 -0
- package/dist/tools/__tests__/specs.test.js.map +1 -0
- package/dist/tools/analytics.js +3 -3
- package/dist/tools/analytics.js.map +1 -1
- package/dist/tools/attachments.d.ts.map +1 -1
- package/dist/tools/attachments.js +11 -19
- package/dist/tools/attachments.js.map +1 -1
- package/dist/tools/backlog.js +4 -4
- package/dist/tools/backlog.js.map +1 -1
- package/dist/tools/boardConfig.js +2 -2
- package/dist/tools/boardConfig.js.map +1 -1
- package/dist/tools/boards.js +4 -4
- package/dist/tools/boards.js.map +1 -1
- package/dist/tools/codeDocs.d.ts +7 -6
- package/dist/tools/codeDocs.d.ts.map +1 -1
- package/dist/tools/codeDocs.js +16 -26
- package/dist/tools/codeDocs.js.map +1 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +2 -14
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/connect.d.ts.map +1 -1
- package/dist/tools/connect.js +26 -13
- package/dist/tools/connect.js.map +1 -1
- package/dist/tools/context.js +2 -2
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/devLinks.js +2 -2
- package/dist/tools/devLinks.js.map +1 -1
- package/dist/tools/help.d.ts.map +1 -1
- package/dist/tools/help.js +53 -20
- package/dist/tools/help.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/issueLinks.js +3 -3
- package/dist/tools/issueLinks.js.map +1 -1
- package/dist/tools/issuePlanLinks.d.ts +18 -8
- package/dist/tools/issuePlanLinks.d.ts.map +1 -1
- package/dist/tools/issuePlanLinks.js +182 -67
- package/dist/tools/issuePlanLinks.js.map +1 -1
- package/dist/tools/issues.d.ts +15 -19
- package/dist/tools/issues.d.ts.map +1 -1
- package/dist/tools/issues.js +28 -14
- package/dist/tools/issues.js.map +1 -1
- package/dist/tools/labels.d.ts +2 -2
- package/dist/tools/labels.js +3 -3
- package/dist/tools/labels.js.map +1 -1
- package/dist/tools/notificationRules.d.ts +2 -2
- package/dist/tools/notificationRules.js +2 -2
- package/dist/tools/notificationRules.js.map +1 -1
- package/dist/tools/organizations.d.ts +2 -2
- package/dist/tools/plans.d.ts +44 -5
- package/dist/tools/plans.d.ts.map +1 -1
- package/dist/tools/plans.js +132 -32
- package/dist/tools/plans.js.map +1 -1
- package/dist/tools/prScorer.js +3 -3
- package/dist/tools/prScorer.js.map +1 -1
- package/dist/tools/prScorerHistory.js +2 -2
- package/dist/tools/prScorerHistory.js.map +1 -1
- package/dist/tools/projectErrors.d.ts +2 -2
- package/dist/tools/projectErrors.d.ts.map +1 -1
- package/dist/tools/projectErrors.js +2 -14
- package/dist/tools/projectErrors.js.map +1 -1
- package/dist/tools/prompts.d.ts +4 -4
- package/dist/tools/prompts.d.ts.map +1 -1
- package/dist/tools/prompts.js +11 -12
- package/dist/tools/prompts.js.map +1 -1
- package/dist/tools/refinement.js +3 -3
- package/dist/tools/refinement.js.map +1 -1
- package/dist/tools/roadmap.d.ts +12 -12
- package/dist/tools/roadmap.d.ts.map +1 -1
- package/dist/tools/roadmap.js +3 -15
- package/dist/tools/roadmap.js.map +1 -1
- package/dist/tools/rollup.js +2 -2
- package/dist/tools/rollup.js.map +1 -1
- package/dist/tools/search.d.ts +2 -2
- package/dist/tools/search.js +2 -2
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/session.d.ts +33 -2
- package/dist/tools/session.d.ts.map +1 -1
- package/dist/tools/session.js +104 -7
- package/dist/tools/session.js.map +1 -1
- package/dist/tools/skills.d.ts +8 -8
- package/dist/tools/skills.d.ts.map +1 -1
- package/dist/tools/skills.js +21 -0
- package/dist/tools/skills.js.map +1 -1
- package/dist/tools/specs.d.ts +30 -0
- package/dist/tools/specs.d.ts.map +1 -0
- package/dist/tools/specs.js +127 -0
- package/dist/tools/specs.js.map +1 -0
- package/dist/tools/sprints.js +4 -4
- package/dist/tools/sprints.js.map +1 -1
- package/dist/types.d.ts +100 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -2
- package/dist/types.js.map +1 -1
- package/dist/utils/__tests__/zod-json-schema.test.d.ts +2 -0
- package/dist/utils/__tests__/zod-json-schema.test.d.ts.map +1 -0
- package/dist/utils/__tests__/zod-json-schema.test.js +97 -0
- package/dist/utils/__tests__/zod-json-schema.test.js.map +1 -0
- package/dist/utils/zod-json-schema.d.ts +29 -0
- package/dist/utils/zod-json-schema.d.ts.map +1 -0
- package/dist/utils/zod-json-schema.js +128 -0
- package/dist/utils/zod-json-schema.js.map +1 -0
- package/package.json +21 -4
- package/dist/tools/decomposition.d.ts +0 -236
- package/dist/tools/decomposition.d.ts.map +0 -1
- package/dist/tools/decomposition.js +0 -285
- package/dist/tools/decomposition.js.map +0 -1
- package/dist/tools/documents.d.ts +0 -99
- package/dist/tools/documents.d.ts.map +0 -1
- package/dist/tools/documents.js +0 -254
- package/dist/tools/documents.js.map +0 -1
- package/dist/tools/epicSignOff.d.ts +0 -25
- package/dist/tools/epicSignOff.d.ts.map +0 -1
- package/dist/tools/epicSignOff.js +0 -89
- package/dist/tools/epicSignOff.js.map +0 -1
- package/dist/tools/integrations.d.ts +0 -38
- package/dist/tools/integrations.d.ts.map +0 -1
- package/dist/tools/integrations.js +0 -153
- package/dist/tools/integrations.js.map +0 -1
- package/dist/tools/planComments.d.ts.map +0 -1
- package/dist/tools/planComments.js.map +0 -1
- package/dist/tools/status.d.ts.map +0 -1
- package/dist/tools/status.js.map +0 -1
- package/dist/tools/workflows.d.ts +0 -169
- package/dist/tools/workflows.d.ts.map +0 -1
- package/dist/tools/workflows.js +0 -436
- package/dist/tools/workflows.js.map +0 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { getHostedClientOverride, runWithHostedClient } from '../context.js';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// LLAMA-2076 — the whole reason this is AsyncLocalStorage and not a bare
|
|
5
|
+
// module-level "current client" variable: two concurrent hosted requests
|
|
6
|
+
// must never observe each other's client, no matter how their async
|
|
7
|
+
// continuations interleave. These tests fabricate that interleaving
|
|
8
|
+
// deliberately (staggered setTimeout delays) rather than relying on it
|
|
9
|
+
// happening "by luck".
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
function fakeClient(tag) {
|
|
12
|
+
// Only `tag` is ever read by these tests — cast through unknown since a
|
|
13
|
+
// real LlamaApiClient requires baseUrl/apiKey construction we don't need.
|
|
14
|
+
return { tag };
|
|
15
|
+
}
|
|
16
|
+
describe('getHostedClientOverride (LLAMA-2076)', () => {
|
|
17
|
+
it('returns undefined outside any runWithHostedClient() context — the stdio path is unaffected', () => {
|
|
18
|
+
expect(getHostedClientOverride()).toBeUndefined();
|
|
19
|
+
});
|
|
20
|
+
it('returns the bound client for synchronous access inside run()', async () => {
|
|
21
|
+
const client = fakeClient('A');
|
|
22
|
+
await runWithHostedClient(client, async () => {
|
|
23
|
+
expect(getHostedClientOverride()).toBe(client);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it('keeps the binding across multiple awaits inside the same run()', async () => {
|
|
27
|
+
const client = fakeClient('B');
|
|
28
|
+
await runWithHostedClient(client, async () => {
|
|
29
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
30
|
+
expect(getHostedClientOverride()).toBe(client);
|
|
31
|
+
await Promise.resolve().then(() => Promise.resolve());
|
|
32
|
+
expect(getHostedClientOverride()).toBe(client);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
it('reverts to undefined once run() has resolved', async () => {
|
|
36
|
+
await runWithHostedClient(fakeClient('C'), async () => {
|
|
37
|
+
/* no-op */
|
|
38
|
+
});
|
|
39
|
+
expect(getHostedClientOverride()).toBeUndefined();
|
|
40
|
+
});
|
|
41
|
+
it('two concurrent runWithHostedClient() calls never observe each other\'s client, even when their awaits interleave', async () => {
|
|
42
|
+
const clientA = fakeClient('A');
|
|
43
|
+
const clientB = fakeClient('B');
|
|
44
|
+
const observedA = [];
|
|
45
|
+
const observedB = [];
|
|
46
|
+
const taskA = runWithHostedClient(clientA, async () => {
|
|
47
|
+
observedA.push(getHostedClientOverride());
|
|
48
|
+
// Deliberately staggered delay so B's continuation runs while A is
|
|
49
|
+
// still "in flight" — the exact interleaving a bare mutable would get
|
|
50
|
+
// wrong.
|
|
51
|
+
await new Promise((r) => setTimeout(r, 20));
|
|
52
|
+
observedA.push(getHostedClientOverride());
|
|
53
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
54
|
+
observedA.push(getHostedClientOverride());
|
|
55
|
+
});
|
|
56
|
+
const taskB = runWithHostedClient(clientB, async () => {
|
|
57
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
58
|
+
observedB.push(getHostedClientOverride());
|
|
59
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
60
|
+
observedB.push(getHostedClientOverride());
|
|
61
|
+
});
|
|
62
|
+
await Promise.all([taskA, taskB]);
|
|
63
|
+
expect(observedA.every((c) => c === clientA)).toBe(true);
|
|
64
|
+
expect(observedB.every((c) => c === clientB)).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
it('propagates the binding through nested Promise chains, not just direct awaits', async () => {
|
|
67
|
+
const client = fakeClient('D');
|
|
68
|
+
let observed;
|
|
69
|
+
await runWithHostedClient(client, () => Promise.resolve()
|
|
70
|
+
.then(() => new Promise((r) => setTimeout(r, 0)))
|
|
71
|
+
.then(async () => {
|
|
72
|
+
observed = getHostedClientOverride();
|
|
73
|
+
}));
|
|
74
|
+
expect(observed).toBe(client);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=context.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.test.js","sourceRoot":"","sources":["../../../src/hosted/__tests__/context.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAG7E,8EAA8E;AAC9E,yEAAyE;AACzE,yEAAyE;AACzE,oEAAoE;AACpE,oEAAoE;AACpE,uEAAuE;AACvE,uBAAuB;AACvB,8EAA8E;AAE9E,SAAS,UAAU,CAAC,GAAW;IAC7B,wEAAwE;IACxE,0EAA0E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AAI,CAAC,uBAAuB,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QAElC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,KAAK,IAAI,EAAE;QAC5F,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,QAAoC,CAAC;QAEzC,MAAM,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,CACrC,OAAO,CAAC,OAAO,EAAE;aACd,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;aAChD,IAAI,CAAC,KAAK,IAAI,EAAE;YACf,QAAQ,GAAG,uBAAuB,EAAE,CAAC;QACvC,CAAC,CAAC,CACL,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolSurface.test.d.ts","sourceRoot":"","sources":["../../../src/hosted/__tests__/toolSurface.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { HOSTED_EXCLUDED_TOOL_NAMES, HOSTED_TOOL_SURFACE_VERSION, isHostedExcludedTool, } from '../toolSurface.js';
|
|
3
|
+
describe('hosted tool surface (LLAMA-2076 REQ-05/REQ-07)', () => {
|
|
4
|
+
it('excludes exactly the local-filesystem / raw-self-HTTP tools identified by this story', () => {
|
|
5
|
+
expect([...HOSTED_EXCLUDED_TOOL_NAMES].sort()).toEqual(['llama_attach_file', 'llama_download_attachment', 'llama_import_csv', 'llama_list_sessions'].sort());
|
|
6
|
+
});
|
|
7
|
+
it('isHostedExcludedTool() matches the set exactly', () => {
|
|
8
|
+
for (const name of HOSTED_EXCLUDED_TOOL_NAMES) {
|
|
9
|
+
expect(isHostedExcludedTool(name)).toBe(true);
|
|
10
|
+
}
|
|
11
|
+
expect(isHostedExcludedTool('llama_get_issue')).toBe(false);
|
|
12
|
+
expect(isHostedExcludedTool('llama_get_backlog')).toBe(false);
|
|
13
|
+
expect(isHostedExcludedTool('llama_get_transcription')).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
it('has a non-empty version string to key/invalidate a cached tools/list on', () => {
|
|
16
|
+
expect(typeof HOSTED_TOOL_SURFACE_VERSION).toBe('string');
|
|
17
|
+
expect(HOSTED_TOOL_SURFACE_VERSION.length).toBeGreaterThan(0);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=toolSurface.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolSurface.test.js","sourceRoot":"","sources":["../../../src/hosted/__tests__/toolSurface.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC9D,EAAE,CAAC,sFAAsF,EAAE,GAAG,EAAE;QAC9F,MAAM,CAAC,CAAC,GAAG,0BAA0B,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CACpD,CAAC,mBAAmB,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,qBAAqB,CAAC,CAAC,IAAI,EAAE,CACrG,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,KAAK,MAAM,IAAI,IAAI,0BAA0B,EAAE,CAAC;YAC9C,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5D,MAAM,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9D,MAAM,CAAC,oBAAoB,CAAC,yBAAyB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QACjF,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1D,MAAM,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LlamaApiClient } from '../api-client.js';
|
|
2
|
+
/** Returns the current request's hosted client override, or `undefined` on the stdio path. */
|
|
3
|
+
export declare function getHostedClientOverride(): LlamaApiClient | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Runs `fn` with `client` bound as the hosted override for the ENTIRE async
|
|
6
|
+
* continuation `fn` spawns (including every `await` inside every tool file
|
|
7
|
+
* it transitively calls into) — this is the boundary apps/api's `/mcp` route
|
|
8
|
+
* wraps around a single incoming request's `transport.handleRequest(...)`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runWithHostedClient<T>(client: LlamaApiClient, fn: () => Promise<T>): Promise<T>;
|
|
11
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/hosted/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA2BvD,8FAA8F;AAC9F,wBAAgB,uBAAuB,IAAI,cAAc,GAAG,SAAS,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,MAAM,EAAE,cAAc,EACtB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
/**
|
|
3
|
+
* LLAMA-2076 — per-request override for `getApiClient()` (api-client.ts),
|
|
4
|
+
* used ONLY by the hosted `/mcp` Streamable HTTP transport in apps/api.
|
|
5
|
+
*
|
|
6
|
+
* Why `AsyncLocalStorage` and not a plain module-level "current client"
|
|
7
|
+
* variable: Node's event loop can interleave two concurrent hosted `/mcp`
|
|
8
|
+
* requests at any `await` inside tool execution (e.g. two users' requests
|
|
9
|
+
* both awaiting a Prisma query at the same moment). A bare
|
|
10
|
+
* "set before, clear after" mutable would let user B's in-flight tool call
|
|
11
|
+
* observe user A's client (and vice versa) whenever their async
|
|
12
|
+
* continuations interleave — a real cross-tenant identity leak, not a
|
|
13
|
+
* theoretical one, since `getApiClient()` is called from arbitrary depth
|
|
14
|
+
* inside ~40 tool files with no per-call parameter carrying the identity.
|
|
15
|
+
* `AsyncLocalStorage` binds the override to each request's own async
|
|
16
|
+
* continuation, so concurrent hosted requests can never observe each
|
|
17
|
+
* other's client no matter how their awaits interleave.
|
|
18
|
+
*
|
|
19
|
+
* The stdio path (`runServer()` in server.ts — Claude Code, the desktop app,
|
|
20
|
+
* any local MCP client) never calls `runWithHostedClient()`, so
|
|
21
|
+
* `getHostedClientOverride()` always returns `undefined` there and
|
|
22
|
+
* `getApiClient()` falls through to its original env-var singleton exactly
|
|
23
|
+
* as before this story.
|
|
24
|
+
*/
|
|
25
|
+
const hostedClientStorage = new AsyncLocalStorage();
|
|
26
|
+
/** Returns the current request's hosted client override, or `undefined` on the stdio path. */
|
|
27
|
+
export function getHostedClientOverride() {
|
|
28
|
+
return hostedClientStorage.getStore();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Runs `fn` with `client` bound as the hosted override for the ENTIRE async
|
|
32
|
+
* continuation `fn` spawns (including every `await` inside every tool file
|
|
33
|
+
* it transitively calls into) — this is the boundary apps/api's `/mcp` route
|
|
34
|
+
* wraps around a single incoming request's `transport.handleRequest(...)`.
|
|
35
|
+
*/
|
|
36
|
+
export function runWithHostedClient(client, fn) {
|
|
37
|
+
return hostedClientStorage.run(client, fn);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/hosted/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,mBAAmB,GAAG,IAAI,iBAAiB,EAAkB,CAAC;AAEpE,8FAA8F;AAC9F,MAAM,UAAU,uBAAuB;IACrC,OAAO,mBAAmB,CAAC,QAAQ,EAAE,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAsB,EACtB,EAAoB;IAEpB,OAAO,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLAMA-2076 REQ-05 — the SINGLE place that declares which tools are
|
|
3
|
+
* available over the hosted (stateless Streamable HTTP) MCP connector, vs.
|
|
4
|
+
* the full stdio surface (Claude Code, desktop) which is unaffected by this
|
|
5
|
+
* file and always gets every tool.
|
|
6
|
+
*
|
|
7
|
+
* Do NOT fork tool definitions to express this split. apps/api's `/mcp`
|
|
8
|
+
* route filters the `tools/list` response against `HOSTED_EXCLUDED_TOOL_NAMES`
|
|
9
|
+
* and rejects a `tools/call` for an excluded name with a clear message
|
|
10
|
+
* BEFORE ever calling into this package's (unforked) `executeTool` dispatch
|
|
11
|
+
* — never a crash, never an fs error surfacing from inside a tool.
|
|
12
|
+
*
|
|
13
|
+
* REQ-07 — `HOSTED_TOOL_SURFACE_VERSION` is bumped whenever this exclusion
|
|
14
|
+
* set changes, so a cached `tools/list` response (apps/api's ETag/TTL cache,
|
|
15
|
+
* REQ-06) can be keyed/invalidated on it and a later exclusion-set change
|
|
16
|
+
* can't strand a client on a stale, now-inaccurate cached list.
|
|
17
|
+
*/
|
|
18
|
+
export declare const HOSTED_TOOL_SURFACE_VERSION = "v1";
|
|
19
|
+
export declare const HOSTED_EXCLUDED_TOOL_NAMES: ReadonlySet<string>;
|
|
20
|
+
export declare function isHostedExcludedTool(name: string): boolean;
|
|
21
|
+
//# sourceMappingURL=toolSurface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolSurface.d.ts","sourceRoot":"","sources":["../../src/hosted/toolSurface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,MAAM,CA+BzD,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLAMA-2076 REQ-05 — the SINGLE place that declares which tools are
|
|
3
|
+
* available over the hosted (stateless Streamable HTTP) MCP connector, vs.
|
|
4
|
+
* the full stdio surface (Claude Code, desktop) which is unaffected by this
|
|
5
|
+
* file and always gets every tool.
|
|
6
|
+
*
|
|
7
|
+
* Do NOT fork tool definitions to express this split. apps/api's `/mcp`
|
|
8
|
+
* route filters the `tools/list` response against `HOSTED_EXCLUDED_TOOL_NAMES`
|
|
9
|
+
* and rejects a `tools/call` for an excluded name with a clear message
|
|
10
|
+
* BEFORE ever calling into this package's (unforked) `executeTool` dispatch
|
|
11
|
+
* — never a crash, never an fs error surfacing from inside a tool.
|
|
12
|
+
*
|
|
13
|
+
* REQ-07 — `HOSTED_TOOL_SURFACE_VERSION` is bumped whenever this exclusion
|
|
14
|
+
* set changes, so a cached `tools/list` response (apps/api's ETag/TTL cache,
|
|
15
|
+
* REQ-06) can be keyed/invalidated on it and a later exclusion-set change
|
|
16
|
+
* can't strand a client on a stale, now-inaccurate cached list.
|
|
17
|
+
*/
|
|
18
|
+
export const HOSTED_TOOL_SURFACE_VERSION = 'v1';
|
|
19
|
+
export const HOSTED_EXCLUDED_TOOL_NAMES = new Set([
|
|
20
|
+
// Local filesystem: reads a caller-supplied absolute path on the machine
|
|
21
|
+
// running the MCP *client*. That machine — and its filesystem — does not
|
|
22
|
+
// exist server-side.
|
|
23
|
+
'llama_attach_file', // tools/attachments.ts:129 fs.stat, :169 fs.readFile
|
|
24
|
+
// Uses LlamaApiClient#downloadAttachment, a raw fetch() call that (unlike
|
|
25
|
+
// request()/getBacklog()) is NOT routed through the LLAMA-2076 dispatch()
|
|
26
|
+
// hook, and is authenticated with a per-process `X-API-Key` header. Hosted
|
|
27
|
+
// mode has no such key — only the per-request OAuth-verified identity —
|
|
28
|
+
// so this would attempt a REAL self-HTTP call with a missing/invalid key
|
|
29
|
+
// rather than dispatching in-process.
|
|
30
|
+
'llama_download_attachment',
|
|
31
|
+
// Found during this story (not in the original spec's exclusion list):
|
|
32
|
+
// the "parse" action reads a local CSV via fs.readFile and uploads it with
|
|
33
|
+
// LlamaApiClient#uploadFile — the same local-fs AND raw-fetch/X-API-Key
|
|
34
|
+
// issue as the two tools above, just for a different action of a
|
|
35
|
+
// multi-action tool. The execute/status/rollback actions have no local-fs
|
|
36
|
+
// dependency, but the whole tool is excluded here for simplicity — a
|
|
37
|
+
// hosted client (ChatGPT, claude.ai) has no local CSV to parse in the
|
|
38
|
+
// first place.
|
|
39
|
+
'llama_import_csv', // tools/import.ts:79 fs.readFile (parse action)
|
|
40
|
+
// "Session" here means a local Claude Code CLI window (a cwd + a JSONL
|
|
41
|
+
// transcript under ~/.claude/projects/...) — meaningless server-side. In
|
|
42
|
+
// stateless hosted mode every request also gets a fresh, random
|
|
43
|
+
// `clientSessionId` (a new LlamaApiClient per request — see
|
|
44
|
+
// apps/api/src/lib/mcp), so `isThisWindow` could never be meaningfully
|
|
45
|
+
// true for a hosted caller.
|
|
46
|
+
'llama_list_sessions',
|
|
47
|
+
]);
|
|
48
|
+
export function isHostedExcludedTool(name) {
|
|
49
|
+
return HOSTED_EXCLUDED_TOOL_NAMES.has(name);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=toolSurface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolSurface.js","sourceRoot":"","sources":["../../src/hosted/toolSurface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD,MAAM,CAAC,MAAM,0BAA0B,GAAwB,IAAI,GAAG,CAAC;IACrE,yEAAyE;IACzE,yEAAyE;IACzE,qBAAqB;IACrB,mBAAmB,EAAE,qDAAqD;IAE1E,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,yEAAyE;IACzE,sCAAsC;IACtC,2BAA2B;IAE3B,uEAAuE;IACvE,2EAA2E;IAC3E,wEAAwE;IACxE,iEAAiE;IACjE,0EAA0E;IAC1E,qEAAqE;IACrE,sEAAsE;IACtE,eAAe;IACf,kBAAkB,EAAE,gDAAgD;IAEpE,uEAAuE;IACvE,yEAAyE;IACzE,gEAAgE;IAChE,4DAA4D;IAC5D,uEAAuE;IACvE,4BAA4B;IAC5B,qBAAqB;CACtB,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-org-project.test.d.ts","sourceRoot":"","sources":["../../../src/lib/__tests__/resolve-org-project.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { resolveOrgProject } from '../resolve-org-project.js';
|
|
3
|
+
import { executeListCodeDocs } from '../../tools/codeDocs.js';
|
|
4
|
+
import { executeManageComment } from '../../tools/comments.js';
|
|
5
|
+
import { getSessionDefaults } from '../../tools/session.js';
|
|
6
|
+
import { getApiClient } from '../../api-client.js';
|
|
7
|
+
const ORG_SLUG_REQUIRED = 'orgSlug is required. Either provide it or set session context with llama_set_context first.';
|
|
8
|
+
const PROJECT_KEY_REQUIRED = 'projectKey is required. Either provide it or set session context with llama_set_context first.';
|
|
9
|
+
const listPlanComments = vi.fn();
|
|
10
|
+
const listCodeDocs = vi.fn();
|
|
11
|
+
vi.mock('../../tools/session.js', () => ({
|
|
12
|
+
getSessionDefaults: vi.fn(),
|
|
13
|
+
orgSlugRequiredMessage: vi.fn(() => ORG_SLUG_REQUIRED),
|
|
14
|
+
}));
|
|
15
|
+
vi.mock('../../api-client.js', () => ({
|
|
16
|
+
getApiClient: vi.fn(),
|
|
17
|
+
LlamaApiError: class LlamaApiError extends Error {
|
|
18
|
+
statusCode;
|
|
19
|
+
constructor(statusCode, message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.statusCode = statusCode;
|
|
22
|
+
this.name = 'LlamaApiError';
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
vi.mocked(getSessionDefaults).mockReset();
|
|
28
|
+
vi.mocked(getSessionDefaults).mockResolvedValue(null);
|
|
29
|
+
listPlanComments.mockReset();
|
|
30
|
+
listCodeDocs.mockReset();
|
|
31
|
+
vi.mocked(getApiClient).mockReturnValue({
|
|
32
|
+
listPlanComments,
|
|
33
|
+
listCodeDocs,
|
|
34
|
+
searchCodeDocs: vi.fn(),
|
|
35
|
+
recordToolCall: vi.fn().mockResolvedValue(undefined),
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('resolveOrgProject', () => {
|
|
39
|
+
it('returns org-only context when requireProject is false and session is empty', async () => {
|
|
40
|
+
const result = await resolveOrgProject({ orgSlug: 'ag-llama' }, { requireProject: false });
|
|
41
|
+
expect(result).toEqual({ orgSlug: 'ag-llama', projectKey: undefined });
|
|
42
|
+
expect('error' in result).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
it('returns the exact orgSlug error when input and session are empty', async () => {
|
|
45
|
+
const result = await resolveOrgProject({});
|
|
46
|
+
expect('error' in result).toBe(true);
|
|
47
|
+
if ('error' in result) {
|
|
48
|
+
expect(result.error).toBe(ORG_SLUG_REQUIRED);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
it('returns the exact projectKey error when requireProject is true', async () => {
|
|
52
|
+
const result = await resolveOrgProject({ orgSlug: 'ag-llama' }, { requireProject: true });
|
|
53
|
+
expect('error' in result).toBe(true);
|
|
54
|
+
if ('error' in result) {
|
|
55
|
+
expect(result.error).toBe(PROJECT_KEY_REQUIRED);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
it('defaults requireProject to true', async () => {
|
|
59
|
+
const result = await resolveOrgProject({ orgSlug: 'ag-llama' });
|
|
60
|
+
expect('error' in result).toBe(true);
|
|
61
|
+
if ('error' in result) {
|
|
62
|
+
expect(result.error).toBe(PROJECT_KEY_REQUIRED);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
it('falls back to session orgSlug and projectKey', async () => {
|
|
66
|
+
vi.mocked(getSessionDefaults).mockResolvedValue({
|
|
67
|
+
orgSlug: 'sess-org',
|
|
68
|
+
projectKey: 'SESS',
|
|
69
|
+
});
|
|
70
|
+
const result = await resolveOrgProject({});
|
|
71
|
+
expect(result).toEqual({ orgSlug: 'sess-org', projectKey: 'SESS' });
|
|
72
|
+
});
|
|
73
|
+
it('lets explicit input override session defaults', async () => {
|
|
74
|
+
vi.mocked(getSessionDefaults).mockResolvedValue({
|
|
75
|
+
orgSlug: 'sess-org',
|
|
76
|
+
projectKey: 'SESS',
|
|
77
|
+
});
|
|
78
|
+
const result = await resolveOrgProject({ orgSlug: 'in-org', projectKey: 'IN' });
|
|
79
|
+
expect(result).toEqual({ orgSlug: 'in-org', projectKey: 'IN' });
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('executeListCodeDocs', () => {
|
|
83
|
+
it('still returns the exact projectKey error for org-only input', async () => {
|
|
84
|
+
const raw = await executeListCodeDocs({ orgSlug: 'ag-llama' });
|
|
85
|
+
const result = JSON.parse(raw);
|
|
86
|
+
expect(result.success).toBe(false);
|
|
87
|
+
expect(result.error).toBe(PROJECT_KEY_REQUIRED);
|
|
88
|
+
expect(listCodeDocs).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe('executeManageComment', () => {
|
|
92
|
+
it('still fails the same way for target=issue without projectKey', async () => {
|
|
93
|
+
const missingBoth = JSON.parse(await executeManageComment({ target: 'issue', action: 'list' }));
|
|
94
|
+
expect(missingBoth.success).toBe(false);
|
|
95
|
+
expect(missingBoth.error).toBe(ORG_SLUG_REQUIRED);
|
|
96
|
+
const raw = await executeManageComment({ orgSlug: 'ag-llama', target: 'issue', action: 'list' });
|
|
97
|
+
const result = JSON.parse(raw);
|
|
98
|
+
expect(result.success).toBe(false);
|
|
99
|
+
expect(result.error).toBe(PROJECT_KEY_REQUIRED);
|
|
100
|
+
});
|
|
101
|
+
it('still returns the exact projectKey error for target=plan and does not list comments', async () => {
|
|
102
|
+
const raw = await executeManageComment({
|
|
103
|
+
orgSlug: 'ag-llama',
|
|
104
|
+
target: 'plan',
|
|
105
|
+
action: 'list',
|
|
106
|
+
planId: 'x',
|
|
107
|
+
});
|
|
108
|
+
const result = JSON.parse(raw);
|
|
109
|
+
expect(result.success).toBe(false);
|
|
110
|
+
expect(result.error).toBe(PROJECT_KEY_REQUIRED);
|
|
111
|
+
expect(listPlanComments).not.toHaveBeenCalled();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=resolve-org-project.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-org-project.test.js","sourceRoot":"","sources":["../../../src/lib/__tests__/resolve-org-project.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,iBAAiB,GACrB,6FAA6F,CAAC;AAChG,MAAM,oBAAoB,GACxB,gGAAgG,CAAC;AAEnG,MAAM,gBAAgB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;AACjC,MAAM,YAAY,GAAG,EAAE,CAAC,EAAE,EAAE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ACrC,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,GAAG;SACZ,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyC,CAAC;QAEvE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAChD,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const PROJECT_KEY_REQUIRED = "projectKey is required. Either provide it or set session context with llama_set_context first.";
|
|
2
|
+
export type ResolveOrgProjectInput = {
|
|
3
|
+
orgSlug?: string;
|
|
4
|
+
projectKey?: string;
|
|
5
|
+
};
|
|
6
|
+
export type ResolveOrgProjectOptions = {
|
|
7
|
+
requireProject?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type ResolveOrgProjectError = {
|
|
10
|
+
error: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function resolveOrgProject(input: ResolveOrgProjectInput, opts?: {
|
|
13
|
+
requireProject?: true;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
orgSlug: string;
|
|
16
|
+
projectKey: string;
|
|
17
|
+
} | ResolveOrgProjectError>;
|
|
18
|
+
export declare function resolveOrgProject(input: ResolveOrgProjectInput, opts: {
|
|
19
|
+
requireProject: false;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
orgSlug: string;
|
|
22
|
+
projectKey?: string;
|
|
23
|
+
} | ResolveOrgProjectError>;
|
|
24
|
+
export declare function resolveOrgProject(input: ResolveOrgProjectInput, opts?: ResolveOrgProjectOptions): Promise<{
|
|
25
|
+
orgSlug: string;
|
|
26
|
+
projectKey?: string;
|
|
27
|
+
} | ResolveOrgProjectError>;
|
|
28
|
+
//# sourceMappingURL=resolve-org-project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-org-project.d.ts","sourceRoot":"","sources":["../../src/lib/resolve-org-project.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,mGACiE,CAAC;AAEnG,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,sBAAsB,EAC7B,IAAI,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,IAAI,CAAA;CAAE,GAC/B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,sBAAsB,CAAC,CAAC;AAC7E,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,sBAAsB,EAC7B,IAAI,EAAE;IAAE,cAAc,EAAE,KAAK,CAAA;CAAE,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,sBAAsB,CAAC,CAAC;AAC9E,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,sBAAsB,EAC7B,IAAI,CAAC,EAAE,wBAAwB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getSessionDefaults, orgSlugRequiredMessage } from '../tools/session.js';
|
|
2
|
+
export const PROJECT_KEY_REQUIRED = 'projectKey is required. Either provide it or set session context with llama_set_context first.';
|
|
3
|
+
export async function resolveOrgProject(input, opts) {
|
|
4
|
+
const requireProject = opts?.requireProject ?? true;
|
|
5
|
+
const defaults = await getSessionDefaults();
|
|
6
|
+
const orgSlug = input.orgSlug ?? defaults?.orgSlug;
|
|
7
|
+
const projectKey = input.projectKey ?? defaults?.projectKey;
|
|
8
|
+
if (!orgSlug) {
|
|
9
|
+
return { error: orgSlugRequiredMessage() };
|
|
10
|
+
}
|
|
11
|
+
if (requireProject && !projectKey) {
|
|
12
|
+
return { error: PROJECT_KEY_REQUIRED };
|
|
13
|
+
}
|
|
14
|
+
return { orgSlug, projectKey };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=resolve-org-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-org-project.js","sourceRoot":"","sources":["../../src/lib/resolve-org-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,MAAM,CAAC,MAAM,oBAAoB,GAC/B,gGAAgG,CAAC;AA2BnG,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAA6B,EAC7B,IAA+B;IAE/B,MAAM,cAAc,GAAG,IAAI,EAAE,cAAc,IAAI,IAAI,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,QAAQ,EAAE,OAAO,CAAC;IACnD,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,QAAQ,EAAE,UAAU,CAAC;IAE5D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,KAAK,EAAE,sBAAsB,EAAE,EAAE,CAAC;IAC7C,CAAC;IACD,IAAI,cAAc,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC;IACzC,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACjC,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
export declare const tools: Tool[];
|
|
4
|
+
type ContentBlock = {
|
|
5
|
+
type: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare function executeTool(name: string, args: Record<string, unknown>): Promise<string | ContentBlock[]>;
|
|
2
9
|
export declare function createServer(): Promise<Server>;
|
|
3
10
|
export declare function runServer(): Promise<void>;
|
|
11
|
+
export {};
|
|
4
12
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAGL,IAAI,EACL,MAAM,oCAAoC,CAAC;AA6hB5C,eAAO,MAAM,KAAK,EAAE,IAAI,EAumBvB,CAAC;AAGF,KAAK,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAU7D,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC,CA0YlC;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CA4GpD;AAED,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ/C"}
|