@opengeni/core 0.16.3 → 0.18.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.
@@ -0,0 +1,107 @@
1
+ import { type KnowledgeMemoryKind, type KnowledgeMemoryStatus } from "@opengeni/contracts";
2
+ export declare const MEMORY_SLACK_PROJECTION_VERSION = 1;
3
+ export declare const MEMORY_SLACK_SUMMARY_MAX_UTF8_BYTES = 512;
4
+ export declare const MEMORY_SLACK_NAMESPACE_MAX_UTF8_BYTES = 128;
5
+ export declare const MEMORY_SLACK_LABEL_MAX_UTF8_BYTES = 64;
6
+ export declare const MEMORY_SLACK_LABEL_MAX_COUNT = 8;
7
+ export declare const MEMORY_SLACK_OWNER_MAX_UTF8_BYTES = 96;
8
+ export declare const MEMORY_SLACK_PROJECTION_MAX_UTF8_BYTES = 4096;
9
+ export type MemorySlackImportance = "major" | "normal" | "minor";
10
+ export type MemorySlackRequestedMode = "auto" | "review" | "never";
11
+ export type MemorySlackDeliveryMode = Exclude<MemorySlackRequestedMode, "never">;
12
+ export type MemorySlackChangeKind = "created" | "corrected" | "superseded";
13
+ export type MemorySlackOrigin = "native" | "slack_derived";
14
+ export type MemorySlackAudience = "workspace" | "restricted";
15
+ export type MemorySlackPublicationPolicy = {
16
+ enabled: boolean;
17
+ autoImportances: readonly MemorySlackImportance[];
18
+ reviewImportances: readonly MemorySlackImportance[];
19
+ };
20
+ /**
21
+ * Nothing publishes without an explicit workspace-admin enablement. When
22
+ * enabled without tuning, major changes may publish automatically, normal
23
+ * changes require review, and minor changes stay quiet.
24
+ */
25
+ export declare const DEFAULT_MEMORY_SLACK_PUBLICATION_POLICY: {
26
+ readonly enabled: false;
27
+ readonly autoImportances: readonly ["major"];
28
+ readonly reviewImportances: readonly ["normal"];
29
+ };
30
+ export type MemorySlackPublicationInput = {
31
+ context: {
32
+ accountId: string;
33
+ workspaceId: string;
34
+ now: string;
35
+ };
36
+ policy?: MemorySlackPublicationPolicy | undefined;
37
+ memory: {
38
+ sourceType: "workspace_memory";
39
+ accountId: string;
40
+ workspaceId: string;
41
+ id: string;
42
+ version: number;
43
+ status: KnowledgeMemoryStatus;
44
+ kind: KnowledgeMemoryKind;
45
+ scopeType: "workspace" | "user" | "role" | "session" | "ephemeral" | "legacy";
46
+ namespace: string;
47
+ labels: readonly string[];
48
+ validFrom: string;
49
+ validUntil: string | null;
50
+ supersedesId: string | null;
51
+ supersededById: string | null;
52
+ };
53
+ change: {
54
+ kind: MemorySlackChangeKind;
55
+ relatedMemoryId: string | null;
56
+ occurredAt: string;
57
+ origin: MemorySlackOrigin;
58
+ ownerLabel?: string | null | undefined;
59
+ };
60
+ distribution: {
61
+ importance: MemorySlackImportance;
62
+ audience: MemorySlackAudience;
63
+ slackMode: MemorySlackRequestedMode;
64
+ shareSummary: string;
65
+ };
66
+ };
67
+ export type MemorySlackPublicationDenialReason = "disabled" | "invalid_input" | "unsupported_source" | "tenant_mismatch" | "not_decision" | "status_ineligible" | "restricted_scope" | "restricted_audience" | "not_yet_valid" | "expired" | "slack_origin_loop" | "mode_never" | "below_noise_policy" | "missing_summary" | "invalid_change_lineage";
68
+ export type MemorySlackPublicationProjection = {
69
+ version: typeof MEMORY_SLACK_PROJECTION_VERSION;
70
+ workspaceId: string;
71
+ memoryId: string;
72
+ memoryVersion: number;
73
+ changeKind: MemorySlackChangeKind;
74
+ relatedMemoryId: string | null;
75
+ occurredAt: string;
76
+ importance: MemorySlackImportance;
77
+ deliveryMode: MemorySlackDeliveryMode;
78
+ summary: string;
79
+ summaryRedacted: boolean;
80
+ summaryTruncated: boolean;
81
+ namespace: string;
82
+ labels: string[];
83
+ labelsTruncated: boolean;
84
+ ownerLabel: string | null;
85
+ ownerLabelRedacted: boolean;
86
+ ownerLabelTruncated: boolean;
87
+ authoritativeRecord: {
88
+ workspaceId: string;
89
+ memoryId: string;
90
+ };
91
+ };
92
+ export type MemorySlackPublicationDecision = {
93
+ eligible: false;
94
+ reason: MemorySlackPublicationDenialReason;
95
+ } | {
96
+ eligible: true;
97
+ deliveryMode: MemorySlackDeliveryMode;
98
+ idempotencyKey: string;
99
+ projection: MemorySlackPublicationProjection;
100
+ };
101
+ /**
102
+ * Produce the only data shape a later delivery slice may persist or
103
+ * render. This is a deterministic policy/security boundary, not a persistence
104
+ * hook: callers must durably bind the returned projection and key in a later
105
+ * transaction/outbox slice.
106
+ */
107
+ export declare function evaluateMemorySlackPublication(input: MemorySlackPublicationInput): MemorySlackPublicationDecision;
@@ -0,0 +1,48 @@
1
+ import type { McpServerConfig, Settings } from "@opengeni/config";
2
+ import type { AccessGrant, ConnectionMetadata, McpPersonalConnectionDelegation, SessionTurn, ToolRef } from "@opengeni/contracts";
3
+ import { type Database, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult } from "@opengeni/db";
4
+ export type PersonalConnectionDelegationSource = {
5
+ kind: "subject";
6
+ subjectId: string;
7
+ } | {
8
+ kind: "turn";
9
+ sessionId: string;
10
+ turnId: string;
11
+ } | {
12
+ kind: "none";
13
+ };
14
+ export declare function directPersonalConnectionSubjectId(turn: Pick<SessionTurn, "source" | "initiator" | "initiatorContext">): string | undefined;
15
+ export declare function personalConnectionDelegationSourceForGrant(grant: AccessGrant): PersonalConnectionDelegationSource;
16
+ export declare function selectedPersonalConnectionServers(settings: Pick<Settings, "mcpServers">, tools: ToolRef[]): McpServerConfig[];
17
+ export declare function personalConnectionDelegationsFromVisibleConnections(input: {
18
+ servers: McpServerConfig[];
19
+ subjectId: string;
20
+ connections: ConnectionMetadata[];
21
+ }): McpPersonalConnectionDelegation[];
22
+ export declare function personalConnectionDelegationsFromParent(input: {
23
+ servers: McpServerConfig[];
24
+ parentDelegations: McpPersonalConnectionDelegation[];
25
+ }): McpPersonalConnectionDelegation[];
26
+ export declare function personalConnectionDelegationsEqual(left: McpPersonalConnectionDelegation[], right: McpPersonalConnectionDelegation[]): boolean;
27
+ export declare function personalConnectionDelegationForServer(delegations: McpPersonalConnectionDelegation[], server: Pick<McpServerConfig, "id" | "connectionRef">): McpPersonalConnectionDelegation | null;
28
+ type ConnectionCredentialResolver = (request: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
29
+ /**
30
+ * Resolves subject-owned MCP credentials only through the exact authority
31
+ * frozen on the causal turn. A direct human subject, worker Toolspace caller,
32
+ * retry, or recovery can identify the caller, but none may widen or replace
33
+ * the persisted connection UUID.
34
+ */
35
+ export declare function withFrozenPersonalConnectionDelegations(input: {
36
+ resolveCredential: ConnectionCredentialResolver;
37
+ settings: Pick<Settings, "mcpServers">;
38
+ personalConnectionDelegations: McpPersonalConnectionDelegation[];
39
+ ownerHasWorkspaceMembership: (subjectId: string) => Promise<boolean>;
40
+ }): ConnectionCredentialResolver;
41
+ export declare function freezePersonalConnectionDelegations(input: {
42
+ db: Database;
43
+ workspaceId: string;
44
+ settings: Pick<Settings, "mcpServers">;
45
+ tools: ToolRef[];
46
+ source: PersonalConnectionDelegationSource;
47
+ }): Promise<McpPersonalConnectionDelegation[]>;
48
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { Settings } from "@opengeni/config";
2
- import type { AccessGrant, ScheduledTask, CreateScheduledTaskRequest as CreateScheduledTaskPayload, UpdateScheduledTaskRequest as UpdateScheduledTaskPayload } from "@opengeni/contracts";
2
+ import type { AccessGrant, McpPersonalConnectionDelegation, ScheduledTask, CreateScheduledTaskRequest as CreateScheduledTaskPayload, UpdateScheduledTaskRequest as UpdateScheduledTaskPayload } from "@opengeni/contracts";
3
3
  import { type Database, type UpdateScheduledTaskInput } from "@opengeni/db";
4
4
  import type { SessionWorkflowClient } from "../dependencies";
5
5
  import type { ObjectStorageDependency } from "../dependencies";
@@ -32,7 +32,12 @@ export declare function validatedScheduledTaskUpdate(input: {
32
32
  toolsProvided?: boolean;
33
33
  }): Promise<UpdateScheduledTaskInput>;
34
34
  export declare function requireScheduledTaskForApi(db: Database, workspaceId: string, taskId: string): Promise<ScheduledTask>;
35
- export declare function restoreScheduledTask(db: Database, task: ScheduledTask): Promise<ScheduledTask>;
35
+ export type ScheduledTaskRestoreState = {
36
+ task: ScheduledTask;
37
+ personalConnectionDelegations: McpPersonalConnectionDelegation[];
38
+ };
39
+ export declare function captureScheduledTaskRestoreState(db: Database, task: ScheduledTask): Promise<ScheduledTaskRestoreState>;
40
+ export declare function restoreScheduledTask(db: Database, previous: ScheduledTaskRestoreState): Promise<ScheduledTask>;
36
41
  export declare function syncCreatedScheduledTask(input: {
37
42
  db: Database;
38
43
  workflowClient: SessionWorkflowClient;
@@ -41,7 +46,7 @@ export declare function syncCreatedScheduledTask(input: {
41
46
  export declare function syncUpdatedScheduledTask(input: {
42
47
  db: Database;
43
48
  workflowClient: SessionWorkflowClient;
44
- previous: ScheduledTask;
49
+ previous: ScheduledTaskRestoreState;
45
50
  task: ScheduledTask;
46
51
  }): Promise<void>;
47
52
  export declare function scheduledTaskTemporalScheduleId(taskId: string): string;
@@ -1,5 +1,5 @@
1
1
  import { type Settings } from "@opengeni/config";
2
- import { SessionSpawnDenial, type AccessGrant, type CreateSessionResponse, type GoalSpec, type FirstPartyMcpToolName, type Permission, type ReasoningEffort, type ResourceRef, type Session, type SessionSkill, type SessionEvent, SessionMcpApprovalPolicy, type SessionMcpCredentialUpdateInput, type SessionMcpServerMetadata, type UpdateSessionMcpApprovalPolicyResponse, type UpdateSessionToolPolicyRequest, type SessionAuthorizationPort, type SessionToolPolicy, type SessionTurn, type ToolRef, type TurnInitiator, type TurnInitiatorContext, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
2
+ import { SessionSpawnDenial, type AccessGrant, type CreateSessionResponse, type GoalSpec, type FirstPartyMcpToolName, type McpPersonalConnectionDelegation, type Permission, type ReasoningEffort, type ResourceRef, type Session, type SessionSkill, type SessionEvent, SessionMcpApprovalPolicy, type SessionMcpCredentialUpdateInput, type SessionMcpServerMetadata, type UpdateSessionMcpApprovalPolicyResponse, type UpdateSessionToolPolicyRequest, type SessionAuthorizationPort, type SessionToolPolicy, type SessionTurn, type ToolRef, type TurnInitiator, type TurnInitiatorContext, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
3
3
  import { type CreateSessionMcpServerInput, type Database, type UpdateSessionMcpServerCredentialsInput, type SessionCommandActor } from "@opengeni/db";
4
4
  import { type EventBus } from "@opengeni/events";
5
5
  import type { AcceptSessionUserMessageDependencies, ApiRouteDeps, SessionWorkflowClient } from "../dependencies";
@@ -40,6 +40,14 @@ export declare function sessionSpawnDenialEnvelope(error: SessionSpawnDeniedErro
40
40
  };
41
41
  };
42
42
  };
43
+ export type FrozenCreationInitiator = {
44
+ initiator?: TurnInitiator;
45
+ context?: TurnInitiatorContext;
46
+ actor?: Extract<SessionCommandActor, {
47
+ type: "agent_attempt";
48
+ }>;
49
+ };
50
+ export declare function creationInitiatorForGrant(grant: AccessGrant): FrozenCreationInitiator;
43
51
  export declare function settingsWithSessionMcpServerMetadata(settings: Settings, servers: SessionMcpServerMetadata[]): Settings;
44
52
  export declare function createAndStartSession(input: {
45
53
  requestedSessionId?: string;
@@ -79,6 +87,7 @@ export declare function createAndStartSession(input: {
79
87
  firstPartyMcpTools: FirstPartyMcpToolName[];
80
88
  mcpServers?: CreateSessionMcpServerInput[];
81
89
  sessionMcpServers?: SessionMcpServerMetadata[];
90
+ personalConnectionDelegations?: McpPersonalConnectionDelegation[];
82
91
  parentSessionId?: string | null;
83
92
  createIdempotencyKey?: string | null;
84
93
  sandboxGroupId?: string | null;
@@ -165,6 +174,7 @@ export declare function postUserMessageTurn(input: {
165
174
  latencyMode?: "standard" | "priority" | "fast" | null;
166
175
  clientEventId?: string;
167
176
  mcpCredentialUpdates?: UpdateSessionMcpServerCredentialsInput[];
177
+ personalConnectionDelegations?: McpPersonalConnectionDelegation[];
168
178
  delivery?: "send" | "steer";
169
179
  origin?: "human" | "operator";
170
180
  actor?: string;
package/dist/index.d.ts CHANGED
@@ -12,11 +12,13 @@ export * from "./domain/capabilities";
12
12
  export * from "./domain/environments";
13
13
  export * from "./rigs";
14
14
  export * from "./domain/packs";
15
+ export * from "./domain/personal-connection-delegations";
15
16
  export * from "./domain/resources";
16
17
  export * from "./domain/session-tool-policy";
17
18
  export * from "./domain/scheduled-tasks";
18
19
  export * from "./domain/sessions";
19
20
  export * from "./domain/insights";
21
+ export * from "./domain/memory-slack-publication";
20
22
  export * from "./domain/slack-bot";
21
23
  export * from "./domain/workspace-members";
22
24
  export * from "./application/new-session-drafts";