@opengeni/db 3.6.0 → 3.7.3-canary.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.
Files changed (80) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-744DFC65.js → chunk-4NAR7FBA.js} +92 -6
  3. package/dist/chunk-4NAR7FBA.js.map +1 -0
  4. package/dist/{chunk-IW6O6G7R.js → chunk-5NNCGFQY.js} +2 -2
  5. package/dist/{chunk-G3732M3T.js → chunk-DZCYW2WT.js} +2 -2
  6. package/dist/{chunk-WW7AJ5IC.js → chunk-F6PBS6WE.js} +5 -7
  7. package/dist/chunk-F6PBS6WE.js.map +1 -0
  8. package/dist/{chunk-UJ2EW3QI.js → chunk-O56DM5GZ.js} +340 -85
  9. package/dist/chunk-O56DM5GZ.js.map +1 -0
  10. package/dist/{chunk-CDMMSUWJ.js → chunk-S3TDDCS2.js} +3 -3
  11. package/dist/{chunk-Q5YUGQVK.js → chunk-SZAWDXQC.js} +3 -3
  12. package/dist/{chunk-UGDVSQ6U.js → chunk-U4WPPEBH.js} +2 -2
  13. package/dist/{chunk-2NT476HD.js → chunk-US4IS6IV.js} +2 -2
  14. package/dist/codex-token-resolver.d.ts +12 -1
  15. package/dist/company-profile-agent-admin.d.ts +4 -2
  16. package/dist/company-profile-agent-policy.d.ts +20 -0
  17. package/dist/company-profile-schema.d.ts +573 -0
  18. package/dist/editable-artifact-durable-export.js +2 -2
  19. package/dist/editable-artifacts.js +3 -3
  20. package/dist/index.d.ts +382 -18
  21. package/dist/index.js +4513 -2065
  22. package/dist/index.js.map +1 -1
  23. package/dist/managed-auth-session-sets.js +3 -3
  24. package/dist/managed-human-provisioning.d.ts +3 -3
  25. package/dist/memory-domain.d.ts +5 -3
  26. package/dist/provision-roles.js +1 -1
  27. package/dist/runtime-posture.d.ts +5 -5
  28. package/dist/schema.d.ts +725 -4
  29. package/dist/schema.js +13 -1
  30. package/dist/session-background-commands.js +3 -3
  31. package/dist/session-control.d.ts +40 -5
  32. package/dist/session-queue-commands.d.ts +2 -0
  33. package/dist/session-tenancy.js +3 -3
  34. package/dist/user-resource-authority.d.ts +8 -0
  35. package/dist/video-generation.js +3 -3
  36. package/drizzle/0369_local_human_personal_authority.sql +350 -0
  37. package/drizzle/0370_workspace_member_management_scope.sql +98 -0
  38. package/drizzle/0371_workspace_member_candidate_inventory.sql +128 -0
  39. package/drizzle/0372_ordered_variable_set_runtime_authority.sql +287 -0
  40. package/drizzle/0373_sandbox_shared_preparation.sql +59 -0
  41. package/drizzle/0374_session_event_cursors.sql +315 -0
  42. package/drizzle/0375_session_recovery_observability.sql +73 -0
  43. package/drizzle/0376_organization_workspace_inventory.sql +88 -0
  44. package/drizzle/0377_scoped_rig_health_projection.sql +80 -0
  45. package/drizzle/0378_scoped_rig_health_audit_timestamp.sql +77 -0
  46. package/drizzle/0379_session_event_raw_lane_activation.sql +518 -0
  47. package/drizzle/0380_autonomous_company_profile_agent_policy.sql +829 -0
  48. package/drizzle/0381_organization_codex_subscription_inheritance.sql +720 -0
  49. package/drizzle/0382_organization_api_key_provenance.sql +91 -0
  50. package/drizzle/0383_codex_cooldown_reconciliation.sql +51 -0
  51. package/drizzle/0384_codex_cooldown_revision_guard_privileges.sql +6 -0
  52. package/drizzle/0385_connected_machine_legacy_tilde_workdirs.sql +25 -0
  53. package/drizzle/0386_local_organization_administration.sql +157 -0
  54. package/package.json +6 -6
  55. package/src/codex-token-resolver.ts +26 -1
  56. package/src/company-brain-governed-writes.ts +30 -1
  57. package/src/company-profile-agent-admin.ts +68 -1
  58. package/src/company-profile-agent-policy.ts +126 -0
  59. package/src/company-profile-schema.ts +115 -1
  60. package/src/database.ts +3 -5
  61. package/src/index.ts +3626 -456
  62. package/src/managed-human-provisioning.ts +3 -3
  63. package/src/memory-domain.ts +9 -4
  64. package/src/organization-membership-lifecycle.ts +0 -1
  65. package/src/provision-roles.ts +83 -4
  66. package/src/runtime-posture.ts +22 -0
  67. package/src/schema.ts +161 -8
  68. package/src/session-control.ts +177 -59
  69. package/src/session-queue-commands.ts +146 -40
  70. package/src/session-tool-call-settlement.ts +34 -7
  71. package/src/user-resource-authority.ts +56 -0
  72. package/dist/chunk-744DFC65.js.map +0 -1
  73. package/dist/chunk-UJ2EW3QI.js.map +0 -1
  74. package/dist/chunk-WW7AJ5IC.js.map +0 -1
  75. /package/dist/{chunk-IW6O6G7R.js.map → chunk-5NNCGFQY.js.map} +0 -0
  76. /package/dist/{chunk-G3732M3T.js.map → chunk-DZCYW2WT.js.map} +0 -0
  77. /package/dist/{chunk-CDMMSUWJ.js.map → chunk-S3TDDCS2.js.map} +0 -0
  78. /package/dist/{chunk-Q5YUGQVK.js.map → chunk-SZAWDXQC.js.map} +0 -0
  79. /package/dist/{chunk-UGDVSQ6U.js.map → chunk-U4WPPEBH.js.map} +0 -0
  80. /package/dist/{chunk-2NT476HD.js.map → chunk-US4IS6IV.js.map} +0 -0
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  withRlsContext
3
- } from "./chunk-WW7AJ5IC.js";
3
+ } from "./chunk-F6PBS6WE.js";
4
4
  import {
5
5
  sandboxRetainedProcesses,
6
6
  sessionBackgroundCommands,
7
7
  sessions
8
- } from "./chunk-UJ2EW3QI.js";
8
+ } from "./chunk-O56DM5GZ.js";
9
9
 
