apps 0.0.1-beta.46 → 0.0.1-beta.48
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/framework-reference.json +1 -1
- package/js/{chunk-XK5I2XOI.js → chunk-D45JTD6N.js} +2 -2
- package/js/{chunk-3B2JAOSE.js → chunk-GDYPM7RS.js} +102 -3
- package/js/{chunk-CVAJ4F6O.js → chunk-JY56GVSV.js} +81 -3
- package/js/{chunk-OJ47HQVJ.js → chunk-PO5NPRFT.js} +67 -14
- package/js/{chunk-7LGRK7TP.js → chunk-QKHTRD6G.js} +2 -2
- package/js/{chunk-3UGDI2UI.js → chunk-SVHI6AKV.js} +2 -2
- package/js/{chunk-LHCGND3R.js → chunk-X5U5KIWQ.js} +1 -1
- package/js/{chunk-6QXPBJ5T.js → chunk-YQD2MLFY.js} +2 -2
- package/js/contracts.js +19 -1
- package/js/effect.js +5 -5
- package/js/graphql.js +6 -6
- package/js/host.js +5 -5
- package/js/index.js +6 -4
- package/js/mcp/effect.js +7 -7
- package/js/mcp/stdio.js +7 -7
- package/js/mcp.js +8 -8
- package/js/openapi.js +4 -4
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/contracts/app.d.ts +2 -0
- package/types/apps/src/contracts/context.d.ts +8 -1
- package/types/apps/src/contracts/events.d.ts +93 -0
- package/types/apps/src/contracts/host.d.ts +6 -4
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/11.d.ts +1098 -0
- package/types/apps/src/implementation/account-router.d.ts +4 -3
- package/types/apps/src/implementation/events.d.ts +59 -0
- package/types/apps/src/implementation/operations.d.ts +5 -0
- package/types/apps/src/implementation/router.d.ts +7 -5
- package/types/apps/src/implementation/sql.d.ts +5 -0
- package/types/apps/src/index.d.ts +3 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
prepareElicitation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PO5NPRFT.js";
|
|
4
4
|
import {
|
|
5
5
|
bodyUpstreamError,
|
|
6
6
|
fromPromise
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
defaultElicitationLimits,
|
|
17
17
|
defaultMcpClientLimits,
|
|
18
18
|
mcpSdkTimerCeilingMs
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JY56GVSV.js";
|
|
20
20
|
import {
|
|
21
21
|
jsonSchemaDecoder,
|
|
22
22
|
nestJsonSchema,
|
|
@@ -2,17 +2,21 @@ import {
|
|
|
2
2
|
declaredOperations,
|
|
3
3
|
nativeOperation,
|
|
4
4
|
nativeRouter
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-X5U5KIWQ.js";
|
|
6
6
|
import {
|
|
7
7
|
fromPromise,
|
|
8
8
|
method
|
|
9
9
|
} from "./chunk-LTDHQJ2Z.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
EmittedEvent,
|
|
12
|
+
EventName,
|
|
13
|
+
ScheduleTiming,
|
|
14
|
+
defaultEventLimits
|
|
15
|
+
} from "./chunk-JY56GVSV.js";
|
|
13
16
|
import {
|
|
14
17
|
decoderOf,
|
|
15
18
|
isSchema,
|
|
19
|
+
jsonSchemaDocument,
|
|
16
20
|
schemaArgument
|
|
17
21
|
} from "./chunk-KGCTYL2S.js";
|
|
18
22
|
import {
|
|
@@ -57,6 +61,87 @@ var nativeWorkflow = (value) => {
|
|
|
57
61
|
return value[NativeWorkflow];
|
|
58
62
|
};
|
|
59
63
|
|
|
64
|
+
// src/implementation/events.ts
|
|
65
|
+
var Native = /* @__PURE__ */ Symbol("apps.Event");
|
|
66
|
+
var scalarTypes = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean"]);
|
|
67
|
+
var isScalarSchema = (document) => {
|
|
68
|
+
const type = document.type;
|
|
69
|
+
if (typeof type === "string") return scalarTypes.has(type);
|
|
70
|
+
const choices = Array.isArray(document.enum) ? document.enum : "const" in document ? [document.const] : void 0;
|
|
71
|
+
return choices !== void 0 && choices.length > 0 && choices.every((value) => ["string", "number", "boolean"].includes(typeof value));
|
|
72
|
+
};
|
|
73
|
+
var event = (options) => {
|
|
74
|
+
const filters = options.filters ?? {};
|
|
75
|
+
const fieldDecoders = Object.fromEntries(
|
|
76
|
+
Object.entries(filters).map(([key, field]) => [
|
|
77
|
+
key,
|
|
78
|
+
decoderOf(schemaArgument(field, `The event filter ${JSON.stringify(key)}`))
|
|
79
|
+
])
|
|
80
|
+
);
|
|
81
|
+
for (const [key, decoder] of Object.entries(fieldDecoders)) {
|
|
82
|
+
const document = Effect_exports.runSync(jsonSchemaDocument(decoder));
|
|
83
|
+
if (!isScalarSchema(document))
|
|
84
|
+
throw new TypeError(
|
|
85
|
+
`The event filter ${JSON.stringify(key)} must be a string, number, boolean or literal`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
[Native]: {
|
|
90
|
+
description: options.description,
|
|
91
|
+
filters: fieldDecoders,
|
|
92
|
+
payload: decoderOf(schemaArgument(options.payload, "The event payload"))
|
|
93
|
+
},
|
|
94
|
+
description: options.description,
|
|
95
|
+
filters,
|
|
96
|
+
payload: options.payload
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
var nativeEvent = (declaration) => typeof declaration === "object" && declaration !== null && Native in declaration ? declaration[Native] : void 0;
|
|
100
|
+
var declaredEvents = (events) => Effect_exports.forEach(
|
|
101
|
+
Object.entries(events),
|
|
102
|
+
([name, declared]) => Effect_exports.gen(function* () {
|
|
103
|
+
const filters = yield* jsonSchemaDocument(Schema_exports.Struct(declared.filters));
|
|
104
|
+
const payload = yield* jsonSchemaDocument(declared.payload);
|
|
105
|
+
return [name, { description: declared.description, filters, payload }];
|
|
106
|
+
})
|
|
107
|
+
).pipe(Effect_exports.map((entries) => Object.fromEntries(entries)));
|
|
108
|
+
var makeEmitter = (input) => ({
|
|
109
|
+
emit: (name, data, ...rest) => {
|
|
110
|
+
const options = rest[0] ?? {};
|
|
111
|
+
const declared = Object.hasOwn(input.events, name) ? input.events[name] : void 0;
|
|
112
|
+
if (declared === void 0) throw new TypeError(`This app declares no event named "${name}"`);
|
|
113
|
+
if (input.emitted.length >= defaultEventLimits.maxEventsPerInvocation)
|
|
114
|
+
throw new RangeError(
|
|
115
|
+
`An invocation can emit at most ${defaultEventLimits.maxEventsPerInvocation} events`
|
|
116
|
+
);
|
|
117
|
+
const payload = Schema_exports.decodeUnknownSync(declared.payload)(data);
|
|
118
|
+
const filters = Schema_exports.decodeUnknownSync(Schema_exports.Struct(declared.filters))(
|
|
119
|
+
options.filters ?? {}
|
|
120
|
+
);
|
|
121
|
+
const account = options.account ?? input.sourceAccount ?? (input.accounts.length === 1 ? input.accounts[0] : void 0) ?? null;
|
|
122
|
+
if (account === null && input.accounts.length > 1)
|
|
123
|
+
throw new TypeError(
|
|
124
|
+
"This invocation has several accounts; name the one the event came from with { account }"
|
|
125
|
+
);
|
|
126
|
+
if (account !== null && !input.accounts.includes(account))
|
|
127
|
+
throw new TypeError("The event's account is not one of this invocation's accounts");
|
|
128
|
+
const occurredAt = options.occurredAt === void 0 ? Date.now() : options.occurredAt instanceof Date ? options.occurredAt.getTime() : options.occurredAt;
|
|
129
|
+
const occurrence = Schema_exports.decodeUnknownSync(EmittedEvent)({
|
|
130
|
+
name: Schema_exports.decodeUnknownSync(EventName)(name),
|
|
131
|
+
id: options.id ?? crypto.randomUUID(),
|
|
132
|
+
occurredAt,
|
|
133
|
+
data: payload,
|
|
134
|
+
filters,
|
|
135
|
+
account
|
|
136
|
+
});
|
|
137
|
+
if (new TextEncoder().encode(JSON.stringify(occurrence.data)).byteLength > defaultEventLimits.maxDataBytes)
|
|
138
|
+
throw new RangeError(
|
|
139
|
+
`An event's data can be at most ${defaultEventLimits.maxDataBytes} bytes of JSON; send a summary and a tool to read the rest`
|
|
140
|
+
);
|
|
141
|
+
input.emitted.push(occurrence);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
60
145
|
// src/implementation/app.ts
|
|
61
146
|
var InternalApp = /* @__PURE__ */ Symbol("apps.App");
|
|
62
147
|
var isApp = (value) => typeof value === "object" && value !== null && InternalApp in value;
|
|
@@ -146,8 +231,19 @@ var defineApp = (requirements, definition) => {
|
|
|
146
231
|
if (typeof definition !== "function") rejectCatalogs(definition);
|
|
147
232
|
const evaluate = typeof definition === "function" ? definition : async () => definition;
|
|
148
233
|
const factory = fromPromise(evaluate, "factory");
|
|
234
|
+
const events = requirements.events === void 0 ? void 0 : Object.fromEntries(
|
|
235
|
+
Object.entries(requirements.events).map(([name, declared]) => {
|
|
236
|
+
const native2 = nativeEvent(declared);
|
|
237
|
+
if (native2 === void 0)
|
|
238
|
+
throw new TypeError(
|
|
239
|
+
`The event ${JSON.stringify(name)} must be declared with event()`
|
|
240
|
+
);
|
|
241
|
+
return [name, native2];
|
|
242
|
+
})
|
|
243
|
+
);
|
|
149
244
|
const native = {
|
|
150
245
|
accounts: requirements.accounts,
|
|
246
|
+
...events === void 0 ? {} : { events },
|
|
151
247
|
evaluate: (context) => factory(context).pipe(Effect_exports.map((value) => adaptDefinition(value)))
|
|
152
248
|
};
|
|
153
249
|
return {
|
|
@@ -161,6 +257,9 @@ export {
|
|
|
161
257
|
ResponseStatusError,
|
|
162
258
|
ResponseDecodeError,
|
|
163
259
|
workflow,
|
|
260
|
+
event,
|
|
261
|
+
declaredEvents,
|
|
262
|
+
makeEmitter,
|
|
164
263
|
isApp,
|
|
165
264
|
toEffectApp,
|
|
166
265
|
defineApp
|
|
@@ -1983,6 +1983,52 @@ var WebhookCommand = Schema_exports.Union([
|
|
|
1983
1983
|
})
|
|
1984
1984
|
]);
|
|
1985
1985
|
|
|
1986
|
+
// src/contracts/events.ts
|
|
1987
|
+
var EventName = Schema_exports.String.check(
|
|
1988
|
+
Schema_exports.isPattern(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$/u),
|
|
1989
|
+
Schema_exports.isMaxLength(64)
|
|
1990
|
+
);
|
|
1991
|
+
var EventFilterValue = Schema_exports.Union([Schema_exports.String, Schema_exports.Finite, Schema_exports.Boolean]);
|
|
1992
|
+
var EventLimits = Schema_exports.Struct({
|
|
1993
|
+
/** An occurrence's `data`, leaving room under a 256 KiB delivery for its envelope. */
|
|
1994
|
+
maxDataBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
|
|
1995
|
+
maxEventsPerInvocation: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
|
|
1996
|
+
maxDescriptionLength: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
|
|
1997
|
+
maxIdLength: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
|
|
1998
|
+
});
|
|
1999
|
+
var defaultEventLimits = EventLimits.make({
|
|
2000
|
+
maxDataBytes: 250 * 1024,
|
|
2001
|
+
maxEventsPerInvocation: 100,
|
|
2002
|
+
maxDescriptionLength: 1e3,
|
|
2003
|
+
maxIdLength: 200
|
|
2004
|
+
});
|
|
2005
|
+
var DeclaredEvent = Schema_exports.Struct({
|
|
2006
|
+
description: Schema_exports.String.check(
|
|
2007
|
+
Schema_exports.isMinLength(1),
|
|
2008
|
+
Schema_exports.isMaxLength(defaultEventLimits.maxDescriptionLength)
|
|
2009
|
+
),
|
|
2010
|
+
/** An object of scalar fields. Subscribers may name any of them to narrow an event. */
|
|
2011
|
+
filters: JsonObject2,
|
|
2012
|
+
/** The shape of each occurrence's `data`. */
|
|
2013
|
+
payload: JsonObject2
|
|
2014
|
+
});
|
|
2015
|
+
var DeclaredEvents = Schema_exports.Record(EventName, DeclaredEvent);
|
|
2016
|
+
var EmittedEvent = Schema_exports.Struct({
|
|
2017
|
+
name: EventName,
|
|
2018
|
+
id: Schema_exports.String.check(
|
|
2019
|
+
Schema_exports.isMinLength(1),
|
|
2020
|
+
Schema_exports.isMaxLength(defaultEventLimits.maxIdLength)
|
|
2021
|
+
),
|
|
2022
|
+
/** Milliseconds since the epoch when the event happened. */
|
|
2023
|
+
occurredAt: Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0)),
|
|
2024
|
+
data: JsonValue,
|
|
2025
|
+
filters: Schema_exports.Record(Schema_exports.String, EventFilterValue),
|
|
2026
|
+
account: Schema_exports.NullOr(AccountId)
|
|
2027
|
+
});
|
|
2028
|
+
var EmittedEvents = Schema_exports.Array(EmittedEvent).check(
|
|
2029
|
+
Schema_exports.isMaxLength(defaultEventLimits.maxEventsPerInvocation)
|
|
2030
|
+
);
|
|
2031
|
+
|
|
1986
2032
|
// src/contracts/provider.ts
|
|
1987
2033
|
var SecretsMethod = class extends Data_exports.TaggedClass(
|
|
1988
2034
|
"secrets"
|
|
@@ -2139,7 +2185,7 @@ var ManyAccounts = class extends Data_exports.TaggedClass("many") {
|
|
|
2139
2185
|
};
|
|
2140
2186
|
|
|
2141
2187
|
// src/contracts/protocol-version.ts
|
|
2142
|
-
var frameworkProtocol =
|
|
2188
|
+
var frameworkProtocol = 11;
|
|
2143
2189
|
|
|
2144
2190
|
// src/contracts/protocols/oauth.ts
|
|
2145
2191
|
var OAuthClientAuth2 = Schema_exports.Literals([
|
|
@@ -3197,6 +3243,29 @@ var protocol10 = {
|
|
|
3197
3243
|
}
|
|
3198
3244
|
};
|
|
3199
3245
|
|
|
3246
|
+
// src/contracts/protocols/11.ts
|
|
3247
|
+
var DeclaredRequirements6 = Schema_exports.Struct({
|
|
3248
|
+
...DeclaredRequirements5.fields,
|
|
3249
|
+
events: Schema_exports.optionalKey(DeclaredEvents)
|
|
3250
|
+
});
|
|
3251
|
+
var HostResponse6 = Schema_exports.Union([
|
|
3252
|
+
Schema_exports.Struct({
|
|
3253
|
+
ok: Schema_exports.Literal(true),
|
|
3254
|
+
value: JsonValue,
|
|
3255
|
+
toolError: Schema_exports.optionalKey(Schema_exports.Literal(true)),
|
|
3256
|
+
events: Schema_exports.optionalKey(EmittedEvents)
|
|
3257
|
+
}),
|
|
3258
|
+
Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError5 })
|
|
3259
|
+
]);
|
|
3260
|
+
var protocol11 = {
|
|
3261
|
+
version: 11,
|
|
3262
|
+
schemas: {
|
|
3263
|
+
...protocol10.schemas,
|
|
3264
|
+
requirements: DeclaredRequirements6,
|
|
3265
|
+
response: HostResponse6
|
|
3266
|
+
}
|
|
3267
|
+
};
|
|
3268
|
+
|
|
3200
3269
|
// src/contracts/host.ts
|
|
3201
3270
|
var skillsCommand = (sources) => sources ? { operation: "skills", sources: true } : { operation: "skills" };
|
|
3202
3271
|
var skillCatalog = (response) => Schema_exports.is(SkillSources2)(response) ? response : { skills: response };
|
|
@@ -3340,6 +3409,14 @@ export {
|
|
|
3340
3409
|
ManualWebhookDescriptor,
|
|
3341
3410
|
HostedWebhook,
|
|
3342
3411
|
WebhookCommand,
|
|
3412
|
+
EventName,
|
|
3413
|
+
EventFilterValue,
|
|
3414
|
+
EventLimits,
|
|
3415
|
+
defaultEventLimits,
|
|
3416
|
+
DeclaredEvent,
|
|
3417
|
+
DeclaredEvents,
|
|
3418
|
+
EmittedEvent,
|
|
3419
|
+
EmittedEvents,
|
|
3343
3420
|
frameworkProtocol,
|
|
3344
3421
|
minimumIntervalMilliseconds,
|
|
3345
3422
|
Interval,
|
|
@@ -3388,14 +3465,15 @@ export {
|
|
|
3388
3465
|
HostedCatalog3 as HostedCatalog,
|
|
3389
3466
|
HostedCatalogSummary3 as HostedCatalogSummary,
|
|
3390
3467
|
HostError5 as HostError,
|
|
3391
|
-
HostResponse5 as HostResponse,
|
|
3392
3468
|
protocol9,
|
|
3393
|
-
DeclaredRequirements5 as DeclaredRequirements,
|
|
3394
3469
|
MigrateCommand,
|
|
3395
3470
|
MigrateResult,
|
|
3396
3471
|
HostRequest4 as HostRequest,
|
|
3397
3472
|
HostInvocation6 as HostInvocation,
|
|
3398
3473
|
protocol10,
|
|
3474
|
+
DeclaredRequirements6 as DeclaredRequirements,
|
|
3475
|
+
HostResponse6 as HostResponse,
|
|
3476
|
+
protocol11,
|
|
3399
3477
|
skillsCommand,
|
|
3400
3478
|
skillCatalog,
|
|
3401
3479
|
inspectCommand,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
parseSkillLoadFailed,
|
|
12
12
|
readCatalog,
|
|
13
13
|
routerSkills
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-SVHI6AKV.js";
|
|
15
15
|
import {
|
|
16
16
|
appInvocationFetch
|
|
17
17
|
} from "./chunk-7UUHJR2Q.js";
|
|
@@ -20,14 +20,16 @@ import {
|
|
|
20
20
|
} from "./chunk-XBG7HHXC.js";
|
|
21
21
|
import {
|
|
22
22
|
ResponseStatusError,
|
|
23
|
+
declaredEvents,
|
|
23
24
|
isApp,
|
|
25
|
+
makeEmitter,
|
|
24
26
|
toEffectApp
|
|
25
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-GDYPM7RS.js";
|
|
26
28
|
import {
|
|
27
29
|
declaredOperations,
|
|
28
30
|
locate,
|
|
29
31
|
nativeOperation
|
|
30
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-X5U5KIWQ.js";
|
|
31
33
|
import {
|
|
32
34
|
accountProviderError,
|
|
33
35
|
appCode,
|
|
@@ -86,7 +88,7 @@ import {
|
|
|
86
88
|
migrationsDirectory,
|
|
87
89
|
reservedTablePrefix,
|
|
88
90
|
workflowDurationMillis
|
|
89
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-JY56GVSV.js";
|
|
90
92
|
import {
|
|
91
93
|
CacheError
|
|
92
94
|
} from "./chunk-MWKHKOTL.js";
|
|
@@ -665,6 +667,7 @@ var dispatchWebhook = (definition, command, context, accounts) => Effect_exports
|
|
|
665
667
|
|
|
666
668
|
// src/implementation/sql.ts
|
|
667
669
|
var receipts = `${reservedTablePrefix}step_receipts`;
|
|
670
|
+
var stepEvents = `${reservedTablePrefix}step_events`;
|
|
668
671
|
var migrationsTable = `${reservedTablePrefix}migrations`;
|
|
669
672
|
var legacyRows = `${reservedTablePrefix}legacy_rows`;
|
|
670
673
|
var materialize = (cursor) => {
|
|
@@ -811,7 +814,12 @@ var authorSql = (storage, options) => {
|
|
|
811
814
|
transactions += 1;
|
|
812
815
|
violation = void 0;
|
|
813
816
|
const handle = transactionHandle();
|
|
814
|
-
|
|
817
|
+
const emittedBefore = options.emitted?.length;
|
|
818
|
+
const discardEmitted = () => {
|
|
819
|
+
if (options.emitted !== void 0 && emittedBefore !== void 0)
|
|
820
|
+
options.emitted.length = emittedBefore;
|
|
821
|
+
};
|
|
822
|
+
const body = () => {
|
|
815
823
|
open = true;
|
|
816
824
|
try {
|
|
817
825
|
const complete = () => {
|
|
@@ -828,12 +836,25 @@ var authorSql = (storage, options) => {
|
|
|
828
836
|
`CREATE TABLE IF NOT EXISTS ${receipts} (id TEXT PRIMARY KEY, fingerprint TEXT NOT NULL, result TEXT NOT NULL) WITHOUT ROWID`
|
|
829
837
|
);
|
|
830
838
|
const saved = storage.sql.exec(`SELECT fingerprint, result FROM ${receipts} WHERE id = ?`, step.key).toArray()[0];
|
|
839
|
+
storage.sql.exec(
|
|
840
|
+
`CREATE TABLE IF NOT EXISTS ${stepEvents} (id TEXT PRIMARY KEY, events TEXT NOT NULL) WITHOUT ROWID`
|
|
841
|
+
);
|
|
831
842
|
if (saved !== void 0) {
|
|
832
843
|
if (saved.fingerprint !== step.fingerprint)
|
|
833
844
|
throw new Error("This workflow step already ran with different input.");
|
|
845
|
+
const replayed = storage.sql.exec(`SELECT events FROM ${stepEvents} WHERE id = ?`, step.key).toArray()[0];
|
|
846
|
+
if (replayed !== void 0 && options.emitted !== void 0)
|
|
847
|
+
options.emitted.push(...JSON.parse(String(replayed.events)));
|
|
834
848
|
return JSON.parse(String(saved.result));
|
|
835
849
|
}
|
|
836
850
|
const encoded = JSON.stringify(complete() ?? null);
|
|
851
|
+
const emitted = options.emitted?.slice(emittedBefore ?? 0) ?? [];
|
|
852
|
+
if (emitted.length > 0)
|
|
853
|
+
storage.sql.exec(
|
|
854
|
+
`INSERT INTO ${stepEvents} (id, events) VALUES (?, ?)`,
|
|
855
|
+
step.key,
|
|
856
|
+
JSON.stringify(emitted)
|
|
857
|
+
);
|
|
837
858
|
storage.sql.exec(
|
|
838
859
|
`INSERT INTO ${receipts} (id, fingerprint, result) VALUES (?, ?, ?)`,
|
|
839
860
|
step.key,
|
|
@@ -845,7 +866,13 @@ var authorSql = (storage, options) => {
|
|
|
845
866
|
open = false;
|
|
846
867
|
handle.end();
|
|
847
868
|
}
|
|
848
|
-
}
|
|
869
|
+
};
|
|
870
|
+
try {
|
|
871
|
+
return storage.transactionSync(body);
|
|
872
|
+
} catch (error) {
|
|
873
|
+
discardEmitted();
|
|
874
|
+
throw error;
|
|
875
|
+
}
|
|
849
876
|
};
|
|
850
877
|
const writer = {
|
|
851
878
|
// A step's writes go through its one transaction, which also records its receipt.
|
|
@@ -1149,7 +1176,7 @@ function providerDeclaration(provider) {
|
|
|
1149
1176
|
`Account provider "${provider.name}" has an invalid declaration`
|
|
1150
1177
|
);
|
|
1151
1178
|
}
|
|
1152
|
-
function requirements(slots, sql) {
|
|
1179
|
+
function requirements(slots, sql, events) {
|
|
1153
1180
|
return Effect_exports.gen(function* () {
|
|
1154
1181
|
const accounts = /* @__PURE__ */ new Map();
|
|
1155
1182
|
for (const [slot, selection] of Object.entries(slots)) {
|
|
@@ -1163,7 +1190,13 @@ function requirements(slots, sql) {
|
|
|
1163
1190
|
return yield* Schema_exports.decodeUnknownEffect(DeclaredRequirements)({
|
|
1164
1191
|
accounts: Object.fromEntries(accounts),
|
|
1165
1192
|
capabilities: { skills: true, toolIndex: true, skillSources: true, scheduledTools: true },
|
|
1166
|
-
...sql ? { sql: true } : {}
|
|
1193
|
+
...sql ? { sql: true } : {},
|
|
1194
|
+
...events === void 0 || Object.keys(events).length === 0 ? {} : {
|
|
1195
|
+
events: yield* declarationSafe(
|
|
1196
|
+
() => declaredEvents(events),
|
|
1197
|
+
"The app's event declarations are invalid"
|
|
1198
|
+
)
|
|
1199
|
+
}
|
|
1167
1200
|
}).pipe(
|
|
1168
1201
|
Effect_exports.mapError(
|
|
1169
1202
|
(cause) => declarationInvalid("The app's account declarations are invalid", cause)
|
|
@@ -1262,7 +1295,7 @@ var fetchLifetime = (signal, background) => Effect_exports.acquireRelease(
|
|
|
1262
1295
|
}),
|
|
1263
1296
|
(lifetime) => Effect_exports.sync(lifetime.close)
|
|
1264
1297
|
);
|
|
1265
|
-
function dispatch(app, request, context, signal) {
|
|
1298
|
+
function dispatch(app, request, context, signal, emitted) {
|
|
1266
1299
|
return Effect_exports.scoped(
|
|
1267
1300
|
Effect_exports.gen(function* () {
|
|
1268
1301
|
if (!isApp(app))
|
|
@@ -1272,7 +1305,7 @@ function dispatch(app, request, context, signal) {
|
|
|
1272
1305
|
const native = toEffectApp(app);
|
|
1273
1306
|
const secrets = accountSecrets(context.accounts);
|
|
1274
1307
|
const ownsSql = hasMigrations(context.files ?? []);
|
|
1275
|
-
const declared = yield* requirements(native.accounts, ownsSql);
|
|
1308
|
+
const declared = yield* requirements(native.accounts, ownsSql, native.events);
|
|
1276
1309
|
if (request.operation === "requirements")
|
|
1277
1310
|
return yield* safe2(
|
|
1278
1311
|
() => Schema_exports.decodeUnknownEffect(JsonValue)(declared),
|
|
@@ -1311,6 +1344,7 @@ function dispatch(app, request, context, signal) {
|
|
|
1311
1344
|
Effect_exports.sync(
|
|
1312
1345
|
() => authorSql(storage, {
|
|
1313
1346
|
signal: invocationSignal,
|
|
1347
|
+
emitted,
|
|
1314
1348
|
...step === void 0 ? {} : { step }
|
|
1315
1349
|
})
|
|
1316
1350
|
),
|
|
@@ -1428,6 +1462,17 @@ function dispatch(app, request, context, signal) {
|
|
|
1428
1462
|
fetch: yield* appInvocationFetch(fetching.signal),
|
|
1429
1463
|
elicit: makeElicit(delivery, invocationSignal, telemetry.context)
|
|
1430
1464
|
};
|
|
1465
|
+
const accountIds = Object.values(bound.accounts).flatMap(
|
|
1466
|
+
(selected) => (Array.isArray(selected) ? selected : [selected]).map(
|
|
1467
|
+
(account) => account.id
|
|
1468
|
+
)
|
|
1469
|
+
);
|
|
1470
|
+
const emitter = (sourceAccount) => makeEmitter({
|
|
1471
|
+
events: native.events ?? {},
|
|
1472
|
+
accounts: accountIds,
|
|
1473
|
+
...sourceAccount === void 0 ? {} : { sourceAccount },
|
|
1474
|
+
emitted
|
|
1475
|
+
});
|
|
1431
1476
|
const definition = yield* evaluationSafe(native.evaluate(bound), secrets).pipe(
|
|
1432
1477
|
Effect_exports.withSpan("app.evaluate")
|
|
1433
1478
|
);
|
|
@@ -1562,7 +1607,8 @@ function dispatch(app, request, context, signal) {
|
|
|
1562
1607
|
workflows: workflowControls,
|
|
1563
1608
|
signal: bound.signal,
|
|
1564
1609
|
fetch: bound.fetch,
|
|
1565
|
-
sql: session2.writer
|
|
1610
|
+
sql: session2.writer,
|
|
1611
|
+
events: emitter("sourceAccount" in request ? request.sourceAccount : void 0)
|
|
1566
1612
|
},
|
|
1567
1613
|
Redacted_exports.value(context.accounts)
|
|
1568
1614
|
);
|
|
@@ -1642,7 +1688,8 @@ function dispatch(app, request, context, signal) {
|
|
|
1642
1688
|
...bound,
|
|
1643
1689
|
fetch,
|
|
1644
1690
|
workflows: kind === "mutate" ? workflowControls : workflowReads,
|
|
1645
|
-
sql: kind === "mutate" ? session.writer : session.reader
|
|
1691
|
+
sql: kind === "mutate" ? session.writer : session.reader,
|
|
1692
|
+
...kind === "mutate" ? { events: emitter() } : {}
|
|
1646
1693
|
},
|
|
1647
1694
|
input
|
|
1648
1695
|
);
|
|
@@ -1771,7 +1818,8 @@ var createAppHandler = (app) => (request, context) => Effect_exports.gen(functio
|
|
|
1771
1818
|
...command.operation === "call" ? { "executor.tool.name": command.tool } : {}
|
|
1772
1819
|
});
|
|
1773
1820
|
let toolError = false;
|
|
1774
|
-
const
|
|
1821
|
+
const emitted = [];
|
|
1822
|
+
const value = yield* dispatch(app, command, context, request.signal, emitted).pipe(
|
|
1775
1823
|
Effect_exports.provideService(ToolResultObservation, {
|
|
1776
1824
|
failed: () => {
|
|
1777
1825
|
toolError = true;
|
|
@@ -1795,7 +1843,12 @@ var createAppHandler = (app) => (request, context) => Effect_exports.gen(functio
|
|
|
1795
1843
|
"executor.outcome": "failed",
|
|
1796
1844
|
"error.type": "McpToolError"
|
|
1797
1845
|
});
|
|
1798
|
-
return Response.json({
|
|
1846
|
+
return Response.json({
|
|
1847
|
+
ok: true,
|
|
1848
|
+
value,
|
|
1849
|
+
...toolError ? { toolError: true } : {},
|
|
1850
|
+
...emitted.length === 0 ? {} : { events: emitted }
|
|
1851
|
+
});
|
|
1799
1852
|
}).pipe(
|
|
1800
1853
|
Effect_exports.catch(
|
|
1801
1854
|
(error) => Schema_exports.encodeEffect(HostError)(error).pipe(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fixedRouter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SVHI6AKV.js";
|
|
4
4
|
import {
|
|
5
5
|
nativeOperation,
|
|
6
6
|
operationDeclaration,
|
|
7
7
|
routerDeclaration
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-X5U5KIWQ.js";
|
|
9
9
|
|
|
10
10
|
// src/implementation/protocol-operations.ts
|
|
11
11
|
var protocolOperations = (operations, kinds = {}) => {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
joinPath,
|
|
6
6
|
mergeMeta
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-X5U5KIWQ.js";
|
|
8
8
|
import {
|
|
9
9
|
isShortenedUpstream,
|
|
10
10
|
parseProviderError,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
McpError,
|
|
22
22
|
McpError2,
|
|
23
23
|
SkillLoadFailed as SkillLoadFailed2
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-JY56GVSV.js";
|
|
25
25
|
import {
|
|
26
26
|
CacheError,
|
|
27
27
|
FailureCode,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
answeredError,
|
|
4
4
|
mcpClient,
|
|
5
5
|
mcpJsonSchemaValidator
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-D45JTD6N.js";
|
|
7
7
|
import {
|
|
8
8
|
failOnNetworkRefusal
|
|
9
9
|
} from "./chunk-7UUHJR2Q.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
McpToolsOptions,
|
|
21
21
|
defaultMcpClientLimits,
|
|
22
22
|
mcpHealthReserveMs
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-JY56GVSV.js";
|
|
24
24
|
import {
|
|
25
25
|
NetworkRefused,
|
|
26
26
|
ProviderError
|
package/js/contracts.js
CHANGED
|
@@ -10,12 +10,19 @@ import {
|
|
|
10
10
|
DatabaseFieldReserved,
|
|
11
11
|
DatabaseLimitExceeded,
|
|
12
12
|
DeclaredAuthMethod,
|
|
13
|
+
DeclaredEvent,
|
|
14
|
+
DeclaredEvents,
|
|
13
15
|
DeclaredProvider,
|
|
14
16
|
DeclaredRequirements,
|
|
15
17
|
ElicitationFailed,
|
|
16
18
|
ElicitationLimits,
|
|
17
19
|
ElicitationReply,
|
|
18
20
|
ElicitationResponse,
|
|
21
|
+
EmittedEvent,
|
|
22
|
+
EmittedEvents,
|
|
23
|
+
EventFilterValue,
|
|
24
|
+
EventLimits,
|
|
25
|
+
EventName,
|
|
19
26
|
FormElicitation,
|
|
20
27
|
HostAccountCheckError,
|
|
21
28
|
HostAccountsInvalid,
|
|
@@ -97,6 +104,7 @@ import {
|
|
|
97
104
|
WorkflowValue,
|
|
98
105
|
approvalElicitation,
|
|
99
106
|
defaultElicitationLimits,
|
|
107
|
+
defaultEventLimits,
|
|
100
108
|
defaultMcpClientLimits,
|
|
101
109
|
defaultWebhookTransportLimits,
|
|
102
110
|
frameworkProtocol,
|
|
@@ -108,6 +116,7 @@ import {
|
|
|
108
116
|
minimumIntervalMilliseconds,
|
|
109
117
|
protocol1,
|
|
110
118
|
protocol10,
|
|
119
|
+
protocol11,
|
|
111
120
|
protocol2,
|
|
112
121
|
protocol3,
|
|
113
122
|
protocol4,
|
|
@@ -120,7 +129,7 @@ import {
|
|
|
120
129
|
skillCatalog,
|
|
121
130
|
skillsCommand,
|
|
122
131
|
workflowDurationMillis
|
|
123
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-JY56GVSV.js";
|
|
124
133
|
import {
|
|
125
134
|
FailureCode,
|
|
126
135
|
FailureDetail,
|
|
@@ -182,12 +191,19 @@ export {
|
|
|
182
191
|
DatabaseFieldReserved,
|
|
183
192
|
DatabaseLimitExceeded,
|
|
184
193
|
DeclaredAuthMethod,
|
|
194
|
+
DeclaredEvent,
|
|
195
|
+
DeclaredEvents,
|
|
185
196
|
DeclaredProvider,
|
|
186
197
|
DeclaredRequirements,
|
|
187
198
|
ElicitationFailed,
|
|
188
199
|
ElicitationLimits,
|
|
189
200
|
ElicitationReply,
|
|
190
201
|
ElicitationResponse,
|
|
202
|
+
EmittedEvent,
|
|
203
|
+
EmittedEvents,
|
|
204
|
+
EventFilterValue,
|
|
205
|
+
EventLimits,
|
|
206
|
+
EventName,
|
|
191
207
|
FailureCode,
|
|
192
208
|
FailureDetail,
|
|
193
209
|
FailureFieldName,
|
|
@@ -288,6 +304,7 @@ export {
|
|
|
288
304
|
WorkflowValue,
|
|
289
305
|
approvalElicitation,
|
|
290
306
|
defaultElicitationLimits,
|
|
307
|
+
defaultEventLimits,
|
|
291
308
|
defaultMcpClientLimits,
|
|
292
309
|
defaultWebhookTransportLimits,
|
|
293
310
|
frameworkProtocol,
|
|
@@ -306,6 +323,7 @@ export {
|
|
|
306
323
|
networkRefusalStatus,
|
|
307
324
|
protocol1,
|
|
308
325
|
protocol10,
|
|
326
|
+
protocol11,
|
|
309
327
|
protocol2,
|
|
310
328
|
protocol3,
|
|
311
329
|
protocol4,
|
package/js/effect.js
CHANGED
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
ApprovalDecision,
|
|
4
4
|
createAppHandler,
|
|
5
5
|
prepareElicitation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PO5NPRFT.js";
|
|
7
7
|
import "./chunk-AQU56EPI.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-SVHI6AKV.js";
|
|
9
9
|
import "./chunk-7UUHJR2Q.js";
|
|
10
10
|
import "./chunk-XBG7HHXC.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-GDYPM7RS.js";
|
|
12
|
+
import "./chunk-X5U5KIWQ.js";
|
|
13
13
|
import "./chunk-LTDHQJ2Z.js";
|
|
14
14
|
import {
|
|
15
15
|
ToolAnnotations
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JY56GVSV.js";
|
|
17
17
|
import "./chunk-MWKHKOTL.js";
|
|
18
18
|
import "./chunk-H72MEDMN.js";
|
|
19
19
|
import {
|
package/js/graphql.js
CHANGED
|
@@ -4,28 +4,28 @@ import {
|
|
|
4
4
|
} from "./chunk-UM62MBJQ.js";
|
|
5
5
|
import {
|
|
6
6
|
protocolOperations
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QKHTRD6G.js";
|
|
8
8
|
import "./chunk-BCSNKUAC.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-PO5NPRFT.js";
|
|
10
10
|
import {
|
|
11
11
|
cacheKey
|
|
12
12
|
} from "./chunk-AQU56EPI.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-SVHI6AKV.js";
|
|
14
14
|
import {
|
|
15
15
|
failOnNetworkRefusal
|
|
16
16
|
} from "./chunk-7UUHJR2Q.js";
|
|
17
17
|
import "./chunk-XBG7HHXC.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-GDYPM7RS.js";
|
|
19
19
|
import {
|
|
20
20
|
nativeOperation,
|
|
21
21
|
routerDeclaration
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-X5U5KIWQ.js";
|
|
23
23
|
import {
|
|
24
24
|
accountProviderError,
|
|
25
25
|
graphqlProviderError,
|
|
26
26
|
httpProviderError
|
|
27
27
|
} from "./chunk-LTDHQJ2Z.js";
|
|
28
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-JY56GVSV.js";
|
|
29
29
|
import {
|
|
30
30
|
NetworkRefused,
|
|
31
31
|
ProviderError
|