@wakeshift/sdk 0.2.0 → 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/CHANGELOG.md +182 -0
- package/README.md +81 -64
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +92 -48
- package/dist/events.js +217 -76
- package/dist/events.js.map +1 -1
- package/dist/harness.js +2 -2
- package/dist/harness.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/key.d.ts +1 -6
- package/dist/key.js +9 -5
- package/dist/key.js.map +1 -1
- package/dist/retry.js +1 -1
- package/dist/retry.js.map +1 -1
- package/dist/spec.d.ts +2 -2
- package/dist/spec.js +2 -2
- package/dist/spec.js.map +1 -1
- package/dist/toolcall.d.ts +154 -0
- package/dist/toolcall.js +558 -0
- package/dist/toolcall.js.map +1 -0
- package/dist/wakeshift.d.ts +75 -241
- package/dist/wakeshift.js +157 -247
- package/dist/wakeshift.js.map +1 -1
- package/package.json +17 -3
- package/dist/guest.d.ts +0 -119
- package/dist/guest.js +0 -506
- package/dist/guest.js.map +0 -1
- package/dist/limits.d.ts +0 -19
- package/dist/limits.js +0 -105
- package/dist/limits.js.map +0 -1
- package/dist/sealed.d.ts +0 -4
- package/dist/sealed.js +0 -38
- package/dist/sealed.js.map +0 -1
package/dist/events.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
1
|
import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
|
|
4
2
|
import { type AnySchema, type SchemaInput, type SchemaOutput, type ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
3
|
+
import { WakeshiftError } from "./errors.js";
|
|
5
4
|
import { type Dialect } from "./spec.js";
|
|
6
|
-
import { type
|
|
5
|
+
import { type Emitted, type PublishUrl, type Recipient, type ToolExtra, type Via, type Wakeshift } from "./wakeshift.js";
|
|
6
|
+
import { type EventsOptions } from "./toolcall.js";
|
|
7
7
|
/** Who is subscribing: what authorize decides on. */
|
|
8
8
|
export interface Subscriber {
|
|
9
9
|
/** The app's ID for the person (attach's identify), if it has one. */
|
|
@@ -45,15 +45,26 @@ export interface EventOptions<A extends AnySchema, P extends AnySchema> {
|
|
|
45
45
|
* to keep. One that isn't delivered expires as any other does.
|
|
46
46
|
*/
|
|
47
47
|
deleteOnDelivery?: boolean;
|
|
48
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Advanced: the topic template and payload filter, if the defaults don't
|
|
50
|
+
* fit. A filter without a topic adds to the optional arguments' filters,
|
|
51
|
+
* and may not name the same payload field as one of them.
|
|
52
|
+
*/
|
|
49
53
|
topic?: string;
|
|
50
54
|
filter?: Record<string, string>;
|
|
51
55
|
}
|
|
52
56
|
export interface EmitOptions {
|
|
53
|
-
/** Makes retries emit once for a day (at most 200 characters). */
|
|
57
|
+
/** Makes retries emit once for a day (at most 200 characters). A retry must name the same recipients: Wakeshift uses the first's. */
|
|
54
58
|
id?: string;
|
|
55
|
-
/**
|
|
56
|
-
|
|
59
|
+
/**
|
|
60
|
+
* A personal event's recipients (at most 1,000), one or a list, mixed: a
|
|
61
|
+
* user, the app's ID for them (attach's identify), reaching every
|
|
62
|
+
* subscription they have to the event with these arguments;
|
|
63
|
+
* `{ user, subscription }`, exactly that subscription of that user's;
|
|
64
|
+
* `{ native: user }`, only that user's native (webhook) subscriptions.
|
|
65
|
+
* Required for personal events, refused otherwise.
|
|
66
|
+
*/
|
|
67
|
+
to?: string | Recipient | (string | Recipient)[];
|
|
57
68
|
}
|
|
58
69
|
/** The manifest form of an event type. */
|
|
59
70
|
export interface EventTypeManifest {
|
|
@@ -79,10 +90,11 @@ export declare class WakeEvent<A extends AnySchema = AnySchema, P extends AnySch
|
|
|
79
90
|
constructor(wake: Wakeshift, name: string, opts: EventOptions<A, P>);
|
|
80
91
|
/**
|
|
81
92
|
* Sends one occurrence: to everyone subscribed with these arguments, or,
|
|
82
|
-
* for a personal event, to the
|
|
93
|
+
* for a personal event, to the recipients `to` names. The payload is
|
|
83
94
|
* checked against the event's schema first.
|
|
84
95
|
*/
|
|
85
|
-
emit(args: SchemaInput<A>, payload: SchemaInput<P>, opts?: EmitOptions): Promise<
|
|
96
|
+
emit(args: SchemaInput<A>, payload: SchemaInput<P>, opts?: EmitOptions): Promise<Emitted>;
|
|
97
|
+
private wireTo;
|
|
86
98
|
/**
|
|
87
99
|
* A capability URL that emits this event with these arguments (a personal
|
|
88
100
|
* event: to the one subscriber `to` names), for services that can only
|
|
@@ -95,65 +107,97 @@ export declare class WakeEvent<A extends AnySchema = AnySchema, P extends AnySch
|
|
|
95
107
|
to?: string;
|
|
96
108
|
}): Promise<PublishUrl>;
|
|
97
109
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
* How many conversations are subscribed to this event with these
|
|
111
|
+
* arguments (a personal event: those of the one user `to` names), how
|
|
112
|
+
* many are connected now, and how. Only reads.
|
|
113
|
+
*/
|
|
114
|
+
status(args: SchemaInput<A>, opts?: {
|
|
115
|
+
to?: string;
|
|
116
|
+
}): Promise<EventStatus>;
|
|
117
|
+
/**
|
|
118
|
+
* Reads subscriptions to this event by ID, each with the user
|
|
119
|
+
* `call.subscribe` made it for, up to 1,000 at once: whether each is live
|
|
120
|
+
* and its conversation connected now, and how. Only reads.
|
|
105
121
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
wakeArgs?: Record<string, unknown>;
|
|
111
|
-
}): Promise<CallerSubscription>;
|
|
122
|
+
statusOf(subs: {
|
|
123
|
+
user: string;
|
|
124
|
+
subscription: string;
|
|
125
|
+
}[]): Promise<EventSubscriptionStatus[]>;
|
|
112
126
|
/**
|
|
113
|
-
* Ends
|
|
114
|
-
*
|
|
115
|
-
*
|
|
127
|
+
* Ends one of user's subscriptions to this app's events, by its ID (a
|
|
128
|
+
* Subscription's id from call.subscribe, or list_subscriptions'), outside
|
|
129
|
+
* a tool: a player who timed out, a member removed. False if there was none.
|
|
116
130
|
*/
|
|
117
|
-
unsubscribe(extra: ToolExtra, args: SchemaInput<A>, opts: {
|
|
118
|
-
server?: McpServer;
|
|
119
|
-
client?: string;
|
|
120
|
-
user?: string;
|
|
121
|
-
wakeArgs?: Record<string, unknown>;
|
|
122
|
-
}): Promise<boolean>;
|
|
123
|
-
/** Ends one of user's subscriptions to this app's events, by its ID (from subscribe or list_subscriptions). False if there was none. */
|
|
124
131
|
end(user: string, id: string): Promise<boolean>;
|
|
125
132
|
}
|
|
126
|
-
/**
|
|
127
|
-
export
|
|
133
|
+
/** The most subscriptions one `statusOf` reads. */
|
|
134
|
+
export declare const MAX_STATUS_SUBSCRIPTIONS = 1000;
|
|
135
|
+
/** Who is subscribed to an event with some arguments right now (`event.status`). */
|
|
136
|
+
export interface EventStatus {
|
|
137
|
+
/** Conversations subscribed (ended or expired subscriptions don't count). */
|
|
138
|
+
subscriptions: number;
|
|
139
|
+
/** Of those, connected now. */
|
|
140
|
+
connected: number;
|
|
141
|
+
/** How many are connected each way. */
|
|
142
|
+
via: Record<Via, number>;
|
|
143
|
+
}
|
|
144
|
+
/** One subscription right now (`event.statusOf`). */
|
|
145
|
+
export interface EventSubscriptionStatus {
|
|
128
146
|
id: string;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/** Your tool's text, with what the agent needs to be woken added. */
|
|
136
|
-
result(text: string | CallToolResult): CallToolResult;
|
|
147
|
+
user: string;
|
|
148
|
+
/** The subscription is the user's, to this event, and hasn't ended. One that names nothing is false too. */
|
|
149
|
+
live: boolean;
|
|
150
|
+
/** Its conversation is reachable now, and `via` says how. */
|
|
151
|
+
connected: boolean;
|
|
152
|
+
via?: Via;
|
|
137
153
|
}
|
|
138
|
-
/**
|
|
139
|
-
|
|
154
|
+
/**
|
|
155
|
+
* An event's arguments or payload don't match its schema: a WakeshiftError
|
|
156
|
+
* with code bad_arguments (status 400), as Wakeshift answers the same
|
|
157
|
+
* mistake, thrown before asking it.
|
|
158
|
+
*/
|
|
159
|
+
export declare class ArgsError extends WakeshiftError {
|
|
160
|
+
constructor(message: string);
|
|
140
161
|
}
|
|
141
162
|
/** Who is behind a request to the app's MCP server, as the app knows them (AttachOptions.identify). */
|
|
142
163
|
export interface Identity {
|
|
143
164
|
/** The app's ID for the person: what personal events and list_subscriptions need, and native subscriptions belong to. */
|
|
144
165
|
user?: string;
|
|
166
|
+
/**
|
|
167
|
+
* The MCP client's name, for a request that doesn't carry one: a
|
|
168
|
+
* stateless server never sees initialize, so the app passes the name it
|
|
169
|
+
* knows from its own sign-in (an OAuth registration's client_name, say).
|
|
170
|
+
* Wakeshift reads it to tell which program the agent runs in, and
|
|
171
|
+
* whether the client subscribes to events itself. A name the request
|
|
172
|
+
* carries (initialize's, or its _meta's) wins. Leave it out for a caller
|
|
173
|
+
* that must have no name.
|
|
174
|
+
*/
|
|
175
|
+
client?: string;
|
|
145
176
|
}
|
|
146
177
|
export interface AttachOptions {
|
|
147
178
|
/**
|
|
148
|
-
* Who is behind a request,
|
|
149
|
-
* the
|
|
179
|
+
* Who is behind a request. The app passes identify, returning { user }:
|
|
180
|
+
* its own ID for the person, from its own sign-in (and, on a stateless
|
|
181
|
+
* server, the client's name as `client`). Without it, requests have no
|
|
182
|
+
* user, so personal events and list_subscriptions refuse.
|
|
150
183
|
*/
|
|
151
184
|
identify?: (extra: ToolExtra & {
|
|
152
185
|
authInfo?: AuthInfo;
|
|
153
186
|
}) => Identity | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* Which of attach's own tools it adds (BUILTIN_TOOLS): subscribe_events,
|
|
189
|
+
* unsubscribe_events and list_subscriptions. Default: all three; `[]`
|
|
190
|
+
* adds none. Leave out unsubscribe_events or list_subscriptions only if
|
|
191
|
+
* your own tools let a person see and stop their subscriptions.
|
|
192
|
+
*/
|
|
193
|
+
tools?: readonly BuiltinTool[];
|
|
194
|
+
/** The event features' options: events.native overrides native detection for wrapped tools (attached.events). */
|
|
195
|
+
events?: EventsOptions;
|
|
154
196
|
}
|
|
155
|
-
/**
|
|
156
|
-
export declare
|
|
197
|
+
/** The tools attach adds, unless AttachOptions.tools names fewer. */
|
|
198
|
+
export declare const BUILTIN_TOOLS: readonly ["subscribe_events", "unsubscribe_events", "list_subscriptions"];
|
|
199
|
+
/** One of attach's own tools. */
|
|
200
|
+
export type BuiltinTool = (typeof BUILTIN_TOOLS)[number];
|
|
157
201
|
export declare const EVENT_TOOL_TEXT: {
|
|
158
202
|
readonly a_webhook: "a webhook";
|
|
159
203
|
readonly arguments_argument: "The event's arguments, as an object: see the event's list above";
|