10
10
  // src/session-background-commands.ts
11
11
  import { and, desc, eq, inArray, sql } from "drizzle-orm";
@@ -513,4 +513,4 @@ export {
513
513
  settleSessionBackgroundCommandForRetainedProcess,
514
514
  settleConnectedMachineSessionBackgroundCommand
515
515
  };
516
- //# sourceMappingURL=chunk-CDMMSUWJ.js.map
516
+ //# sourceMappingURL=chunk-S3TDDCS2.js.map
@@ -2,7 +2,7 @@ import {
2
2
  rawRows,
3
3
  withRlsContext,
4
4
  withWorkspaceRls
5
- } from "./chunk-WW7AJ5IC.js";
5
+ } from "./chunk-F6PBS6WE.js";
6
6
  import {
7
7
  connections,
8
8
  creditLedgerEntries,
@@ -14,7 +14,7 @@ import {
14
14
  workspaceVideoGenerationPolicies,
15
15
  workspaceVideoGenerationQuotas,
16
16
  workspaces
17
- } from "./chunk-UJ2EW3QI.js";
17
+ } from "./chunk-O56DM5GZ.js";
18
18
 
19
19
  // src/video-generation.ts
20
20
  import {
@@ -992,4 +992,4 @@ export {
992
992
  mediaGenerationResultForStoredOperation,
993
993
  getVideoGenerationOperationSummary
994
994
  };
995
- //# sourceMappingURL=chunk-Q5YUGQVK.js.map
995
+ //# sourceMappingURL=chunk-SZAWDXQC.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-WW7AJ5IC.js";
4
+ } from "./chunk-F6PBS6WE.js";
5
5
 
6
6
  // src/canonical-human-identities.ts
7
7
  import { createHash } from "crypto";
@@ -309,4 +309,4 @@ export {
309
309
  getCanonicalHumanIdentityProjection,
310
310
  applyCanonicalHumanIdentityOperation
311
311
  };
312
- //# sourceMappingURL=chunk-UGDVSQ6U.js.map
312
+ //# sourceMappingURL=chunk-U4WPPEBH.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-WW7AJ5IC.js";
4
+ } from "./chunk-F6PBS6WE.js";
5
5
 
6
6
  // src/editable-artifacts.ts
7
7
  import { createHash } from "crypto";
@@ -3540,4 +3540,4 @@ export {
3540
3540
  PostgresEditableArtifactStore,
3541
3541
  PostgresEditableArtifactLiveReadStore
3542
3542
  };
3543
- //# sourceMappingURL=chunk-2NT476HD.js.map
3543
+ //# sourceMappingURL=chunk-US4IS6IV.js.map
@@ -7,6 +7,7 @@ export type CodexCredentialTokens = {
7
7
  refreshToken: string;
8
8
  idToken: string;
9
9
  };
