@tinycloud/node-sdk 3.3.2-beta.1 → 3.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { ReplicationOptions } from '@tinycloud/sdk-core';
2
2
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
3
3
  import { _ as __gated_network } from './gated-network-BEF2XSTC.cjs';
4
- import { _ as __authority } from './authority-BO2VqGnD.cjs';
4
+ import { _ as __authority } from './authority-BgZpUFss.cjs';
5
5
  import { _ as __runtime } from './runtime-D1o9Eybt.cjs';
6
6
  import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
7
7
  export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.cjs';
8
- export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, l as NodeUserAuthorizationConfig, p as OwnerDelegationReceipt, P as PortableDelegation, u as RuntimePermissionGrantOptions, S as SecretPermissionHint, v as SecretReadInput, w as SecretReadResult, y as SignStrategy, T as TinyCloudNode, z as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, F as UnifiedOwnerRootReceipt, G as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, J as activateCompactRuntimeDelegation, L as defaultSignStrategy, M as deserializeDelegation, W as serializeDelegation } from './TinyCloudNode-DeV-L_14.cjs';
8
+ export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, l as NodeUserAuthorizationConfig, p as OwnerDelegationReceipt, P as PortableDelegation, u as RuntimePermissionGrantOptions, S as SecretPermissionHint, v as SecretReadInput, w as SecretReadResult, y as SignStrategy, T as TinyCloudNode, z as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, F as UnifiedOwnerRootReceipt, G as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, J as activateCompactRuntimeDelegation, L as defaultSignStrategy, M as deserializeDelegation, W as serializeDelegation } from './TinyCloudNode-N4mfZI_k.cjs';
9
9
  import '@tinycloud/sdk-services';
10
10
  import 'events';
11
11
 
package/dist/core.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { ReplicationOptions } from '@tinycloud/sdk-core';
2
2
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
3
3
  import { _ as __gated_network } from './gated-network-BEF2XSTC.js';
4
- import { _ as __authority } from './authority-CtsxSAoP.js';
4
+ import { _ as __authority } from './authority-C670-9su.js';
5
5
  import { _ as __runtime } from './runtime-v62FzQHz.js';
6
6
  import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
7
7
  export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.js';
8
- export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, l as NodeUserAuthorizationConfig, p as OwnerDelegationReceipt, P as PortableDelegation, u as RuntimePermissionGrantOptions, S as SecretPermissionHint, v as SecretReadInput, w as SecretReadResult, y as SignStrategy, T as TinyCloudNode, z as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, F as UnifiedOwnerRootReceipt, G as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, J as activateCompactRuntimeDelegation, L as defaultSignStrategy, M as deserializeDelegation, W as serializeDelegation } from './TinyCloudNode-DeV-L_14.js';
8
+ export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, l as NodeUserAuthorizationConfig, p as OwnerDelegationReceipt, P as PortableDelegation, u as RuntimePermissionGrantOptions, S as SecretPermissionHint, v as SecretReadInput, w as SecretReadResult, y as SignStrategy, T as TinyCloudNode, z as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, F as UnifiedOwnerRootReceipt, G as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, J as activateCompactRuntimeDelegation, L as defaultSignStrategy, M as deserializeDelegation, W as serializeDelegation } from './TinyCloudNode-N4mfZI_k.js';
9
9
  import '@tinycloud/sdk-services';
10
10
  import 'events';
11
11
 
package/dist/core.js CHANGED
@@ -2053,6 +2053,173 @@ var NodeUserAuthorization = class {
2053
2053
  }
2054
2054
  };
2055
2055
 
