apps 0.0.1-beta.67 → 0.0.1-beta.69
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-5NQDJMLY.js → chunk-3R3KFCDU.js} +172 -12
- package/js/{chunk-MWKHKOTL.js → chunk-7LMU3ER3.js} +35 -1
- package/js/{chunk-WFPDJ4R3.js → chunk-CXDAEGXB.js} +3 -3
- package/js/{chunk-ZA6YCHLZ.js → chunk-CY4MT7PI.js} +5 -5
- package/js/{chunk-524HNOCY.js → chunk-DZN5TQ53.js} +83 -16
- package/js/{chunk-AZIV4XRH.js → chunk-ECCWT5GJ.js} +2 -2
- package/js/{chunk-5EOB55ID.js → chunk-FZB6D6ZD.js} +20 -10
- package/js/{chunk-6RH2UYRB.js → chunk-GJSNQSR7.js} +2 -2
- package/js/{chunk-TLWLJ7PD.js → chunk-JW5LYSER.js} +94 -3
- package/js/{chunk-T3FPHPJJ.js → chunk-MHB7IFG7.js} +1 -1
- package/js/{chunk-AQU56EPI.js → chunk-RUP4JMKO.js} +17 -10
- package/js/{chunk-X36WUWBJ.js → chunk-ZEJ3IKEC.js} +2 -2
- package/js/{chunk-K2VZ3O27.js → chunk-ZR7QAG67.js} +1 -1
- package/js/contracts.js +34 -2
- package/js/effect.js +9 -9
- package/js/graphql.js +11 -11
- package/js/host.js +9 -9
- package/js/index.js +59 -12
- package/js/mcp/effect.js +11 -11
- package/js/mcp/stdio.js +11 -11
- package/js/mcp.js +13 -13
- package/js/openapi.js +7 -7
- package/js/skills.js +5 -5
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +2 -0
- package/types/apps/src/contracts/host.d.ts +600 -2
- package/types/apps/src/contracts/network.d.ts +36 -0
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +1 -1
- package/types/apps/src/contracts/protocols/current.d.ts +1368 -2
- package/types/apps/src/contracts/provider.d.ts +25 -0
- package/types/apps/src/contracts/sql.d.ts +5 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +3 -3
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/provider.d.ts +8 -2
- package/types/apps/src/index.d.ts +27 -3
|
@@ -2,17 +2,21 @@ import {
|
|
|
2
2
|
declaredOperations,
|
|
3
3
|
nativeOperation,
|
|
4
4
|
nativeRouter
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZEJ3IKEC.js";
|
|
6
6
|
import {
|
|
7
7
|
fromPromise,
|
|
8
8
|
method
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZR7QAG67.js";
|
|
10
10
|
import {
|
|
11
11
|
EmittedEvent,
|
|
12
12
|
EventName,
|
|
13
|
+
Placement,
|
|
13
14
|
ScheduleTiming,
|
|
14
|
-
defaultEventLimits
|
|
15
|
-
|
|
15
|
+
defaultEventLimits,
|
|
16
|
+
normalizePlacements,
|
|
17
|
+
placementFields,
|
|
18
|
+
renderPlacement
|
|
19
|
+
} from "./chunk-JW5LYSER.js";
|
|
16
20
|
import {
|
|
17
21
|
decoderOf,
|
|
18
22
|
isSchema,
|
|
@@ -24,6 +28,7 @@ import {
|
|
|
24
28
|
} from "./chunk-H2CJWXA3.js";
|
|
25
29
|
import {
|
|
26
30
|
Effect_exports,
|
|
31
|
+
Result_exports,
|
|
27
32
|
Schema_exports
|
|
28
33
|
} from "./chunk-IFJU5SYQ.js";
|
|
29
34
|
|
|
@@ -45,6 +50,153 @@ var ResponseDecodeError = class extends Schema_exports.TaggedError()(
|
|
|
45
50
|
}
|
|
46
51
|
};
|
|
47
52
|
|
|
53
|
+
// src/implementation/placement.ts
|
|
54
|
+
var misuse = (name) => `${name} is a credential placement, not a string. Build placement values with t\`...\`, such as t\`Bearer \${token}\`, instead of an untagged template literal or string concatenation.`;
|
|
55
|
+
var NotAString = class {
|
|
56
|
+
#described;
|
|
57
|
+
constructor(described) {
|
|
58
|
+
this.#described = described;
|
|
59
|
+
}
|
|
60
|
+
[Symbol.toPrimitive]() {
|
|
61
|
+
throw new TypeError(misuse(this.#described));
|
|
62
|
+
}
|
|
63
|
+
toString() {
|
|
64
|
+
throw new TypeError(misuse(this.#described));
|
|
65
|
+
}
|
|
66
|
+
toJSON() {
|
|
67
|
+
throw new TypeError(misuse(this.#described));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var FieldRef = class extends NotAString {
|
|
71
|
+
field;
|
|
72
|
+
constructor(field) {
|
|
73
|
+
super(`The field reference ${JSON.stringify(field)}`);
|
|
74
|
+
this.field = field;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var PlacementValue = class extends NotAString {
|
|
78
|
+
parts;
|
|
79
|
+
constructor(parts) {
|
|
80
|
+
super("A t`...` value");
|
|
81
|
+
this.parts = parts;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var partsOf = (input) => {
|
|
85
|
+
if (typeof input === "string") return input === "" ? [] : [input];
|
|
86
|
+
if (input instanceof FieldRef) return [{ field: input.field }];
|
|
87
|
+
if (input instanceof PlacementValue) return input.parts;
|
|
88
|
+
throw new TypeError(
|
|
89
|
+
`A credential placement interpolates text, a field reference, t\`...\` or base64(...), not ${typeof input}.`
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
var joined = (parts) => parts.reduce((all, part) => {
|
|
93
|
+
const last = all.at(-1);
|
|
94
|
+
if (typeof part === "string" && typeof last === "string") all[all.length - 1] = last + part;
|
|
95
|
+
else all.push(part);
|
|
96
|
+
return all;
|
|
97
|
+
}, []);
|
|
98
|
+
var t = (strings, ...values) => new PlacementValue(
|
|
99
|
+
joined(
|
|
100
|
+
strings.flatMap((text, index) => [
|
|
101
|
+
...partsOf(text),
|
|
102
|
+
...index < values.length ? partsOf(values[index]) : []
|
|
103
|
+
])
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
var base64 = (value2) => {
|
|
107
|
+
const inner = partsOf(value2).map((part) => {
|
|
108
|
+
if (typeof part === "object" && "base64" in part)
|
|
109
|
+
throw new TypeError("base64(...) cannot contain another base64(...).");
|
|
110
|
+
return part;
|
|
111
|
+
});
|
|
112
|
+
if (inner.length === 0) throw new TypeError("base64(...) needs a value.");
|
|
113
|
+
return new PlacementValue([{ base64: inner }]);
|
|
114
|
+
};
|
|
115
|
+
var value = (input) => {
|
|
116
|
+
const parts = partsOf(input);
|
|
117
|
+
if (parts.length === 0) throw new TypeError("A credential placement needs a value.");
|
|
118
|
+
return joined(parts);
|
|
119
|
+
};
|
|
120
|
+
var header = (name, input) => ({
|
|
121
|
+
in: "header",
|
|
122
|
+
name: name.toLowerCase(),
|
|
123
|
+
value: value(input)
|
|
124
|
+
});
|
|
125
|
+
var query = (name, input) => ({
|
|
126
|
+
in: "query",
|
|
127
|
+
name,
|
|
128
|
+
value: value(input)
|
|
129
|
+
});
|
|
130
|
+
var bearer = (token) => header("authorization", t`Bearer ${token}`);
|
|
131
|
+
var basic = (user, password) => header("authorization", t`Basic ${base64(t`${user}:${password}`)}`);
|
|
132
|
+
var declarePlacements = (method2, names, exposure, request) => {
|
|
133
|
+
const declared = new Set(names);
|
|
134
|
+
const refs = new Proxy(Object.fromEntries(names.map((name) => [name, new FieldRef(name)])), {
|
|
135
|
+
get: (target, key) => {
|
|
136
|
+
if (typeof key === "string" && !declared.has(key))
|
|
137
|
+
throw new TypeError(
|
|
138
|
+
`The ${method2} request references "${key}", which is not one of its fields: ${names.join(", ")}.`
|
|
139
|
+
);
|
|
140
|
+
return Reflect.get(target, key);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const returned = request(refs);
|
|
144
|
+
const placements = Array.isArray(returned) ? returned : [returned];
|
|
145
|
+
if (placements.length === 0) throw new TypeError(`The ${method2} request declares no placements.`);
|
|
146
|
+
if (!placements.every(Schema_exports.is(Placement)))
|
|
147
|
+
throw new TypeError(
|
|
148
|
+
`The ${method2} request must return header(...) or query(...) placements, or an array of them.`
|
|
149
|
+
);
|
|
150
|
+
for (const placement of placements) {
|
|
151
|
+
const fields = placementFields(placement);
|
|
152
|
+
for (const field of fields) {
|
|
153
|
+
if (!declared.has(field))
|
|
154
|
+
throw new TypeError(
|
|
155
|
+
`The ${method2} request references "${field}", which is not one of its fields: ${names.join(", ")}.`
|
|
156
|
+
);
|
|
157
|
+
if (exposure?.[field] === "raw")
|
|
158
|
+
throw new TypeError(
|
|
159
|
+
`The ${method2} request references the raw() field "${field}". App code reads raw fields as real values, so they are never placed; remove raw() or the reference.`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (![...fields].some((field) => exposure?.[field] === void 0))
|
|
163
|
+
throw new TypeError(
|
|
164
|
+
`The ${method2} request's ${placement.in} ${placement.name} references no secret field. A placement places a secret: reference a field that is not plain() or raw().`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
return normalizePlacements(placements);
|
|
168
|
+
};
|
|
169
|
+
var undeclared = (method2) => `The ${method2} account declares no request. Declare where its credentials go with request, such as request: ({ token }) => bearer(token), to use headers() and url().`;
|
|
170
|
+
var withPlacements = (account, placements) => {
|
|
171
|
+
const fields = typeof account.fields === "object" && account.fields !== null ? account.fields : {};
|
|
172
|
+
const render = (placement) => Result_exports.getOrThrowWith(
|
|
173
|
+
renderPlacement(placement, fields),
|
|
174
|
+
(error) => new TypeError(error.message)
|
|
175
|
+
);
|
|
176
|
+
const declared = () => {
|
|
177
|
+
if (placements === void 0 || placements.length === 0)
|
|
178
|
+
throw new TypeError(undeclared(account.method));
|
|
179
|
+
return placements;
|
|
180
|
+
};
|
|
181
|
+
return Object.defineProperties(account, {
|
|
182
|
+
headers: {
|
|
183
|
+
enumerable: false,
|
|
184
|
+
value: () => Object.fromEntries(
|
|
185
|
+
declared().filter((placement) => placement.in === "header").map((placement) => [placement.name, render(placement)])
|
|
186
|
+
)
|
|
187
|
+
},
|
|
188
|
+
url: {
|
|
189
|
+
enumerable: false,
|
|
190
|
+
value: (input) => {
|
|
191
|
+
const url = new URL(input);
|
|
192
|
+
for (const placement of declared())
|
|
193
|
+
if (placement.in === "query") url.searchParams.set(placement.name, render(placement));
|
|
194
|
+
return url.href;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
|
|
48
200
|
// src/implementation/workflows.ts
|
|
49
201
|
var NativeWorkflow = /* @__PURE__ */ Symbol("apps.Workflow");
|
|
50
202
|
var workflow = (options, run) => ({
|
|
@@ -56,9 +208,9 @@ var workflow = (options, run) => ({
|
|
|
56
208
|
run: (context, input) => fromPromise(run, "workflow")(context, input)
|
|
57
209
|
}
|
|
58
210
|
});
|
|
59
|
-
var nativeWorkflow = (
|
|
60
|
-
if (typeof
|
|
61
|
-
return
|
|
211
|
+
var nativeWorkflow = (value2) => {
|
|
212
|
+
if (typeof value2 !== "object" || value2 === null || !(NativeWorkflow in value2)) return void 0;
|
|
213
|
+
return value2[NativeWorkflow];
|
|
62
214
|
};
|
|
63
215
|
|
|
64
216
|
// src/implementation/events.ts
|
|
@@ -68,7 +220,7 @@ var isScalarSchema = (document) => {
|
|
|
68
220
|
const type = document.type;
|
|
69
221
|
if (typeof type === "string") return scalarTypes.has(type);
|
|
70
222
|
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((
|
|
223
|
+
return choices !== void 0 && choices.length > 0 && choices.every((value2) => ["string", "number", "boolean"].includes(typeof value2));
|
|
72
224
|
};
|
|
73
225
|
var event = (options) => {
|
|
74
226
|
const filters = options.filters ?? {};
|
|
@@ -144,7 +296,7 @@ var makeEmitter = (input) => ({
|
|
|
144
296
|
|
|
145
297
|
// src/implementation/app.ts
|
|
146
298
|
var InternalApp = /* @__PURE__ */ Symbol("apps.App");
|
|
147
|
-
var isApp = (
|
|
299
|
+
var isApp = (value2) => typeof value2 === "object" && value2 !== null && InternalApp in value2;
|
|
148
300
|
var toEffectApp = (app) => app[InternalApp];
|
|
149
301
|
function rejectCatalogs(definition) {
|
|
150
302
|
if ("queries" in definition || "mutations" in definition)
|
|
@@ -180,8 +332,8 @@ function adaptDefinition(definition) {
|
|
|
180
332
|
};
|
|
181
333
|
const workflows = definition.workflows === void 0 ? {} : {
|
|
182
334
|
workflows: Object.fromEntries(
|
|
183
|
-
Object.entries(definition.workflows).map(([name,
|
|
184
|
-
const declared2 = nativeWorkflow(
|
|
335
|
+
Object.entries(definition.workflows).map(([name, value2]) => {
|
|
336
|
+
const declared2 = nativeWorkflow(value2);
|
|
185
337
|
if (declared2 === void 0) throw new Error("Invalid workflow declaration");
|
|
186
338
|
return [name, declared2];
|
|
187
339
|
})
|
|
@@ -244,7 +396,7 @@ var defineApp = (requirements, definition) => {
|
|
|
244
396
|
const native = {
|
|
245
397
|
accounts: requirements.accounts,
|
|
246
398
|
...events === void 0 ? {} : { events },
|
|
247
|
-
evaluate: (context) => factory(context).pipe(Effect_exports.map((
|
|
399
|
+
evaluate: (context) => factory(context).pipe(Effect_exports.map((value2) => adaptDefinition(value2)))
|
|
248
400
|
};
|
|
249
401
|
return {
|
|
250
402
|
[InternalApp]: native,
|
|
@@ -256,6 +408,14 @@ var defineApp = (requirements, definition) => {
|
|
|
256
408
|
export {
|
|
257
409
|
ResponseStatusError,
|
|
258
410
|
ResponseDecodeError,
|
|
411
|
+
t,
|
|
412
|
+
base64,
|
|
413
|
+
header,
|
|
414
|
+
query,
|
|
415
|
+
bearer,
|
|
416
|
+
basic,
|
|
417
|
+
declarePlacements,
|
|
418
|
+
withPlacements,
|
|
259
419
|
workflow,
|
|
260
420
|
event,
|
|
261
421
|
declaredEvents,
|
|
@@ -66,6 +66,23 @@ var NetworkRefusal = Schema_exports.Union([
|
|
|
66
66
|
reason: Schema_exports.Literal("credential_expired"),
|
|
67
67
|
/** The provider of the expired credential handle. */
|
|
68
68
|
provider: Schema_exports.String
|
|
69
|
+
}),
|
|
70
|
+
Schema_exports.Struct({
|
|
71
|
+
reason: Schema_exports.Literal("credential_placement"),
|
|
72
|
+
/** The provider of the misplaced credential handle. */
|
|
73
|
+
provider: Schema_exports.String,
|
|
74
|
+
/** Where the handle was found, such as `body` or `header x-note`. */
|
|
75
|
+
location: Schema_exports.String
|
|
76
|
+
}),
|
|
77
|
+
Schema_exports.Struct({
|
|
78
|
+
reason: Schema_exports.Literal("credential_transport"),
|
|
79
|
+
/** The provider of the credential handle the request carried. */
|
|
80
|
+
provider: Schema_exports.String
|
|
81
|
+
}),
|
|
82
|
+
Schema_exports.Struct({
|
|
83
|
+
reason: Schema_exports.Literal("credential_method"),
|
|
84
|
+
/** The refused HTTP method. */
|
|
85
|
+
method: Schema_exports.String
|
|
69
86
|
})
|
|
70
87
|
]);
|
|
71
88
|
var NetworkRefused = class extends Schema_exports.TaggedError()("NetworkRefused", {
|
|
@@ -84,6 +101,12 @@ var NetworkRefused = class extends Schema_exports.TaggedError()("NetworkRefused"
|
|
|
84
101
|
return "Executor refused this request: it carries a credential handle that is not valid for this app. Use the account fields this invocation received.";
|
|
85
102
|
case "credential_expired":
|
|
86
103
|
return `Executor refused this request: it carries an expired ${refusal.provider} credential handle. Use the account fields this invocation received.`;
|
|
104
|
+
case "credential_placement":
|
|
105
|
+
return `Executor refused this request: it carries a ${refusal.provider} credential handle in the ${refusal.location}, where the provider does not place it. Send credentials only as the provider's request declares, for example with the account's headers() and url().`;
|
|
106
|
+
case "credential_transport":
|
|
107
|
+
return `Executor refused this request: ${refusal.provider} credentials are sent only over HTTPS, and ${this.host} was requested over plain HTTP.`;
|
|
108
|
+
case "credential_method":
|
|
109
|
+
return `Executor refused this request: credential handles are never sent with ${refusal.method}, which asks the service to echo the request back.`;
|
|
87
110
|
}
|
|
88
111
|
}
|
|
89
112
|
};
|
|
@@ -135,7 +158,18 @@ var FetchOptionUnsupported = class extends Schema_exports.TaggedError()(
|
|
|
135
158
|
|
|
136
159
|
// ../app-cache/src/contracts/cache.ts
|
|
137
160
|
var CacheError = class extends Schema_exports.TaggedError()("CacheError", {
|
|
138
|
-
reason: Schema_exports.Literals(["unavailable", "storage", "invalid", "capacity", "timeout"])
|
|
161
|
+
reason: Schema_exports.Literals(["unavailable", "storage", "invalid", "capacity", "timeout"]),
|
|
162
|
+
/** Which of `cacheLimits` the request exceeded, when one did. */
|
|
163
|
+
limit: Schema_exports.optionalKey(
|
|
164
|
+
Schema_exports.Literals([
|
|
165
|
+
"keyBytes",
|
|
166
|
+
"entryBytes",
|
|
167
|
+
"batchBytes",
|
|
168
|
+
"batchEntries",
|
|
169
|
+
"totalBytes",
|
|
170
|
+
"totalEntries"
|
|
171
|
+
])
|
|
172
|
+
)
|
|
139
173
|
}) {
|
|
140
174
|
};
|
|
141
175
|
var cacheLimits = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
prepareElicitation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DZN5TQ53.js";
|
|
4
4
|
import {
|
|
5
5
|
bodyUpstreamError,
|
|
6
6
|
fromPromise
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZR7QAG67.js";
|
|
8
8
|
import {
|
|
9
9
|
ElicitationFailed,
|
|
10
10
|
McpError,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
defaultElicitationLimits,
|
|
17
17
|
defaultMcpClientLimits,
|
|
18
18
|
mcpSdkTimerCeilingMs
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JW5LYSER.js";
|
|
20
20
|
import {
|
|
21
21
|
jsonSchemaDecoder,
|
|
22
22
|
nestJsonSchema,
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
answeredError,
|
|
4
4
|
mcpClient,
|
|
5
5
|
mcpJsonSchemaValidator
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CXDAEGXB.js";
|
|
7
7
|
import {
|
|
8
8
|
failOnNetworkRefusal
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MHB7IFG7.js";
|
|
10
10
|
import {
|
|
11
11
|
accountProviderError,
|
|
12
12
|
bodyUpstreamError,
|
|
13
13
|
httpProviderError,
|
|
14
14
|
providerErrorDetail
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZR7QAG67.js";
|
|
16
16
|
import {
|
|
17
17
|
McpCredentialsUnverified,
|
|
18
18
|
McpError,
|
|
@@ -20,11 +20,11 @@ import {
|
|
|
20
20
|
McpToolsOptions,
|
|
21
21
|
defaultMcpClientLimits,
|
|
22
22
|
mcpHealthReserveMs
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-JW5LYSER.js";
|
|
24
24
|
import {
|
|
25
25
|
NetworkRefused,
|
|
26
26
|
ProviderError
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-7LMU3ER3.js";
|
|
28
28
|
import {
|
|
29
29
|
captureTelemetry,
|
|
30
30
|
owned
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
makeCache
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RUP4JMKO.js";
|
|
4
4
|
import {
|
|
5
5
|
accountSecrets,
|
|
6
6
|
boundFailureMessage,
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
parseSkillLoadFailed,
|
|
12
12
|
readCatalog,
|
|
13
13
|
routerSkills
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FZB6D6ZD.js";
|
|
15
15
|
import {
|
|
16
16
|
appInvocationFetch
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-MHB7IFG7.js";
|
|
18
18
|
import {
|
|
19
19
|
folderSkillsEffect
|
|
20
20
|
} from "./chunk-XBG7HHXC.js";
|
|
@@ -23,13 +23,14 @@ import {
|
|
|
23
23
|
declaredEvents,
|
|
24
24
|
isApp,
|
|
25
25
|
makeEmitter,
|
|
26
|
-
toEffectApp
|
|
27
|
-
|
|
26
|
+
toEffectApp,
|
|
27
|
+
withPlacements
|
|
28
|
+
} from "./chunk-3R3KFCDU.js";
|
|
28
29
|
import {
|
|
29
30
|
declaredOperations,
|
|
30
31
|
locate,
|
|
31
32
|
nativeOperation
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-ZEJ3IKEC.js";
|
|
33
34
|
import {
|
|
34
35
|
accountProviderError,
|
|
35
36
|
appCode,
|
|
@@ -38,7 +39,7 @@ import {
|
|
|
38
39
|
method,
|
|
39
40
|
parseProviderError,
|
|
40
41
|
toPromise
|
|
41
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-ZR7QAG67.js";
|
|
42
43
|
import {
|
|
43
44
|
AccountCheckResult,
|
|
44
45
|
DeclaredProvider,
|
|
@@ -86,12 +87,14 @@ import {
|
|
|
86
87
|
defaultWebhookTransportLimits,
|
|
87
88
|
maxInputProblems,
|
|
88
89
|
migrationsDirectory,
|
|
90
|
+
normalizePlacements,
|
|
89
91
|
reservedTablePrefix,
|
|
92
|
+
sqlBindingsLimit,
|
|
90
93
|
workflowDurationMillis
|
|
91
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-JW5LYSER.js";
|
|
92
95
|
import {
|
|
93
96
|
CacheError
|
|
94
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-7LMU3ER3.js";
|
|
95
98
|
import {
|
|
96
99
|
AppSkills,
|
|
97
100
|
SkillFile
|
|
@@ -748,6 +751,12 @@ var authorSql = (storage, options) => {
|
|
|
748
751
|
};
|
|
749
752
|
const runStatement = (query, bindings, mode) => {
|
|
750
753
|
live();
|
|
754
|
+
if (bindings.length > sqlBindingsLimit)
|
|
755
|
+
throw refuse(
|
|
756
|
+
new Error(
|
|
757
|
+
`A statement can bind at most ${sqlBindingsLimit} values, but this one binds ${bindings.length}. Pass a long list as one JSON array and read it with json_each(?), or split the work into batches.`
|
|
758
|
+
)
|
|
759
|
+
);
|
|
751
760
|
if (mode === "write") {
|
|
752
761
|
const statement = () => {
|
|
753
762
|
const cursor = materialize(storage.sql.exec(query, ...bindings));
|
|
@@ -920,6 +929,47 @@ var sha256 = (text) => (
|
|
|
920
929
|
)
|
|
921
930
|
)
|
|
922
931
|
);
|
|
932
|
+
var statementsOf = (script) => {
|
|
933
|
+
let end = 0;
|
|
934
|
+
let index = 0;
|
|
935
|
+
while (index < script.length) {
|
|
936
|
+
const char = script[index];
|
|
937
|
+
const next = script[index + 1];
|
|
938
|
+
if (char === "-" && next === "-") {
|
|
939
|
+
const newline = script.indexOf("\n", index);
|
|
940
|
+
index = newline === -1 ? script.length : newline + 1;
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
943
|
+
if (char === "/" && next === "*") {
|
|
944
|
+
const close = script.indexOf("*/", index + 2);
|
|
945
|
+
index = close === -1 ? script.length : close + 2;
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
const closing = char === "'" || char === '"' || char === "`" ? char : char === "[" ? "]" : void 0;
|
|
949
|
+
if (closing !== void 0) {
|
|
950
|
+
let after = index + 1;
|
|
951
|
+
while (true) {
|
|
952
|
+
const found = script.indexOf(closing, after);
|
|
953
|
+
if (found === -1) {
|
|
954
|
+
after = script.length;
|
|
955
|
+
break;
|
|
956
|
+
}
|
|
957
|
+
if (closing !== "]" && script[found + 1] === closing) {
|
|
958
|
+
after = found + 2;
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
after = found + 1;
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
index = after;
|
|
965
|
+
end = index;
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
index += 1;
|
|
969
|
+
if (char !== void 0 && !/\s/u.test(char)) end = index;
|
|
970
|
+
}
|
|
971
|
+
return script.slice(0, end);
|
|
972
|
+
};
|
|
923
973
|
var hasMigrations = (files) => files.some(
|
|
924
974
|
(file) => file.path.startsWith(`${migrationsDirectory}/`) && file.path.endsWith(".sql")
|
|
925
975
|
);
|
|
@@ -990,8 +1040,9 @@ var migrate = (storage, files) => Effect_exports.gen(function* () {
|
|
|
990
1040
|
const pending = migrations.slice(history.length);
|
|
991
1041
|
const appliedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
992
1042
|
for (const [offset, migration] of pending.entries()) {
|
|
1043
|
+
const statements = statementsOf(migration.content);
|
|
993
1044
|
try {
|
|
994
|
-
storage.sql.exec(
|
|
1045
|
+
if (statements !== "") storage.sql.exec(statements);
|
|
995
1046
|
} catch (error) {
|
|
996
1047
|
throw new MigrationFailed({
|
|
997
1048
|
path: migration.path,
|
|
@@ -1142,6 +1193,9 @@ function declaredExposure(exposure) {
|
|
|
1142
1193
|
const raw = named("raw");
|
|
1143
1194
|
return { ...plain.length === 0 ? {} : { plain }, ...raw.length === 0 ? {} : { raw } };
|
|
1144
1195
|
}
|
|
1196
|
+
function declaredPlacements(request) {
|
|
1197
|
+
return request === void 0 || request.length === 0 ? {} : { request: normalizePlacements(request) };
|
|
1198
|
+
}
|
|
1145
1199
|
function providerDeclaration(provider) {
|
|
1146
1200
|
return declarationSafe(
|
|
1147
1201
|
() => Effect_exports.gen(function* () {
|
|
@@ -1153,7 +1207,8 @@ function providerDeclaration(provider) {
|
|
|
1153
1207
|
type: "secrets",
|
|
1154
1208
|
label: method2.label,
|
|
1155
1209
|
fields: yield* jsonSchemaDocument(method2.fields),
|
|
1156
|
-
...declaredExposure(method2.exposure)
|
|
1210
|
+
...declaredExposure(method2.exposure),
|
|
1211
|
+
...declaredPlacements(method2.request)
|
|
1157
1212
|
});
|
|
1158
1213
|
break;
|
|
1159
1214
|
case "oauth2":
|
|
@@ -1161,7 +1216,8 @@ function providerDeclaration(provider) {
|
|
|
1161
1216
|
type: "oauth2",
|
|
1162
1217
|
...method2.config,
|
|
1163
1218
|
response: yield* jsonSchemaDocument(method2.response),
|
|
1164
|
-
...declaredExposure(method2.exposure)
|
|
1219
|
+
...declaredExposure(method2.exposure),
|
|
1220
|
+
...declaredPlacements(method2.request)
|
|
1165
1221
|
});
|
|
1166
1222
|
break;
|
|
1167
1223
|
}
|
|
@@ -1211,8 +1267,16 @@ function canonical(value) {
|
|
|
1211
1267
|
}
|
|
1212
1268
|
return JSON.stringify(value);
|
|
1213
1269
|
}
|
|
1214
|
-
function
|
|
1215
|
-
return
|
|
1270
|
+
function withoutGrants({ hosts: _hosts, ...provider }) {
|
|
1271
|
+
return {
|
|
1272
|
+
...provider,
|
|
1273
|
+
auth: Object.fromEntries(
|
|
1274
|
+
Object.entries(provider.auth).map(([name, { request: _request, ...method2 }]) => [
|
|
1275
|
+
name,
|
|
1276
|
+
method2
|
|
1277
|
+
])
|
|
1278
|
+
)
|
|
1279
|
+
};
|
|
1216
1280
|
}
|
|
1217
1281
|
function bindAccounts(slots, declarations, context) {
|
|
1218
1282
|
return safe2(
|
|
@@ -1239,14 +1303,17 @@ function bindAccounts(slots, declarations, context) {
|
|
|
1239
1303
|
for (const account of accounts) {
|
|
1240
1304
|
if (ids.has(account.id)) return yield* Effect_exports.fail(new HostAccountsInvalid());
|
|
1241
1305
|
ids.add(account.id);
|
|
1242
|
-
if (canonical(
|
|
1306
|
+
if (canonical(withoutGrants(account.provider)) !== canonical(withoutGrants(requirement.definition)) || !Object.hasOwn(provider.auth, account.method))
|
|
1243
1307
|
return yield* Effect_exports.fail(new HostAccountsInvalid());
|
|
1244
1308
|
const method2 = provider.auth[account.method];
|
|
1245
1309
|
if (method2 === void 0) return yield* Effect_exports.fail(new HostAccountsInvalid());
|
|
1246
1310
|
const fields = yield* Schema_exports.decodeUnknownEffect(
|
|
1247
1311
|
method2._tag === "secrets" ? method2.fields : method2.response
|
|
1248
1312
|
)(account.fields);
|
|
1249
|
-
|
|
1313
|
+
const granted = Object.hasOwn(account.provider.auth, account.method) ? account.provider.auth[account.method]?.request : void 0;
|
|
1314
|
+
values.push(
|
|
1315
|
+
withPlacements({ id: account.id, method: account.method, fields }, granted)
|
|
1316
|
+
);
|
|
1250
1317
|
}
|
|
1251
1318
|
if (many) bound.set(slot, values);
|
|
1252
1319
|
else {
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
joinPath,
|
|
6
6
|
mergeMeta
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZEJ3IKEC.js";
|
|
8
8
|
import {
|
|
9
9
|
isShortenedUpstream,
|
|
10
10
|
parseProviderError,
|
|
11
11
|
providerError
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZR7QAG67.js";
|
|
13
13
|
import {
|
|
14
14
|
ApiErrorResponse,
|
|
15
15
|
HostDeclarationInvalid,
|
|
@@ -21,18 +21,19 @@ import {
|
|
|
21
21
|
McpError,
|
|
22
22
|
McpError2,
|
|
23
23
|
SkillLoadFailed as SkillLoadFailed2
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-JW5LYSER.js";
|
|
25
25
|
import {
|
|
26
26
|
CacheError,
|
|
27
27
|
FailureCode,
|
|
28
28
|
FailureFieldName,
|
|
29
29
|
FetchOptionUnsupported,
|
|
30
30
|
NetworkRefused,
|
|
31
|
+
cacheLimits,
|
|
31
32
|
maxFailureFieldLength,
|
|
32
33
|
maxFailureFields,
|
|
33
34
|
maxFailureMessageLength,
|
|
34
35
|
maxUpstreamMessageLength
|
|
35
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-7LMU3ER3.js";
|
|
36
37
|
import {
|
|
37
38
|
SkillLoadFailed,
|
|
38
39
|
skillFormatLimits
|
|
@@ -238,7 +239,7 @@ var compileMessage = (error) => {
|
|
|
238
239
|
if (group === void 0) groups.set(key, { first: operation, count: 1 });
|
|
239
240
|
else group.count++;
|
|
240
241
|
}
|
|
241
|
-
const example = ({ first, count }) => `${first.method} ${first.path}${
|
|
242
|
+
const example = ({ first, count: count2 }) => `${first.method} ${first.path}${count2 > 1 ? ` and ${count2 - 1} more` : ""}`;
|
|
242
243
|
const [only, ...others] = groups.values();
|
|
243
244
|
if (only !== void 0 && others.length === 0 && only.first.code === error.code && only.first.reason === error.reason)
|
|
244
245
|
return `${error.reason} Left out: ${example(only)}.`;
|
|
@@ -293,6 +294,15 @@ var cacheMessages = {
|
|
|
293
294
|
storage: "The app cache failed to complete the operation.",
|
|
294
295
|
timeout: "The app cache did not respond in time."
|
|
295
296
|
};
|
|
297
|
+
var count = (value) => value.toLocaleString("en-US");
|
|
298
|
+
var cacheLimitMessages = {
|
|
299
|
+
keyBytes: `A cache key exceeded the app cache's limit of ${count(cacheLimits.keyBytes)} bytes per key.`,
|
|
300
|
+
entryBytes: `A cache value exceeded the app cache's limit of ${count(cacheLimits.entryBytes)} bytes per entry.`,
|
|
301
|
+
batchBytes: `A cache read or write exceeded the app cache's limit of ${count(cacheLimits.batchBytes)} bytes per batch.`,
|
|
302
|
+
batchEntries: `A cache read or write exceeded the app cache's limit of ${count(cacheLimits.batchEntries)} entries per batch.`,
|
|
303
|
+
totalBytes: `The app cache is full: it holds at most ${count(cacheLimits.totalBytes)} bytes.`,
|
|
304
|
+
totalEntries: `The app cache is full: it holds at most ${count(cacheLimits.totalEntries)} entries.`
|
|
305
|
+
};
|
|
296
306
|
var mcpStages = {
|
|
297
307
|
connect: "connecting",
|
|
298
308
|
transport: "connecting",
|
|
@@ -393,18 +403,18 @@ var ownCode = (error, secrets) => Predicate_exports.hasProperty(error, "code") &
|
|
|
393
403
|
var reservedFields = /* @__PURE__ */ new Set(["name", "message", "stack", "cause", "_tag"]);
|
|
394
404
|
var ownFields = (error, code, secrets) => {
|
|
395
405
|
const fields = {};
|
|
396
|
-
let
|
|
406
|
+
let count2 = 0;
|
|
397
407
|
for (const [key, value] of Object.entries(error)) {
|
|
398
|
-
if (
|
|
408
|
+
if (count2 === maxFailureFields) break;
|
|
399
409
|
if (reservedFields.has(key) || key === "code" && code !== void 0) continue;
|
|
400
410
|
if (!Schema_exports.is(FailureFieldName)(key)) continue;
|
|
401
411
|
if (typeof value === "string") fields[key] = boundText(value, secrets, maxFailureFieldLength);
|
|
402
412
|
else if (typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))
|
|
403
413
|
fields[key] = value;
|
|
404
414
|
else continue;
|
|
405
|
-
|
|
415
|
+
count2++;
|
|
406
416
|
}
|
|
407
|
-
return
|
|
417
|
+
return count2 === 0 ? void 0 : fields;
|
|
408
418
|
};
|
|
409
419
|
var ownMessage = (error) => {
|
|
410
420
|
const cause = error.cause;
|
|
@@ -429,7 +439,7 @@ var failureDetail = (error, secrets) => {
|
|
|
429
439
|
source: "storage",
|
|
430
440
|
errorName: "CacheError",
|
|
431
441
|
code: error.reason,
|
|
432
|
-
message: cacheMessages[error.reason]
|
|
442
|
+
message: error.limit === void 0 ? cacheMessages[error.reason] : cacheLimitMessages[error.limit]
|
|
433
443
|
};
|
|
434
444
|
if (Schema_exports.is(OpenapiError)(error))
|
|
435
445
|
return {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fixedRouter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FZB6D6ZD.js";
|
|
4
4
|
import {
|
|
5
5
|
nativeOperation,
|
|
6
6
|
operationDeclaration,
|
|
7
7
|
routerDeclaration
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZEJ3IKEC.js";
|
|
9
9
|
|
|
10
10
|
// src/implementation/protocol-operations.ts
|
|
11
11
|
var protocolOperations = (operations, kinds = {}) => {
|