@forg3t/sdk 0.1.5 → 0.1.6

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 CHANGED
@@ -35,6 +35,25 @@ There is now also a live bearer-token bootstrap path for first-time tenant creat
35
35
 
36
36
  This closes the biggest admin-led onboarding gap. The published npm package now includes the bootstrap flow and request-creation surface, but the overall product is still not fully self-serve enterprise onboarding because tenant lifecycle cleanup, whitebox activation, and some runtime specialization paths remain operator-led.
37
37
 
38
+ ## Execution Modes
39
+
40
+ Forg3t now has three materially different execution lanes. Keeping them separate is important:
41
+
42
+ 1. **Managed black-box lane**
43
+ - default baseline path for API-only and retrieval-style first runs
44
+ - request enters via `https://api.forg3t.io`
45
+ - control-plane managed worker claims the job
46
+ - a private executor service runs the black-box workload
47
+ - this is the path verified by the published SDK cleanroom smoke
48
+
49
+ 2. **Customer-scoped generic worker**
50
+ - used when a customer wants execution tied to their own project-scoped worker runtime
51
+ - not the same thing as the default managed black-box lane
52
+
53
+ 3. **Customer-side whitebox worker**
54
+ - required when the customer wants staged model-weight intervention
55
+ - this remains a separate install and acceptance path
56
+
38
57
  ## Local Development
39
58
  1. **Build**: `npm run build`
40
59
  2. **Typecheck**: `node ../../node_modules/typescript/bin/tsc -p tsconfig.json --noEmit`
@@ -63,6 +82,9 @@ This validates:
63
82
  - API key creation
64
83
  - unlearning request creation
65
84
  - request detail fetch
85
+ - terminal job success
86
+ - evidence readiness
87
+ - artifact download readiness
66
88
  - API key revoke
67
89
  - job contract correctness
68
90
  - first-customer path through the public API hostname
@@ -78,7 +100,7 @@ export SUPABASE_ANON_KEY=...
78
100
  npm run smoke:cleanroom