2056
+ // src/recordingServiceContext.ts
2057
+ import {
2058
+ ServiceContext
2059
+ } from "@tinycloud/sdk-services";
2060
+ import {
2061
+ buildRequestEvent,
2062
+ invocationMetaOf,
2063
+ requestBytesOf
2064
+ } from "@tinycloud/sdk-services/telemetry/requestLog";
2065
+
2066
+ // src/recordingRegistry.ts
2067
+ var unrecordedFetches = /* @__PURE__ */ new WeakMap();
2068
+ function registerRecording(context, unrecordedFetch) {
2069
+ unrecordedFetches.set(context, unrecordedFetch);
2070
+ }
2071
+ function unrecordedFetchOf(context) {
2072
+ const unrecordedFetch = unrecordedFetches.get(context);
2073
+ return unrecordedFetch ? unrecordedFetch() : context.fetch;
2074
+ }
2075
+
2076
+ // src/recordingServiceContext.ts
2077
+ var SYNC_ABILITY = "tinycloud.kv/sync";
2078
+ var INFO_PATH = "/info";
2079
+ function outcomeCodeOf(response) {
2080
+ return response === void 0 ? "ERROR" : response.ok ? "ok" : `HTTP_${response.status}`;
2081
+ }
2082
+ function replicationOp(url, meta) {
2083
+ if (meta !== void 0) return meta.action === SYNC_ABILITY ? `${meta.service}/sync` : void 0;
2084
+ return isInfoUrl(url) ? "sync/info" : void 0;
2085
+ }
2086
+ function isInfoUrl(url) {
2087
+ try {
2088
+ return new URL(url).pathname.replace(/\/+$/, "") === INFO_PATH;
2089
+ } catch {
2090
+ return false;
2091
+ }
2092
+ }
2093
+ function replicationEvent(sample, op) {
2094
+ return buildRequestEvent({
2095
+ service: "sync",
2096
+ op,
2097
+ url: sample.url,
2098
+ bytes: requestBytesOf(sample.init?.body, sample.response?.headers.get("content-length")),
2099
+ durationMs: performance.now() - sample.clock,
2100
+ attempts: sample.attempts ?? 1,
2101
+ ok: sample.response?.ok === true,
2102
+ code: outcomeCodeOf(sample.response),
2103
+ at: sample.at
2104
+ });
2105
+ }
2106
+ function createServiceContext(config) {
2107
+ const { requestSink, ...base } = config;
2108
+ return requestSink === void 0 ? new ServiceContext(base) : new RecordingServiceContext(base, requestSink);
2109
+ }
2110
+ var RecordingServiceContext = class extends ServiceContext {
2111
+ constructor(config, sink) {
2112
+ const pending = {};
2113
+ super({
2114
+ ...config,
2115
+ invoke: rememberInvoke(config.invoke, sink, pending),
2116
+ invokeAny: config.invokeAny ? rememberInvokeAny(config.invokeAny, sink, pending) : void 0
2117
+ });
2118
+ this.requestSink = sink;
2119
+ this.pending = pending;
2120
+ registerRecording(this, () => this.unrecordedFetch);
2121
+ }
2122
+ /** Per-call recording; `_fetch` is read at access time, so overrides apply. */
2123
+ get fetch() {
2124
+ const raw = super.fetch;
2125
+ return (url, init) => this.recordCall(raw, url, init);
2126
+ }
2127
+ /** Transport without per-call recording. */
2128
+ get unrecordedFetch() {
2129
+ return super.fetch;
2130
+ }
2131
+ /**
2132
+ * One event per logical request. The first resolved attempt's init is the logged request and
2133
+ * `attempts` counts resolved builds. A retired context throws before the first build and records
2134
+ * nothing, as master does.
2135
+ */
2136
+ async invokeWithRetry(url, build) {
2137
+ const at = Date.now();
2138
+ const clock = performance.now();
2139
+ let reached = false;
2140
+ let attempts = 0;
2141
+ let first;
2142
+ let firstMeta;
2143
+ let response;
2144
+ const attempt = async () => {
2145
+ reached = true;
2146
+ this.pending.meta = void 0;
2147
+ const built = build();
2148
+ const meta = this.pending.meta;
2149
+ const init = await built;
2150
+ attempts += 1;
2151
+ if (first === void 0) {
2152
+ first = init;
2153
+ firstMeta = meta;
2154
+ }
2155
+ return init;
2156
+ };
2157
+ try {
2158
+ response = await super.invokeWithRetry(url, attempt);
2159
+ return response;
2160
+ } finally {
2161
+ if (reached) {
2162
+ this.observeAttempt({ url, init: first, response, meta: firstMeta, at, clock, attempts });
2163
+ }
2164
+ }
2165
+ }
2166
+ async recordCall(fetchFn, url, init) {
2167
+ const at = Date.now();
2168
+ const clock = performance.now();
2169
+ let response;
2170
+ try {
2171
+ response = await fetchFn(url, init);
2172
+ return response;
2173
+ } finally {
2174
+ this.observeAttempt({ url, init, response, at, clock });
2175
+ }
2176
+ }
2177
+ observeAttempt(sample) {
2178
+ try {
2179
+ const replication = replicationOp(sample.url, sample.meta ?? invocationMetaOf(sample.init?.headers));
2180
+ if (replication !== void 0) {
2181
+ this.requestSink.record(replicationEvent(sample, replication));
2182
+ return;
2183
+ }
2184
+ const headers = sample.init?.headers;
2185
+ if (sample.meta !== void 0 && typeof headers === "object" && headers !== null) {
2186
+ this.requestSink.remember(headers, sample.meta);
2187
+ }
2188
+ this.requestSink.observe({
2189
+ url: sample.url,
2190
+ requestHeaders: headers,
2191
+ requestBody: sample.init?.body,
2192
+ responseContentLength: sample.response?.headers.get("content-length"),
2193
+ ok: sample.response?.ok === true,
2194
+ code: outcomeCodeOf(sample.response),
2195
+ durationMs: performance.now() - sample.clock,
2196
+ attempts: sample.attempts ?? 1,
2197
+ at: sample.at
2198
+ });
2199
+ } catch {
2200
+ }
2201
+ }
2202
+ };
2203
+ function rememberInvoke(invoke, sink, pending) {
2204
+ return (session, service, path, action, facts) => {
2205
+ const headers = invoke(session, service, path, action, facts);
2206
+ const meta = { service, path, action, spaceId: session.spaceId };
2207
+ pending.meta = meta;
2208
+ sink.remember(headers, meta);
2209
+ return headers;
2210
+ };
2211
+ }
2212
+ function rememberInvokeAny(invokeAny, sink, pending) {
2213
+ return (session, entries, facts) => {
2214
+ const headers = invokeAny(session, entries, facts);
2215
+ const first = entries[0];
2216
+ const meta = first === void 0 ? void 0 : { service: first.service, path: first.path, action: first.action, spaceId: first.spaceId ?? session.spaceId };
2217
+ pending.meta = meta;
2218
+ if (meta !== void 0) sink.remember(headers, meta);
2219
+ return headers;
2220
+ };
2221
+ }
2222
+
2056
2223
  // src/delegation.ts
