@opengeni/core 3.1.3-canary.38890816741001 → 3.3.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 (36) hide show
  1. package/dist/access/index.d.ts +13 -0
  2. package/dist/application/site-session-cancellation.d.ts +14 -0
  3. package/dist/dependencies.d.ts +3 -0
  4. package/dist/domain/insights-usage.d.ts +24 -1
  5. package/dist/domain/vaults/external-provider-connections.d.ts +126 -0
  6. package/dist/domain/vaults/index.d.ts +2 -1
  7. package/dist/domain/vaults/mapping.d.ts +18 -2
  8. package/dist/domain/vaults/provider-registry.d.ts +4 -1
  9. package/dist/domain/vaults/provider-sync.d.ts +135 -21
  10. package/dist/domain/vaults/provider-writes.d.ts +102 -12
  11. package/dist/domain/vaults/remote-provider-runtime.d.ts +7 -0
  12. package/dist/domain/vaults/secret-resolver.d.ts +29 -1
  13. package/dist/goal-admission.d.ts +2 -0
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.js +1578 -394
  16. package/dist/index.js.map +1 -1
  17. package/package.json +13 -13
  18. package/src/access/index.ts +100 -0
  19. package/src/application/site-session-cancellation.ts +47 -0
  20. package/src/dependencies.ts +3 -0
  21. package/src/domain/file-owner.ts +1 -0
  22. package/src/domain/insights-usage.ts +20 -1
  23. package/src/domain/realtime-voice-billing.ts +4 -1
  24. package/src/domain/vaults/external-provider-connections.ts +395 -0
  25. package/src/domain/vaults/index.ts +8 -0
  26. package/src/domain/vaults/mapping.ts +95 -1
  27. package/src/domain/vaults/provider-registry.ts +29 -0
  28. package/src/domain/vaults/provider-sync.ts +492 -136
  29. package/src/domain/vaults/provider-writes.ts +415 -71
  30. package/src/domain/vaults/remote-provider-runtime.ts +129 -0
  31. package/src/domain/vaults/secret-resolver.ts +203 -33
  32. package/src/domain/vaults/vault-service.ts +226 -34
  33. package/src/domain/voice-input-billing.ts +5 -1
  34. package/src/index.ts +3 -0
  35. package/src/sandbox/fleet.ts +1 -0
  36. package/src/session-authorization.ts +21 -0
@@ -1,11 +1,20 @@
1
- import { type VaultFieldInput, type VaultFieldKind, type VaultItemType } from "@opengeni/contracts";
2
- import { type Database, type VaultDbContext, type VaultFieldRow, type VaultRow } from "@opengeni/db";
3
- import { type ProviderCallBudget, type VaultProviderRegistry } from "@opengeni/vaults";
1
+ import { type VaultFieldInput, type VaultFieldKind, type VaultItemType, type VaultProviderOperations } from "@opengeni/contracts";
2
+ import { VaultError, type Database, type VaultDbContext, type VaultFieldRow, type VaultRow } from "@opengeni/db";
3
+ import { type ProviderCallBudget, type VaultProvider, type VaultProviderRegistry } from "@opengeni/vaults";
4
+ import { type ProviderVaultSyncResult } from "./provider-sync.js";
4
5
  /**
5
- * Edits of items in a read-write connected vault (OP-3): the change is written
6
- * to the provider (1Password `items.get` → patch → `items.put`, with the
7
- * mirrored version as the expected version), then the metadata mirror is
8
- * refreshed. Values never touch Opengeni storage.
6
+ * Edits of items in a read-write connected vault (OP-3, external vaults §10):
7
+ * the change is written to the provider (with the mirrored version as the
8
+ * expected version), then the metadata mirror is refreshed. Values never
9
+ * touch Opengeni storage.
10
+ *
11
+ * Every write is checked against the vault's effective operations first (the
12
+ * provider's current capabilities, narrowed by what it last reported for the
13
+ * vault and by the link mode), before any reference is resolved or value
14
+ * generated. A provider mutation is never retried: when its outcome is
15
+ * unknown the caller is told to check the vault, and a write that succeeded
16
+ * but could not be listed yet is reported as saved, never as a failure that
17
+ * invites saving it again.
9
18
  */
