apps 0.0.1-beta.89 → 0.0.1-beta.90
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/README.md +27 -10
- package/framework-reference.json +1 -1
- package/js/{chunk-H6NFR354.js → chunk-36UFTECB.js} +6 -8
- package/js/{chunk-I46RIOKQ.js → chunk-5MDA7MKL.js} +14 -13
- package/js/{chunk-NQW2E44U.js → chunk-6XQLA5NC.js} +579 -81
- package/js/{chunk-6FUJH3T4.js → chunk-7PHHWYV4.js} +6 -5
- package/js/{chunk-7Z3NUCTP.js → chunk-DADXWWRZ.js} +24 -6
- package/js/{chunk-BZFFXNWA.js → chunk-I5C7FD5Z.js} +1 -1
- package/js/{chunk-EKZLPXHK.js → chunk-KUCCHNVY.js} +3 -3
- package/js/{chunk-ZK7JDZJS.js → chunk-PYQLOLOC.js} +2 -2
- package/js/{chunk-ELSILABS.js → chunk-WMD4NHXZ.js} +113 -73
- package/js/{chunk-JJH3MBAM.js → chunk-YNJ5CZMJ.js} +3 -2
- package/js/{chunk-5ZVAYXLT.js → chunk-YRGL4QEF.js} +1 -1
- package/js/{chunk-GLXEYET6.js → chunk-YWFUWTUJ.js} +12 -7
- package/js/client.js +1 -1
- package/js/contracts.js +37 -25
- package/js/effect.js +8 -9
- package/js/graphql.js +10 -11
- package/js/host.js +11 -13
- package/js/index.js +29 -31
- package/js/mcp/effect.js +9 -10
- package/js/mcp.js +11 -12
- package/js/openapi.js +9 -11
- package/js/skills.js +6 -6
- package/js/ui/contracts.js +1 -1
- package/js/ui/serving.js +5 -6
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/contracts/app.d.ts +51 -8
- package/types/apps/src/contracts/cache.d.ts +1 -1
- package/types/apps/src/contracts/context.d.ts +37 -8
- package/types/apps/src/contracts/events.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +800 -4
- package/types/apps/src/contracts/operations.d.ts +6 -3
- package/types/apps/src/contracts/protocol-version.d.ts +1 -1
- package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
- package/types/apps/src/contracts/protocols/current.d.ts +4445 -1633
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/ui.d.ts +11 -15
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +13 -17
- package/types/apps/src/implementation/app.d.ts +41 -14
- package/types/apps/src/implementation/cache.d.ts +1 -1
- package/types/apps/src/implementation/events.d.ts +6 -1
- package/types/apps/src/implementation/failure-detail.d.ts +3 -2
- package/types/apps/src/implementation/operations.d.ts +40 -5
- package/types/apps/src/implementation/router-catalog.d.ts +4 -0
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/ui-serving.d.ts +2 -2
- package/types/apps/src/implementation/webhooks.d.ts +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +6 -2
- package/types/apps/src/implementation/workflows.d.ts +10 -3
- package/types/apps/src/index.d.ts +15 -9
- package/js/chunk-F2G534HD.js +0 -285
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
/** Ordinary async workflow declarations, adapted once into native Effect handlers. */
|
|
2
2
|
import type { Schema as EffectSchema } from "effect";
|
|
3
3
|
import type { AppWorkflow, WorkflowContext } from "../contracts/workflows.js";
|
|
4
|
+
import type { AppRequirements } from "../contracts/context.js";
|
|
5
|
+
import type { AccountScope } from "../contracts/app.js";
|
|
4
6
|
import { type Schema } from "./schema.js";
|
|
5
7
|
declare const NativeWorkflow: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* The context any workflow may declare: either scope, so a run started without a caller, such as
|
|
10
|
+
* by an app schedule, declares `WorkflowContext<typeof requirements, "app">`.
|
|
11
|
+
*/
|
|
12
|
+
export type AnyWorkflowContext = WorkflowContext<AppRequirements, AccountScope>;
|
|
6
13
|
declare const HandlerContext: unique symbol;
|
|
7
14
|
/** A workflow declaration retains input/output inference and required context compatibility. */
|
|
8
|
-
export interface Workflow<Input, Output, Context extends
|
|
15
|
+
export interface Workflow<Input, Output, Context extends AnyWorkflowContext = WorkflowContext> {
|
|
9
16
|
readonly [HandlerContext]?: (context: Context) => void;
|
|
10
17
|
readonly [NativeWorkflow]: AppWorkflow<Input, Output>;
|
|
11
18
|
}
|
|
12
19
|
/** Composition view erases input only after retaining its runtime decoder. */
|
|
13
|
-
export interface WorkflowDeclaration<Context extends
|
|
20
|
+
export interface WorkflowDeclaration<Context extends AnyWorkflowContext> {
|
|
14
21
|
readonly [HandlerContext]?: (context: Context) => void;
|
|
15
22
|
readonly [NativeWorkflow]: Omit<AppWorkflow<never>, "input"> & {
|
|
16
23
|
readonly input: EffectSchema.Decoder<unknown>;
|
|
17
24
|
};
|
|
18
25
|
}
|
|
19
26
|
/** Declare durable orchestration without starting a run or performing I/O. */
|
|
20
|
-
export declare const workflow: <Input, Output, Context extends
|
|
27
|
+
export declare const workflow: <Input, Output, Context extends AnyWorkflowContext = WorkflowContext>(options: {
|
|
21
28
|
readonly input: Schema<Input, boolean>;
|
|
22
29
|
readonly output?: Schema<Output, boolean>;
|
|
23
30
|
readonly description?: string;
|
|
@@ -7,15 +7,16 @@ export { CacheError } from "../../app-cache/src/contracts/cache.js";
|
|
|
7
7
|
* exposes ordinary declarations, schema helpers and Promise operations.
|
|
8
8
|
*/
|
|
9
9
|
import { type Schema as EffectSchema } from "effect";
|
|
10
|
-
import type { WebhookContext } from "./contracts/context.js";
|
|
10
|
+
import type { AppRequirements, WebhookContext } from "./contracts/context.js";
|
|
11
|
+
import type { AccountScope } from "./contracts/app.js";
|
|
11
12
|
import { type JsonResponse as NativeResponse } from "./contracts/http.js";
|
|
12
13
|
import { type OAuth2Config as NativeOAuth2Config, type OAuth2Method as NativeOAuth2Method, type ReservedAuthorizationParam, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
|
|
13
14
|
import type { Webhook as NativeWebhook } from "./contracts/webhooks.js";
|
|
14
15
|
import { type PromiseMethods } from "./implementation/authoring.js";
|
|
15
16
|
import { type PlacementInput, type RequestPlacements } from "./implementation/placement.js";
|
|
16
17
|
import type { Placement } from "./contracts/placement.js";
|
|
17
|
-
import type {
|
|
18
|
-
import { query as operationQuery, type OperationOptions } from "./implementation/operations.js";
|
|
18
|
+
import type { QueryContext as NativeQueryContext } from "./contracts/context.js";
|
|
19
|
+
import { query as operationQuery, type AnyContext, type OperationOptions } from "./implementation/operations.js";
|
|
19
20
|
import { type Fields, type Infer, type ObjectSchema, type Schema, type SecretFields, type SecretObject } from "./implementation/schema.js";
|
|
20
21
|
export { DeclarationInvalid, type DeclarationIssue, type JsonObject, type JsonValue, ValidationError, } from "./contracts/schema.js";
|
|
21
22
|
export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, plain, raw, type SecretString, } from "./implementation/schema.js";
|
|
@@ -75,8 +76,8 @@ export declare function oauth2<Response extends Schema<unknown, boolean>>(option
|
|
|
75
76
|
readonly response: Response;
|
|
76
77
|
readonly request?: RequestPlacements<FieldNameOf<Response>>;
|
|
77
78
|
}): OAuth2Method<Response>;
|
|
78
|
-
export type { AccountSlots } from "./contracts/app.js";
|
|
79
|
-
export type { AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext, } from "./contracts/context.js";
|
|
79
|
+
export type { AccountScope, AccountSlots, WebhookAccount } from "./contracts/app.js";
|
|
80
|
+
export type { AnyScopeMutationContext, AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext, } from "./contracts/context.js";
|
|
80
81
|
export { type App, type AppDefinition, defineApp } from "./implementation/app.js";
|
|
81
82
|
export { event, type EventDeclaration, type EventEmitter } from "./implementation/events.js";
|
|
82
83
|
export type { EmitOptions } from "./contracts/events.js";
|
|
@@ -86,7 +87,12 @@ type AuthorWebhook<Member, Config, State> = Member extends object ? Omit<Promise
|
|
|
86
87
|
readonly state: State;
|
|
87
88
|
} : never;
|
|
88
89
|
/** Author lifecycle methods use async functions and share native decoded context/state types. */
|
|
89
|
-
|
|
90
|
+
/**
|
|
91
|
+
* A webhook's context names its source account's scope: one with `user` serves a user requirement
|
|
92
|
+
* (`account: { user: "x" }`), one of the `"app"` scope an app requirement (`account: { app: "x" }`)
|
|
93
|
+
* and runs without a caller.
|
|
94
|
+
*/
|
|
95
|
+
export type Webhook<Context extends WebhookContext<AppRequirements, AccountScope>, Config extends Schema<unknown, boolean>, State extends Schema<unknown, boolean>> = AuthorWebhook<NativeWebhook<Context, EffectSchema.Decoder<Infer<Config>>, EffectSchema.Decoder<Infer<State>>>, Config, State>;
|
|
90
96
|
export { ResponseDecodeError, ResponseStatusError } from "./contracts/http.js";
|
|
91
97
|
/** Native fetch-compatible response accepted at the author boundary. */
|
|
92
98
|
export type JsonResponse = PromiseMethods<NativeResponse>;
|
|
@@ -100,10 +106,10 @@ export type { Sql, SqlCursor, SqlReader, SqlRow, SqlTransaction, SqlValue, } fro
|
|
|
100
106
|
* `request` places a credential in a query parameter, such as `query("key", key)`.
|
|
101
107
|
*/
|
|
102
108
|
export declare function query(name: string, value: PlacementInput): Placement;
|
|
103
|
-
export declare function query<Input, Output, Context extends
|
|
104
|
-
export { mutation, withApproval, toolAnnotations, type Operation, type OperationOptions, } from "./implementation/operations.js";
|
|
109
|
+
export declare function query<Input, Output, Context extends AnyContext = NativeQueryContext>(options: OperationOptions<Input, Output>, run: (context: Context, input: Input) => Promise<Output>): ReturnType<typeof operationQuery<Input, Output, Context>>;
|
|
110
|
+
export { mutation, withApproval, toolAnnotations, type Approved, type Operation, type OperationOptions, } from "./implementation/operations.js";
|
|
105
111
|
export type { OperationContext } from "./contracts/operations.js";
|
|
106
112
|
export { workflow, type Workflow, type WorkflowDeclaration } from "./implementation/workflows.js";
|
|
107
113
|
export { NonRetryableError, WorkflowFailure, type WorkflowContext, type WorkflowStepContext, type WorkflowStep, type WorkflowStepOptions, type WorkflowDuration, type WorkflowReads, type WorkflowControls, } from "./contracts/workflows.js";
|
|
108
|
-
export {
|
|
114
|
+
export { appCron, appInterval, userCron, userInterval, type ScheduleDeclaration, } from "./implementation/schedules.js";
|
|
109
115
|
export type { AppSkillSource as Skill, SkillFile } from "./contracts/skills.js";
|
package/js/chunk-F2G534HD.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AccountId
|
|
3
|
-
} from "./chunk-DDHBUKXX.js";
|
|
4
|
-
import {
|
|
5
|
-
Schema_exports
|
|
6
|
-
} from "./chunk-IFJU5SYQ.js";
|
|
7
|
-
|
|
8
|
-
// src/contracts/failure.ts
|
|
9
|
-
var maxFailureMessageLength = 2048;
|
|
10
|
-
var FailureSource = Schema_exports.Literals(["app", "storage", "service"]);
|
|
11
|
-
var FailureName = Schema_exports.String.check(Schema_exports.isMaxLength(128));
|
|
12
|
-
var FailureCode = Schema_exports.String.check(Schema_exports.isMaxLength(128));
|
|
13
|
-
var FailureMessage = Schema_exports.String.check(Schema_exports.isMaxLength(maxFailureMessageLength));
|
|
14
|
-
var maxFailureFields = 8;
|
|
15
|
-
var maxFailureFieldLength = 256;
|
|
16
|
-
var FailureFieldName = Schema_exports.String.check(
|
|
17
|
-
Schema_exports.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]{0,63}$/)
|
|
18
|
-
);
|
|
19
|
-
var FailureFieldValue = Schema_exports.Union([
|
|
20
|
-
Schema_exports.String.check(Schema_exports.isMaxLength(maxFailureFieldLength)),
|
|
21
|
-
Schema_exports.Finite,
|
|
22
|
-
Schema_exports.Boolean
|
|
23
|
-
]);
|
|
24
|
-
var FailureFields = Schema_exports.Record(FailureFieldName, FailureFieldValue).check(
|
|
25
|
-
Schema_exports.isMaxProperties(maxFailureFields)
|
|
26
|
-
);
|
|
27
|
-
var FailureDetail = {
|
|
28
|
-
source: Schema_exports.optionalKey(FailureSource),
|
|
29
|
-
errorName: Schema_exports.optionalKey(FailureName),
|
|
30
|
-
code: Schema_exports.optionalKey(FailureCode),
|
|
31
|
-
message: Schema_exports.optionalKey(FailureMessage),
|
|
32
|
-
fields: Schema_exports.optionalKey(FailureFields)
|
|
33
|
-
};
|
|
34
|
-
var maxUpstreamMessageLength = 1024;
|
|
35
|
-
var UpstreamError = Schema_exports.Struct({
|
|
36
|
-
code: Schema_exports.Union([
|
|
37
|
-
Schema_exports.Int,
|
|
38
|
-
Schema_exports.String.check(Schema_exports.isMinLength(1), Schema_exports.isMaxLength(128))
|
|
39
|
-
]),
|
|
40
|
-
message: Schema_exports.optionalKey(Schema_exports.String.check(Schema_exports.isMaxLength(maxUpstreamMessageLength)))
|
|
41
|
-
});
|
|
42
|
-
var FailurePhase = Schema_exports.Literals(["connect", "discover", "call"]);
|
|
43
|
-
|
|
44
|
-
// src/contracts/provider-error.ts
|
|
45
|
-
var ProviderError = class extends Schema_exports.TaggedError()("ProviderError", {
|
|
46
|
-
reason: Schema_exports.Literals(["unauthorized", "forbidden", "rate_limited", "unavailable", "rejected"]),
|
|
47
|
-
status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
|
|
48
|
-
accountId: Schema_exports.optional(AccountId),
|
|
49
|
-
phase: Schema_exports.optional(FailurePhase),
|
|
50
|
-
upstream: Schema_exports.optional(UpstreamError)
|
|
51
|
-
}) {
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// src/contracts/network.ts
|
|
55
|
-
var NetworkRefusal = Schema_exports.Union([
|
|
56
|
-
Schema_exports.Struct({ reason: Schema_exports.Literal("private_address") }),
|
|
57
|
-
Schema_exports.Struct({
|
|
58
|
-
reason: Schema_exports.Literal("credential_host"),
|
|
59
|
-
/** The provider of the credential handle the request carried. */
|
|
60
|
-
provider: Schema_exports.String,
|
|
61
|
-
/** The hosts that provider's credentials may reach; empty when it declares none. */
|
|
62
|
-
allowedHosts: Schema_exports.Array(Schema_exports.String)
|
|
63
|
-
}),
|
|
64
|
-
Schema_exports.Struct({ reason: Schema_exports.Literal("credential_app") }),
|
|
65
|
-
Schema_exports.Struct({
|
|
66
|
-
reason: Schema_exports.Literal("credential_expired"),
|
|
67
|
-
/** The provider of the expired credential handle. */
|
|
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
|
|
86
|
-
})
|
|
87
|
-
]);
|
|
88
|
-
var NetworkRefused = class extends Schema_exports.TaggedError()("NetworkRefused", {
|
|
89
|
-
/** The refused destination, with its port when the URL names one. */
|
|
90
|
-
host: Schema_exports.String,
|
|
91
|
-
refusal: NetworkRefusal
|
|
92
|
-
}) {
|
|
93
|
-
get message() {
|
|
94
|
-
const refusal = this.refusal;
|
|
95
|
-
switch (refusal.reason) {
|
|
96
|
-
case "private_address":
|
|
97
|
-
return `Executor refused a request to ${this.host}: apps on this instance can reach only public addresses, and ${this.host} is a private, loopback or internal address. The request was not sent.`;
|
|
98
|
-
case "credential_host":
|
|
99
|
-
return refusal.allowedHosts.length === 0 ? `Executor refused this request: ${refusal.provider} credentials cannot be sent to ${this.host}: the provider declares no hosts.` : `Executor refused this request: ${refusal.provider} credentials cannot be sent to ${this.host}. The provider allows: ${refusal.allowedHosts.join(", ")}.`;
|
|
100
|
-
case "credential_app":
|
|
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.";
|
|
102
|
-
case "credential_expired":
|
|
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.`;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
var networkRefusalStatus = 421;
|
|
114
|
-
var networkRefusalHeader = "x-executor-refused";
|
|
115
|
-
var NetworkRefusedHeader = Schema_exports.StringFromUriComponent.pipe(
|
|
116
|
-
Schema_exports.decodeTo(Schema_exports.fromJsonString(NetworkRefused))
|
|
117
|
-
);
|
|
118
|
-
var encodeRefusal = Schema_exports.encodeSync(NetworkRefused);
|
|
119
|
-
var encodeRefusalHeader = Schema_exports.encodeSync(NetworkRefusedHeader);
|
|
120
|
-
var networkRefusalResponse = (refused) => new Response(JSON.stringify({ ...encodeRefusal(refused), message: refused.message }), {
|
|
121
|
-
status: networkRefusalStatus,
|
|
122
|
-
statusText: "Refused by Executor",
|
|
123
|
-
headers: {
|
|
124
|
-
"content-type": "application/json; charset=utf-8",
|
|
125
|
-
[networkRefusalHeader]: encodeRefusalHeader(refused)
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
var RestrictedFetchOption = Schema_exports.Literals(["redirect", "cache", "integrity"]);
|
|
129
|
-
var supportedFetchOptions = {
|
|
130
|
-
redirect: ["follow", "manual"],
|
|
131
|
-
cache: ["no-store", "no-cache"],
|
|
132
|
-
integrity: [""]
|
|
133
|
-
};
|
|
134
|
-
var FetchOptionUnsupported = class extends Schema_exports.TaggedError()(
|
|
135
|
-
"FetchOptionUnsupported",
|
|
136
|
-
{
|
|
137
|
-
option: RestrictedFetchOption,
|
|
138
|
-
value: Schema_exports.String,
|
|
139
|
-
supported: Schema_exports.Array(Schema_exports.String)
|
|
140
|
-
}
|
|
141
|
-
) {
|
|
142
|
-
get message() {
|
|
143
|
-
const supported = this.supported.map((value) => JSON.stringify(value)).join(" or ");
|
|
144
|
-
return `fetch option ${this.option}: ${JSON.stringify(this.value)} is not supported by Executor's app runtime. Use ${supported}, or omit ${this.option}.${this.advice}`;
|
|
145
|
-
}
|
|
146
|
-
/** What to do instead, when the standard value has an equivalent the runtime supports. */
|
|
147
|
-
get advice() {
|
|
148
|
-
switch (this.option) {
|
|
149
|
-
case "redirect":
|
|
150
|
-
return this.value === "error" ? ` To reject redirects, send redirect: "manual" and treat a 3xx response as the error.` : "";
|
|
151
|
-
case "cache":
|
|
152
|
-
return "";
|
|
153
|
-
case "integrity":
|
|
154
|
-
return " To check a digest, read the body and hash it with crypto.subtle.digest.";
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// ../app-cache/src/contracts/cache.ts
|
|
160
|
-
var CacheError = class extends Schema_exports.TaggedError()("CacheError", {
|
|
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
|
-
)
|
|
173
|
-
}) {
|
|
174
|
-
};
|
|
175
|
-
var cacheLimits = {
|
|
176
|
-
keyBytes: 8192,
|
|
177
|
-
entryBytes: 2e6,
|
|
178
|
-
batchBytes: 8e6,
|
|
179
|
-
batchEntries: 128,
|
|
180
|
-
totalBytes: 128e6,
|
|
181
|
-
totalEntries: 1e5,
|
|
182
|
-
retentionMs: 7 * 24 * 60 * 60 * 1e3,
|
|
183
|
-
loadTimeoutMs: 9e4,
|
|
184
|
-
/**
|
|
185
|
-
* A loader's lease lapses this long after its host last renewed it. Hosts renew every
|
|
186
|
-
* `renewMs` while the invocation that claimed it runs, so a stalled or lost holder frees the
|
|
187
|
-
* key well inside an MCP execute budget.
|
|
188
|
-
*/
|
|
189
|
-
leaseMs: 15e3,
|
|
190
|
-
renewMs: 5e3,
|
|
191
|
-
/** The longest a caller waits on another loader before loading for itself without publishing. */
|
|
192
|
-
waitMs: 1e4,
|
|
193
|
-
/** Bound for one command to a host store; a lost reply fails instead of holding its caller. */
|
|
194
|
-
commandTimeoutMs: 1e4
|
|
195
|
-
};
|
|
196
|
-
var Key = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{64}$/));
|
|
197
|
-
var Time = Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0));
|
|
198
|
-
var CacheEntry = Schema_exports.Struct({
|
|
199
|
-
value: Schema_exports.Json,
|
|
200
|
-
version: Schema_exports.String,
|
|
201
|
-
freshUntil: Time,
|
|
202
|
-
staleUntil: Time
|
|
203
|
-
});
|
|
204
|
-
var CacheAcquired = Schema_exports.Struct({
|
|
205
|
-
entry: Schema_exports.NullOr(CacheEntry),
|
|
206
|
-
lease: Schema_exports.NullOr(Schema_exports.String),
|
|
207
|
-
/**
|
|
208
|
-
* The entries of the command's `reads`, in order, read in the same transaction as `entry`.
|
|
209
|
-
* Absent when the store did not read them: a store that predates them, or reads past the
|
|
210
|
-
* batch byte bound. The caller then reads them with a separate `read`.
|
|
211
|
-
*/
|
|
212
|
-
reads: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NullOr(CacheEntry)))
|
|
213
|
-
});
|
|
214
|
-
var CacheCommand = Schema_exports.Union([
|
|
215
|
-
Schema_exports.Struct({ operation: Schema_exports.Literal("read"), keys: Schema_exports.Array(Key) }),
|
|
216
|
-
Schema_exports.Struct({
|
|
217
|
-
operation: Schema_exports.Literal("acquire"),
|
|
218
|
-
key: Key,
|
|
219
|
-
/** Claim even a fresh entry, as an explicit refresh does. */
|
|
220
|
-
refresh: Schema_exports.Boolean,
|
|
221
|
-
/** Claim only while the entry still has this version. Absent accepts the current one. */
|
|
222
|
-
version: Schema_exports.optionalKey(Schema_exports.NullOr(Schema_exports.String)),
|
|
223
|
-
/**
|
|
224
|
-
* Other keys to read in the same transaction, as `read` would, so a caller that needs them
|
|
225
|
-
* beside the entry makes one round trip. Reading them claims and changes nothing.
|
|
226
|
-
*/
|
|
227
|
-
reads: Schema_exports.optionalKey(Schema_exports.Array(Key))
|
|
228
|
-
}),
|
|
229
|
-
Schema_exports.Struct({
|
|
230
|
-
operation: Schema_exports.Literal("claim"),
|
|
231
|
-
key: Key,
|
|
232
|
-
version: Schema_exports.NullOr(Schema_exports.String)
|
|
233
|
-
}),
|
|
234
|
-
Schema_exports.Struct({
|
|
235
|
-
operation: Schema_exports.Literal("publish"),
|
|
236
|
-
key: Key,
|
|
237
|
-
lease: Schema_exports.String,
|
|
238
|
-
entry: CacheEntry
|
|
239
|
-
}),
|
|
240
|
-
Schema_exports.Struct({ operation: Schema_exports.Literal("release"), key: Key, lease: Schema_exports.String }),
|
|
241
|
-
/** Extend a lease its holder still owns. Replies false once the lease lapsed or was replaced. */
|
|
242
|
-
Schema_exports.Struct({ operation: Schema_exports.Literal("renew"), key: Key, lease: Schema_exports.String }),
|
|
243
|
-
Schema_exports.Struct({
|
|
244
|
-
operation: Schema_exports.Literal("write"),
|
|
245
|
-
entries: Schema_exports.Array(Schema_exports.Struct({ key: Key, entry: CacheEntry }))
|
|
246
|
-
}),
|
|
247
|
-
Schema_exports.Struct({ operation: Schema_exports.Literal("invalidate"), key: Key })
|
|
248
|
-
]);
|
|
249
|
-
var CacheReply = Schema_exports.Union([
|
|
250
|
-
Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: Schema_exports.Json }),
|
|
251
|
-
Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: CacheError })
|
|
252
|
-
]);
|
|
253
|
-
|
|
254
|
-
export {
|
|
255
|
-
maxFailureMessageLength,
|
|
256
|
-
FailureSource,
|
|
257
|
-
FailureName,
|
|
258
|
-
FailureCode,
|
|
259
|
-
FailureMessage,
|
|
260
|
-
maxFailureFields,
|
|
261
|
-
maxFailureFieldLength,
|
|
262
|
-
FailureFieldName,
|
|
263
|
-
FailureFieldValue,
|
|
264
|
-
FailureFields,
|
|
265
|
-
FailureDetail,
|
|
266
|
-
maxUpstreamMessageLength,
|
|
267
|
-
UpstreamError,
|
|
268
|
-
FailurePhase,
|
|
269
|
-
ProviderError,
|
|
270
|
-
NetworkRefusal,
|
|
271
|
-
NetworkRefused,
|
|
272
|
-
networkRefusalStatus,
|
|
273
|
-
networkRefusalHeader,
|
|
274
|
-
NetworkRefusedHeader,
|
|
275
|
-
networkRefusalResponse,
|
|
276
|
-
RestrictedFetchOption,
|
|
277
|
-
supportedFetchOptions,
|
|
278
|
-
FetchOptionUnsupported,
|
|
279
|
-
CacheError,
|
|
280
|
-
cacheLimits,
|
|
281
|
-
CacheEntry,
|
|
282
|
-
CacheAcquired,
|
|
283
|
-
CacheCommand,
|
|
284
|
-
CacheReply
|
|
285
|
-
};
|