@asterism-app/sdk 1.6.0 → 1.7.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/examples/author.ts +1 -1
- package/package.json +1 -1
- package/src/mcp.ts +4 -9
- package/src/messaging.ts +3 -0
- package/src/models.ts +0 -1
- package/src/provider-settings.ts +1 -1
- package/src/runtime.ts +1 -1
package/examples/author.ts
CHANGED
|
@@ -133,7 +133,7 @@ export async function modelWork(plugin: PluginContext, object: ObjectExecutor, s
|
|
|
133
133
|
const result = await plugin.execution.run({
|
|
134
134
|
access: object.ref, interactive: false, requestParentId: snapshot.position.nodeId, target: { provider: "configured-provider", model: "configured-model" },
|
|
135
135
|
system: { blocks: [{ id: research.name("instruction"), text: "Inspect linked materials and report findings." }] },
|
|
136
|
-
messages: projectOwnContext(snapshot, object.ref),
|
|
136
|
+
messages: projectOwnContext(snapshot, object.ref), signal,
|
|
137
137
|
observer: { event(event) {
|
|
138
138
|
if (event.type === "progress") return;
|
|
139
139
|
object.commit(writer => {
|
package/package.json
CHANGED
package/src/mcp.ts
CHANGED
|
@@ -5,11 +5,13 @@ import { jsonSchema } from "./json.ts";
|
|
|
5
5
|
|
|
6
6
|
export const SERVER_ID_PATTERN = /^[a-z0-9][a-z0-9_-]*$/u;
|
|
7
7
|
export const serverIdSchema = z.string().min(1).max(64).regex(SERVER_ID_PATTERN);
|
|
8
|
+
/** Environment variables (stdio) or request headers (http); values may be `!` credential commands. */
|
|
9
|
+
export const mcpVariablesSchema = z.record(z.string().min(1), z.string());
|
|
8
10
|
export const mcpServerSchema = z.strictObject({
|
|
9
11
|
id: serverIdSchema, name: z.string().trim().min(1), enabled: z.boolean(),
|
|
10
12
|
mode: z.enum(["eager", "lazy"]), idleSeconds: z.number().int().min(1).max(86_400),
|
|
11
13
|
transport: z.enum(["stdio", "http"]), command: z.string(), args: z.array(z.string()), cwd: z.string(),
|
|
12
|
-
url: z.string(), auth: z.enum(["none", "oauth"]),
|
|
14
|
+
url: z.string(), auth: z.enum(["none", "oauth"]), env: mcpVariablesSchema, headers: mcpVariablesSchema,
|
|
13
15
|
}).superRefine((value, ctx) => {
|
|
14
16
|
if (value.transport === "stdio" && !value.command.trim()) ctx.addIssue({ code: "custom", path: ["command"], message: "An executable is required." });
|
|
15
17
|
if (value.transport === "http") {
|
|
@@ -21,7 +23,6 @@ export type McpServerConfig = z.infer<typeof mcpServerSchema>;
|
|
|
21
23
|
export const mcpSettingsSchema = z.object({ servers: z.array(mcpServerSchema).refine(values =>
|
|
22
24
|
new Set(values.map(value => value.id)).size === values.length, "Server IDs are unique.") });
|
|
23
25
|
export const defaultMcpSettings = { servers: [] };
|
|
24
|
-
export const credentialsSchema = z.record(z.string(), z.string());
|
|
25
26
|
export const connectionPhases = ["disconnected", "connecting", "awaiting_auth", "authorizing", "connected", "error"] as const;
|
|
26
27
|
export type ConnectionPhase = typeof connectionPhases[number];
|
|
27
28
|
export const mcpServerStateSchema = z.object({
|
|
@@ -43,14 +44,8 @@ export interface McpCatalogServer { config: McpServerConfig; state: McpServerSta
|
|
|
43
44
|
|
|
44
45
|
export const McpChanged = defineEvent("core.mcp.changed", { schema: z.object({}), source: "host", semantics: { kind: "snapshot", key: [] } });
|
|
45
46
|
export const ReadMcp = defineCall("core.mcp.status", { scope: "plugin", input: z.object({}), output: z.array(mcpServerStateSchema) });
|
|
46
|
-
/** keep retains saved environment or headers; a new server with keep starts without any. */
|
|
47
|
-
export const mcpCredentialUpdateSchema = z.discriminatedUnion("action", [
|
|
48
|
-
z.strictObject({ action: z.literal("keep") }), z.strictObject({ action: z.literal("replace"), values: credentialsSchema }),
|
|
49
|
-
]);
|
|
50
|
-
export type McpCredentialUpdate = z.infer<typeof mcpCredentialUpdateSchema>;
|
|
51
47
|
export const SaveMcpServer = defineCall("core.mcp.save-server", { scope: "plugin",
|
|
52
|
-
input: z.object({ server: mcpServerSchema, create: z.boolean()
|
|
53
|
-
export const ReadMcpCredentials = defineCall("core.mcp.read-credentials", { scope: "plugin", input: z.object({ serverId: z.string() }), output: credentialsSchema });
|
|
48
|
+
input: z.object({ server: mcpServerSchema, create: z.boolean() }), output: z.null() });
|
|
54
49
|
export const mcpToolSummarySchema = z.object({ name: z.string(), title: z.string().optional(), description: z.string().optional() });
|
|
55
50
|
export type McpToolSummary = z.infer<typeof mcpToolSummarySchema>;
|
|
56
51
|
export const ReadMcpTools = defineCall("core.mcp.read-tools", { scope: "plugin", input: z.object({ serverId: z.string() }),
|
package/src/messaging.ts
CHANGED
|
@@ -41,9 +41,12 @@ export const messagingFilePartSchema = z.strictObject({
|
|
|
41
41
|
});
|
|
42
42
|
export const messagingTextPartSchema = z.strictObject({ kind: z.literal("text"), text: z.string() });
|
|
43
43
|
export const messagingPartSchema = z.discriminatedUnion("kind", [messagingTextPartSchema, messagingFilePartSchema]);
|
|
44
|
+
/** Content supplied with a reply, without asserting the original message's identity, author, or time. */
|
|
45
|
+
export const messageQuoteSchema = z.strictObject({ parts: z.array(messagingPartSchema) });
|
|
44
46
|
export const messageSchema = z.strictObject({
|
|
45
47
|
id, sender: messageSenderSchema, parts: z.array(messagingPartSchema),
|
|
46
48
|
sentAt: z.string(), replyTo: id.optional(), threadId: id.optional(), groupId: id.optional(),
|
|
49
|
+
quote: messageQuoteSchema.optional(),
|
|
47
50
|
});
|
|
48
51
|
export const messagingFileQuerySchema = conversationAddressSchema.extend({ messageId: id, fileId: id });
|
|
49
52
|
export const conversationQuerySchema = z.strictObject({ since: id.optional() });
|
package/src/models.ts
CHANGED
|
@@ -117,7 +117,6 @@ export interface ModelRunRequest extends ModelRequestIdentity {
|
|
|
117
117
|
system: SystemPrompt;
|
|
118
118
|
messages: ModelItem[];
|
|
119
119
|
tools?: ModelTools;
|
|
120
|
-
cache?: { expectHit: boolean };
|
|
121
120
|
/** Synchronously package domain data after final request preparation; delivered with the actual response's completion. */
|
|
122
121
|
completionExtensions?: (context: ModelRequestContext) => readonly Presentation[];
|
|
123
122
|
signal: AbortSignal;
|
package/src/provider-settings.ts
CHANGED
|
@@ -6,7 +6,7 @@ const base = { key: z.string().regex(/^[A-Za-z][A-Za-z0-9_]*$/u), label: uiTextS
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Provider settings use a closed set of kinds that the host renders, validates, and stores.
|
|
9
|
-
* Secret values are stored
|
|
9
|
+
* Secret values are stored with other settings and may be `!` credential commands; settings inputs mask them.
|
|
10
10
|
* Text values are saved trimmed; choices always resolve to a declared option.
|
|
11
11
|
*/
|
|
12
12
|
export const providerSettingSchema = z.discriminatedUnion("kind", [
|
package/src/runtime.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface PluginConfig<T extends Json> {
|
|
|
36
36
|
update(next: (current: T) => T): void;
|
|
37
37
|
subscribe(listener: (value: T) => void): () => void;
|
|
38
38
|
}
|
|
39
|
-
/** Namespaced credentials
|
|
39
|
+
/** Namespaced credentials stored as given in the plugin's managed directory. */
|
|
40
40
|
export interface PluginSecrets {
|
|
41
41
|
get(key: string): Promise<string | null>;
|
|
42
42
|
set(key: string, value: string): Promise<void>;
|