@lanework/contracts 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +39 -2
- package/package.json +32 -4
- package/src/agent-notes.ts +69 -0
- package/src/auth.ts +251 -0
- package/src/boards.ts +932 -0
- package/src/checkpoints.ts +96 -0
- package/src/common.ts +85 -0
- package/src/endpoints.ts +435 -0
- package/src/index.ts +18 -0
- package/src/sync.ts +148 -0
- package/src/tools/board.ts +590 -0
- package/src/tools/control.ts +519 -0
- package/src/tools/index.ts +41 -0
- package/src/tools/instructions.ts +153 -0
- package/src/tools/kit.ts +233 -0
- package/src/tools/outputs.ts +279 -0
- package/src/tools/schema.ts +149 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// A tool's parameters, spelled once (FE-152). The JSON Schema an MCP server
|
|
2
|
+
// advertises in `tools/list` derives from it, and so does the validator the
|
|
3
|
+
// desktop's servers run on `tools/call`, so the two cannot disagree. It is
|
|
4
|
+
// small on purpose: the tools need strings, booleans, integers, enums, string
|
|
5
|
+
// lists, string maps and lists of flat objects.
|
|
6
|
+
|
|
7
|
+
/** One tool parameter: its type and the limits a validator enforces. */
|
|
8
|
+
export type ToolParam =
|
|
9
|
+
| {
|
|
10
|
+
type: "string";
|
|
11
|
+
description?: string;
|
|
12
|
+
enum?: readonly string[];
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
/** A regular expression, as JSON Schema spells it. */
|
|
15
|
+
pattern?: string;
|
|
16
|
+
}
|
|
17
|
+
| { type: "boolean"; description?: string }
|
|
18
|
+
| {
|
|
19
|
+
type: "integer";
|
|
20
|
+
description?: string;
|
|
21
|
+
minimum?: number;
|
|
22
|
+
maximum?: number;
|
|
23
|
+
}
|
|
24
|
+
| { type: "string[]"; description?: string }
|
|
25
|
+
| { type: "nullable-string"; description?: string }
|
|
26
|
+
| { type: "string-map"; description?: string }
|
|
27
|
+
| {
|
|
28
|
+
type: "object";
|
|
29
|
+
description?: string;
|
|
30
|
+
properties: Readonly<Record<string, ToolParam>>;
|
|
31
|
+
required?: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
| {
|
|
34
|
+
type: "object[]";
|
|
35
|
+
description?: string;
|
|
36
|
+
properties: Readonly<Record<string, ToolParam>>;
|
|
37
|
+
required?: readonly string[];
|
|
38
|
+
minItems?: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** A tool's parameters: each one by name, and which are required. */
|
|
42
|
+
export interface ToolShape {
|
|
43
|
+
properties: Readonly<Record<string, ToolParam>>;
|
|
44
|
+
required?: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** One tool as every server and client of it states it. */
|
|
48
|
+
export interface ToolContract<Name extends string = string> extends ToolShape {
|
|
49
|
+
name: Name;
|
|
50
|
+
/** A short label for people (MCP's `title`); models read `description`. */
|
|
51
|
+
title?: string;
|
|
52
|
+
/** Sent to the model verbatim. A literal: it sits in a cached prompt prefix. */
|
|
53
|
+
description: string;
|
|
54
|
+
/** True when the tool changes nothing (MCP's `readOnlyHint`). */
|
|
55
|
+
readOnly: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A JSON Schema object, as `tools/list` carries it. */
|
|
59
|
+
export type JsonSchema = Record<string, unknown>;
|
|
60
|
+
|
|
61
|
+
function paramSchema(param: ToolParam): JsonSchema {
|
|
62
|
+
const described = (schema: JsonSchema): JsonSchema =>
|
|
63
|
+
param.description ? { ...schema, description: param.description } : schema;
|
|
64
|
+
switch (param.type) {
|
|
65
|
+
case "string":
|
|
66
|
+
return described({
|
|
67
|
+
type: "string",
|
|
68
|
+
...(param.enum ? { enum: [...param.enum] } : {}),
|
|
69
|
+
...(param.maxLength !== undefined
|
|
70
|
+
? { maxLength: param.maxLength }
|
|
71
|
+
: {}),
|
|
72
|
+
...(param.pattern !== undefined ? { pattern: param.pattern } : {}),
|
|
73
|
+
});
|
|
74
|
+
case "boolean":
|
|
75
|
+
return described({ type: "boolean" });
|
|
76
|
+
case "integer":
|
|
77
|
+
return described({
|
|
78
|
+
type: "integer",
|
|
79
|
+
...(param.minimum !== undefined ? { minimum: param.minimum } : {}),
|
|
80
|
+
...(param.maximum !== undefined ? { maximum: param.maximum } : {}),
|
|
81
|
+
});
|
|
82
|
+
case "string[]":
|
|
83
|
+
return described({ type: "array", items: { type: "string" } });
|
|
84
|
+
case "nullable-string":
|
|
85
|
+
return described({ type: ["string", "null"] });
|
|
86
|
+
case "string-map":
|
|
87
|
+
return described({
|
|
88
|
+
type: "object",
|
|
89
|
+
additionalProperties: { type: ["string", "null"] },
|
|
90
|
+
});
|
|
91
|
+
case "object":
|
|
92
|
+
return described(toolInputSchema(param));
|
|
93
|
+
case "object[]":
|
|
94
|
+
return described({
|
|
95
|
+
type: "array",
|
|
96
|
+
items: toolInputSchema(param),
|
|
97
|
+
...(param.minItems ? { minItems: param.minItems } : {}),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The JSON Schema `tools/list` advertises for a {@link ToolShape}.
|
|
104
|
+
*
|
|
105
|
+
* NOTE: `additionalProperties: false` is what the schema says; servers still
|
|
106
|
+
* drop unknown arguments rather than refuse them, as the cloud's zod schemas
|
|
107
|
+
* do.
|
|
108
|
+
*/
|
|
109
|
+
export function toolInputSchema(shape: ToolShape): JsonSchema {
|
|
110
|
+
const properties: Record<string, JsonSchema> = {};
|
|
111
|
+
for (const [name, param] of Object.entries(shape.properties))
|
|
112
|
+
properties[name] = paramSchema(param);
|
|
113
|
+
return {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties,
|
|
116
|
+
...(shape.required?.length ? { required: [...shape.required] } : {}),
|
|
117
|
+
additionalProperties: false,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* One tool as `tools/list` advertises it (BE-27). Both board servers build
|
|
123
|
+
* their list with this, so the cloud and the offline one cannot drift on the
|
|
124
|
+
* fields around the schema either.
|
|
125
|
+
*/
|
|
126
|
+
export function toolListEntry(tool: ToolContract): {
|
|
127
|
+
name: string;
|
|
128
|
+
title?: string;
|
|
129
|
+
description: string;
|
|
130
|
+
inputSchema: JsonSchema;
|
|
131
|
+
annotations: {
|
|
132
|
+
readOnlyHint: boolean;
|
|
133
|
+
destructiveHint: boolean;
|
|
134
|
+
openWorldHint: false;
|
|
135
|
+
};
|
|
136
|
+
} {
|
|
137
|
+
return {
|
|
138
|
+
name: tool.name,
|
|
139
|
+
...(tool.title ? { title: tool.title } : {}),
|
|
140
|
+
description: tool.description,
|
|
141
|
+
inputSchema: toolInputSchema(tool),
|
|
142
|
+
annotations: {
|
|
143
|
+
readOnlyHint: tool.readOnly,
|
|
144
|
+
// Only `delete_review` takes something away, and it archives.
|
|
145
|
+
destructiveHint: tool.name === "delete_review",
|
|
146
|
+
openWorldHint: false,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|