taurusdb-core 0.5.0-rc.2 → 0.5.0-rc.3
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/config/env.js +2 -1
- package/dist/config/schema.d.ts +10 -5
- package/dist/config/schema.js +2 -1
- package/dist/engine.d.ts +1 -4
- package/dist/engine.js +1 -10
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/safety/sql-validator.js +1 -1
- package/package.json +1 -1
package/dist/config/env.js
CHANGED
|
@@ -160,11 +160,12 @@ export function buildRawConfigFromEnv(env) {
|
|
|
160
160
|
maxFiles: parseInteger(env.TAURUSDB_MCP_AUDIT_MAX_FILES, "TAURUSDB_MCP_AUDIT_MAX_FILES"),
|
|
161
161
|
},
|
|
162
162
|
security: {
|
|
163
|
-
mutationsEnabled: parseBoolean(env.TAURUSDB_ENABLE_MUTATIONS, "TAURUSDB_ENABLE_MUTATIONS"),
|
|
164
163
|
dynamicTargetsEnabled: parseBoolean(env.TAURUSDB_ENABLE_DYNAMIC_TARGETS, "TAURUSDB_ENABLE_DYNAMIC_TARGETS"),
|
|
165
164
|
requireTls: parseBoolean(env.TAURUSDB_REQUIRE_TLS, "TAURUSDB_REQUIRE_TLS"),
|
|
166
165
|
approvalSecretPath: expandTildePath(readString(env.TAURUSDB_MUTATION_APPROVAL_SECRET_FILE)),
|
|
167
166
|
approvalTtlSeconds: parseInteger(env.TAURUSDB_MUTATION_APPROVAL_TTL_SECONDS, "TAURUSDB_MUTATION_APPROVAL_TTL_SECONDS"),
|
|
167
|
+
credentialIdleTtlMinutes: parseInteger(env.TAURUSDB_SQL_CREDENTIAL_IDLE_TTL_MINUTES, "TAURUSDB_SQL_CREDENTIAL_IDLE_TTL_MINUTES"),
|
|
168
|
+
credentialMaxTtlMinutes: parseInteger(env.TAURUSDB_SQL_CREDENTIAL_MAX_TTL_MINUTES, "TAURUSDB_SQL_CREDENTIAL_MAX_TTL_MINUTES"),
|
|
168
169
|
},
|
|
169
170
|
slowSqlSource: {
|
|
170
171
|
taurusApi: {
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -105,23 +105,26 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
105
105
|
maxFiles?: number | undefined;
|
|
106
106
|
}>>;
|
|
107
107
|
security: z.ZodDefault<z.ZodObject<{
|
|
108
|
-
mutationsEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
109
108
|
dynamicTargetsEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
110
109
|
requireTls: z.ZodDefault<z.ZodBoolean>;
|
|
111
110
|
approvalSecretPath: z.ZodOptional<z.ZodString>;
|
|
112
111
|
approvalTtlSeconds: z.ZodDefault<z.ZodNumber>;
|
|
112
|
+
credentialIdleTtlMinutes: z.ZodDefault<z.ZodNumber>;
|
|
113
|
+
credentialMaxTtlMinutes: z.ZodDefault<z.ZodNumber>;
|
|
113
114
|
}, "strip", z.ZodTypeAny, {
|
|
114
|
-
mutationsEnabled: boolean;
|
|
115
115
|
dynamicTargetsEnabled: boolean;
|
|
116
116
|
requireTls: boolean;
|
|
117
117
|
approvalTtlSeconds: number;
|
|
118
|
+
credentialIdleTtlMinutes: number;
|
|
119
|
+
credentialMaxTtlMinutes: number;
|
|
118
120
|
approvalSecretPath?: string | undefined;
|
|
119
121
|
}, {
|
|
120
|
-
mutationsEnabled?: boolean | undefined;
|
|
121
122
|
dynamicTargetsEnabled?: boolean | undefined;
|
|
122
123
|
requireTls?: boolean | undefined;
|
|
123
124
|
approvalSecretPath?: string | undefined;
|
|
124
125
|
approvalTtlSeconds?: number | undefined;
|
|
126
|
+
credentialIdleTtlMinutes?: number | undefined;
|
|
127
|
+
credentialMaxTtlMinutes?: number | undefined;
|
|
125
128
|
}>>;
|
|
126
129
|
slowSqlSource: z.ZodDefault<z.ZodObject<{
|
|
127
130
|
taurusApi: z.ZodDefault<z.ZodObject<{
|
|
@@ -358,10 +361,11 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
358
361
|
maxFiles: number;
|
|
359
362
|
};
|
|
360
363
|
security: {
|
|
361
|
-
mutationsEnabled: boolean;
|
|
362
364
|
dynamicTargetsEnabled: boolean;
|
|
363
365
|
requireTls: boolean;
|
|
364
366
|
approvalTtlSeconds: number;
|
|
367
|
+
credentialIdleTtlMinutes: number;
|
|
368
|
+
credentialMaxTtlMinutes: number;
|
|
365
369
|
approvalSecretPath?: string | undefined;
|
|
366
370
|
};
|
|
367
371
|
slowSqlSource: {
|
|
@@ -449,11 +453,12 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
449
453
|
maxFiles?: number | undefined;
|
|
450
454
|
} | undefined;
|
|
451
455
|
security?: {
|
|
452
|
-
mutationsEnabled?: boolean | undefined;
|
|
453
456
|
dynamicTargetsEnabled?: boolean | undefined;
|
|
454
457
|
requireTls?: boolean | undefined;
|
|
455
458
|
approvalSecretPath?: string | undefined;
|
|
456
459
|
approvalTtlSeconds?: number | undefined;
|
|
460
|
+
credentialIdleTtlMinutes?: number | undefined;
|
|
461
|
+
credentialMaxTtlMinutes?: number | undefined;
|
|
457
462
|
} | undefined;
|
|
458
463
|
slowSqlSource?: {
|
|
459
464
|
taurusApi?: {
|
package/dist/config/schema.js
CHANGED
|
@@ -22,11 +22,12 @@ const AuditSchema = z
|
|
|
22
22
|
.default({});
|
|
23
23
|
const SecuritySchema = z
|
|
24
24
|
.object({
|
|
25
|
-
mutationsEnabled: z.boolean().default(false),
|
|
26
25
|
dynamicTargetsEnabled: z.boolean().default(false),
|
|
27
26
|
requireTls: z.boolean().default(true),
|
|
28
27
|
approvalSecretPath: z.string().min(1).optional(),
|
|
29
28
|
approvalTtlSeconds: z.number().int().positive().max(3600).default(300),
|
|
29
|
+
credentialIdleTtlMinutes: z.number().int().positive().max(30).default(30),
|
|
30
|
+
credentialMaxTtlMinutes: z.number().int().positive().max(480).default(480),
|
|
30
31
|
})
|
|
31
32
|
.default({});
|
|
32
33
|
const CloudSchema = z
|
package/dist/engine.d.ts
CHANGED
|
@@ -5,12 +5,11 @@ import type { CapabilitySnapshot, FeatureMatrix, KernelInfo } from "./capability
|
|
|
5
5
|
import { type Config } from "./config/index.js";
|
|
6
6
|
import type { DatasourceResolveInput, DatasourceResolver, SessionContext } from "./context/session-context.js";
|
|
7
7
|
import { type ConnectionPool } from "./executor/connection-pool.js";
|
|
8
|
-
import { type CancelResult, type ExplainResult, type
|
|
8
|
+
import { type CancelResult, type ExplainResult, type QueryResult, type QueryStatus, type ReadonlyOptions, type SqlExecutor } from "./executor/sql-executor.js";
|
|
9
9
|
import { type ConfirmationStore, type ConfirmationRequest, type ConfirmationValidationResult } from "./safety/confirmation-store.js";
|
|
10
10
|
import { type Guardrail, type GuardrailDecision, type InspectInput } from "./safety/guardrail.js";
|
|
11
11
|
import { type DatabaseInfo, type SchemaIntrospector, type TableInfo, type TableSchema } from "./schema/introspector.js";
|
|
12
12
|
import { type FlashbackInput } from "./taurus/flashback.js";
|
|
13
|
-
import { type RestoreRecycleBinTableInput } from "./taurus/recycle-bin.js";
|
|
14
13
|
import { type DbHotspotResult, type DiagnoseDbHotspotInput, type DiagnoseServiceLatencyInput, type FindTopSlowSqlInput, type FindTopSlowSqlResult, type DiagnoseConnectionSpikeInput, type DiagnoseLockContentionInput, type DiagnoseSlowQueryInput, type DiagnoseStoragePressureInput, type DiagnoseReplicationLagInput, type DiagnosticResult, type ServiceLatencyResult } from "./diagnostics/types.js";
|
|
15
14
|
import { type SlowSqlSource } from "./diagnostics/slow-sql-source.js";
|
|
16
15
|
import { type MetricsSource } from "./diagnostics/metrics-source.js";
|
|
@@ -65,10 +64,8 @@ export declare class TaurusDBEngine {
|
|
|
65
64
|
explain(sql: string, ctx: SessionContext): Promise<ExplainResult>;
|
|
66
65
|
explainEnhanced(sql: string, ctx: SessionContext): Promise<EnhancedExplainResult>;
|
|
67
66
|
executeReadonly(sql: string, ctx: SessionContext, opts?: ReadonlyOptions): Promise<QueryResult>;
|
|
68
|
-
executeMutation(sql: string, ctx: SessionContext, opts?: MutationOptions): Promise<MutationResult>;
|
|
69
67
|
flashbackQuery(input: FlashbackInput, ctx: SessionContext, opts?: ReadonlyOptions): Promise<QueryResult>;
|
|
70
68
|
listRecycleBin(ctx: SessionContext, opts?: ReadonlyOptions): Promise<QueryResult>;
|
|
71
|
-
restoreRecycleBinTable(input: RestoreRecycleBinTableInput, ctx: SessionContext, opts?: MutationOptions): Promise<MutationResult>;
|
|
72
69
|
getQueryStatus(queryId: string): Promise<QueryStatus>;
|
|
73
70
|
cancelQuery(queryId: string): Promise<CancelResult>;
|
|
74
71
|
issueConfirmation(input: IssueConfirmationInput): Promise<ConfirmationRequest>;
|
package/dist/engine.js
CHANGED
|
@@ -18,7 +18,7 @@ import { createSlowSqlSource, } from "./diagnostics/slow-sql-source.js";
|
|
|
18
18
|
import { createMetricsSource, } from "./diagnostics/metrics-source.js";
|
|
19
19
|
import { findLatestDeadlock, findMetadataLockWaits, findStatementDigestCandidatesForSqlHints, findStatementDigestSample, findStatementDigestSampleForSql, findStatementWaitEvents, findStorageStatementDigests, findTableStorageStats, findTopStatementDigests, isPerformanceSchemaEnabled, showLockWaits, showProcesslist, } from "./engine/data-access.js";
|
|
20
20
|
import { diagnoseConnectionSpike, diagnoseDbHotspot, diagnoseLockContention, diagnoseServiceLatency, diagnoseSlowQuery, diagnoseStoragePressure, findTopSlowSql, } from "./engine/diagnostics.js";
|
|
21
|
-
import { cancelQuery, close,
|
|
21
|
+
import { cancelQuery, close, executeReadonly, explain, explainEnhanced, flashbackQuery, getQueryStatus, handleConfirmation, issueConfirmation, listRecycleBin, validateConfirmation, } from "./engine/runtime.js";
|
|
22
22
|
async function readMutationApprovalSecret(filePath) {
|
|
23
23
|
const info = await lstat(filePath);
|
|
24
24
|
if (!info.isFile() || info.isSymbolicLink()) {
|
|
@@ -114,9 +114,6 @@ export class TaurusDBEngine {
|
|
|
114
114
|
if (config.security.approvalSecretPath) {
|
|
115
115
|
approvalSecret = await readMutationApprovalSecret(config.security.approvalSecretPath);
|
|
116
116
|
}
|
|
117
|
-
if (config.security.mutationsEnabled && !approvalSecret && !options.confirmationStore) {
|
|
118
|
-
throw new Error("Mutations require TAURUSDB_MUTATION_APPROVAL_SECRET_FILE with at least 32 bytes.");
|
|
119
|
-
}
|
|
120
117
|
const confirmationStore = options.confirmationStore ??
|
|
121
118
|
createConfirmationStore({
|
|
122
119
|
approvalSecret,
|
|
@@ -248,18 +245,12 @@ export class TaurusDBEngine {
|
|
|
248
245
|
async executeReadonly(sql, ctx, opts) {
|
|
249
246
|
return executeReadonly(this, sql, ctx, opts);
|
|
250
247
|
}
|
|
251
|
-
async executeMutation(sql, ctx, opts) {
|
|
252
|
-
return executeMutation(this, sql, ctx, opts);
|
|
253
|
-
}
|
|
254
248
|
async flashbackQuery(input, ctx, opts) {
|
|
255
249
|
return flashbackQuery(this, input, ctx, opts);
|
|
256
250
|
}
|
|
257
251
|
async listRecycleBin(ctx, opts) {
|
|
258
252
|
return listRecycleBin(this, ctx, opts);
|
|
259
253
|
}
|
|
260
|
-
async restoreRecycleBinTable(input, ctx, opts) {
|
|
261
|
-
return restoreRecycleBinTable(this, input, ctx, opts);
|
|
262
|
-
}
|
|
263
254
|
async getQueryStatus(queryId) {
|
|
264
255
|
return getQueryStatus(this, queryId);
|
|
265
256
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export type { CapabilitySnapshot, FeatureMatrix, FeatureStatus, KernelInfo, Taur
|
|
|
18
18
|
export { createConfirmationStore, InMemoryConfirmationStore, parseApprovalRequest, signApprovalRequest, } from "./safety/confirmation-store.js";
|
|
19
19
|
export type { ConfirmationStore, ConfirmationRequest, ConfirmationValidationResult, IssueInput, } from "./safety/confirmation-store.js";
|
|
20
20
|
export { createGuardrail } from "./safety/guardrail.js";
|
|
21
|
+
export { createSqlParser } from "./safety/parser/index.js";
|
|
22
|
+
export type { SqlAst, StatementType as ParsedStatementType } from "./safety/parser/index.js";
|
|
21
23
|
export type { Guardrail, GuardrailDecision, GuardrailRuntimeLimits, InspectInput, } from "./safety/guardrail.js";
|
|
22
24
|
export type { ExplainRiskSummary, RiskLevel, ValidationResult } from "./safety/sql-validator.js";
|
|
23
25
|
export { SchemaIntrospectionError } from "./schema/introspector.js";
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { createCapabilityProbe } from "./capability/probe.js";
|
|
|
10
10
|
export { UnsupportedFeatureError } from "./capability/types.js";
|
|
11
11
|
export { createConfirmationStore, InMemoryConfirmationStore, parseApprovalRequest, signApprovalRequest, } from "./safety/confirmation-store.js";
|
|
12
12
|
export { createGuardrail } from "./safety/guardrail.js";
|
|
13
|
+
export { createSqlParser } from "./safety/parser/index.js";
|
|
13
14
|
export { SchemaIntrospectionError } from "./schema/introspector.js";
|
|
14
15
|
export { ErrorCode, formatBlocked, formatConfirmationRequired, formatError, formatSuccess, } from "./utils/formatter.js";
|
|
15
16
|
export { normalizeSql, sqlHash } from "./utils/hash.js";
|
|
@@ -54,7 +54,7 @@ export function validateToolScope(toolName, cls) {
|
|
|
54
54
|
if (!READONLY_STATEMENTS.has(cls.statementType)) {
|
|
55
55
|
return block(["T001"], [
|
|
56
56
|
`Tool execute_readonly_sql only allows SELECT/SHOW/EXPLAIN/DESCRIBE, got ${cls.statementType}.`,
|
|
57
|
-
"Use
|
|
57
|
+
"Use analyze_mutation_sql to generate non-executing SQL Advice.",
|
|
58
58
|
]);
|
|
59
59
|
}
|
|
60
60
|
return allow("low");
|