presubmit 0.1.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/LICENSE +202 -0
- package/README.md +51 -0
- package/THIRD_PARTY_NOTICES.md +24 -0
- package/apps/web/dist/assets/FileCode-CZZH52o7.js +5 -0
- package/apps/web/dist/assets/FileCode-DovDO7Jh.css +1 -0
- package/apps/web/dist/assets/SettingsPage-CRvOwdjt.js +4 -0
- package/apps/web/dist/assets/SettingsPage-UbYSCwJj.css +1 -0
- package/apps/web/dist/assets/TerminalPanel-0sw-J6YS.css +1 -0
- package/apps/web/dist/assets/TerminalPanel-BqUjPWav.js +16 -0
- package/apps/web/dist/assets/index-BhqNNFja.js +54 -0
- package/apps/web/dist/assets/index-DD8VXy8H.css +1 -0
- package/apps/web/dist/assets/presubmit-mark-BBQ19Fmr.svg +7 -0
- package/apps/web/dist/assets/presubmit-mark-busy-CwBC-7on.svg +8 -0
- package/apps/web/dist/assets/react-vendor-wiHys0m2.js +9 -0
- package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/apps/web/dist/index.html +6 -0
- package/apps/web/dist/service-worker.js +11 -0
- package/dist/apps/server/src/agent-builder.js +204 -0
- package/dist/apps/server/src/attach.js +163 -0
- package/dist/apps/server/src/attachments.js +86 -0
- package/dist/apps/server/src/browser-access.js +131 -0
- package/dist/apps/server/src/check-provenance.js +95 -0
- package/dist/apps/server/src/check-supervisor.js +112 -0
- package/dist/apps/server/src/checks.js +402 -0
- package/dist/apps/server/src/child-collaboration-guidance.js +2 -0
- package/dist/apps/server/src/child-sessions.js +191 -0
- package/dist/apps/server/src/cli.js +162 -0
- package/dist/apps/server/src/conversation-search.js +12 -0
- package/dist/apps/server/src/coordinator-messages.js +72 -0
- package/dist/apps/server/src/dev-auth.js +54 -0
- package/dist/apps/server/src/dev-server.js +201 -0
- package/dist/apps/server/src/dev-worker.js +48 -0
- package/dist/apps/server/src/diagnostics.js +105 -0
- package/dist/apps/server/src/fast-mode.js +8 -0
- package/dist/apps/server/src/folder-picker.js +54 -0
- package/dist/apps/server/src/git-blobs.js +62 -0
- package/dist/apps/server/src/git-handoff.js +127 -0
- package/dist/apps/server/src/history-sources.js +59 -0
- package/dist/apps/server/src/hub.js +159 -0
- package/dist/apps/server/src/internal-transport.js +38 -0
- package/dist/apps/server/src/local-embeddings.js +70 -0
- package/dist/apps/server/src/ollama-setup.js +56 -0
- package/dist/apps/server/src/planning.js +30 -0
- package/dist/apps/server/src/project-agents.js +276 -0
- package/dist/apps/server/src/project-memory.js +94 -0
- package/dist/apps/server/src/projects.js +106 -0
- package/dist/apps/server/src/queued-launch.js +13 -0
- package/dist/apps/server/src/reply-search.js +172 -0
- package/dist/apps/server/src/review-context.js +60 -0
- package/dist/apps/server/src/review-refresh.js +14 -0
- package/dist/apps/server/src/reviewers.js +75 -0
- package/dist/apps/server/src/search-settings.js +22 -0
- package/dist/apps/server/src/semantic-history.js +186 -0
- package/dist/apps/server/src/server.js +4338 -0
- package/dist/apps/server/src/session-changes.js +181 -0
- package/dist/apps/server/src/session-router-settings.js +198 -0
- package/dist/apps/server/src/session-workspaces.js +135 -0
- package/dist/apps/server/src/sessions.js +579 -0
- package/dist/apps/server/src/shared-auth.js +70 -0
- package/dist/apps/server/src/shell-evaluator-settings.js +53 -0
- package/dist/apps/server/src/store.js +203 -0
- package/dist/apps/server/src/tailscale-process.js +115 -0
- package/dist/apps/server/src/tailscale-serve-worker.js +33 -0
- package/dist/apps/server/src/tailscale-serve.js +276 -0
- package/dist/apps/server/src/task-capacity.js +92 -0
- package/dist/apps/server/src/task-graph.js +190 -0
- package/dist/apps/server/src/task-logs.js +74 -0
- package/dist/apps/server/src/task-numbers.js +25 -0
- package/dist/apps/server/src/task-orchestrator.js +1088 -0
- package/dist/apps/server/src/terminal.js +182 -0
- package/dist/apps/server/src/terminals.js +80 -0
- package/dist/apps/server/src/tool-safety.js +2 -0
- package/dist/apps/server/src/workspace-lock.js +140 -0
- package/dist/apps/server/src/workspace-watcher.js +65 -0
- package/dist/apps/server/src/workspace.js +517 -0
- package/dist/packages/agent-pi/src/agent-builder-tool.js +32 -0
- package/dist/packages/agent-pi/src/agent-capabilities.js +44 -0
- package/dist/packages/agent-pi/src/ask-user.js +86 -0
- package/dist/packages/agent-pi/src/auth.js +510 -0
- package/dist/packages/agent-pi/src/check-tools.js +72 -0
- package/dist/packages/agent-pi/src/command-policy.js +246 -0
- package/dist/packages/agent-pi/src/coordinator-tools.js +122 -0
- package/dist/packages/agent-pi/src/fast-mode.js +67 -0
- package/dist/packages/agent-pi/src/file-tools.js +163 -0
- package/dist/packages/agent-pi/src/history-tool.js +40 -0
- package/dist/packages/agent-pi/src/history.js +34 -0
- package/dist/packages/agent-pi/src/index.js +177 -0
- package/dist/packages/agent-pi/src/ipc.js +314 -0
- package/dist/packages/agent-pi/src/jev-session-router.js +408 -0
- package/dist/packages/agent-pi/src/jev-tools.js +71 -0
- package/dist/packages/agent-pi/src/local-model.js +277 -0
- package/dist/packages/agent-pi/src/memory-tools.js +119 -0
- package/dist/packages/agent-pi/src/model.js +25 -0
- package/dist/packages/agent-pi/src/planning.js +206 -0
- package/dist/packages/agent-pi/src/resource-loader.js +23 -0
- package/dist/packages/agent-pi/src/review-tools.js +158 -0
- package/dist/packages/agent-pi/src/review-transition.js +73 -0
- package/dist/packages/agent-pi/src/review.js +40 -0
- package/dist/packages/agent-pi/src/routing.js +27 -0
- package/dist/packages/agent-pi/src/session-setup.js +118 -0
- package/dist/packages/agent-pi/src/shell-context.js +51 -0
- package/dist/packages/agent-pi/src/shell-policy.js +281 -0
- package/dist/packages/agent-pi/src/shell-safety.js +205 -0
- package/dist/packages/agent-pi/src/shell.js +121 -0
- package/dist/packages/agent-pi/src/snapshot-permissions.js +12 -0
- package/dist/packages/agent-pi/src/spike.js +41 -0
- package/dist/packages/agent-pi/src/task-tools.js +53 -0
- package/dist/packages/agent-pi/src/types.js +1 -0
- package/dist/packages/agent-pi/src/usage.js +30 -0
- package/dist/packages/agent-pi/src/worker.js +602 -0
- package/dist/packages/protocol/src/activity-summary.js +77 -0
- package/dist/packages/protocol/src/agents.js +301 -0
- package/dist/packages/protocol/src/browser-access.js +1 -0
- package/dist/packages/protocol/src/checks.js +40 -0
- package/dist/packages/protocol/src/child-sessions.js +28 -0
- package/dist/packages/protocol/src/command-policy.js +3 -0
- package/dist/packages/protocol/src/coordinator.js +135 -0
- package/dist/packages/protocol/src/delegation.js +40 -0
- package/dist/packages/protocol/src/git-diff.js +71 -0
- package/dist/packages/protocol/src/git-handoff.js +1 -0
- package/dist/packages/protocol/src/index.js +1 -0
- package/dist/packages/protocol/src/memory.js +46 -0
- package/dist/packages/protocol/src/metrics.js +70 -0
- package/dist/packages/protocol/src/planning.js +138 -0
- package/dist/packages/protocol/src/retrieval.js +36 -0
- package/dist/packages/protocol/src/reviewers.js +17 -0
- package/dist/packages/protocol/src/search.js +16 -0
- package/dist/packages/protocol/src/session-changes.js +29 -0
- package/dist/packages/protocol/src/session-router.js +123 -0
- package/dist/packages/protocol/src/shell-evaluator.js +43 -0
- package/dist/packages/protocol/src/task-graph.js +1 -0
- package/dist/packages/protocol/src/token-usage.js +17 -0
- package/dist/packages/protocol/src/user-questions.js +106 -0
- package/package.json +71 -0
- package/vendor/lancedb/NODEJS_THIRD_PARTY_LICENSES.md +668 -0
- package/vendor/lancedb/RUST_THIRD_PARTY_LICENSES.html +14607 -0
- package/vendor/lancedb/dist/arrow.d.ts +296 -0
- package/vendor/lancedb/dist/arrow.js +1145 -0
- package/vendor/lancedb/dist/arrow_type.d.ts +9 -0
- package/vendor/lancedb/dist/arrow_type.js +29 -0
- package/vendor/lancedb/dist/connection.d.ts +508 -0
- package/vendor/lancedb/dist/connection.js +298 -0
- package/vendor/lancedb/dist/embedding/embedding_function.d.ts +103 -0
- package/vendor/lancedb/dist/embedding/embedding_function.js +192 -0
- package/vendor/lancedb/dist/embedding/index.d.ts +37 -0
- package/vendor/lancedb/dist/embedding/index.js +108 -0
- package/vendor/lancedb/dist/embedding/openai.d.ts +16 -0
- package/vendor/lancedb/dist/embedding/openai.js +81 -0
- package/vendor/lancedb/dist/embedding/registry.d.ts +94 -0
- package/vendor/lancedb/dist/embedding/registry.js +221 -0
- package/vendor/lancedb/dist/embedding/transformers.d.ts +36 -0
- package/vendor/lancedb/dist/embedding/transformers.js +110 -0
- package/vendor/lancedb/dist/header.d.ts +162 -0
- package/vendor/lancedb/dist/header.js +217 -0
- package/vendor/lancedb/dist/index.d.ts +246 -0
- package/vendor/lancedb/dist/index.js +176 -0
- package/vendor/lancedb/dist/indices.d.ts +721 -0
- package/vendor/lancedb/dist/indices.js +166 -0
- package/vendor/lancedb/dist/materialized_view.d.ts +69 -0
- package/vendor/lancedb/dist/materialized_view.js +112 -0
- package/vendor/lancedb/dist/merge.d.ts +104 -0
- package/vendor/lancedb/dist/merge.js +120 -0
- package/vendor/lancedb/dist/native.d.ts +1193 -0
- package/vendor/lancedb/dist/native.js +688 -0
- package/vendor/lancedb/dist/oauth.d.ts +66 -0
- package/vendor/lancedb/dist/oauth.js +15 -0
- package/vendor/lancedb/dist/otel.d.ts +26 -0
- package/vendor/lancedb/dist/otel.js +114 -0
- package/vendor/lancedb/dist/permutation.d.ts +143 -0
- package/vendor/lancedb/dist/permutation.js +184 -0
- package/vendor/lancedb/dist/query.d.ts +663 -0
- package/vendor/lancedb/dist/query.js +966 -0
- package/vendor/lancedb/dist/rerankers/index.d.ts +5 -0
- package/vendor/lancedb/dist/rerankers/index.js +19 -0
- package/vendor/lancedb/dist/rerankers/rrf.d.ts +14 -0
- package/vendor/lancedb/dist/rerankers/rrf.js +28 -0
- package/vendor/lancedb/dist/sanitize.d.ts +32 -0
- package/vendor/lancedb/dist/sanitize.js +544 -0
- package/vendor/lancedb/dist/scannable.d.ts +92 -0
- package/vendor/lancedb/dist/scannable.js +200 -0
- package/vendor/lancedb/dist/schema.d.ts +16 -0
- package/vendor/lancedb/dist/schema.js +387 -0
- package/vendor/lancedb/dist/table.d.ts +1069 -0
- package/vendor/lancedb/dist/table.js +498 -0
- package/vendor/lancedb/dist/util.d.ts +14 -0
- package/vendor/lancedb/dist/util.js +77 -0
- package/vendor/lancedb/license_header.txt +2 -0
- package/vendor/lancedb/package.json +56 -0
- package/vendor/transformers/LICENSE +202 -0
- package/vendor/transformers/dist/transformers.cjs +30844 -0
- package/vendor/transformers/dist/transformers.mjs +31404 -0
- package/vendor/transformers/package.json +55 -0
- package/vendor/transformers/types/backends/onnx.d.ts +30 -0
- package/vendor/transformers/types/configs.d.ts +85 -0
- package/vendor/transformers/types/env.d.ts +110 -0
- package/vendor/transformers/types/generation/configuration_utils.d.ts +320 -0
- package/vendor/transformers/types/generation/logits_process.d.ts +354 -0
- package/vendor/transformers/types/generation/logits_sampler.d.ts +51 -0
- package/vendor/transformers/types/generation/parameters.d.ts +47 -0
- package/vendor/transformers/types/generation/stopping_criteria.d.ts +81 -0
- package/vendor/transformers/types/generation/streamers.d.ts +81 -0
- package/vendor/transformers/types/models/whisper/common_whisper.d.ts +8 -0
- package/vendor/transformers/types/models/whisper/generation_whisper.d.ts +76 -0
- package/vendor/transformers/types/models.d.ts +3684 -0
- package/vendor/transformers/types/ops/registry.d.ts +11 -0
- package/vendor/transformers/types/pipelines.d.ts +2402 -0
- package/vendor/transformers/types/processors.d.ts +924 -0
- package/vendor/transformers/types/tokenizers.d.ts +990 -0
- package/vendor/transformers/types/transformers.d.ts +13 -0
- package/vendor/transformers/types/utils/audio.d.ts +130 -0
- package/vendor/transformers/types/utils/constants.d.ts +2 -0
- package/vendor/transformers/types/utils/core.d.ts +98 -0
- package/vendor/transformers/types/utils/data-structures.d.ts +236 -0
- package/vendor/transformers/types/utils/devices.d.ts +18 -0
- package/vendor/transformers/types/utils/dtypes.d.ts +19 -0
- package/vendor/transformers/types/utils/generic.d.ts +11 -0
- package/vendor/transformers/types/utils/hub.d.ts +152 -0
- package/vendor/transformers/types/utils/image.d.ts +119 -0
- package/vendor/transformers/types/utils/maths.d.ts +280 -0
- package/vendor/transformers/types/utils/tensor.d.ts +418 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth authentication flow types.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum OAuthFlowType {
|
|
5
|
+
/** Client Credentials grant (service-to-service / M2M). */
|
|
6
|
+
ClientCredentials = "client_credentials",
|
|
7
|
+
/** Azure Managed Identity via IMDS. */
|
|
8
|
+
AzureManagedIdentity = "azure_managed_identity"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* OAuth configuration for LanceDB authentication.
|
|
12
|
+
*
|
|
13
|
+
* This is the public TypeScript OAuth configuration type. The generated
|
|
14
|
+
* `NativeOAuthConfig` type has the same runtime shape but is an implementation
|
|
15
|
+
* detail of the napi-rs binding.
|
|
16
|
+
*
|
|
17
|
+
* All token acquisition and refresh is handled in the Rust layer.
|
|
18
|
+
* This config is passed through to Rust via napi-rs.
|
|
19
|
+
*
|
|
20
|
+
* @example Client Credentials (service-to-service):
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const config: OAuthConfig = {
|
|
23
|
+
* issuerUrl: "https://login.microsoftonline.com/{tenant}/v2.0",
|
|
24
|
+
* clientId: "app-id",
|
|
25
|
+
* clientSecret: "secret",
|
|
26
|
+
* scopes: ["api://lancedb-api/.default"],
|
|
27
|
+
* };
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Azure Managed Identity:
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const config: OAuthConfig = {
|
|
33
|
+
* issuerUrl: "https://login.microsoftonline.com/{tenant}/v2.0",
|
|
34
|
+
* clientId: "app-id",
|
|
35
|
+
* scopes: ["api://lancedb-api/.default"],
|
|
36
|
+
* flow: OAuthFlowType.AzureManagedIdentity,
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export interface OAuthConfig {
|
|
41
|
+
/**
|
|
42
|
+
* OIDC issuer URL or OAuth authority URL.
|
|
43
|
+
* For Azure: `https://login.microsoftonline.com/{tenant_id}/v2.0`
|
|
44
|
+
*/
|
|
45
|
+
issuerUrl: string;
|
|
46
|
+
/** Application / Client ID. */
|
|
47
|
+
clientId: string;
|
|
48
|
+
/**
|
|
49
|
+
* OAuth scopes to request.
|
|
50
|
+
* For Azure managed identity, exactly one scope or resource is required.
|
|
51
|
+
* For example: `["api://{app_id}/.default"]`
|
|
52
|
+
*/
|
|
53
|
+
scopes: string[];
|
|
54
|
+
/** Authentication flow (default: ClientCredentials). */
|
|
55
|
+
flow?: OAuthFlowType;
|
|
56
|
+
/** Client secret (required for ClientCredentials). */
|
|
57
|
+
clientSecret?: string;
|
|
58
|
+
/** Client ID for user-assigned managed identity (AzureManagedIdentity). */
|
|
59
|
+
managedIdentityClientId?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Seconds before expiry to trigger proactive refresh (default: 300).
|
|
62
|
+
* Keep this well below the token TTL; if it is greater than or equal to
|
|
63
|
+
* the TTL, each request refreshes the token.
|
|
64
|
+
*/
|
|
65
|
+
refreshBufferSecs?: number;
|
|
66
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.OAuthFlowType = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* OAuth authentication flow types.
|
|
8
|
+
*/
|
|
9
|
+
var OAuthFlowType;
|
|
10
|
+
(function (OAuthFlowType) {
|
|
11
|
+
/** Client Credentials grant (service-to-service / M2M). */
|
|
12
|
+
OAuthFlowType["ClientCredentials"] = "client_credentials";
|
|
13
|
+
/** Azure Managed Identity via IMDS. */
|
|
14
|
+
OAuthFlowType["AzureManagedIdentity"] = "azure_managed_identity";
|
|
15
|
+
})(OAuthFlowType || (exports.OAuthFlowType = OAuthFlowType = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type MeterProvider } from "@opentelemetry/api";
|
|
2
|
+
/**
|
|
3
|
+
* Register LanceDB metrics as OpenTelemetry observable instruments.
|
|
4
|
+
*
|
|
5
|
+
* Installs a process-global metrics recorder and creates one observable
|
|
6
|
+
* instrument per LanceDB metric (currently object store request counts, bytes,
|
|
7
|
+
* latency, errors, and throttles) on the given (or global) `MeterProvider`. The
|
|
8
|
+
* configured `MetricReader` then collects them on its own schedule.
|
|
9
|
+
*
|
|
10
|
+
* Counters and gauges map directly to observable counters/gauges. Because
|
|
11
|
+
* OpenTelemetry has no asynchronous histogram instrument, each histogram is
|
|
12
|
+
* exported Prometheus-style as cumulative `le` bucket counts (`<name>_bucket`,
|
|
13
|
+
* with an `le` attribute) plus `<name>_count` and `<name>_sum`.
|
|
14
|
+
*
|
|
15
|
+
* Requires `@opentelemetry/api` (a dependency) and, to actually export, an
|
|
16
|
+
* OpenTelemetry SDK such as `@opentelemetry/sdk-metrics`.
|
|
17
|
+
*
|
|
18
|
+
* @param meterProvider The provider to register instruments on. Defaults to the
|
|
19
|
+
* global provider from `@opentelemetry/api`.
|
|
20
|
+
* @returns `true` if the recorder is installed and instruments are registered.
|
|
21
|
+
* `false` if a different `metrics` recorder is already installed in this
|
|
22
|
+
* process (only one global recorder is permitted), in which case a warning is
|
|
23
|
+
* emitted and no instruments are created. Calling this more than once is safe;
|
|
24
|
+
* instruments are created only on the first successful call.
|
|
25
|
+
*/
|
|
26
|
+
export declare function instrumentLanceDbMetrics(meterProvider?: MeterProvider): boolean;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.instrumentLanceDbMetrics = instrumentLanceDbMetrics;
|
|
6
|
+
const api_1 = require("@opentelemetry/api");
|
|
7
|
+
const native_1 = require("./native");
|
|
8
|
+
let instrumented = false;
|
|
9
|
+
/**
|
|
10
|
+
* Register LanceDB metrics as OpenTelemetry observable instruments.
|
|
11
|
+
*
|
|
12
|
+
* Installs a process-global metrics recorder and creates one observable
|
|
13
|
+
* instrument per LanceDB metric (currently object store request counts, bytes,
|
|
14
|
+
* latency, errors, and throttles) on the given (or global) `MeterProvider`. The
|
|
15
|
+
* configured `MetricReader` then collects them on its own schedule.
|
|
16
|
+
*
|
|
17
|
+
* Counters and gauges map directly to observable counters/gauges. Because
|
|
18
|
+
* OpenTelemetry has no asynchronous histogram instrument, each histogram is
|
|
19
|
+
* exported Prometheus-style as cumulative `le` bucket counts (`<name>_bucket`,
|
|
20
|
+
* with an `le` attribute) plus `<name>_count` and `<name>_sum`.
|
|
21
|
+
*
|
|
22
|
+
* Requires `@opentelemetry/api` (a dependency) and, to actually export, an
|
|
23
|
+
* OpenTelemetry SDK such as `@opentelemetry/sdk-metrics`.
|
|
24
|
+
*
|
|
25
|
+
* @param meterProvider The provider to register instruments on. Defaults to the
|
|
26
|
+
* global provider from `@opentelemetry/api`.
|
|
27
|
+
* @returns `true` if the recorder is installed and instruments are registered.
|
|
28
|
+
* `false` if a different `metrics` recorder is already installed in this
|
|
29
|
+
* process (only one global recorder is permitted), in which case a warning is
|
|
30
|
+
* emitted and no instruments are created. Calling this more than once is safe;
|
|
31
|
+
* instruments are created only on the first successful call.
|
|
32
|
+
*/
|
|
33
|
+
function instrumentLanceDbMetrics(meterProvider) {
|
|
34
|
+
if (!(0, native_1.registerLancedbMetricsRecorder)()) {
|
|
35
|
+
console.warn("Could not install the LanceDB metrics recorder: another `metrics` " +
|
|
36
|
+
"recorder is already installed in this process. LanceDB metrics will " +
|
|
37
|
+
"not be exported via OpenTelemetry.");
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (instrumented) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
const provider = meterProvider ?? api_1.metrics.getMeterProvider();
|
|
44
|
+
const meter = provider.getMeter("lancedb");
|
|
45
|
+
const scalarCallback = (metricName) => (result) => {
|
|
46
|
+
for (const point of (0, native_1.snapshotLancedbMetrics)()) {
|
|
47
|
+
if (point.name === metricName && point.value != null) {
|
|
48
|
+
result.observe(point.value, point.attributes);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const bucketCallback = (metricName) => (result) => {
|
|
53
|
+
for (const point of (0, native_1.snapshotLancedbMetrics)()) {
|
|
54
|
+
if (point.name !== metricName || point.buckets == null) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
for (const bucket of point.buckets) {
|
|
58
|
+
const attributes = {
|
|
59
|
+
...point.attributes,
|
|
60
|
+
le: bucket.le,
|
|
61
|
+
};
|
|
62
|
+
result.observe(bucket.cumulativeCount, attributes);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const fieldCallback = (metricName, field) => (result) => {
|
|
67
|
+
for (const point of (0, native_1.snapshotLancedbMetrics)()) {
|
|
68
|
+
if (point.name !== metricName) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const value = point[field];
|
|
72
|
+
if (value != null) {
|
|
73
|
+
result.observe(value, point.attributes);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
for (const desc of (0, native_1.lancedbMetricsCatalog)()) {
|
|
78
|
+
const unit = desc.unit ?? "";
|
|
79
|
+
if (desc.kind === "counter") {
|
|
80
|
+
const counter = meter.createObservableCounter(desc.name, {
|
|
81
|
+
unit,
|
|
82
|
+
description: desc.description,
|
|
83
|
+
});
|
|
84
|
+
counter.addCallback(scalarCallback(desc.name));
|
|
85
|
+
}
|
|
86
|
+
else if (desc.kind === "gauge") {
|
|
87
|
+
const gauge = meter.createObservableGauge(desc.name, {
|
|
88
|
+
unit,
|
|
89
|
+
description: desc.description,
|
|
90
|
+
});
|
|
91
|
+
gauge.addCallback(scalarCallback(desc.name));
|
|
92
|
+
}
|
|
93
|
+
else if (desc.kind === "histogram") {
|
|
94
|
+
// `_bucket` and `_count` observe cumulative sample counts, not the
|
|
95
|
+
// histogram's measured quantity, so they are unitless; only `_sum`
|
|
96
|
+
// carries the histogram's unit.
|
|
97
|
+
const bucket = meter.createObservableCounter(`${desc.name}_bucket`, {
|
|
98
|
+
description: `${desc.description} (cumulative buckets)`,
|
|
99
|
+
});
|
|
100
|
+
bucket.addCallback(bucketCallback(desc.name));
|
|
101
|
+
const count = meter.createObservableCounter(`${desc.name}_count`, {
|
|
102
|
+
description: `${desc.description} (count)`,
|
|
103
|
+
});
|
|
104
|
+
count.addCallback(fieldCallback(desc.name, "count"));
|
|
105
|
+
const sum = meter.createObservableCounter(`${desc.name}_sum`, {
|
|
106
|
+
unit,
|
|
107
|
+
description: `${desc.description} (sum)`,
|
|
108
|
+
});
|
|
109
|
+
sum.addCallback(fieldCallback(desc.name, "sum"));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
instrumented = true;
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Connection } from "./connection.js";
|
|
2
|
+
import { PermutationBuilder as NativePermutationBuilder, ShuffleOptions, SplitCalculatedOptions, SplitHashOptions, SplitRandomOptions, SplitSequentialOptions } from "./native.js";
|
|
3
|
+
import { Table } from "./table";
|
|
4
|
+
/**
|
|
5
|
+
* A PermutationBuilder for creating data permutations with splits, shuffling, and filtering.
|
|
6
|
+
*
|
|
7
|
+
* This class provides a TypeScript wrapper around the native Rust PermutationBuilder,
|
|
8
|
+
* offering methods to configure data splits, shuffling, and filtering before executing
|
|
9
|
+
* the permutation to create a new table.
|
|
10
|
+
*/
|
|
11
|
+
export declare class PermutationBuilder {
|
|
12
|
+
private inner;
|
|
13
|
+
/**
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
constructor(inner: NativePermutationBuilder);
|
|
17
|
+
/**
|
|
18
|
+
* Configure the permutation to be persisted.
|
|
19
|
+
*
|
|
20
|
+
* @param connection - The connection to persist the permutation to
|
|
21
|
+
* @param tableName - The name of the table to create
|
|
22
|
+
* @returns A new PermutationBuilder instance
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* builder.persist(connection, "permutation_table");
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
persist(connection: Connection, tableName: string): PermutationBuilder;
|
|
29
|
+
/**
|
|
30
|
+
* Configure random splits for the permutation.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Configuration for random splitting
|
|
33
|
+
* @returns A new PermutationBuilder instance
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* // Split by ratios
|
|
37
|
+
* builder.splitRandom({ ratios: [0.7, 0.3], seed: 42 });
|
|
38
|
+
*
|
|
39
|
+
* // Split by counts
|
|
40
|
+
* builder.splitRandom({ counts: [1000, 500], seed: 42 });
|
|
41
|
+
*
|
|
42
|
+
* // Split with fixed size
|
|
43
|
+
* builder.splitRandom({ fixed: 100, seed: 42 });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
splitRandom(options: SplitRandomOptions): PermutationBuilder;
|
|
47
|
+
/**
|
|
48
|
+
* Configure hash-based splits for the permutation.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Configuration for hash-based splitting
|
|
51
|
+
* @returns A new PermutationBuilder instance
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* builder.splitHash({
|
|
55
|
+
* columns: ["user_id"],
|
|
56
|
+
* splitWeights: [70, 30],
|
|
57
|
+
* discardWeight: 0
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
splitHash(options: SplitHashOptions): PermutationBuilder;
|
|
62
|
+
/**
|
|
63
|
+
* Configure sequential splits for the permutation.
|
|
64
|
+
*
|
|
65
|
+
* @param options - Configuration for sequential splitting
|
|
66
|
+
* @returns A new PermutationBuilder instance
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* // Split by ratios
|
|
70
|
+
* builder.splitSequential({ ratios: [0.8, 0.2] });
|
|
71
|
+
*
|
|
72
|
+
* // Split by counts
|
|
73
|
+
* builder.splitSequential({ counts: [800, 200] });
|
|
74
|
+
*
|
|
75
|
+
* // Split with fixed size
|
|
76
|
+
* builder.splitSequential({ fixed: 1000 });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
splitSequential(options: SplitSequentialOptions): PermutationBuilder;
|
|
80
|
+
/**
|
|
81
|
+
* Configure calculated splits for the permutation.
|
|
82
|
+
*
|
|
83
|
+
* @param options - Configuration for calculated splitting
|
|
84
|
+
* @returns A new PermutationBuilder instance
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* builder.splitCalculated({ calculation: "user_id % 3" });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
splitCalculated(options: SplitCalculatedOptions): PermutationBuilder;
|
|
91
|
+
/**
|
|
92
|
+
* Configure shuffling for the permutation.
|
|
93
|
+
*
|
|
94
|
+
* @param options - Configuration for shuffling
|
|
95
|
+
* @returns A new PermutationBuilder instance
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* // Basic shuffle
|
|
99
|
+
* builder.shuffle({ seed: 42 });
|
|
100
|
+
*
|
|
101
|
+
* // Shuffle with clump size
|
|
102
|
+
* builder.shuffle({ seed: 42, clumpSize: 10 });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
shuffle(options: ShuffleOptions): PermutationBuilder;
|
|
106
|
+
/**
|
|
107
|
+
* Configure filtering for the permutation.
|
|
108
|
+
*
|
|
109
|
+
* @param filter - SQL filter expression
|
|
110
|
+
* @returns A new PermutationBuilder instance
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* builder.filter("age > 18 AND status = 'active'");
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
filter(filter: string): PermutationBuilder;
|
|
117
|
+
/**
|
|
118
|
+
* Execute the permutation and create the destination table.
|
|
119
|
+
*
|
|
120
|
+
* @returns A Promise that resolves to the new Table instance
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const permutationTable = await builder.execute();
|
|
124
|
+
* console.log(`Created table: ${permutationTable.name}`);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
execute(): Promise<Table>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a permutation builder for the given table.
|
|
131
|
+
*
|
|
132
|
+
* @param table - The source table to create a permutation from
|
|
133
|
+
* @returns A PermutationBuilder instance
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const builder = permutationBuilder(sourceTable, "training_data")
|
|
137
|
+
* .splitRandom({ ratios: [0.8, 0.2], seed: 42 })
|
|
138
|
+
* .shuffle({ seed: 123 });
|
|
139
|
+
*
|
|
140
|
+
* const trainingTable = await builder.execute();
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export declare function permutationBuilder(table: Table): PermutationBuilder;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.PermutationBuilder = void 0;
|
|
6
|
+
exports.permutationBuilder = permutationBuilder;
|
|
7
|
+
const native_js_1 = require("./native.js");
|
|
8
|
+
const table_1 = require("./table");
|
|
9
|
+
/**
|
|
10
|
+
* A PermutationBuilder for creating data permutations with splits, shuffling, and filtering.
|
|
11
|
+
*
|
|
12
|
+
* This class provides a TypeScript wrapper around the native Rust PermutationBuilder,
|
|
13
|
+
* offering methods to configure data splits, shuffling, and filtering before executing
|
|
14
|
+
* the permutation to create a new table.
|
|
15
|
+
*/
|
|
16
|
+
class PermutationBuilder {
|
|
17
|
+
inner;
|
|
18
|
+
/**
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
constructor(inner) {
|
|
22
|
+
this.inner = inner;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Configure the permutation to be persisted.
|
|
26
|
+
*
|
|
27
|
+
* @param connection - The connection to persist the permutation to
|
|
28
|
+
* @param tableName - The name of the table to create
|
|
29
|
+
* @returns A new PermutationBuilder instance
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* builder.persist(connection, "permutation_table");
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
persist(connection, tableName) {
|
|
36
|
+
const localConnection = connection;
|
|
37
|
+
const newInner = this.inner.persist(localConnection.inner, tableName);
|
|
38
|
+
return new PermutationBuilder(newInner);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configure random splits for the permutation.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Configuration for random splitting
|
|
44
|
+
* @returns A new PermutationBuilder instance
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* // Split by ratios
|
|
48
|
+
* builder.splitRandom({ ratios: [0.7, 0.3], seed: 42 });
|
|
49
|
+
*
|
|
50
|
+
* // Split by counts
|
|
51
|
+
* builder.splitRandom({ counts: [1000, 500], seed: 42 });
|
|
52
|
+
*
|
|
53
|
+
* // Split with fixed size
|
|
54
|
+
* builder.splitRandom({ fixed: 100, seed: 42 });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
splitRandom(options) {
|
|
58
|
+
const newInner = this.inner.splitRandom(options);
|
|
59
|
+
return new PermutationBuilder(newInner);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Configure hash-based splits for the permutation.
|
|
63
|
+
*
|
|
64
|
+
* @param options - Configuration for hash-based splitting
|
|
65
|
+
* @returns A new PermutationBuilder instance
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* builder.splitHash({
|
|
69
|
+
* columns: ["user_id"],
|
|
70
|
+
* splitWeights: [70, 30],
|
|
71
|
+
* discardWeight: 0
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
splitHash(options) {
|
|
76
|
+
const newInner = this.inner.splitHash(options);
|
|
77
|
+
return new PermutationBuilder(newInner);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Configure sequential splits for the permutation.
|
|
81
|
+
*
|
|
82
|
+
* @param options - Configuration for sequential splitting
|
|
83
|
+
* @returns A new PermutationBuilder instance
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* // Split by ratios
|
|
87
|
+
* builder.splitSequential({ ratios: [0.8, 0.2] });
|
|
88
|
+
*
|
|
89
|
+
* // Split by counts
|
|
90
|
+
* builder.splitSequential({ counts: [800, 200] });
|
|
91
|
+
*
|
|
92
|
+
* // Split with fixed size
|
|
93
|
+
* builder.splitSequential({ fixed: 1000 });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
splitSequential(options) {
|
|
97
|
+
const newInner = this.inner.splitSequential(options);
|
|
98
|
+
return new PermutationBuilder(newInner);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Configure calculated splits for the permutation.
|
|
102
|
+
*
|
|
103
|
+
* @param options - Configuration for calculated splitting
|
|
104
|
+
* @returns A new PermutationBuilder instance
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* builder.splitCalculated({ calculation: "user_id % 3" });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
splitCalculated(options) {
|
|
111
|
+
const newInner = this.inner.splitCalculated(options);
|
|
112
|
+
return new PermutationBuilder(newInner);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Configure shuffling for the permutation.
|
|
116
|
+
*
|
|
117
|
+
* @param options - Configuration for shuffling
|
|
118
|
+
* @returns A new PermutationBuilder instance
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* // Basic shuffle
|
|
122
|
+
* builder.shuffle({ seed: 42 });
|
|
123
|
+
*
|
|
124
|
+
* // Shuffle with clump size
|
|
125
|
+
* builder.shuffle({ seed: 42, clumpSize: 10 });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
shuffle(options) {
|
|
129
|
+
const newInner = this.inner.shuffle(options);
|
|
130
|
+
return new PermutationBuilder(newInner);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Configure filtering for the permutation.
|
|
134
|
+
*
|
|
135
|
+
* @param filter - SQL filter expression
|
|
136
|
+
* @returns A new PermutationBuilder instance
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* builder.filter("age > 18 AND status = 'active'");
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
filter(filter) {
|
|
143
|
+
const newInner = this.inner.filter(filter);
|
|
144
|
+
return new PermutationBuilder(newInner);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Execute the permutation and create the destination table.
|
|
148
|
+
*
|
|
149
|
+
* @returns A Promise that resolves to the new Table instance
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const permutationTable = await builder.execute();
|
|
153
|
+
* console.log(`Created table: ${permutationTable.name}`);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
async execute() {
|
|
157
|
+
const nativeTable = await this.inner.execute();
|
|
158
|
+
return new table_1.LocalTable(nativeTable);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.PermutationBuilder = PermutationBuilder;
|
|
162
|
+
/**
|
|
163
|
+
* Create a permutation builder for the given table.
|
|
164
|
+
*
|
|
165
|
+
* @param table - The source table to create a permutation from
|
|
166
|
+
* @returns A PermutationBuilder instance
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* const builder = permutationBuilder(sourceTable, "training_data")
|
|
170
|
+
* .splitRandom({ ratios: [0.8, 0.2], seed: 42 })
|
|
171
|
+
* .shuffle({ seed: 123 });
|
|
172
|
+
*
|
|
173
|
+
* const trainingTable = await builder.execute();
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
function permutationBuilder(table) {
|
|
177
|
+
// Extract the inner native table from the TypeScript wrapper
|
|
178
|
+
const localTable = table;
|
|
179
|
+
// Access inner through type assertion since it's private
|
|
180
|
+
const nativeBuilder = (0, native_js_1.permutationBuilder)(
|
|
181
|
+
// biome-ignore lint/suspicious/noExplicitAny: need access to private variable
|
|
182
|
+
localTable.inner);
|
|
183
|
+
return new PermutationBuilder(nativeBuilder);
|
|
184
|
+
}
|