@callsitehq/emit 0.1.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/index.d.ts +13 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CapabilityIR } from '@callsitehq/core';
|
|
2
|
+
|
|
3
|
+
interface EmitOptions {
|
|
4
|
+
readonly name?: string;
|
|
5
|
+
readonly version?: string;
|
|
6
|
+
readonly baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function emitMcpJson(ir: CapabilityIR, options?: EmitOptions): string;
|
|
9
|
+
declare function emitOpenApi(ir: CapabilityIR, options?: EmitOptions): string;
|
|
10
|
+
declare function emitChatGptAppConfig(ir: CapabilityIR, options?: EmitOptions): string;
|
|
11
|
+
declare function emitClaudeConnectorConfig(ir: CapabilityIR, options?: EmitOptions): string;
|
|
12
|
+
|
|
13
|
+
export { type EmitOptions, emitChatGptAppConfig, emitClaudeConnectorConfig, emitMcpJson, emitOpenApi };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function emitMcpJson(ir, options = {}) {
|
|
3
|
+
return stringify({
|
|
4
|
+
name: options.name ?? "callsite",
|
|
5
|
+
version: options.version ?? "0.0.0",
|
|
6
|
+
tools: ir.capabilities.map((capability) => ({
|
|
7
|
+
name: capability.id,
|
|
8
|
+
description: capability.intent,
|
|
9
|
+
inputSchema: capability.inputSchema,
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: capability.destructive
|
|
12
|
+
}
|
|
13
|
+
}))
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function emitOpenApi(ir, options = {}) {
|
|
17
|
+
const paths = Object.fromEntries(
|
|
18
|
+
ir.capabilities.map((capability) => [
|
|
19
|
+
`/capabilities/${capability.id}`,
|
|
20
|
+
capabilityToOpenApiPath(capability)
|
|
21
|
+
])
|
|
22
|
+
);
|
|
23
|
+
return stringify({
|
|
24
|
+
openapi: "3.1.0",
|
|
25
|
+
info: {
|
|
26
|
+
title: options.name ?? "Callsite API",
|
|
27
|
+
version: options.version ?? "0.0.0"
|
|
28
|
+
},
|
|
29
|
+
...options.baseUrl === void 0 ? {} : { servers: [{ url: options.baseUrl }] },
|
|
30
|
+
paths
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function emitChatGptAppConfig(ir, options = {}) {
|
|
34
|
+
return stringify({
|
|
35
|
+
name: options.name ?? "callsite",
|
|
36
|
+
version: options.version ?? "0.0.0",
|
|
37
|
+
tools: ir.capabilities.map((capability) => ({
|
|
38
|
+
id: capability.id,
|
|
39
|
+
description: capability.intent,
|
|
40
|
+
input_schema: capability.inputSchema
|
|
41
|
+
}))
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function emitClaudeConnectorConfig(ir, options = {}) {
|
|
45
|
+
return stringify({
|
|
46
|
+
name: options.name ?? "callsite",
|
|
47
|
+
version: options.version ?? "0.0.0",
|
|
48
|
+
capabilities: ir.capabilities.map((capability) => ({
|
|
49
|
+
name: capability.id,
|
|
50
|
+
description: capability.intent,
|
|
51
|
+
input_schema: capability.inputSchema
|
|
52
|
+
}))
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function capabilityToOpenApiPath(capability) {
|
|
56
|
+
return {
|
|
57
|
+
post: {
|
|
58
|
+
operationId: capability.id.replaceAll(".", "_"),
|
|
59
|
+
summary: capability.intent,
|
|
60
|
+
requestBody: {
|
|
61
|
+
required: true,
|
|
62
|
+
content: {
|
|
63
|
+
"application/json": {
|
|
64
|
+
schema: capability.inputSchema
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
responses: {
|
|
69
|
+
"200": {
|
|
70
|
+
description: "Capability result",
|
|
71
|
+
content: {
|
|
72
|
+
"application/json": {
|
|
73
|
+
schema: capability.outputSchema
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"400": {
|
|
78
|
+
description: "Invalid request"
|
|
79
|
+
},
|
|
80
|
+
"500": {
|
|
81
|
+
description: "Capability error"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function stringify(value) {
|
|
88
|
+
return `${JSON.stringify(value, null, 2)}
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
emitChatGptAppConfig,
|
|
93
|
+
emitClaudeConnectorConfig,
|
|
94
|
+
emitMcpJson,
|
|
95
|
+
emitOpenApi
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CapabilityIR, CapabilityIRNode, JsonObject } from \"@callsitehq/core\";\n\nexport interface EmitOptions {\n readonly name?: string;\n readonly version?: string;\n readonly baseUrl?: string;\n}\n\nexport function emitMcpJson(ir: CapabilityIR, options: EmitOptions = {}): string {\n return stringify({\n name: options.name ?? \"callsite\",\n version: options.version ?? \"0.0.0\",\n tools: ir.capabilities.map((capability) => ({\n name: capability.id,\n description: capability.intent,\n inputSchema: capability.inputSchema,\n annotations: {\n destructiveHint: capability.destructive\n }\n }))\n });\n}\n\nexport function emitOpenApi(ir: CapabilityIR, options: EmitOptions = {}): string {\n const paths = Object.fromEntries(\n ir.capabilities.map((capability) => [\n `/capabilities/${capability.id}`,\n capabilityToOpenApiPath(capability)\n ])\n );\n\n return stringify({\n openapi: \"3.1.0\",\n info: {\n title: options.name ?? \"Callsite API\",\n version: options.version ?? \"0.0.0\"\n },\n ...(options.baseUrl === undefined ? {} : { servers: [{ url: options.baseUrl }] }),\n paths\n });\n}\n\nexport function emitChatGptAppConfig(ir: CapabilityIR, options: EmitOptions = {}): string {\n return stringify({\n name: options.name ?? \"callsite\",\n version: options.version ?? \"0.0.0\",\n tools: ir.capabilities.map((capability) => ({\n id: capability.id,\n description: capability.intent,\n input_schema: capability.inputSchema\n }))\n });\n}\n\nexport function emitClaudeConnectorConfig(ir: CapabilityIR, options: EmitOptions = {}): string {\n return stringify({\n name: options.name ?? \"callsite\",\n version: options.version ?? \"0.0.0\",\n capabilities: ir.capabilities.map((capability) => ({\n name: capability.id,\n description: capability.intent,\n input_schema: capability.inputSchema\n }))\n });\n}\n\nfunction capabilityToOpenApiPath(capability: CapabilityIRNode): JsonObject {\n return {\n post: {\n operationId: capability.id.replaceAll(\".\", \"_\"),\n summary: capability.intent,\n requestBody: {\n required: true,\n content: {\n \"application/json\": {\n schema: capability.inputSchema\n }\n }\n },\n responses: {\n \"200\": {\n description: \"Capability result\",\n content: {\n \"application/json\": {\n schema: capability.outputSchema\n }\n }\n },\n \"400\": {\n description: \"Invalid request\"\n },\n \"500\": {\n description: \"Capability error\"\n }\n }\n }\n };\n}\n\nfunction stringify(value: unknown): string {\n return `${JSON.stringify(value, null, 2)}\\n`;\n}\n"],"mappings":";AAQO,SAAS,YAAY,IAAkB,UAAuB,CAAC,GAAW;AAC/E,SAAO,UAAU;AAAA,IACf,MAAM,QAAQ,QAAQ;AAAA,IACtB,SAAS,QAAQ,WAAW;AAAA,IAC5B,OAAO,GAAG,aAAa,IAAI,CAAC,gBAAgB;AAAA,MAC1C,MAAM,WAAW;AAAA,MACjB,aAAa,WAAW;AAAA,MACxB,aAAa,WAAW;AAAA,MACxB,aAAa;AAAA,QACX,iBAAiB,WAAW;AAAA,MAC9B;AAAA,IACF,EAAE;AAAA,EACJ,CAAC;AACH;AAEO,SAAS,YAAY,IAAkB,UAAuB,CAAC,GAAW;AAC/E,QAAM,QAAQ,OAAO;AAAA,IACnB,GAAG,aAAa,IAAI,CAAC,eAAe;AAAA,MAClC,iBAAiB,WAAW,EAAE;AAAA,MAC9B,wBAAwB,UAAU;AAAA,IACpC,CAAC;AAAA,EACH;AAEA,S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;AAAA,UACF;AAAA,QACF;AAAA,QACA,OAAO;AAAA,UACL,aAAa;AAAA,QACf;AAAA,QACA,OAAO;AAAA,UACL,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAwB;AACzC,SAAO,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;AAAA;AAC1C;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@callsitehq/emit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Pure renderers from Callsite IR to agent-facing artifacts.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@callsitehq/core": "0.1.0"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
|
+
}
|
|
24
|
+
}
|