10
+ export type CodexCredentialCooldownKind = "quota" | "rate_limit";
10
11
  export type CodexCredentialForRun = {
11
12
  id: string;
12
13
  version: number;
@@ -20,6 +21,9 @@ export type CodexCredentialForRun = {
20
21
  lastRefreshAt: Date | null;
21
22
  status: string;
22
23
  lastError: string | null;
24
+ exhaustedUntil: Date | null;
25
+ exhaustedKind: CodexCredentialCooldownKind | null;
26
+ exhaustedRevision: number;
23
27
  };
24
28
  export type CodexAccountUsageSnapshot = {
25
29
  primaryUsedPercent?: number | null;
@@ -29,6 +33,12 @@ export type CodexAccountUsageSnapshot = {
29
33
  checkedAt?: Date;
30
34
  resetCreditAvailableCount?: number | null;
31
35
  resetCreditsCheckedAt?: Date | null;
36
+ /**
37
+ * Clear only a quota cooldown with this exact revision. Set solely after a
38
+ * live provider response proves allowance is open; a concurrent refusal
39
+ * advances the revision and makes this observation stale.
40
+ */
41
+ clearQuotaCooldownRevision?: number;
32
42
  };
33
43
  type CodexCredentialRefreshInput = {
34
44
  id: string;
@@ -81,7 +91,8 @@ export declare function buildCodexTokenResolver(db: Database, settings: Settings
81
91
  * account's expired JWT from 401-ing the usage read.
82
92
  * 2. fetch GET /wham/usage with that bearer.
83
93
  * 3. normalize (§3) into the P2/P3 contract.
84
- * 4. on any windows present, write the five usage-cache columns (the TTL clock).
94
+ * 4. on any windows present, write the usage cache and conditionally reconcile
95
+ * the exact older typed quota cooldown observed before provider I/O.
85
96
  *
86
97
  * A refresh that stamps needs_relogin returns { status:"error", reason } and never
87
98
  * hits the provider; a transient refresh error returns a plain error payload.
@@ -1,10 +1,12 @@
1
1
  import { type CompanyProfileAgentAttempt as CompanyProfileAgentAttemptType, type CompanyProfileAgentConfirmRequest as CompanyProfileAgentConfirmRequestType, type CompanyProfileAgentConfirmationReceipt as CompanyProfileAgentConfirmationReceiptType, type CompanyProfileAgentProposalReceipt as CompanyProfileAgentProposalReceiptType, type CompanyProfileAgentProposalRequest as CompanyProfileAgentProposalRequestType } from "@opengeni/contracts";
2
2
  import { type Database } from "./database.js";
3
3
  export declare class CompanyProfileAgentAdminError extends Error {
4
- readonly code: "authority_unavailable" | "confirmation_unavailable" | "profile_conflict" | "operation_reused" | "invalid_operation";
4
+ readonly code: "authority_unavailable" | "policy_disabled" | "confirmation_unavailable" | "profile_conflict" | "operation_reused" | "invalid_operation";
5
5
  readonly name = "CompanyProfileAgentAdminError";
6
- constructor(code: "authority_unavailable" | "confirmation_unavailable" | "profile_conflict" | "operation_reused" | "invalid_operation", message: string, options?: ErrorOptions);
6
+ constructor(code: "authority_unavailable" | "policy_disabled" | "confirmation_unavailable" | "profile_conflict" | "operation_reused" | "invalid_operation", message: string, options?: ErrorOptions);
7
7
  }
8
+ /** Deterministic UUID-shaped id for the activation stage of one proposal operation. */
9
+ export declare function derivedCompanyProfileAutomaticActivationOperationId(operationId: string): string;
8
10
  export declare function proposeCompanyProfileForAgent(db: Database, raw: {
9
11
  attempt: CompanyProfileAgentAttemptType;
10
12
  request: CompanyProfileAgentProposalRequestType;
@@ -0,0 +1,20 @@
1
+ import { type CompanyProfileAgentPolicy as CompanyProfileAgentPolicyType, type CompanyProfileAgentPolicyMode as CompanyProfileAgentPolicyModeType } from "@opengeni/contracts";
2
+ import { type Database } from "./database.js";
3
+ export declare class CompanyProfileAgentPolicyError extends Error {
4
+ readonly code: "authority_unavailable" | "policy_conflict" | "operation_reused" | "invalid";
5
+ readonly name = "CompanyProfileAgentPolicyError";
6
+ constructor(code: "authority_unavailable" | "policy_conflict" | "operation_reused" | "invalid", message: string, options?: ErrorOptions);
7
+ }
8
+ export declare function getCompanyProfileAgentPolicy(db: Database, input: {
9
+ accountId: string;
10
+ workspaceId: string;
11
+ actorSubjectId: string;
12
+ }): Promise<CompanyProfileAgentPolicyType>;
13
+ export declare function updateCompanyProfileAgentPolicy(db: Database, input: {
14
+ accountId: string;
15
+ workspaceId: string;
16
+ actorSubjectId: string;
17
+ mode: CompanyProfileAgentPolicyModeType;
18
+ expectedVersion: number;
19
+ operationId: string;
20
+ }): Promise<CompanyProfileAgentPolicyType>;