@byollm/protocol 0.1.0-alpha.85 → 0.1.0-alpha.86
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 +1 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1828,6 +1828,39 @@ declare const MAX_ENVELOPE_BYTES: number;
|
|
|
1828
1828
|
* this function is that one number answers both questions.
|
|
1829
1829
|
*/
|
|
1830
1830
|
declare function envelopeBytes(envelope: unknown): number;
|
|
1831
|
+
/**
|
|
1832
|
+
* A size somebody can act on, rounded **up** and only ever up.
|
|
1833
|
+
*
|
|
1834
|
+
* The rounding rule, in one place, because it has now been got wrong twice —
|
|
1835
|
+
* B072. `toFixed` rounds to nearest, so a message one byte over the line
|
|
1836
|
+
* printed "this message is 10.5 MB and the limit is 10.5 MB": a refusal that
|
|
1837
|
+
* reads as a contradiction, given to somebody who now has no idea what to
|
|
1838
|
+
* change.
|
|
1839
|
+
*
|
|
1840
|
+
* The relay found that, fixed it, and wrote the reasoning down beside the
|
|
1841
|
+
* fix. The SDK's refusal then rediscovered the identical bug, because it
|
|
1842
|
+
* copied the SENTENCE rather than the function — which is the same shape as
|
|
1843
|
+
* `MAX_BODY_BYTES` diverging from `MAX_ENVELOPE_BYTES`, and the same answer:
|
|
1844
|
+
* neither side holds the rule.
|
|
1845
|
+
*
|
|
1846
|
+
* Up is also the honest direction. Understating how far over a message is
|
|
1847
|
+
* sends somebody to trim a hundred bytes off something that needs to lose a
|
|
1848
|
+
* megabyte; overstating by a tenth costs them nothing.
|
|
1849
|
+
*/
|
|
1850
|
+
declare function describeBytes(bytes: number): string;
|
|
1851
|
+
/**
|
|
1852
|
+
* What a message that is too big is told, minus anything about pricing.
|
|
1853
|
+
*
|
|
1854
|
+
* Shared because both planes refuse the same thing for the same reason. What
|
|
1855
|
+
* is NOT shared is the relay's "every plan has the same ceiling" — a hosted
|
|
1856
|
+
* sentence, and meaningless to somebody self-hosting the direct lane, where
|
|
1857
|
+
* there are no plans. One rule, two audiences: the rule travels, the words
|
|
1858
|
+
* about our billing do not.
|
|
1859
|
+
*/
|
|
1860
|
+
declare function tooLargeMessage(input: {
|
|
1861
|
+
readonly bytes: number;
|
|
1862
|
+
readonly limit: number;
|
|
1863
|
+
}): string;
|
|
1831
1864
|
/** Where the bucket boundaries sit, in characters of payload text. */
|
|
1832
1865
|
declare const SIZE_CLASS_LIMITS: Readonly<{
|
|
1833
1866
|
small: 4000;
|
|
@@ -2842,4 +2875,4 @@ declare const MUST_IDS: readonly ("PAIR_ONE_USER" | "PAIR_INTERACTIVE" | "PAIR_C
|
|
|
2842
2875
|
/** Every MUST verified a particular way. */
|
|
2843
2876
|
declare function mustsVerifiedBy(kind: MustVerification): MustId[];
|
|
2844
2877
|
|
|
2845
|
-
export { ABOUT, ABOUT_SHORT, ABOUT_SHORT_LEDE, ABOUT_SHORT_TAIL, AUDIENCES, Audience, BACKENDS, BACKEND_CLASSES, BACKEND_IDS, BackendClass, BackendCost, type BackendDescriptor, type BackendId, BackendIdSchema, CLOCK_ATTRIBUTION_MS, CLOCK_SKEW_WARN_MS, Capability, CapabilityMatrix, ChatMessage, ChatPayload, ClaimRequest, ClaimResponse, ClaimedJob, ClaimedStub, DeliveredResult, ENCRYPTION_KEY_CONTEXT, ENDPOINTS, ENVELOPE_MAX_AGE_MS, ERROR_STATUS, type Endpoint, type EnvelopeContext, EnvelopeDirection, type EnvelopeFailure, FetchRequest, FetchResponse, type FloorRefusal, GRANT_CONTEXT, GRANT_MAX_AGE_MS, GRANT_SIGNED_FIELDS, GeneratePayload, type GrantClaims, GrantRef, type GrantRefusal, HeartbeatRequest, HeartbeatResponse, JOB_KINDS, JobKind, JobOutcome, JobPayload, JobRefused, JobResultCanceled, JobResultError, JobResultOk, JobState, JobStub, KindedPayload, Lease, MAX_CLOCK_SKEW_MS, MAX_ENVELOPE_BYTES, MAX_PURPOSES, MAX_SUCCESSION_CHAIN, MIN_PROTOCOL_VERSION, MUSTS, MUST_IDS, Manifest, type MatchDaemon, type MatchJob, MatchRefusal, type MatchResult, type Must, type MustEnforcer, type MustId, type MustVerification, type MustVerifiedBy, OFFER_SCOPES, OfferScope, type OpenResult, PAYLOAD_LIMITS, PROTOCOL_PREFIX, PROTOCOL_VERSION, PairPollRequest, PairPollResponse, PairRequest, PairStartRequest, PairStartResponse, type PayloadFor, PublicIdentity, Purpose, REFUSAL_MESSAGES, RESERVED_PURPOSE, RETIREMENT_WINDOW_MS, RefusalReason, ReleaseRequest, ReleaseResponse, RequestSignature, ResultDisposition, ResultProvenance, ResultRequest, ResultResponse, RunMetadata, SIZE_CLASSES, SIZE_CLASS_LIMITS, SUCCESSION_CONTEXT, SUPPORTED_PROTOCOL_VERSIONS, SealedEnvelope, SealedOutcome, type SignatureFailure, SignedGrant, SizeClass, type SpendConsent, StoredKeys, Succession, type SuccessionFailure, type SuccessionWalk, TERMINAL_STATES, UPDATE_OFFER_SINCE, UPGRADE_COMMAND, type VersionRefusal, WireError, WireErrorCode, WithheldKind, backendDescriptor, backendName, canTransition, canonicalRequest, checkDaemonFloor, checkProtocolVersion, classifyCost, compareVersions, cryptoReady, declaredVersion, effectiveOfferScope, envelopeBytes, fingerprint, generateKeys, grantStatement, isBackendId, isCloudTaggedModel, isJobKind, isLocalHost, isTerminal, keyId, kindsOf, matchAudience, mayOfferUpdate, mentionsWireField, mustsVerifiedBy, open, payloadTextLength, provenanceFor, publicIdentityOf, resolveCost, seal, signGrant, signRequest, signSiteRequest, signSuccession, signWith, singlePurposeManifest, sizeClassCeiling, sizeClassOf, successionStatement, updateOfferFor, verifyGrant, verifyLink, verifyPublicIdentity, verifyRequest, verifySiteRequest, verifyWith, walkSuccession, withoutComments };
|
|
2878
|
+
export { ABOUT, ABOUT_SHORT, ABOUT_SHORT_LEDE, ABOUT_SHORT_TAIL, AUDIENCES, Audience, BACKENDS, BACKEND_CLASSES, BACKEND_IDS, BackendClass, BackendCost, type BackendDescriptor, type BackendId, BackendIdSchema, CLOCK_ATTRIBUTION_MS, CLOCK_SKEW_WARN_MS, Capability, CapabilityMatrix, ChatMessage, ChatPayload, ClaimRequest, ClaimResponse, ClaimedJob, ClaimedStub, DeliveredResult, ENCRYPTION_KEY_CONTEXT, ENDPOINTS, ENVELOPE_MAX_AGE_MS, ERROR_STATUS, type Endpoint, type EnvelopeContext, EnvelopeDirection, type EnvelopeFailure, FetchRequest, FetchResponse, type FloorRefusal, GRANT_CONTEXT, GRANT_MAX_AGE_MS, GRANT_SIGNED_FIELDS, GeneratePayload, type GrantClaims, GrantRef, type GrantRefusal, HeartbeatRequest, HeartbeatResponse, JOB_KINDS, JobKind, JobOutcome, JobPayload, JobRefused, JobResultCanceled, JobResultError, JobResultOk, JobState, JobStub, KindedPayload, Lease, MAX_CLOCK_SKEW_MS, MAX_ENVELOPE_BYTES, MAX_PURPOSES, MAX_SUCCESSION_CHAIN, MIN_PROTOCOL_VERSION, MUSTS, MUST_IDS, Manifest, type MatchDaemon, type MatchJob, MatchRefusal, type MatchResult, type Must, type MustEnforcer, type MustId, type MustVerification, type MustVerifiedBy, OFFER_SCOPES, OfferScope, type OpenResult, PAYLOAD_LIMITS, PROTOCOL_PREFIX, PROTOCOL_VERSION, PairPollRequest, PairPollResponse, PairRequest, PairStartRequest, PairStartResponse, type PayloadFor, PublicIdentity, Purpose, REFUSAL_MESSAGES, RESERVED_PURPOSE, RETIREMENT_WINDOW_MS, RefusalReason, ReleaseRequest, ReleaseResponse, RequestSignature, ResultDisposition, ResultProvenance, ResultRequest, ResultResponse, RunMetadata, SIZE_CLASSES, SIZE_CLASS_LIMITS, SUCCESSION_CONTEXT, SUPPORTED_PROTOCOL_VERSIONS, SealedEnvelope, SealedOutcome, type SignatureFailure, SignedGrant, SizeClass, type SpendConsent, StoredKeys, Succession, type SuccessionFailure, type SuccessionWalk, TERMINAL_STATES, UPDATE_OFFER_SINCE, UPGRADE_COMMAND, type VersionRefusal, WireError, WireErrorCode, WithheldKind, backendDescriptor, backendName, canTransition, canonicalRequest, checkDaemonFloor, checkProtocolVersion, classifyCost, compareVersions, cryptoReady, declaredVersion, describeBytes, effectiveOfferScope, envelopeBytes, fingerprint, generateKeys, grantStatement, isBackendId, isCloudTaggedModel, isJobKind, isLocalHost, isTerminal, keyId, kindsOf, matchAudience, mayOfferUpdate, mentionsWireField, mustsVerifiedBy, open, payloadTextLength, provenanceFor, publicIdentityOf, resolveCost, seal, signGrant, signRequest, signSiteRequest, signSuccession, signWith, singlePurposeManifest, sizeClassCeiling, sizeClassOf, successionStatement, tooLargeMessage, updateOfferFor, verifyGrant, verifyLink, verifyPublicIdentity, verifyRequest, verifySiteRequest, verifyWith, walkSuccession, withoutComments };
|
package/dist/index.js
CHANGED
|
@@ -905,6 +905,12 @@ function envelopeBytes(envelope) {
|
|
|
905
905
|
const serialised = JSON.stringify(envelope);
|
|
906
906
|
return serialised === void 0 ? 0 : serialised.length;
|
|
907
907
|
}
|
|
908
|
+
function describeBytes(bytes) {
|
|
909
|
+
return `${(Math.ceil(bytes / (1024 * 1024) * 10) / 10).toFixed(1)} MB`;
|
|
910
|
+
}
|
|
911
|
+
function tooLargeMessage(input) {
|
|
912
|
+
return `this message is ${describeBytes(input.bytes)} and the limit is ${describeBytes(input.limit)} \u2014 it is a limit on one message rather than on how many you send. Split the work into smaller jobs and send them separately.`;
|
|
913
|
+
}
|
|
908
914
|
var SIZE_CLASS_LIMITS = Object.freeze({
|
|
909
915
|
small: 4e3,
|
|
910
916
|
medium: 64e3,
|
|
@@ -2627,6 +2633,7 @@ export {
|
|
|
2627
2633
|
compareVersions,
|
|
2628
2634
|
cryptoReady,
|
|
2629
2635
|
declaredVersion,
|
|
2636
|
+
describeBytes,
|
|
2630
2637
|
effectiveOfferScope,
|
|
2631
2638
|
envelopeBytes,
|
|
2632
2639
|
fingerprint,
|
|
@@ -2658,6 +2665,7 @@ export {
|
|
|
2658
2665
|
sizeClassCeiling,
|
|
2659
2666
|
sizeClassOf,
|
|
2660
2667
|
successionStatement,
|
|
2668
|
+
tooLargeMessage,
|
|
2661
2669
|
updateOfferFor,
|
|
2662
2670
|
verifyGrant,
|
|
2663
2671
|
verifyLink,
|