2057
2224
  import {
2058
2225
  canonicalizeRecapCaveats,
@@ -2553,7 +2720,6 @@ import {
2553
2720
  DecryptTransportResponseError,
2554
2721
  SecretsService,
2555
2722
  createVaultCrypto,
2556
- ServiceContext as ServiceContext2,
2557
2723
  SilentNotificationHandler,
2558
2724
  DelegationManager,
2559
2725
  SpaceService,
@@ -2617,6 +2783,7 @@ import {
2617
2783
  parsePermissionHint,
2618
2784
  tinyCloudDebugLogger
2619
2785
  } from "@tinycloud/sdk-services";
2786
+ import { RequestLog, observeReplicaReads, readOnlyRequestLog } from "@tinycloud/sdk-services/telemetry/requestLog";
2620
2787
 
2621
2788
  // src/account/AccountService.ts
2622
2789
  import { AccountService } from "@tinycloud/sdk-core";
@@ -2626,8 +2793,7 @@ import {
2626
2793
  KVService,
2627
2794
  HooksService,
2628
2795
  SQLService,
2629
- DuckDbService,
2630
- ServiceContext
2796
+ DuckDbService
2631
2797
  } from "@tinycloud/sdk-core";
2632
2798
  var DelegatedAccess = class {
2633
2799
  /**
@@ -2640,12 +2806,13 @@ var DelegatedAccess = class {
2640
2806
  this.session = session;
2641
2807
  this._delegation = delegation;
2642
2808
  this.host = host;
2643
- const context = new ServiceContext({
2809
+ const context = createServiceContext({
2644
2810
  invoke,
2645
2811
  invokeAny,
2646
2812
  fetch: lifetime?.fetch ?? globalThis.fetch.bind(globalThis),
2647
2813
  hosts: [host],
2648
- telemetry
2814
+ telemetry,
2815
+ requestSink: lifetime?.requestSink
2649
2816
  });
2650
2817
  this._serviceContext = lifetime ? lifetime.track(context) : context;
2651
2818
  const prefix = this._delegation.path.replace(/\/$/, "");
@@ -3245,11 +3412,12 @@ function createDefaultSessionKey(wasm) {
3245
3412
  return { manager, keyId, jwk: JSON.parse(jwkStr) };
3246
3413
  }
3247
3414
  var ServiceGraphLifetime = class {
3248
- constructor(invokeFn, invokeAnyFn, fetchFn, observeContext) {
3415
+ constructor(invokeFn, invokeAnyFn, fetchFn, observeContext, requestSink) {
3249
3416
  this.invokeFn = invokeFn;
3250
3417
  this.invokeAnyFn = invokeAnyFn;
3251
3418
  this.fetchFn = fetchFn;
3252
3419
  this.observeContext = observeContext;
3420
+ this.requestSink = requestSink;
3253
3421
  this.abortController = new AbortController();
3254
3422
  this.contexts = /* @__PURE__ */ new Set();
3255
3423
  this.retired = false;
@@ -3820,6 +3988,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3820
3988
  this.sessionManager = sessionKey.manager;
3821
3989
  this.sessionKeyId = sessionKey.keyId;
3822
3990
  this.sessionKeyJwk = sessionKey.jwk;
3991
+ this._requestLog = config.requestLog === true ? new RequestLog() : void 0;
3823
3992
  this._serviceGraph = this.createServiceGraphLifetime();
3824
3993
  this._capabilityRegistry = new CapabilityKeyRegistry();
3825
3994
  this._keyProvider = new WasmKeyProvider({
@@ -3991,7 +4160,8 @@ var _TinyCloudNode = class _TinyCloudNode {
3991
4160
  createKVService: (config) => {
3992
4161
  const prefix = config.pathPrefix?.replace(/\/$/, "");
3993
4162
  const kvService = new KVService2({ prefix });
3994
- const kvContext = receiveOnlyGraph.track(new ServiceContext2({
4163
+ const kvContext = receiveOnlyGraph.track(createServiceContext({
4164
+ requestSink: receiveOnlyGraph.requestSink,
3995
4165
  invoke: config.invoke,
3996
4166
  fetch: config.fetch ?? globalThis.fetch.bind(globalThis),
3997
4167
  hosts: config.hosts,
@@ -4054,6 +4224,10 @@ var _TinyCloudNode = class _TinyCloudNode {
4054
4224
  shouldUseBootstrapSignInRequest(config) {
4055
4225
  return config.autoBootstrapAccount !== false && config.manifest === void 0 && config.capabilityRequest === void 0 && (config.prefix ?? "default") === "default" && isOpenKeyAutoSignStrategy(config.signStrategy);
4056
4226
  }
4227
+ /** Sanitized developer request events; undefined unless the node was built with `requestLog: true`. */
4228
+ get requests() {
4229
+ return this._requestLog === void 0 ? void 0 : readOnlyRequestLog(this._requestLog);
4230
+ }
4057
4231
  createServiceGraphLifetime() {
4058
4232
  return new ServiceGraphLifetime(
4059
4233
  this.invokeWithRuntimePermissions,
@@ -4064,7 +4238,9 @@ var _TinyCloudNode = class _TinyCloudNode {
4064
4238
  (url, init) => globalThis.fetch(url, init),
4065
4239
  (context) => {
4066
4240
  this.storageFull.observe(context);
4067
- }
4241
+ if (this._requestLog) observeReplicaReads(context, this._requestLog);
4242
+ },
4243
+ this._requestLog
4068
4244
  );
4069
4245
  }
4070
4246
  syncResolvedHostFromAuth() {
@@ -4387,6 +4563,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4387
4563
  this.hostedOwnedSpaceIds.clear();
4388
4564
  this.cancelOwnedSpaceHosts();
4389
4565
  this.storageFull.clear();
4566
+ this._requestLog?.clear();
4390
4567
  this._bootstrapSkipped = false;
4391
4568
  this._bootstrapStatus = { skipped: false };
4392
4569
  this.replicationDelegateSession = void 0;
@@ -4478,7 +4655,10 @@ var _TinyCloudNode = class _TinyCloudNode {
4478
4655
  const denial = await this.denyReplicaGate({ reason: "account_switch", principal: priorPrincipal, next: nextPrincipal });
4479
4656
  this.replicaRestoreGate = denial?.status === "unguarded" ? "gate_unavailable" : "stamp_stale";
4480
4657
  }
4481
- if (address !== this._address || chainId !== this._chainId) this.storageFull.clear();
4658
+ if (address !== this._address || chainId !== this._chainId) {
4659
+ this.storageFull.clear();
4660
+ this._requestLog?.clear();
4661
+ }
4482
4662
  this._address = address;
4483
4663
  this._chainId = chainId;
4484
4664
  this._kv = void 0;
@@ -5057,10 +5237,11 @@ var _TinyCloudNode = class _TinyCloudNode {
5057
5237
  const contexts = [context];
5058
5238
  const accountSpaceId = this.ownedSpaceId(ACCOUNT_REGISTRY_SPACE2);
5059
5239
  const createScopedContext = (spaceId) => {
5060
- const scoped = this._serviceGraph.track(new ServiceContext2({
5240
+ const scoped = this._serviceGraph.track(createServiceContext({
5241
+ requestSink: this._serviceGraph.requestSink,
5061
5242
  invoke: context.invoke,
5062
5243
  invokeAny: context.invokeAny,
5063
- fetch: context.fetch,
5244
+ fetch: unrecordedFetchOf(context),
5064
5245
  hosts: context.hosts,
5065
5246
  telemetry: this.config.telemetry,
5066
5247
  retryPolicy: this.config.retryPolicy
@@ -5124,10 +5305,11 @@ var _TinyCloudNode = class _TinyCloudNode {
5124
5305
  const promise = this.enqueueAccountRegistryOperation(session, async () => {
5125
5306
  const sharedContext = this._serviceContext;
5126
5307
  if (!sharedContext) return;
5127
- const context = this._serviceGraph.track(new ServiceContext2({
5308
+ const context = this._serviceGraph.track(createServiceContext({
5309
+ requestSink: this._serviceGraph.requestSink,
5128
5310
  invoke: sharedContext.invoke,
5129
5311
  invokeAny: sharedContext.invokeAny,
5130
- fetch: sharedContext.fetch,
5312
+ fetch: unrecordedFetchOf(sharedContext),
5131
5313
  hosts: sharedContext.hosts,
5132
5314
  telemetry: this.config.telemetry,
5133
5315
  retryPolicy: this.config.retryPolicy
@@ -5861,6 +6043,7 @@ var _TinyCloudNode = class _TinyCloudNode {
5861
6043
  if (resolvedHost) this.config.host = resolvedHost;
5862
6044
  if (spaceOwnerKey(serviceSession.spaceId) !== this.currentStorageOwner()) {
5863
6045
  this.storageFull.clear();
6046
+ this._requestLog?.clear();
5864
6047
  }
5865
6048
  this._address = stagedAddress;
5866
6049
  this._chainId = stagedChainId;
@@ -5980,7 +6163,8 @@ var _TinyCloudNode = class _TinyCloudNode {
5980
6163
  const coreContext = graph.track(core.serviceContext);
5981
6164
  coreContext.setSession(input.serviceSession);
5982
6165
  }
5983
- const serviceContext = graph.track(new ServiceContext2({
6166
+ const serviceContext = graph.track(createServiceContext({
6167
+ requestSink: graph.requestSink,
5984
6168
  invoke: graph.invoke,
5985
6169
  invokeAny: graph.invokeAny,
5986
6170
  fetch: graph.fetch,
@@ -6068,7 +6252,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6068
6252
  },
6069
6253
  createKVService: (config) => {
6070
6254
  const service = new KVService2({ prefix: config.pathPrefix?.replace(/\/$/, "") });
6071
- const context = graph.track(new ServiceContext2({
6255
+ const context = graph.track(createServiceContext({
6256
+ requestSink: graph.requestSink,
6072
6257
  invoke: config.invoke,
6073
6258
  fetch: config.fetch ?? globalThis.fetch.bind(globalThis),
6074
6259
  hosts: config.hosts,
@@ -6108,7 +6293,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6108
6293
  createKVService: (spaceId) => {
6109
6294
  graph.assertActive();
6110
6295
  const scopedKv = new KVService2({});
6111
- const context = graph.track(new ServiceContext2({
6296
+ const context = graph.track(createServiceContext({
6297
+ requestSink: graph.requestSink,
6112
6298
  invoke: graph.invoke,
6113
6299
  invokeAny: graph.invokeAny,
6114
6300
  fetch: graph.fetch,
@@ -6124,7 +6310,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6124
6310
  createVaultService: (spaceId) => {
6125
6311
  graph.assertActive();
6126
6312
  const scopedKv = new KVService2({});
6127
- const context = graph.track(new ServiceContext2({
6313
+ const context = graph.track(createServiceContext({
6314
+ requestSink: graph.requestSink,
6128
6315
  invoke: graph.invoke,
6129
6316
  invokeAny: graph.invokeAny,
6130
6317
  fetch: graph.fetch,
@@ -6523,7 +6710,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6523
6710
  this._serviceGraph.fetch
6524
6711
  );
6525
6712
  this._serviceGraph.track(this.tc.serviceContext);
6526
- this._serviceContext = this._serviceGraph.track(new ServiceContext2({
6713
+ this._serviceContext = this._serviceGraph.track(createServiceContext({
6714
+ requestSink: this._serviceGraph.requestSink,
6527
6715
  invoke: this._serviceGraph.invoke,
6528
6716
  invokeAny: this._serviceGraph.invokeAny,
6529
6717
  fetch: this._serviceGraph.fetch,
@@ -6571,10 +6759,11 @@ var _TinyCloudNode = class _TinyCloudNode {
6571
6759
  createSpaceScopedKVService(spaceId) {
6572
6760
  const kvService = new KVService2({});
6573
6761
  if (this._serviceContext) {
6574
- const spaceScopedContext = this._serviceGraph.track(new ServiceContext2({
6762
+ const spaceScopedContext = this._serviceGraph.track(createServiceContext({
6763
+ requestSink: this._serviceGraph.requestSink,
6575
6764
  invoke: this._serviceContext.invoke,
6576
6765
  invokeAny: this._serviceContext.invokeAny,
6577
- fetch: this._serviceContext.fetch,
6766
+ fetch: unrecordedFetchOf(this._serviceContext),
6578
6767
  hosts: this._serviceContext.hosts,
6579
6768
  telemetry: this.config.telemetry,
6580
6769
  retryPolicy: this.config.retryPolicy
@@ -7040,7 +7229,8 @@ var _TinyCloudNode = class _TinyCloudNode {
7040
7229
  createKVService: (config) => {
7041
7230
  graph.assertActive();
7042
7231
  const service = new KVService2({ prefix: config.pathPrefix?.replace(/\/$/, "") });
7043
- const context = graph.track(new ServiceContext2({
7232
+ const context = graph.track(createServiceContext({
7233
+ requestSink: graph.requestSink,
7044
7234
  invoke: config.invoke,
7045
7235
  fetch: config.fetch ?? graph.fetch,
7046
7236
  hosts: config.hosts,
@@ -7361,10 +7551,11 @@ var _TinyCloudNode = class _TinyCloudNode {
7361
7551
  throw new Error("Not signed in. Call signIn() first.");
7362
7552
  }
7363
7553
  const sql = new SQLService2({});
7364
- const spaceScopedContext = this._serviceGraph.track(new ServiceContext2({
7554
+ const spaceScopedContext = this._serviceGraph.track(createServiceContext({
7555
+ requestSink: this._serviceGraph.requestSink,
7365
7556
  invoke: this._serviceContext.invoke,
7366
7557
  invokeAny: this._serviceContext.invokeAny,
7367
- fetch: this._serviceContext.fetch,
7558
+ fetch: unrecordedFetchOf(this._serviceContext),
7368
7559
  hosts: this._serviceContext.hosts,
7369
7560
  telemetry: this.config.telemetry,
7370
7561
  retryPolicy: this.config.retryPolicy
@@ -7392,10 +7583,11 @@ var _TinyCloudNode = class _TinyCloudNode {
7392
7583
  throw new Error("Not signed in. Call signIn() first.");
7393
7584
  }
7394
7585
  const kv = new KVService2({});
7395
- const spaceScopedContext = this._serviceGraph.track(new ServiceContext2({
7586
+ const spaceScopedContext = this._serviceGraph.track(createServiceContext({
7587
+ requestSink: this._serviceGraph.requestSink,
7396
7588
  invoke: this._serviceContext.invoke,
7397
7589
  invokeAny: this._serviceContext.invokeAny,
7398
- fetch: this._serviceContext.fetch,
7590
+ fetch: unrecordedFetchOf(this._serviceContext),
7399
7591
  hosts: this._serviceContext.hosts
7400
7592
  }));
7401
7593
  spaceScopedContext.setSession({ ...this._serviceContext.session, spaceId });
@@ -8181,7 +8373,8 @@ var _TinyCloudNode = class _TinyCloudNode {
8181
8373
  }
8182
8374
  if (this._serviceContext) {
8183
8375
  const publicKV = new KVService2({ prefix: "" });
8184
- const publicContext = this._serviceGraph.track(new ServiceContext2({
8376
+ const publicContext = this._serviceGraph.track(createServiceContext({
8377
+ requestSink: this._serviceGraph.requestSink,
8185
8378
  invoke: this._serviceGraph.invoke,
8186
8379
  fetch: this._serviceGraph.fetch,
8187
8380
  hosts: this._serviceContext.hosts,
@@ -9764,7 +9957,7 @@ import {
9764
9957
  UnsupportedFeatureError as UnsupportedFeatureError2,
9765
9958
  checkNodeInfo as checkNodeInfo3
9766
9959
  } from "@tinycloud/sdk-core";
9767
- import { ServiceContext as ServiceContext3 } from "@tinycloud/sdk-core";
9960
+ import { ServiceContext as ServiceContext4 } from "@tinycloud/sdk-core";
9768
9961
  export {
9769
9962
  ACCOUNT_REGISTRY_PATH,
9770
9963
  ACCOUNT_REGISTRY_SPACE3 as ACCOUNT_REGISTRY_SPACE,
@@ -9798,7 +9991,7 @@ export {
9798
9991
  SQLAction,
9799
9992
  SQLService3 as SQLService,
9800
9993
  SecretsService2 as SecretsService,
9801
- ServiceContext3 as ServiceContext,
9994
+ ServiceContext4 as ServiceContext,
9802
9995
  SessionExpiredError2 as SessionExpiredError,
9803
9996
  SharingService2 as SharingService,
9804
9997
  SilentNotificationHandler2 as SilentNotificationHandler,