10
19
  /** One field change; the REST `VaultFieldInput` and the agent `secret_save` field both fit. */
11
20
  export interface ProviderFieldChange {
@@ -33,10 +42,38 @@ export interface ProviderWriteDeps {
33
42
  resolveReference: (raw: string) => Promise<string>;
34
43
  budget?: ProviderCallBudget;
35
44
  }
45
+ /** An operation a connected vault may not allow; reported in `vault_read_only` details. */
46
+ export type ProviderWriteOperation = "createItem" | "updateItem" | "removeField" | "createTotp" | "updateTotp" | "archiveItem" | "deleteItem" | "restoreItem" | "writeFiles" | "restoreFieldHistory";
47
+ /** The result of a provider write once the mirror was refreshed. */
48
+ export type ProviderWriteOutcome = {
49
+ status: "listed";
50
+ itemId: string;
51
+ } | {
52
+ /**
53
+ * The provider confirmed the write, but the refreshed mirror does not
54
+ * show it yet (for example the refresh was rate limited). It must not be
55
+ * saved again; it appears after the next successful sync.
56
+ */
57
+ status: "saved_not_listed";
58
+ vaultId: string;
59
+ sync: ProviderVaultSyncResult["status"] | "error";
60
+ };
36
61
  /** A connected vault the caller may change items in. */
37
62
  export declare function assertProviderVaultWritable(vault: VaultRow): void;
38
- /** Create (existing = null) or update an item in a connected read-write vault; returns its item id. */
39
- export declare function writeProviderVaultItem(deps: ProviderWriteDeps, input: {
63
+ /**
64
+ * What a connected vault allows now: the provider's current capabilities,
65
+ * narrowed by the operations it last reported for this vault (a read-only
66
+ * share, for example) and by the link mode. Permanent deletion is never
67
+ * allowed.
68
+ */
69
+ export declare function effectiveProviderOperations(vault: VaultRow, provider: Pick<VaultProvider, "capabilities"> | null): VaultProviderOperations;
70
+ /** Refuses a provider operation Opengeni never performs, with the reason. */
71
+ export declare function refuseProviderOperation(vault: VaultRow, operation: Extract<ProviderWriteOperation, "deleteItem" | "restoreItem" | "restoreFieldHistory">): never;
72
+ /**
73
+ * Create (existing = null) or update an item in a connected read-write vault
74
+ * and report whether the refreshed mirror lists it.
75
+ */
76
+ export declare function writeProviderVaultItemOutcome(deps: ProviderWriteDeps, input: {
40
77
  vault: VaultRow;
41
78
  existing: {
42
79
  itemId: string;
@@ -49,9 +86,62 @@ export declare function writeProviderVaultItem(deps: ProviderWriteDeps, input: {
49
86
  change: ProviderItemChange;
50
87
  /** Receives the names of fields whose values were generated. */
51
88
  generated?: string[];
52
- }): Promise<string>;
53
- /** Archive an item in a connected read-write vault (the provider keeps it recoverable). */
89
+ }): Promise<ProviderWriteOutcome>;
90
+ /** Thrown when a confirmed provider write is not listed yet: it must not be saved again. */
91
+ export declare function savedNotListedError(vault: VaultRow, itemName: string, outcome: Extract<ProviderWriteOutcome, {
92
+ status: "saved_not_listed";
93
+ }>): VaultError;
94
+ /**
95
+ * Create (existing = null) or update an item in a connected read-write vault;
96
+ * returns its item id. A confirmed write that is not listed yet throws
97
+ * `provider_inventory_incomplete` with `details.saved = true`.
98
+ */
99
+ export declare function writeProviderVaultItem(deps: ProviderWriteDeps, input: Parameters<typeof writeProviderVaultItemOutcome>[1]): Promise<string>;
100
+ /** Whether an item can leave this vault recoverably (moves need it before anything is written). */
101
+ export declare function providerArchiveKind(vault: VaultRow, provider: Pick<VaultProvider, "capabilities"> | null): "archive" | "trash" | null;
102
+ /**
103
+ * Refuses, before any value is read or written, an item a connected vault
104
+ * cannot receive as a new item (its type, a one-time password, or a file).
105
+ */
106
+ export declare function assertProviderVaultAccepts(deps: ProviderWriteDeps, vault: VaultRow, item: {
107
+ type: VaultItemType;
108
+ fields: ReadonlyArray<{
109
+ kind: VaultFieldKind;
110
+ }>;
111
+ }): Promise<void>;
112
+ /**
113
+ * Refuses a move out of a connected vault that cannot archive the original
114
+ * recoverably (copy instead); returns where the original will go.
115
+ */
116
+ export declare function assertProviderVaultReleases(deps: ProviderWriteDeps, vault: VaultRow): Promise<"archive" | "trash">;
117
+ /** What a fresh provider listing says about one mirrored item. */
118
+ export type ProviderItemObservation = {
119
+ listed: true;
120
+ version: string | null;
121
+ } | {
122
+ listed: false;
123
+ consistent: boolean;
124
+ };
125
+ /**
126
+ * The provider's current version of one item, from a fresh listing of its
127
+ * vault (provider caches bypassed). `version` is null when the provider does
128
+ * not version items. A provider failure is thrown as a `VaultError`.
129
+ *
130
+ * The provider contract has no conditional (compare-and-archive) operation,
131
+ * so this only narrows the window between reading an item and archiving it;
132
+ * it cannot close it.
133
+ */
134
+ export declare function observeProviderItemVersion(deps: ProviderWriteDeps, input: {
135
+ vault: VaultRow;
136
+ providerItemRef: string;
137
+ }): Promise<ProviderItemObservation>;
138
+ /**
139
+ * Archive an item in a connected read-write vault. Only a recoverable archive
140
+ * (the provider's archive or trash) is ever used; permanent deletion is not.
141
+ */
54
142
  export declare function archiveProviderVaultItem(deps: ProviderWriteDeps, input: {
55
143
  vault: VaultRow;
56
144
  itemId: string;
57
- }): Promise<void>;
145
+ }): Promise<{
146
+ archiveKind: "archive" | "trash";
147
+ }>;
@@ -0,0 +1,7 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import { pinnedFetch, type OutboundNetworkSettings } from "@opengeni/network";
3
+ import { type RemoteVaultTransport } from "@opengeni/vaults";
4
+ import type { ExternalVaultProviderFactories } from "./external-provider-connections.js";
5
+ /** Shared by API and worker. No credential-bearing request uses ambient fetch. */
6
+ export declare function createPinnedRemoteVaultTransport(settings: OutboundNetworkSettings, fetchImpl?: typeof pinnedFetch): RemoteVaultTransport;
7
+ export declare function createRemoteExternalVaultFactories(settings: Pick<Settings, "environment" | "integrationsAllowPrivateNetworkTargets">): ExternalVaultProviderFactories;
@@ -4,9 +4,19 @@
4
4
  * chosen here (archived dropped, lowest tier, names over aliases, otherwise
5
5
  * ambiguous), provider values are fetched, hosted values decrypted, and the
6
6
  * batch is recorded. A call resolves all of its references or none (I2).
7
+ *
8
+ * A reference that finds nothing first refreshes the connected vaults that
9
+ * could change the answer: those that could hold it at the priority tier that
10
+ * decided the lookup or above, even when a hosted item matched without the
11
+ * field. When one of those could not be checked (unreachable, rate limited,
12
+ * needing reconnection or still refreshing), the failure names that source
13
+ * instead of reporting the secret missing, so no missing-secret ask card is
14
+ * made for a secret that may exist (external vaults §9). Hosted and
15
+ * explicitly named healthy vaults are never blocked by unrelated outages, and
16
+ * lower-priority vaults never block a miss a higher tier decided.
7
17
  */
8
18
  import { type SecretPrincipal, type SecretReference, type SecretReferenceFailure, type SecretResolver } from "@opengeni/contracts";
9
- import { type SecretReferenceCandidate, type SecretResolutionMeta } from "@opengeni/db";
19
+ import { type SecretReferenceCandidate, type SecretResolutionMeta, type VaultRow } from "@opengeni/db";
10
20
  import { type ProviderCallBudget, type VaultProviderRegistry } from "@opengeni/vaults";
11
21
  import type { VaultServiceDeps } from "./types.js";
12
22
  export type SecretResolverOptions = {
@@ -31,4 +41,22 @@ export declare function chooseSecretCandidate(reference: SecretReference, candid
31
41
  } | {
32
42
  failure: SecretReferenceFailure;
33
43
  };
44
+ /**
45
+ * The connected vaults whose mirror decides a reference that found nothing.
46
+ *
47
+ * Where the item could be: the vault a three-segment reference names; for two
48
+ * segments the named vault when the first segment names one (else every
49
+ * connected vault, since it may be `Item/field`); every connected vault for a
50
+ * bare item name; none for an ID.
51
+ *
52
+ * When some item matched but lacks the field (or the one-time password), the
53
+ * lookup keeps the highest-priority tier, so only vaults at that tier or above
54
+ * can change the answer: the connected vaults of matched items there that lack
55
+ * the field, and the connected vaults that could hold the item there but have
56
+ * no match yet. A hosted match never hides a higher-priority connected vault
57
+ * whose provider gained the item or its one-time password, and a vault of a
58
+ * lower-priority tier that is out of date or unavailable never turns a
59
+ * definite miss into an unchecked one.
60
+ */
61
+ export declare function relevantProviderVaults(reference: SecretReference, candidates: readonly SecretReferenceCandidate[], reachable: readonly VaultRow[]): VaultRow[];
34
62
  export declare function createSecretResolver(deps: VaultServiceDeps, principal: SecretPrincipal, opts: SecretResolverOptions): SecretResolver;
@@ -114,6 +114,7 @@ export declare function resolveGoalModelAdmission(db: Database, settings: Settin
114
114
  ogtoolPackageSpec?: string | undefined;
115
115
  environmentsEncryptionKey?: string | undefined;
116
116
  onePasswordFakeTokens: boolean;
117
+ protonPassCliPath?: string | undefined;
117
118
  integrationsEnabled: boolean;
118
119
  integrationsStateSecret?: string | undefined;
119
120
  integrationsAllowPrivateNetworkTargets: boolean;
@@ -225,6 +226,7 @@ export declare function resolveGoalModelAdmission(db: Database, settings: Settin
225
226
  voiceInputOpenaiPricingJson?: string | undefined;
226
227
  voiceInputAzurePricingJson?: string | undefined;
227
228
  voiceInputCodexExperimentalEnabled: boolean;
229
+ creditMarginBpsOverride?: number | undefined;
228
230
  modelPricingJson: string;
229
231
  modelCatalogSource: "code" | "database";
230
232
  modelCostPolicyJson: string;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,8 @@ export * from "./domain/web-search-billing.js";
12
12
  export * from "./domain/realtime-voice-billing.js";
13
13
  export * from "./dependencies.js";
14
14
  export * from "./domain/vaults/provider-registry.js";
15
+ export * from "./domain/vaults/external-provider-connections.js";
16
+ export * from "./domain/vaults/remote-provider-runtime.js";
15
17
  export * from "./domain/vaults/provider-sync.js";
16
18
  export * from "./workflow-wake-contract.js";
17
19
  export * from "./user-presence.js";
@@ -83,6 +85,7 @@ export * from "./domain/organization-membership-lifecycle.js";
83
85
  export * from "./application/new-session-drafts.js";
84
86
  export * from "./application/composer-submit.js";
85
87
  export * from "./application/session-commands.js";
88
+ export * from "./application/site-session-cancellation.js";
86
89
  export * from "./application/archived-session-imports.js";
87
90
  export * from "./application/session-tenancy.js";
88
91
  export * from "./application/organization-privacy.js";