@hearthscale/app 0.1.0 → 0.2.1
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 +35 -16
- package/dist/index.d.ts +2393 -295
- package/dist/view.d.ts +66 -0
- package/dist/view.js +20 -0
- package/package.json +15 -2
package/dist/view.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { McpUiUpdateModelContextRequest, McpUiMessageRequest, McpUiDownloadFileRequest, McpUiDownloadFileResult, App } from '@modelcontextprotocol/ext-apps';
|
|
2
|
+
import { CallOf, ViewMethods, ModelContextOptions, ModelContextAnswer, MessageOptions } from './index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `@hearthscale/app/view`: the one runtime part of the package, for a
|
|
6
|
+
* view, which bundles it.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** An embedded resource whose bytes are a `Blob`, which `ui/download-file`
|
|
10
|
+
* streams into the file the person picks, at any size. */
|
|
11
|
+
interface BlobResource {
|
|
12
|
+
type: 'resource';
|
|
13
|
+
resource: {
|
|
14
|
+
uri: string;
|
|
15
|
+
mimeType?: string;
|
|
16
|
+
blob: Blob;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** The MCP Apps requests whose params take Hearthscale's own fields, which
|
|
20
|
+
* the SDK's `App` methods refuse by type: the slot of
|
|
21
|
+
* `ui/update-model-context`, the target of `ui/message`, and a `Blob` as
|
|
22
|
+
* the bytes of `ui/download-file`. */
|
|
23
|
+
interface ViewStandardMethods {
|
|
24
|
+
'ui/update-model-context': {
|
|
25
|
+
params: McpUiUpdateModelContextRequest['params'] & {
|
|
26
|
+
_meta?: {
|
|
27
|
+
'hearthscale/modelContext'?: ModelContextOptions;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
result: {
|
|
31
|
+
_meta?: {
|
|
32
|
+
'openai/modelContext'?: ModelContextAnswer;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
'ui/message': {
|
|
37
|
+
params: McpUiMessageRequest['params'] & {
|
|
38
|
+
_meta?: {
|
|
39
|
+
'openai/message'?: MessageOptions;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
result: {
|
|
43
|
+
isError?: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
'ui/download-file': {
|
|
47
|
+
params: {
|
|
48
|
+
contents: (McpUiDownloadFileRequest['params']['contents'][number] | BlobResource)[];
|
|
49
|
+
};
|
|
50
|
+
result: McpUiDownloadFileResult;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** The typed call of a view's requests through its `App`. */
|
|
54
|
+
type ViewCall = CallOf<ViewMethods & ViewStandardMethods>;
|
|
55
|
+
/**
|
|
56
|
+
* The typed call of every request beyond MCP Apps through a view's `App`,
|
|
57
|
+
* and of the MCP Apps requests that take Hearthscale's own fields: the
|
|
58
|
+
* `hearthscale/*` methods every view may call and the extensions its
|
|
59
|
+
* app's `uses` opens, `openai/resources/write` and `openai/files/open`,
|
|
60
|
+
* and `ViewStandardMethods`; the method's params in, its result out. A
|
|
61
|
+
* refusal rejects with the MCP SDK's `McpError`.
|
|
62
|
+
*/
|
|
63
|
+
declare function hostCall(app: App): ViewCall;
|
|
64
|
+
|
|
65
|
+
export { hostCall };
|
|
66
|
+
export type { BlobResource, ViewCall, ViewStandardMethods };
|
package/dist/view.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@hearthscale/app/view`: the one runtime part of the package, for a
|
|
3
|
+
* view, which bundles it.
|
|
4
|
+
*/
|
|
5
|
+
import { McpUiMessageResultSchema, } from '@modelcontextprotocol/ext-apps';
|
|
6
|
+
/**
|
|
7
|
+
* The typed call of every request beyond MCP Apps through a view's `App`,
|
|
8
|
+
* and of the MCP Apps requests that take Hearthscale's own fields: the
|
|
9
|
+
* `hearthscale/*` methods every view may call and the extensions its
|
|
10
|
+
* app's `uses` opens, `openai/resources/write` and `openai/files/open`,
|
|
11
|
+
* and `ViewStandardMethods`; the method's params in, its result out. A
|
|
12
|
+
* refusal rejects with the MCP SDK's `McpError`.
|
|
13
|
+
*/
|
|
14
|
+
export function hostCall(app) {
|
|
15
|
+
// The SDK types the requests of the MCP Apps methods alone, with their
|
|
16
|
+
// standard params; these are requests of the same protocol with
|
|
17
|
+
// methods or fields of their own.
|
|
18
|
+
const request = app.request.bind(app);
|
|
19
|
+
return ((method, params) => request({ method, params: params ?? {} }, McpUiMessageResultSchema));
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hearthscale/app",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "The types a Hearthscale app's backend and views import: the backend's exports and context, the view's host methods, extensions and slots.",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "The types a Hearthscale app's backend and views import: the backend's exports and context, the view's host methods, extensions and slots; and the typed call of a view's requests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts"
|
|
11
11
|
},
|
|
12
|
+
"./view": {
|
|
13
|
+
"types": "./dist/view.d.ts",
|
|
14
|
+
"default": "./dist/view.js"
|
|
15
|
+
},
|
|
12
16
|
"./package.json": "./package.json"
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
@@ -22,7 +26,16 @@
|
|
|
22
26
|
"publishConfig": {
|
|
23
27
|
"access": "public"
|
|
24
28
|
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@modelcontextprotocol/ext-apps": "^1.7.5"
|
|
31
|
+
},
|
|
32
|
+
"peerDependenciesMeta": {
|
|
33
|
+
"@modelcontextprotocol/ext-apps": {
|
|
34
|
+
"optional": true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
25
37
|
"devDependencies": {
|
|
38
|
+
"@modelcontextprotocol/ext-apps": "1.7.5",
|
|
26
39
|
"rollup": "^4.62.2",
|
|
27
40
|
"rollup-plugin-dts": "^6.5.1",
|
|
28
41
|
"typescript": "^5.6.3",
|