@imbue-ai/detent 1.11.2 → 1.13.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/dist/src/schemas/generatedBuiltinSchemas.d.ts.map +1 -1
- package/dist/src/schemas/generatedBuiltinSchemas.js +353 -0
- package/dist/src/schemas/generatedBuiltinSchemas.js.map +1 -1
- package/dist/tests/builtinSchemas.test.js +222 -0
- package/dist/tests/builtinSchemas.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -1764,4 +1764,226 @@ describe('builtin schemas: todoist', () => {
|
|
|
1764
1764
|
.match(makeRequest({ method: 'GET', path: '/api/v1/sync' }))).toBe(false);
|
|
1765
1765
|
});
|
|
1766
1766
|
});
|
|
1767
|
+
describe('builtin schemas: ngrok', () => {
|
|
1768
|
+
it('ngrok scope matches api.ngrok.com', () => {
|
|
1769
|
+
expectSchemaExists('ngrok-api');
|
|
1770
|
+
const request = makeRequest({ domain: 'api.ngrok.com', path: '/api_keys' });
|
|
1771
|
+
expect(builtinRegistry.get('ngrok-api').match(request)).toBe(true);
|
|
1772
|
+
});
|
|
1773
|
+
it('ngrok scope rejects unrelated domains', () => {
|
|
1774
|
+
const request = makeRequest({ domain: 'ngrok.example.com' });
|
|
1775
|
+
expect(builtinRegistry.get('ngrok-api').match(request)).toBe(false);
|
|
1776
|
+
});
|
|
1777
|
+
it('ngrok-read-all matches GET requests', () => {
|
|
1778
|
+
expectSchemaExists('ngrok-read-all');
|
|
1779
|
+
expect(builtinRegistry.get('ngrok-read-all').match(makeRequest({ method: 'GET' }))).toBe(true);
|
|
1780
|
+
expect(builtinRegistry.get('ngrok-read-all').match(makeRequest({ method: 'POST' }))).toBe(false);
|
|
1781
|
+
});
|
|
1782
|
+
it('ngrok-write-all matches mutating methods but rejects GET', () => {
|
|
1783
|
+
expectSchemaExists('ngrok-write-all');
|
|
1784
|
+
const writeAll = builtinRegistry.get('ngrok-write-all');
|
|
1785
|
+
expect(writeAll.match(makeRequest({ method: 'POST' }))).toBe(true);
|
|
1786
|
+
expect(writeAll.match(makeRequest({ method: 'DELETE' }))).toBe(true);
|
|
1787
|
+
expect(writeAll.match(makeRequest({ method: 'GET' }))).toBe(false);
|
|
1788
|
+
});
|
|
1789
|
+
it('ngrok-write-all covers state-changing action endpoints (POST restart/stop)', () => {
|
|
1790
|
+
const writeAll = builtinRegistry.get('ngrok-write-all');
|
|
1791
|
+
expect(writeAll.match(makeRequest({ method: 'POST', path: '/tunnel_sessions/ts_123/restart' }))).toBe(true);
|
|
1792
|
+
expect(writeAll.match(makeRequest({ method: 'POST', path: '/tunnel_sessions/ts_123/stop' }))).toBe(true);
|
|
1793
|
+
});
|
|
1794
|
+
it('ngrok-write-credentials mints/updates/deletes tunnel authtokens but not other writes', () => {
|
|
1795
|
+
expectSchemaExists('ngrok-write-credentials');
|
|
1796
|
+
const writeCreds = builtinRegistry.get('ngrok-write-credentials');
|
|
1797
|
+
expect(writeCreds.match(makeRequest({ method: 'POST', path: '/credentials' }))).toBe(true);
|
|
1798
|
+
expect(writeCreds.match(makeRequest({ method: 'DELETE', path: '/credentials/cr_123' }))).toBe(true);
|
|
1799
|
+
expect(writeCreds.match(makeRequest({ method: 'GET', path: '/credentials' }))).toBe(false);
|
|
1800
|
+
expect(writeCreds.match(makeRequest({ method: 'POST', path: '/endpoints' }))).toBe(false);
|
|
1801
|
+
});
|
|
1802
|
+
it('ngrok-read-credentials lists/inspects authtokens (GET only)', () => {
|
|
1803
|
+
expectSchemaExists('ngrok-read-credentials');
|
|
1804
|
+
const readCreds = builtinRegistry.get('ngrok-read-credentials');
|
|
1805
|
+
expect(readCreds.match(makeRequest({ method: 'GET', path: '/credentials/cr_123' }))).toBe(true);
|
|
1806
|
+
expect(readCreds.match(makeRequest({ method: 'POST', path: '/credentials' }))).toBe(false);
|
|
1807
|
+
});
|
|
1808
|
+
it('ngrok credentials scopes do not leak to /ssh_credentials (^-anchor)', () => {
|
|
1809
|
+
// /ssh_credentials is a distinct ngrok resource whose name contains
|
|
1810
|
+
// "credentials"; the ^-anchored path pattern must not match it.
|
|
1811
|
+
const readCreds = builtinRegistry.get('ngrok-read-credentials');
|
|
1812
|
+
const writeCreds = builtinRegistry.get('ngrok-write-credentials');
|
|
1813
|
+
expect(readCreds.match(makeRequest({ method: 'GET', path: '/ssh_credentials' }))).toBe(false);
|
|
1814
|
+
expect(writeCreds.match(makeRequest({ method: 'POST', path: '/ssh_credentials' }))).toBe(false);
|
|
1815
|
+
});
|
|
1816
|
+
});
|
|
1817
|
+
describe('builtin schemas: huggingface', () => {
|
|
1818
|
+
const scope = () => builtinRegistry.get('huggingface-api');
|
|
1819
|
+
it('huggingface-api matches the Hub API, the hf.co alias, and repository files', () => {
|
|
1820
|
+
expectSchemaExists('huggingface-api');
|
|
1821
|
+
expect(scope().match(makeRequest({ domain: 'huggingface.co', path: '/api/whoami-v2' }))).toBe(true);
|
|
1822
|
+
expect(scope().match(makeRequest({ domain: 'hf.co', path: '/api/models/gpt2' }))).toBe(true);
|
|
1823
|
+
expect(scope().match(makeRequest({ domain: 'huggingface.co', path: '/gpt2/resolve/main/config.json' }))).toBe(true);
|
|
1824
|
+
expect(scope().match(makeRequest({
|
|
1825
|
+
domain: 'huggingface.co',
|
|
1826
|
+
path: '/datasets/stanfordnlp/imdb/resolve/main/README.md',
|
|
1827
|
+
}))).toBe(true);
|
|
1828
|
+
expect(scope().match(makeRequest({ domain: 'huggingface.co', path: '/openai-community/gpt2.git/info/refs' }))).toBe(true);
|
|
1829
|
+
});
|
|
1830
|
+
it('huggingface-api covers the router, the storage hosts downloads redirect to, and the dataset viewer', () => {
|
|
1831
|
+
expect(scope().match(makeRequest({ domain: 'router.huggingface.co', path: '/v1/chat/completions' }))).toBe(true);
|
|
1832
|
+
for (const domain of [
|
|
1833
|
+
'us.aws.cdn.hf.co',
|
|
1834
|
+
'cdn-lfs-us-1.hf.co',
|
|
1835
|
+
'cas-bridge.xethub.hf.co',
|
|
1836
|
+
'transfer.xethub.hf.co',
|
|
1837
|
+
]) {
|
|
1838
|
+
expect(scope().match(makeRequest({ domain, path: '/xet-bridge-us/abc123' }))).toBe(true);
|
|
1839
|
+
}
|
|
1840
|
+
expect(scope().match(makeRequest({ domain: 'datasets-server.huggingface.co', path: '/splits' }))).toBe(true);
|
|
1841
|
+
});
|
|
1842
|
+
it('huggingface-api rejects unrelated domains and the non-API parts of huggingface.co', () => {
|
|
1843
|
+
expect(scope().match(makeRequest({ domain: 'huggingface.example.com' }))).toBe(false);
|
|
1844
|
+
for (const path of ['/', '/mcp', '/oauth/token', '/settings/tokens']) {
|
|
1845
|
+
expect(scope().match(makeRequest({ domain: 'huggingface.co', path }))).toBe(false);
|
|
1846
|
+
}
|
|
1847
|
+
expect(scope().match(makeRequest({ domain: 'gradio-hello-world.hf.space', path: '/' }))).toBe(false);
|
|
1848
|
+
});
|
|
1849
|
+
it('huggingface-read-all matches safe methods, including the HEAD that precedes a download', () => {
|
|
1850
|
+
expectSchemaExists('huggingface-read-all');
|
|
1851
|
+
for (const method of ['GET', 'HEAD', 'OPTIONS']) {
|
|
1852
|
+
expect(builtinRegistry.get('huggingface-read-all').match(makeRequest({
|
|
1853
|
+
method,
|
|
1854
|
+
domain: 'huggingface.co',
|
|
1855
|
+
path: '/gpt2/resolve/main/config.json',
|
|
1856
|
+
}))).toBe(true);
|
|
1857
|
+
}
|
|
1858
|
+
expect(builtinRegistry
|
|
1859
|
+
.get('huggingface-read-all')
|
|
1860
|
+
.match(makeRequest({ method: 'POST', domain: 'huggingface.co', path: '/api/repos/create' }))).toBe(false);
|
|
1861
|
+
});
|
|
1862
|
+
it('huggingface-write-all matches Hub writes but not the paid inference router', () => {
|
|
1863
|
+
expectSchemaExists('huggingface-write-all');
|
|
1864
|
+
const writeAll = builtinRegistry.get('huggingface-write-all');
|
|
1865
|
+
expect(writeAll.match(makeRequest({ method: 'POST', domain: 'huggingface.co', path: '/api/repos/create' }))).toBe(true);
|
|
1866
|
+
expect(writeAll.match(makeRequest({ method: 'POST', domain: 'huggingface.co', path: '/api/jobs/acme' }))).toBe(true);
|
|
1867
|
+
expect(writeAll.match(makeRequest({ method: 'PUT', domain: 'transfer.xethub.hf.co', path: '/xet/abc' }))).toBe(true);
|
|
1868
|
+
expect(writeAll.match(makeRequest({
|
|
1869
|
+
method: 'POST',
|
|
1870
|
+
domain: 'router.huggingface.co',
|
|
1871
|
+
path: '/v1/chat/completions',
|
|
1872
|
+
}))).toBe(false);
|
|
1873
|
+
expect(writeAll.match(makeRequest({ method: 'GET', domain: 'huggingface.co' }))).toBe(false);
|
|
1874
|
+
});
|
|
1875
|
+
it('huggingface-inference matches a POST to the router only', () => {
|
|
1876
|
+
expectSchemaExists('huggingface-inference');
|
|
1877
|
+
expect(builtinRegistry.get('huggingface-inference').match(makeRequest({
|
|
1878
|
+
method: 'POST',
|
|
1879
|
+
domain: 'router.huggingface.co',
|
|
1880
|
+
path: '/v1/chat/completions',
|
|
1881
|
+
}))).toBe(true);
|
|
1882
|
+
expect(builtinRegistry
|
|
1883
|
+
.get('huggingface-inference')
|
|
1884
|
+
.match(makeRequest({ method: 'GET', domain: 'router.huggingface.co' }))).toBe(false);
|
|
1885
|
+
expect(builtinRegistry
|
|
1886
|
+
.get('huggingface-inference')
|
|
1887
|
+
.match(makeRequest({ method: 'POST', domain: 'huggingface.co' }))).toBe(false);
|
|
1888
|
+
});
|
|
1889
|
+
it('huggingface-download covers every transport a repository download uses', () => {
|
|
1890
|
+
expectSchemaExists('huggingface-download');
|
|
1891
|
+
const download = builtinRegistry.get('huggingface-download');
|
|
1892
|
+
expect(download.match(makeRequest({
|
|
1893
|
+
method: 'HEAD',
|
|
1894
|
+
domain: 'huggingface.co',
|
|
1895
|
+
path: '/gpt2/resolve/main/config.json',
|
|
1896
|
+
}))).toBe(true);
|
|
1897
|
+
expect(download.match(makeRequest({
|
|
1898
|
+
method: 'GET',
|
|
1899
|
+
domain: 'huggingface.co',
|
|
1900
|
+
path: '/api/resolve-cache/datasets/stanfordnlp/imdb/abc/README.md',
|
|
1901
|
+
}))).toBe(true);
|
|
1902
|
+
expect(download.match(makeRequest({ method: 'GET', domain: 'us.aws.cdn.hf.co', path: '/xet-bridge-us/abc123' }))).toBe(true);
|
|
1903
|
+
expect(download.match(makeRequest({
|
|
1904
|
+
method: 'GET',
|
|
1905
|
+
domain: 'huggingface.co',
|
|
1906
|
+
path: '/openai-community/gpt2.git/info/refs',
|
|
1907
|
+
queryParams: { service: 'git-upload-pack' },
|
|
1908
|
+
}))).toBe(true);
|
|
1909
|
+
expect(download.match(makeRequest({
|
|
1910
|
+
method: 'POST',
|
|
1911
|
+
domain: 'huggingface.co',
|
|
1912
|
+
path: '/openai-community/gpt2.git/info/lfs/objects/batch',
|
|
1913
|
+
}))).toBe(true);
|
|
1914
|
+
expect(download.match(makeRequest({
|
|
1915
|
+
method: 'GET',
|
|
1916
|
+
domain: 'huggingface.co',
|
|
1917
|
+
path: '/openai-community/gpt2.git/info/refs',
|
|
1918
|
+
queryParams: { service: 'git-receive-pack' },
|
|
1919
|
+
}))).toBe(false);
|
|
1920
|
+
expect(download.match(makeRequest({
|
|
1921
|
+
method: 'POST',
|
|
1922
|
+
domain: 'huggingface.co',
|
|
1923
|
+
path: '/openai-community/gpt2.git/git-receive-pack',
|
|
1924
|
+
}))).toBe(false);
|
|
1925
|
+
expect(download.match(makeRequest({ method: 'GET', domain: 'huggingface.co', path: '/api/models' }))).toBe(false);
|
|
1926
|
+
});
|
|
1927
|
+
});
|
|
1928
|
+
describe('builtin schemas: openrouter', () => {
|
|
1929
|
+
it('openrouter-api matches openrouter.ai', () => {
|
|
1930
|
+
expectSchemaExists('openrouter-api');
|
|
1931
|
+
expect(builtinRegistry
|
|
1932
|
+
.get('openrouter-api')
|
|
1933
|
+
.match(makeRequest({ domain: 'openrouter.ai', path: '/api/v1/chat/completions' }))).toBe(true);
|
|
1934
|
+
});
|
|
1935
|
+
it('openrouter-api rejects unrelated domains', () => {
|
|
1936
|
+
expect(builtinRegistry
|
|
1937
|
+
.get('openrouter-api')
|
|
1938
|
+
.match(makeRequest({ domain: 'openrouter.example.com', path: '/api/v1/models' }))).toBe(false);
|
|
1939
|
+
});
|
|
1940
|
+
it('openrouter-api rejects non-API paths on openrouter.ai', () => {
|
|
1941
|
+
expect(builtinRegistry
|
|
1942
|
+
.get('openrouter-api')
|
|
1943
|
+
.match(makeRequest({ domain: 'openrouter.ai', path: '/models' }))).toBe(false);
|
|
1944
|
+
});
|
|
1945
|
+
it('openrouter-read-all matches GET but not writes', () => {
|
|
1946
|
+
expectSchemaExists('openrouter-read-all');
|
|
1947
|
+
expect(builtinRegistry
|
|
1948
|
+
.get('openrouter-read-all')
|
|
1949
|
+
.match(makeRequest({ method: 'GET', domain: 'openrouter.ai', path: '/api/v1/models' }))).toBe(true);
|
|
1950
|
+
expect(builtinRegistry
|
|
1951
|
+
.get('openrouter-read-all')
|
|
1952
|
+
.match(makeRequest({ method: 'POST', domain: 'openrouter.ai', path: '/api/v1/chat/completions' }))).toBe(false);
|
|
1953
|
+
});
|
|
1954
|
+
it('openrouter-write-all matches writes but not GET', () => {
|
|
1955
|
+
expectSchemaExists('openrouter-write-all');
|
|
1956
|
+
const write = builtinRegistry.get('openrouter-write-all');
|
|
1957
|
+
expect(write.match(makeRequest({ method: 'POST', domain: 'openrouter.ai', path: '/api/v1/keys' }))).toBe(true);
|
|
1958
|
+
expect(write.match(makeRequest({ method: 'DELETE', domain: 'openrouter.ai', path: '/api/v1/keys/abc' }))).toBe(true);
|
|
1959
|
+
expect(write.match(makeRequest({ method: 'GET', domain: 'openrouter.ai' }))).toBe(false);
|
|
1960
|
+
});
|
|
1961
|
+
it('openrouter-inference matches the credit-consuming model endpoints only', () => {
|
|
1962
|
+
expectSchemaExists('openrouter-inference');
|
|
1963
|
+
const inference = builtinRegistry.get('openrouter-inference');
|
|
1964
|
+
// Every model-invoking endpoint in the OpenRouter OpenAPI spec.
|
|
1965
|
+
const inferencePaths = [
|
|
1966
|
+
'/api/v1/chat/completions',
|
|
1967
|
+
'/api/v1/messages',
|
|
1968
|
+
'/api/v1/responses',
|
|
1969
|
+
'/api/v1/embeddings',
|
|
1970
|
+
'/api/v1/rerank',
|
|
1971
|
+
'/api/v1/images',
|
|
1972
|
+
'/api/v1/videos',
|
|
1973
|
+
'/api/v1/audio/speech',
|
|
1974
|
+
'/api/v1/audio/transcriptions',
|
|
1975
|
+
];
|
|
1976
|
+
for (const path of inferencePaths) {
|
|
1977
|
+
expect(inference.match(makeRequest({ method: 'POST', domain: 'openrouter.ai', path })), `expected inference to match POST ${path}`).toBe(true);
|
|
1978
|
+
}
|
|
1979
|
+
// Account/key management writes and read-side GETs are excluded.
|
|
1980
|
+
expect(inference.match(makeRequest({ method: 'POST', domain: 'openrouter.ai', path: '/api/v1/keys' }))).toBe(false);
|
|
1981
|
+
expect(inference.match(makeRequest({
|
|
1982
|
+
method: 'POST',
|
|
1983
|
+
domain: 'openrouter.ai',
|
|
1984
|
+
path: '/api/v1/generation/feedback',
|
|
1985
|
+
}))).toBe(false);
|
|
1986
|
+
expect(inference.match(makeRequest({ method: 'GET', domain: 'openrouter.ai', path: '/api/v1/chat/completions' }))).toBe(false);
|
|
1987
|
+
});
|
|
1988
|
+
});
|
|
1767
1989
|
//# sourceMappingURL=builtinSchemas.test.js.map
|