79
101
  ```
80
102
 
81
- This installs the package into a fresh temporary directory, runs bootstrap, creates a first request, fetches request detail, and revokes the temporary API key. It is the release-candidate gate we use before claiming the SDK package is ready to publish.
103
+ This installs the package into a fresh temporary directory, runs bootstrap, creates a first request, verifies terminal job success plus evidence/artifact readiness, and revokes the temporary API key. It is the release-candidate gate we use before claiming the SDK package is ready to publish.
82
104
 
83
105
  ### First-Time Tenant Bootstrap
84
106
 
package/dist/index.d.mts CHANGED
@@ -269,6 +269,8 @@ declare enum IntegrationType {
269
269
  LANGCHAIN = "langchain",
270
270
  OPENROUTER = "openrouter",
271
271
  OPENAI = "openai",
272
+ PGVECTOR = "pgvector",
273
+ ADAPTER = "adapter",
272
274
  CUSTOM = "custom"
273
275
  }
274
276
  declare enum IntegrationMode {
@@ -290,6 +292,29 @@ interface OpenRouterAdapterConfig extends BaseAdapterConfig {
290
292
  routingStrategy: 'cost' | 'latency' | 'quality';
291
293
  fallbackModels?: string[];
292
294
  }
295
+ interface PgVectorIntegrationConfig extends BaseAdapterConfig {
296
+ backend: 'pgvector_postgres';
297
+ schema?: string;
298
+ table: string;
299
+ document_id_column?: string;
300
+ metadata_column?: string;
301
+ metadata_document_id_key?: string;
302
+ content_column?: string;
303
+ embedding_column?: string;
304
+ database_url_env_var?: string;
305
+ healthcheck_url?: string;
306
+ healthcheck_method?: 'GET' | 'POST';
307
+ worker_mode?: 'rag';
308
+ }
309
+ interface AdapterIntegrationConfig extends BaseAdapterConfig {
310
+ backend: 'peft_lora_safetensors';
311
+ format?: 'safetensors';
312
+ adapter_uri?: string;
313
+ adapter_uri_env_var?: string;
314
+ healthcheck_url?: string;
315
+ healthcheck_method?: 'GET' | 'POST';
316
+ worker_mode?: 'adapter';
317
+ }
293
318
  interface Integration {
294
319
  id: string;
295
320
  projectId: string;
@@ -297,7 +322,7 @@ interface Integration {
297
322
  name: string;
298
323
  description?: string;
299
324
  status: 'active' | 'disconnected' | 'error' | 'pending';
300
- config: BaseAdapterConfig | LangChainAdapterConfig | OpenRouterAdapterConfig | Record<string, unknown>;
325
+ config: BaseAdapterConfig | LangChainAdapterConfig | OpenRouterAdapterConfig | PgVectorIntegrationConfig | AdapterIntegrationConfig | Record<string, unknown>;
301
326
  capabilities: string[];
302
327
  createdAt: string;
303
328
  updatedAt: string;
@@ -353,9 +378,29 @@ interface UnlearningExecutionTargetSpec {
353
378
  responsePath?: string;
354
379
  apiKey?: string;
355
380
  }
381
+ interface UnlearningExecutionRagSpec {
382
+ backend: 'pgvector_postgres';
383
+ mode?: 'delete_documents';
384
+ integrationId?: string;
385
+ dryRun?: boolean;
386
+ }
387
+ interface UnlearningExecutionAdapterSpec {
388
+ backend: 'peft_lora_safetensors';
389
+ integrationId?: string;
390
+ method?: 'disable_adapter' | 'attenuate_adapter';
391
+ scaleFactor?: number;
392
+ dryRun?: boolean;
393
+ updatedAdapterUri?: string;
394
+ }
395
+ interface UnlearningExecutionRoutingSpec {
396
+ lane?: 'managed' | 'project_scoped';
397
+ }
356
398
  interface UnlearningExecutionSpec {
357
399
  target?: UnlearningExecutionTargetSpec;
400
+ rag?: UnlearningExecutionRagSpec;
401
+ adapter?: UnlearningExecutionAdapterSpec;
358
402
  model?: UnlearningExecutionModelRef;
403
+ routing?: UnlearningExecutionRoutingSpec;
359
404
  plan?: UnlearningExecutionPlanSpec;
360
405
  }
361
406
  interface UnlearningJobSummary {
@@ -480,6 +525,7 @@ declare class Forg3tClient {
480
525
  }, requestId?: string): Promise<void>;
481
526
  private assertCreateUnlearningRequest;
482
527
  private assertModelUnlearnPreflight;
528
+ private assertAdapterUnlearnPreflight;
483
529
  }
484
530
 
485
531
  declare class Forg3tError extends Error {
@@ -759,4 +805,4 @@ declare const ENTERPRISE_STRICT_QUALITY_GATE_POLICY: Required<WhiteboxQualityGat
759
805
  declare function assertDeploymentCompatibility(options: DeploymentCompatibilityOptions): void;
760
806
  declare function buildWhiteboxWorkerOptions(profile: Forg3tDeploymentProfile, baseOptions: WhiteboxWorkerBaseOptions): WhiteboxWorkerOptions;
761
807
 
762
- export { AccessLevel, type AdapterCommandSpec, type ApiKey, type AuditEvent, type AuditEventFilters, type AuditEventListResponse, type BaseAdapterConfig, type BootstrapTenantRequest, type BootstrapTenantResponse, type BuildModelUnlearningJobInput, type ClaimAssertion, type ClaimJobsRequest, type ClaimScope, type ClaimType, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateIntegrationRequest, type CreateUnlearningRequestParams, type CreateWebhookRequest, type CurrentUserResponse, DEFAULT_WHITEBOX_QUALITY_GATE_POLICY, type DeploymentCompatibilityOptions, ENTERPRISE_STRICT_QUALITY_GATE_POLICY, type EvidenceArtifact, type EvidencePdfResponse, type EvidenceStatusResponse, type ExecutionPlan, type ExecutionStep, type Forg3tAdapterMode, Forg3tApiConnectionError, Forg3tAuthenticationError, Forg3tClient, type Forg3tClientOptions, type Forg3tDeploymentProfile, Forg3tError, Forg3tNotFoundError, Forg3tNotImplementedError, Forg3tRateLimitError, HttpTrainingAdapter, type HttpTrainingAdapterOptions, type Integration, IntegrationMode, IntegrationType, type Job, type JobConfig, type JobError, type JobMutationOptions, type JobResult, type JobStatus, type JobType, type LangChainAdapterConfig, type LocalCommandAdapterOptions, LocalCommandTrainingAdapter, type ModelArtifactReference, type NativeAdapterConfig, type OpenRouterAdapterConfig, type PaginationParams, type Project, type RevokeApiKeyResponse, type SubmitJobRequest, type TrainingBackendAdapter, type UnlearningClaim, type UnlearningExecutionModelRef, type UnlearningExecutionPlanSpec, type UnlearningExecutionSpec, type UnlearningExecutionTargetSpec, type UnlearningJobSummary, type UnlearningRequest, type UnlearningScope, type UnlearningTarget, type UpdateWebhookRequest, WHITEBOX_QUALITY_GATE_PRESETS, WHITEBOX_QUALITY_GATE_PRESET_EXPLANATIONS, type Webhook, type WebhookDelivery, type WebhookDeliveryFilters, type WhiteboxEvaluationInput, type WhiteboxEvaluationOutput, type WhiteboxJobContext, type WhiteboxQualityGateDecision, type WhiteboxQualityGatePolicy, type WhiteboxQualityGatePreset, type WhiteboxTargetSpec, type WhiteboxUnlearningInput, type WhiteboxUnlearningOutput, type WhiteboxUnlearningPlan, WhiteboxWorker, type WhiteboxWorkerBaseOptions, type WhiteboxWorkerLogger, type WhiteboxWorkerOptions, assertDeploymentCompatibility, buildModelUnlearningPayload, buildWhiteboxWorkerOptions, createNativeTrainingAdapter, evaluateWhiteboxQualityGate, resolveWhiteboxQualityGatePolicy };
808
+ export { AccessLevel, type AdapterCommandSpec, type AdapterIntegrationConfig, type ApiKey, type AuditEvent, type AuditEventFilters, type AuditEventListResponse, type BaseAdapterConfig, type BootstrapTenantRequest, type BootstrapTenantResponse, type BuildModelUnlearningJobInput, type ClaimAssertion, type ClaimJobsRequest, type ClaimScope, type ClaimType, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateIntegrationRequest, type CreateUnlearningRequestParams, type CreateWebhookRequest, type CurrentUserResponse, DEFAULT_WHITEBOX_QUALITY_GATE_POLICY, type DeploymentCompatibilityOptions, ENTERPRISE_STRICT_QUALITY_GATE_POLICY, type EvidenceArtifact, type EvidencePdfResponse, type EvidenceStatusResponse, type ExecutionPlan, type ExecutionStep, type Forg3tAdapterMode, Forg3tApiConnectionError, Forg3tAuthenticationError, Forg3tClient, type Forg3tClientOptions, type Forg3tDeploymentProfile, Forg3tError, Forg3tNotFoundError, Forg3tNotImplementedError, Forg3tRateLimitError, HttpTrainingAdapter, type HttpTrainingAdapterOptions, type Integration, IntegrationMode, IntegrationType, type Job, type JobConfig, type JobError, type JobMutationOptions, type JobResult, type JobStatus, type JobType, type LangChainAdapterConfig, type LocalCommandAdapterOptions, LocalCommandTrainingAdapter, type ModelArtifactReference, type NativeAdapterConfig, type OpenRouterAdapterConfig, type PaginationParams, type PgVectorIntegrationConfig, type Project, type RevokeApiKeyResponse, type SubmitJobRequest, type TrainingBackendAdapter, type UnlearningClaim, type UnlearningExecutionAdapterSpec, type UnlearningExecutionModelRef, type UnlearningExecutionPlanSpec, type UnlearningExecutionRagSpec, type UnlearningExecutionRoutingSpec, type UnlearningExecutionSpec, type UnlearningExecutionTargetSpec, type UnlearningJobSummary, type UnlearningRequest, type UnlearningScope, type UnlearningTarget, type UpdateWebhookRequest, WHITEBOX_QUALITY_GATE_PRESETS, WHITEBOX_QUALITY_GATE_PRESET_EXPLANATIONS, type Webhook, type WebhookDelivery, type WebhookDeliveryFilters, type WhiteboxEvaluationInput, type WhiteboxEvaluationOutput, type WhiteboxJobContext, type WhiteboxQualityGateDecision, type WhiteboxQualityGatePolicy, type WhiteboxQualityGatePreset, type WhiteboxTargetSpec, type WhiteboxUnlearningInput, type WhiteboxUnlearningOutput, type WhiteboxUnlearningPlan, WhiteboxWorker, type WhiteboxWorkerBaseOptions, type WhiteboxWorkerLogger, type WhiteboxWorkerOptions, assertDeploymentCompatibility, buildModelUnlearningPayload, buildWhiteboxWorkerOptions, createNativeTrainingAdapter, evaluateWhiteboxQualityGate, resolveWhiteboxQualityGatePolicy };
package/dist/index.d.ts CHANGED
@@ -269,6 +269,8 @@ declare enum IntegrationType {
269
269
  LANGCHAIN = "langchain",
270
270
  OPENROUTER = "openrouter",
271
271
  OPENAI = "openai",
272
+ PGVECTOR = "pgvector",
273
+ ADAPTER = "adapter",
272
274
  CUSTOM = "custom"
273
275
  }
274
276
  declare enum IntegrationMode {
@@ -290,6 +292,29 @@ interface OpenRouterAdapterConfig extends BaseAdapterConfig {
290
292
  routingStrategy: 'cost' | 'latency' | 'quality';
291
293
  fallbackModels?: string[];
292
294
  }
295
+ interface PgVectorIntegrationConfig extends BaseAdapterConfig {
296
+ backend: 'pgvector_postgres';
297
+ schema?: string;
298
+ table: string;
299
+ document_id_column?: string;
300
+ metadata_column?: string;
301
+ metadata_document_id_key?: string;
302
+ content_column?: string;
303
+ embedding_column?: string;
304
+ database_url_env_var?: string;
305
+ healthcheck_url?: string;
306
+ healthcheck_method?: 'GET' | 'POST';
307
+ worker_mode?: 'rag';
308
+ }
309
+ interface AdapterIntegrationConfig extends BaseAdapterConfig {
310
+ backend: 'peft_lora_safetensors';
311
+ format?: 'safetensors';
312
+ adapter_uri?: string;
313
+ adapter_uri_env_var?: string;
314
+ healthcheck_url?: string;
315
+ healthcheck_method?: 'GET' | 'POST';
316
+ worker_mode?: 'adapter';
317
+ }
293
318
  interface Integration {
294
319
  id: string;
295
320
  projectId: string;
@@ -297,7 +322,7 @@ interface Integration {
297
322
  name: string;
298
323
  description?: string;
299
324
  status: 'active' | 'disconnected' | 'error' | 'pending';
300
- config: BaseAdapterConfig | LangChainAdapterConfig | OpenRouterAdapterConfig | Record<string, unknown>;
325
+ config: BaseAdapterConfig | LangChainAdapterConfig | OpenRouterAdapterConfig | PgVectorIntegrationConfig | AdapterIntegrationConfig | Record<string, unknown>;
301
326
  capabilities: string[];
302
327
  createdAt: string;
303
328
  updatedAt: string;
@@ -353,9 +378,29 @@ interface UnlearningExecutionTargetSpec {
353
378
  responsePath?: string;
354
379
  apiKey?: string;
355
380
  }
381
+ interface UnlearningExecutionRagSpec {
382
+ backend: 'pgvector_postgres';
383
+ mode?: 'delete_documents';
384
+ integrationId?: string;
385
+ dryRun?: boolean;
386
+ }
387
+ interface UnlearningExecutionAdapterSpec {
388
+ backend: 'peft_lora_safetensors';
389
+ integrationId?: string;
390
+ method?: 'disable_adapter' | 'attenuate_adapter';
391
+ scaleFactor?: number;
392
+ dryRun?: boolean;
393
+ updatedAdapterUri?: string;
394
+ }
395
+ interface UnlearningExecutionRoutingSpec {
396
+ lane?: 'managed' | 'project_scoped';
397
+ }
356
398
  interface UnlearningExecutionSpec {
357
399
  target?: UnlearningExecutionTargetSpec;
400
+ rag?: UnlearningExecutionRagSpec;
401
+ adapter?: UnlearningExecutionAdapterSpec;
358
402
  model?: UnlearningExecutionModelRef;
403
+ routing?: UnlearningExecutionRoutingSpec;
359
404
  plan?: UnlearningExecutionPlanSpec;
360
405
  }
361
406
  interface UnlearningJobSummary {
@@ -480,6 +525,7 @@ declare class Forg3tClient {
480
525
  }, requestId?: string): Promise<void>;
481
526
  private assertCreateUnlearningRequest;
482
527
  private assertModelUnlearnPreflight;
528
+ private assertAdapterUnlearnPreflight;
483
529
  }
484
530
 
485
531
  declare class Forg3tError extends Error {
@@ -759,4 +805,4 @@ declare const ENTERPRISE_STRICT_QUALITY_GATE_POLICY: Required<WhiteboxQualityGat
759
805
  declare function assertDeploymentCompatibility(options: DeploymentCompatibilityOptions): void;
760
806
  declare function buildWhiteboxWorkerOptions(profile: Forg3tDeploymentProfile, baseOptions: WhiteboxWorkerBaseOptions): WhiteboxWorkerOptions;
761
807
 
762
- export { AccessLevel, type AdapterCommandSpec, type ApiKey, type AuditEvent, type AuditEventFilters, type AuditEventListResponse, type BaseAdapterConfig, type BootstrapTenantRequest, type BootstrapTenantResponse, type BuildModelUnlearningJobInput, type ClaimAssertion, type ClaimJobsRequest, type ClaimScope, type ClaimType, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateIntegrationRequest, type CreateUnlearningRequestParams, type CreateWebhookRequest, type CurrentUserResponse, DEFAULT_WHITEBOX_QUALITY_GATE_POLICY, type DeploymentCompatibilityOptions, ENTERPRISE_STRICT_QUALITY_GATE_POLICY, type EvidenceArtifact, type EvidencePdfResponse, type EvidenceStatusResponse, type ExecutionPlan, type ExecutionStep, type Forg3tAdapterMode, Forg3tApiConnectionError, Forg3tAuthenticationError, Forg3tClient, type Forg3tClientOptions, type Forg3tDeploymentProfile, Forg3tError, Forg3tNotFoundError, Forg3tNotImplementedError, Forg3tRateLimitError, HttpTrainingAdapter, type HttpTrainingAdapterOptions, type Integration, IntegrationMode, IntegrationType, type Job, type JobConfig, type JobError, type JobMutationOptions, type JobResult, type JobStatus, type JobType, type LangChainAdapterConfig, type LocalCommandAdapterOptions, LocalCommandTrainingAdapter, type ModelArtifactReference, type NativeAdapterConfig, type OpenRouterAdapterConfig, type PaginationParams, type Project, type RevokeApiKeyResponse, type SubmitJobRequest, type TrainingBackendAdapter, type UnlearningClaim, type UnlearningExecutionModelRef, type UnlearningExecutionPlanSpec, type UnlearningExecutionSpec, type UnlearningExecutionTargetSpec, type UnlearningJobSummary, type UnlearningRequest, type UnlearningScope, type UnlearningTarget, type UpdateWebhookRequest, WHITEBOX_QUALITY_GATE_PRESETS, WHITEBOX_QUALITY_GATE_PRESET_EXPLANATIONS, type Webhook, type WebhookDelivery, type WebhookDeliveryFilters, type WhiteboxEvaluationInput, type WhiteboxEvaluationOutput, type WhiteboxJobContext, type WhiteboxQualityGateDecision, type WhiteboxQualityGatePolicy, type WhiteboxQualityGatePreset, type WhiteboxTargetSpec, type WhiteboxUnlearningInput, type WhiteboxUnlearningOutput, type WhiteboxUnlearningPlan, WhiteboxWorker, type WhiteboxWorkerBaseOptions, type WhiteboxWorkerLogger, type WhiteboxWorkerOptions, assertDeploymentCompatibility, buildModelUnlearningPayload, buildWhiteboxWorkerOptions, createNativeTrainingAdapter, evaluateWhiteboxQualityGate, resolveWhiteboxQualityGatePolicy };
808
+ export { AccessLevel, type AdapterCommandSpec, type AdapterIntegrationConfig, type ApiKey, type AuditEvent, type AuditEventFilters, type AuditEventListResponse, type BaseAdapterConfig, type BootstrapTenantRequest, type BootstrapTenantResponse, type BuildModelUnlearningJobInput, type ClaimAssertion, type ClaimJobsRequest, type ClaimScope, type ClaimType, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateIntegrationRequest, type CreateUnlearningRequestParams, type CreateWebhookRequest, type CurrentUserResponse, DEFAULT_WHITEBOX_QUALITY_GATE_POLICY, type DeploymentCompatibilityOptions, ENTERPRISE_STRICT_QUALITY_GATE_POLICY, type EvidenceArtifact, type EvidencePdfResponse, type EvidenceStatusResponse, type ExecutionPlan, type ExecutionStep, type Forg3tAdapterMode, Forg3tApiConnectionError, Forg3tAuthenticationError, Forg3tClient, type Forg3tClientOptions, type Forg3tDeploymentProfile, Forg3tError, Forg3tNotFoundError, Forg3tNotImplementedError, Forg3tRateLimitError, HttpTrainingAdapter, type HttpTrainingAdapterOptions, type Integration, IntegrationMode, IntegrationType, type Job, type JobConfig, type JobError, type JobMutationOptions, type JobResult, type JobStatus, type JobType, type LangChainAdapterConfig, type LocalCommandAdapterOptions, LocalCommandTrainingAdapter, type ModelArtifactReference, type NativeAdapterConfig, type OpenRouterAdapterConfig, type PaginationParams, type PgVectorIntegrationConfig, type Project, type RevokeApiKeyResponse, type SubmitJobRequest, type TrainingBackendAdapter, type UnlearningClaim, type UnlearningExecutionAdapterSpec, type UnlearningExecutionModelRef, type UnlearningExecutionPlanSpec, type UnlearningExecutionRagSpec, type UnlearningExecutionRoutingSpec, type UnlearningExecutionSpec, type UnlearningExecutionTargetSpec, type UnlearningJobSummary, type UnlearningRequest, type UnlearningScope, type UnlearningTarget, type UpdateWebhookRequest, WHITEBOX_QUALITY_GATE_PRESETS, WHITEBOX_QUALITY_GATE_PRESET_EXPLANATIONS, type Webhook, type WebhookDelivery, type WebhookDeliveryFilters, type WhiteboxEvaluationInput, type WhiteboxEvaluationOutput, type WhiteboxJobContext, type WhiteboxQualityGateDecision, type WhiteboxQualityGatePolicy, type WhiteboxQualityGatePreset, type WhiteboxTargetSpec, type WhiteboxUnlearningInput, type WhiteboxUnlearningOutput, type WhiteboxUnlearningPlan, WhiteboxWorker, type WhiteboxWorkerBaseOptions, type WhiteboxWorkerLogger, type WhiteboxWorkerOptions, assertDeploymentCompatibility, buildModelUnlearningPayload, buildWhiteboxWorkerOptions, createNativeTrainingAdapter, evaluateWhiteboxQualityGate, resolveWhiteboxQualityGatePolicy };
package/dist/index.js CHANGED
@@ -431,6 +431,8 @@ var Forg3tClient = class {
431
431
  };
432
432
  if (data.type === "MODEL_UNLEARN") {
433
433
  this.assertModelUnlearnPreflight(normalizedPayload);
434
+ } else if (data.type === "ADAPTER_UNLEARN") {
435
+ this.assertAdapterUnlearnPreflight(normalizedPayload);
434
436
  }
435
437
  const res = await this.transport.request(`/v1/projects/${projectId}/jobs`, {
436
438
  method: "POST",
@@ -655,18 +657,67 @@ var Forg3tClient = class {
655
657
  }
656
658
  }
657
659
  if (data.accessLevel === "layer_a_only") {
660
+ const rag = data.execution?.rag;
658
661
  const target = data.execution?.target;
659
- if (!target) {
660
- throw new Error("createUnlearningRequest: execution.target is required for layer_a_only.");
662
+ const adapter = data.execution?.adapter;
663
+ if (adapter) {
664
+ throw new Error("createUnlearningRequest: execution.adapter is only valid for layer_a_and_b.");
661
665
  }
662
- if ((target.provider === "openai" || target.provider === "groq") && !target.model?.trim()) {
663
- throw new Error(`createUnlearningRequest: execution.target.model is required when provider=${target.provider}.`);
666
+ if (target && rag) {
667
+ throw new Error("createUnlearningRequest: execution.target and execution.rag are mutually exclusive for layer_a_only.");
664
668
  }
665
- if ((target.provider === "http_generic" || target.provider === "custom") && !target.endpoint?.trim()) {
666
- throw new Error(`createUnlearningRequest: execution.target.endpoint is required when provider=${target.provider}.`);
669
+ if (rag) {
670
+ if (rag.backend !== "pgvector_postgres") {
671
+ throw new Error("createUnlearningRequest: execution.rag.backend must be pgvector_postgres.");
672
+ }
673
+ if (data.target.type !== "document_id") {
674
+ throw new Error("createUnlearningRequest: the official RAG lane currently supports target.type=document_id only.");
675
+ }
676
+ if (!Array.isArray(data.scope?.integrationIds) || data.scope.integrationIds.length !== 1) {
677
+ throw new Error("createUnlearningRequest: the official RAG lane requires exactly one scope.integrationIds entry.");
678
+ }
679
+ if (data.execution?.routing?.lane && data.execution.routing.lane !== "project_scoped") {
680
+ throw new Error("createUnlearningRequest: execution.routing.lane must be project_scoped for the official RAG lane.");
681
+ }
682
+ } else {
683
+ if (!target) {
684
+ throw new Error("createUnlearningRequest: execution.target is required for layer_a_only unless execution.rag is provided.");
685
+ }
686
+ if ((target.provider === "openai" || target.provider === "groq") && !target.model?.trim()) {
687
+ throw new Error(`createUnlearningRequest: execution.target.model is required when provider=${target.provider}.`);
688
+ }
689
+ if ((target.provider === "http_generic" || target.provider === "custom") && !target.endpoint?.trim()) {
690
+ throw new Error(`createUnlearningRequest: execution.target.endpoint is required when provider=${target.provider}.`);
691
+ }
667
692
  }
668
693
  }
669
694
  if (data.accessLevel === "layer_a_and_b") {
695
+ const adapter = data.execution?.adapter;
696
+ if (adapter) {
697
+ if (adapter.backend !== "peft_lora_safetensors") {
698
+ throw new Error("createUnlearningRequest: execution.adapter.backend must be peft_lora_safetensors.");
699
+ }
700
+ if (data.execution?.model?.uri?.trim()) {
701
+ throw new Error("createUnlearningRequest: execution.adapter and execution.model are mutually exclusive for layer_a_and_b.");
702
+ }
703
+ if (!Array.isArray(data.scope?.integrationIds) || data.scope.integrationIds.length !== 1) {
704
+ throw new Error("createUnlearningRequest: the official adapter lane requires exactly one scope.integrationIds entry.");
705
+ }
706
+ if (data.execution?.routing?.lane && data.execution.routing.lane !== "project_scoped") {
707
+ throw new Error("createUnlearningRequest: execution.routing.lane must be project_scoped for the official adapter lane.");
708
+ }
709
+ const method = String(adapter.method || "attenuate_adapter").trim();
710
+ if (!["disable_adapter", "attenuate_adapter"].includes(method)) {
711
+ throw new Error("createUnlearningRequest: execution.adapter.method must be disable_adapter or attenuate_adapter.");
712
+ }
713
+ if (method === "attenuate_adapter") {
714
+ const scaleFactor = Number(adapter.scaleFactor);
715
+ if (!Number.isFinite(scaleFactor) || scaleFactor <= 0 || scaleFactor >= 1) {
716
+ throw new Error("createUnlearningRequest: execution.adapter.scaleFactor must be a finite number between 0 and 1 for attenuate_adapter.");
717
+ }
718
+ }
719
+ return;
720
+ }
670
721
  if (!data.execution?.model?.uri?.trim()) {
671
722
  throw new Error("createUnlearningRequest: execution.model.uri is required for layer_a_and_b.");
672
723
  }
@@ -738,6 +789,40 @@ var Forg3tClient = class {
738
789
  );
739
790
  }
740
791
  }
792
+ assertAdapterUnlearnPreflight(payload) {
793
+ if (!payload || typeof payload !== "object") {
794
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload must be an object.");
795
+ }
796
+ const asRecord = payload;
797
+ const config = asRecord.config && typeof asRecord.config === "object" && !Array.isArray(asRecord.config) ? asRecord.config : null;
798
+ if (!config) {
799
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload.config is required.");
800
+ }
801
+ const targetConfig = config.target_config && typeof config.target_config === "object" && !Array.isArray(config.target_config) ? config.target_config : null;
802
+ const parameters = config.parameters && typeof config.parameters === "object" && !Array.isArray(config.parameters) ? config.parameters : null;
803
+ const adapter = parameters?.adapter && typeof parameters.adapter === "object" && !Array.isArray(parameters.adapter) ? parameters.adapter : null;
804
+ if (!targetConfig) {
805
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload.config.target_config is required.");
806
+ }
807
+ if (String(targetConfig.backend || "").trim() !== "peft_lora_safetensors") {
808
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload.config.target_config.backend must be peft_lora_safetensors.");
809
+ }
810
+ const adapterUri = String(targetConfig.adapter_uri || "").trim();
811
+ const adapterUriEnvVar = String(targetConfig.adapter_uri_env_var || "").trim();
812
+ if (!adapterUri && !adapterUriEnvVar) {
813
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload.config.target_config requires adapter_uri or adapter_uri_env_var.");
814
+ }
815
+ const method = String(adapter?.method || "attenuate_adapter").trim();
816
+ if (!["disable_adapter", "attenuate_adapter"].includes(method)) {
817
+ throw new Error("ADAPTER_UNLEARN preflight failed: parameters.adapter.method must be disable_adapter or attenuate_adapter.");
818
+ }
819
+ if (method === "attenuate_adapter") {
820
+ const scaleFactor = Number(adapter?.scaleFactor);
821
+ if (!Number.isFinite(scaleFactor) || scaleFactor <= 0 || scaleFactor >= 1) {
822
+ throw new Error("ADAPTER_UNLEARN preflight failed: parameters.adapter.scaleFactor must be between 0 and 1 for attenuate_adapter.");
823
+ }
824
+ }
825
+ }
741
826
  };
742
827
 
743
828
  // src/types.ts
@@ -750,6 +835,8 @@ var IntegrationType = /* @__PURE__ */ ((IntegrationType2) => {
750
835
  IntegrationType2["LANGCHAIN"] = "langchain";
751
836
  IntegrationType2["OPENROUTER"] = "openrouter";
752
837
  IntegrationType2["OPENAI"] = "openai";
838
+ IntegrationType2["PGVECTOR"] = "pgvector";
839
+ IntegrationType2["ADAPTER"] = "adapter";
753
840
  IntegrationType2["CUSTOM"] = "custom";
754
841
  return IntegrationType2;
755
842
  })(IntegrationType || {});
@@ -1453,10 +1540,19 @@ var ENTERPRISE_STRICT_QUALITY_GATE_POLICY = {
1453
1540
  ...WHITEBOX_QUALITY_GATE_PRESETS.strict
1454
1541
  };
1455
1542
  function assertDeploymentCompatibility(options) {
1456
- const normalizedHost = parseHost(options.apiUrl);
1457
- if (!normalizedHost) {
1543
+ const parsedApiUrl = parseApiUrl(options.apiUrl);
1544
+ if (!parsedApiUrl) {
1458
1545
  throw new Error(`Invalid FORG3T_API_URL: ${options.apiUrl}`);
1459
1546
  }
1547
+ const normalizedHost = parsedApiUrl.hostname.toLowerCase();
1548
+ if (options.profile === "customer_online") {
1549
+ const publicHost = !isPrivateHost(normalizedHost);
1550
+ if (publicHost && parsedApiUrl.protocol !== "https:") {
1551
+ throw new Error(
1552
+ `Customer online profile requires HTTPS for public control-plane hosts. Received ${options.apiUrl}.`
1553
+ );
1554
+ }
1555
+ }
1460
1556
  if (options.profile !== "customer_airgapped") {
1461
1557
  return;
1462
1558
  }
@@ -1487,10 +1583,9 @@ function buildWhiteboxWorkerOptions(profile, baseOptions) {
1487
1583
  logger: baseOptions.logger
1488
1584
  };
1489
1585
  }
1490
- function parseHost(apiUrl) {
1586
+ function parseApiUrl(apiUrl) {
1491
1587
  try {
1492
- const parsed = new URL(apiUrl);
1493
- return parsed.hostname.toLowerCase();
1588
+ return new URL(apiUrl);
1494
1589
  } catch {
1495
1590
  return null;
1496
1591
  }
package/dist/index.mjs CHANGED
@@ -373,6 +373,8 @@ var Forg3tClient = class {
373
373
  };
374
374
  if (data.type === "MODEL_UNLEARN") {
375
375
  this.assertModelUnlearnPreflight(normalizedPayload);
376
+ } else if (data.type === "ADAPTER_UNLEARN") {
377
+ this.assertAdapterUnlearnPreflight(normalizedPayload);
376
378
  }
377
379
  const res = await this.transport.request(`/v1/projects/${projectId}/jobs`, {
378
380
  method: "POST",
@@ -597,18 +599,67 @@ var Forg3tClient = class {
597
599
  }
598
600
  }
599
601
  if (data.accessLevel === "layer_a_only") {
602
+ const rag = data.execution?.rag;
600
603
  const target = data.execution?.target;
601
- if (!target) {
602
- throw new Error("createUnlearningRequest: execution.target is required for layer_a_only.");
604
+ const adapter = data.execution?.adapter;
605
+ if (adapter) {
606
+ throw new Error("createUnlearningRequest: execution.adapter is only valid for layer_a_and_b.");
603
607
  }
604
- if ((target.provider === "openai" || target.provider === "groq") && !target.model?.trim()) {
605
- throw new Error(`createUnlearningRequest: execution.target.model is required when provider=${target.provider}.`);
608
+ if (target && rag) {
609
+ throw new Error("createUnlearningRequest: execution.target and execution.rag are mutually exclusive for layer_a_only.");
606
610
  }
607
- if ((target.provider === "http_generic" || target.provider === "custom") && !target.endpoint?.trim()) {
608
- throw new Error(`createUnlearningRequest: execution.target.endpoint is required when provider=${target.provider}.`);
611
+ if (rag) {
612
+ if (rag.backend !== "pgvector_postgres") {
613
+ throw new Error("createUnlearningRequest: execution.rag.backend must be pgvector_postgres.");
614
+ }
615
+ if (data.target.type !== "document_id") {
616
+ throw new Error("createUnlearningRequest: the official RAG lane currently supports target.type=document_id only.");
617
+ }
618
+ if (!Array.isArray(data.scope?.integrationIds) || data.scope.integrationIds.length !== 1) {
619
+ throw new Error("createUnlearningRequest: the official RAG lane requires exactly one scope.integrationIds entry.");
620
+ }
621
+ if (data.execution?.routing?.lane && data.execution.routing.lane !== "project_scoped") {
622
+ throw new Error("createUnlearningRequest: execution.routing.lane must be project_scoped for the official RAG lane.");
623
+ }
624
+ } else {
625
+ if (!target) {
626
+ throw new Error("createUnlearningRequest: execution.target is required for layer_a_only unless execution.rag is provided.");
627
+ }
628
+ if ((target.provider === "openai" || target.provider === "groq") && !target.model?.trim()) {
629
+ throw new Error(`createUnlearningRequest: execution.target.model is required when provider=${target.provider}.`);
630
+ }
631
+ if ((target.provider === "http_generic" || target.provider === "custom") && !target.endpoint?.trim()) {
632
+ throw new Error(`createUnlearningRequest: execution.target.endpoint is required when provider=${target.provider}.`);
633
+ }
609
634
  }
610
635
  }
611
636
  if (data.accessLevel === "layer_a_and_b") {
637
+ const adapter = data.execution?.adapter;
638
+ if (adapter) {
639
+ if (adapter.backend !== "peft_lora_safetensors") {
640
+ throw new Error("createUnlearningRequest: execution.adapter.backend must be peft_lora_safetensors.");
641
+ }
642
+ if (data.execution?.model?.uri?.trim()) {
643
+ throw new Error("createUnlearningRequest: execution.adapter and execution.model are mutually exclusive for layer_a_and_b.");
644
+ }
645
+ if (!Array.isArray(data.scope?.integrationIds) || data.scope.integrationIds.length !== 1) {
646
+ throw new Error("createUnlearningRequest: the official adapter lane requires exactly one scope.integrationIds entry.");
647
+ }
648
+ if (data.execution?.routing?.lane && data.execution.routing.lane !== "project_scoped") {
649
+ throw new Error("createUnlearningRequest: execution.routing.lane must be project_scoped for the official adapter lane.");
650
+ }
651
+ const method = String(adapter.method || "attenuate_adapter").trim();
652
+ if (!["disable_adapter", "attenuate_adapter"].includes(method)) {
653
+ throw new Error("createUnlearningRequest: execution.adapter.method must be disable_adapter or attenuate_adapter.");
654
+ }
655
+ if (method === "attenuate_adapter") {
656
+ const scaleFactor = Number(adapter.scaleFactor);
657
+ if (!Number.isFinite(scaleFactor) || scaleFactor <= 0 || scaleFactor >= 1) {
658
+ throw new Error("createUnlearningRequest: execution.adapter.scaleFactor must be a finite number between 0 and 1 for attenuate_adapter.");
659
+ }
660
+ }
661
+ return;
662
+ }
612
663
  if (!data.execution?.model?.uri?.trim()) {
613
664
  throw new Error("createUnlearningRequest: execution.model.uri is required for layer_a_and_b.");
614
665
  }
@@ -680,6 +731,40 @@ var Forg3tClient = class {
680
731
  );
681
732
  }
682
733
  }
734
+ assertAdapterUnlearnPreflight(payload) {
735
+ if (!payload || typeof payload !== "object") {
736
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload must be an object.");
737
+ }
738
+ const asRecord = payload;
739
+ const config = asRecord.config && typeof asRecord.config === "object" && !Array.isArray(asRecord.config) ? asRecord.config : null;
740
+ if (!config) {
741
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload.config is required.");
742
+ }
743
+ const targetConfig = config.target_config && typeof config.target_config === "object" && !Array.isArray(config.target_config) ? config.target_config : null;
744
+ const parameters = config.parameters && typeof config.parameters === "object" && !Array.isArray(config.parameters) ? config.parameters : null;
745
+ const adapter = parameters?.adapter && typeof parameters.adapter === "object" && !Array.isArray(parameters.adapter) ? parameters.adapter : null;
746
+ if (!targetConfig) {
747
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload.config.target_config is required.");
748
+ }
749
+ if (String(targetConfig.backend || "").trim() !== "peft_lora_safetensors") {
750
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload.config.target_config.backend must be peft_lora_safetensors.");
751
+ }
752
+ const adapterUri = String(targetConfig.adapter_uri || "").trim();
753
+ const adapterUriEnvVar = String(targetConfig.adapter_uri_env_var || "").trim();
754
+ if (!adapterUri && !adapterUriEnvVar) {
755
+ throw new Error("ADAPTER_UNLEARN preflight failed: payload.config.target_config requires adapter_uri or adapter_uri_env_var.");
756
+ }
757
+ const method = String(adapter?.method || "attenuate_adapter").trim();
758
+ if (!["disable_adapter", "attenuate_adapter"].includes(method)) {
759
+ throw new Error("ADAPTER_UNLEARN preflight failed: parameters.adapter.method must be disable_adapter or attenuate_adapter.");
760
+ }
761
+ if (method === "attenuate_adapter") {
762
+ const scaleFactor = Number(adapter?.scaleFactor);
763
+ if (!Number.isFinite(scaleFactor) || scaleFactor <= 0 || scaleFactor >= 1) {
764
+ throw new Error("ADAPTER_UNLEARN preflight failed: parameters.adapter.scaleFactor must be between 0 and 1 for attenuate_adapter.");
765
+ }
766
+ }
767
+ }
683
768
  };
684
769
 
685
770
  // src/types.ts
@@ -692,6 +777,8 @@ var IntegrationType = /* @__PURE__ */ ((IntegrationType2) => {
692
777
  IntegrationType2["LANGCHAIN"] = "langchain";
693
778
  IntegrationType2["OPENROUTER"] = "openrouter";
694
779
  IntegrationType2["OPENAI"] = "openai";
780
+ IntegrationType2["PGVECTOR"] = "pgvector";
781
+ IntegrationType2["ADAPTER"] = "adapter";
695
782
  IntegrationType2["CUSTOM"] = "custom";
696
783
  return IntegrationType2;
697
784
  })(IntegrationType || {});
@@ -1395,10 +1482,19 @@ var ENTERPRISE_STRICT_QUALITY_GATE_POLICY = {
1395
1482
  ...WHITEBOX_QUALITY_GATE_PRESETS.strict
1396
1483
  };
1397
1484
  function assertDeploymentCompatibility(options) {
1398
- const normalizedHost = parseHost(options.apiUrl);
1399
- if (!normalizedHost) {
1485
+ const parsedApiUrl = parseApiUrl(options.apiUrl);
1486
+ if (!parsedApiUrl) {
1400
1487
  throw new Error(`Invalid FORG3T_API_URL: ${options.apiUrl}`);
1401
1488
  }
1489
+ const normalizedHost = parsedApiUrl.hostname.toLowerCase();
1490
+ if (options.profile === "customer_online") {
1491
+ const publicHost = !isPrivateHost(normalizedHost);
1492
+ if (publicHost && parsedApiUrl.protocol !== "https:") {
1493
+ throw new Error(
1494
+ `Customer online profile requires HTTPS for public control-plane hosts. Received ${options.apiUrl}.`
1495
+ );
1496
+ }
1497
+ }
1402
1498
  if (options.profile !== "customer_airgapped") {
1403
1499
  return;
1404
1500
  }
@@ -1429,10 +1525,9 @@ function buildWhiteboxWorkerOptions(profile, baseOptions) {
1429
1525
  logger: baseOptions.logger
1430
1526
  };
1431
1527
  }
1432
- function parseHost(apiUrl) {
1528
+ function parseApiUrl(apiUrl) {
1433
1529
  try {
1434
- const parsed = new URL(apiUrl);
1435
- return parsed.hostname.toLowerCase();
1530
+ return new URL(apiUrl);
1436
1531
  } catch {
1437
1532
  return null;
1438
1533
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forg3t/sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Official TypeScript SDK for Forg3t Protocol",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",