@opengeni/db 0.14.0 → 0.16.2
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/{chunk-ELMUCYZF.js → chunk-4RUK5CON.js} +183 -42
- package/dist/chunk-4RUK5CON.js.map +1 -0
- package/dist/chunk-HZD7KVAR.js +4648 -0
- package/dist/chunk-HZD7KVAR.js.map +1 -0
- package/dist/{chunk-Y5WZZVQK.js → chunk-SK7YYHBI.js} +5 -2
- package/dist/chunk-SK7YYHBI.js.map +1 -0
- package/dist/codex-token-resolver.d.ts +64 -0
- package/dist/connection-token-resolver.d.ts +90 -0
- package/dist/environment-crypto.d.ts +11 -0
- package/dist/event-payload-sanitizer.d.ts +32 -0
- package/dist/index.d.ts +6217 -10
- package/dist/index.js +6992 -2728
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +157 -0
- package/dist/memory-domain.d.ts +44 -0
- package/dist/migrate.d.ts +5 -7
- package/dist/migrate.js +1 -1
- package/dist/new-session-drafts.d.ts +49 -0
- package/dist/persistence-errors.d.ts +69 -0
- package/dist/preference-registry-schema.d.ts +1147 -0
- package/dist/preference-registry.d.ts +878 -0
- package/dist/provision-roles.d.ts +4 -6478
- package/dist/provision-roles.js +1 -1
- package/dist/role-relationships.d.ts +35 -0
- package/dist/runtime-posture-cli.d.ts +1 -0
- package/dist/runtime-posture.d.ts +103 -0
- package/dist/schema.d.ts +23533 -3
- package/dist/schema.js +17 -1
- package/dist/session-control.d.ts +331 -0
- package/dist/session-queue-commands.d.ts +186 -0
- package/dist/session-tool-call-settlement.d.ts +32 -0
- package/dist/turn-initiator.d.ts +28 -0
- package/dist/workspace-instruction-policies-schema.d.ts +735 -0
- package/dist/workspace-instruction-policies.d.ts +64 -0
- package/drizzle/0136_unified_session_tool_policy.sql +109 -0
- package/drizzle/0137_preference_registry.sql +1347 -0
- package/drizzle/0138_sandbox_checkpoint_artifacts_and_deadlines.sql +1074 -0
- package/drizzle/0139_codex_provider_artifact_invalidations.sql +51 -0
- package/drizzle/0140_sandbox_restore_and_reaper_fences.sql +276 -0
- package/drizzle/0142_sandbox_archive_capture_gate.sql +80 -0
- package/drizzle/0143_session_codex_compaction_mode.sql +20 -0
- package/drizzle/0144_sandbox_viewer_force_drain_gate.sql +95 -0
- package/drizzle/0145_model_call_facts.sql +96 -0
- package/drizzle/0146_slack_bot_delete_idempotency.sql +105 -0
- package/drizzle/0147_draft_latency_mode.sql +12 -0
- package/drizzle/0148_session_turn_latency_mode.sql +12 -0
- package/package.json +6 -6
- package/src/index.ts +5095 -430
- package/src/insights.ts +837 -0
- package/src/migrate.ts +9 -1
- package/src/new-session-drafts.ts +4 -0
- package/src/preference-registry-schema.ts +170 -0
- package/src/preference-registry.ts +1220 -0
- package/src/provision-roles.ts +95 -22
- package/src/role-relationships.ts +132 -0
- package/src/runtime-posture.ts +28 -26
- package/src/schema.ts +484 -12
- package/src/session-queue-commands.ts +47 -46
- package/dist/chunk-ELMUCYZF.js.map +0 -1
- package/dist/chunk-PQKVUWQW.js +0 -4047
- package/dist/chunk-PQKVUWQW.js.map +0 -1
- package/dist/chunk-Y5WZZVQK.js.map +0 -1
- package/dist/schema-FoPub9yt.d.ts +0 -22666
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { WorkspaceInstructionPolicyActivationResponse, WorkspaceInstructionPolicyDiffResponse, WorkspaceInstructionPolicyDraftProvenanceSource, WorkspaceInstructionPolicyHead, WorkspaceInstructionPolicyListQuery, WorkspaceInstructionPolicyListResponse, WorkspaceInstructionPolicyProvenanceSource, WorkspaceInstructionPolicyRevision, WorkspaceInstructionPolicyTarget } from "@opengeni/contracts";
|
|
2
|
+
import type { Database } from "./index";
|
|
3
|
+
type DraftInput = WorkspaceInstructionPolicyTarget & {
|
|
4
|
+
accountId: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
content: string;
|
|
7
|
+
provenanceSource: WorkspaceInstructionPolicyProvenanceSource;
|
|
8
|
+
provenanceSourceId: string | null;
|
|
9
|
+
supersedesRevisionId: string | null;
|
|
10
|
+
createdBySubjectId: string;
|
|
11
|
+
};
|
|
12
|
+
type CallerDraftInput = Omit<DraftInput, "provenanceSource"> & {
|
|
13
|
+
provenanceSource: WorkspaceInstructionPolicyDraftProvenanceSource;
|
|
14
|
+
};
|
|
15
|
+
export declare class WorkspaceInstructionPolicyConflictError extends Error {
|
|
16
|
+
readonly currentHead: WorkspaceInstructionPolicyHead | null;
|
|
17
|
+
readonly name = "WorkspaceInstructionPolicyConflictError";
|
|
18
|
+
readonly code = "WORKSPACE_INSTRUCTION_POLICY_CONFLICT";
|
|
19
|
+
constructor(currentHead: WorkspaceInstructionPolicyHead | null);
|
|
20
|
+
}
|
|
21
|
+
export declare class WorkspaceInstructionPolicyNotFoundError extends Error {
|
|
22
|
+
readonly name = "WorkspaceInstructionPolicyNotFoundError";
|
|
23
|
+
constructor(message?: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class WorkspaceInstructionPolicyInvalidOperationError extends Error {
|
|
26
|
+
readonly name = "WorkspaceInstructionPolicyInvalidOperationError";
|
|
27
|
+
}
|
|
28
|
+
export declare class WorkspaceInstructionPolicyLegacyUnavailableError extends Error {
|
|
29
|
+
readonly name = "WorkspaceInstructionPolicyLegacyUnavailableError";
|
|
30
|
+
constructor();
|
|
31
|
+
}
|
|
32
|
+
export declare function createWorkspaceInstructionPolicyDraft(db: Database, input: CallerDraftInput): Promise<WorkspaceInstructionPolicyRevision>;
|
|
33
|
+
/** Import only the stored legacy override; never materialize a deployment default or activate it. */
|
|
34
|
+
export declare function importLegacyWorkspaceInstructionPolicyDraft(db: Database, input: {
|
|
35
|
+
accountId: string;
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
createdBySubjectId: string;
|
|
38
|
+
supersedesRevisionId: string | null;
|
|
39
|
+
}): Promise<WorkspaceInstructionPolicyRevision>;
|
|
40
|
+
export declare function listWorkspaceInstructionPolicyRevisions(db: Database, workspaceId: string, query: WorkspaceInstructionPolicyListQuery): Promise<WorkspaceInstructionPolicyListResponse>;
|
|
41
|
+
export declare function getWorkspaceInstructionPolicyRevision(db: Database, workspaceId: string, revisionId: string): Promise<WorkspaceInstructionPolicyRevision>;
|
|
42
|
+
/** Deterministic, dependency-free unified line diff; large inputs degrade to a full replacement. */
|
|
43
|
+
export declare function diffWorkspaceInstructionPolicyContent(from: WorkspaceInstructionPolicyRevision, to: WorkspaceInstructionPolicyRevision): string;
|
|
44
|
+
export declare function diffWorkspaceInstructionPolicyRevisions(db: Database, workspaceId: string, input: {
|
|
45
|
+
fromRevisionId: string;
|
|
46
|
+
toRevisionId: string;
|
|
47
|
+
}): Promise<WorkspaceInstructionPolicyDiffResponse>;
|
|
48
|
+
export declare function activateWorkspaceInstructionPolicyRevision(db: Database, input: {
|
|
49
|
+
accountId: string;
|
|
50
|
+
workspaceId: string;
|
|
51
|
+
revisionId: string;
|
|
52
|
+
expectedCurrentRevisionId: string | null;
|
|
53
|
+
actorSubjectId: string;
|
|
54
|
+
reason: string;
|
|
55
|
+
}): Promise<WorkspaceInstructionPolicyActivationResponse>;
|
|
56
|
+
export declare function rollbackWorkspaceInstructionPolicyRevision(db: Database, input: {
|
|
57
|
+
accountId: string;
|
|
58
|
+
workspaceId: string;
|
|
59
|
+
targetRevisionId: string;
|
|
60
|
+
expectedCurrentRevisionId: string;
|
|
61
|
+
actorSubjectId: string;
|
|
62
|
+
reason: string;
|
|
63
|
+
}): Promise<WorkspaceInstructionPolicyActivationResponse>;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
-- deployment-mode: maintenance
|
|
2
|
+
-- One durable session-level tool policy. OpenGeni-native tools are selected by
|
|
3
|
+
-- default, and historical NULL/legacy shapes are eliminated before the new
|
|
4
|
+
-- API starts.
|
|
5
|
+
|
|
6
|
+
CREATE INDEX IF NOT EXISTS "session_history_items_turn_id_idx"
|
|
7
|
+
ON "session_history_items" ("turn_id")
|
|
8
|
+
WHERE "turn_id" IS NOT NULL;
|
|
9
|
+
|
|
10
|
+
ALTER TABLE "sessions"
|
|
11
|
+
ALTER COLUMN "first_party_mcp_tools"
|
|
12
|
+
SET DEFAULT '[
|
|
13
|
+
"set_session_title",
|
|
14
|
+
"goal_set",
|
|
15
|
+
"goal_update",
|
|
16
|
+
"goal_complete",
|
|
17
|
+
"goal_pause",
|
|
18
|
+
"memory_search",
|
|
19
|
+
"memory_save",
|
|
20
|
+
"memory_correct",
|
|
21
|
+
"sandboxes_list",
|
|
22
|
+
"sandbox_attach",
|
|
23
|
+
"sandbox_swap",
|
|
24
|
+
"run_on",
|
|
25
|
+
"sandbox_provision",
|
|
26
|
+
"rig_list",
|
|
27
|
+
"rig_get",
|
|
28
|
+
"rig_propose_change",
|
|
29
|
+
"rig_verify",
|
|
30
|
+
"rig_promote",
|
|
31
|
+
"sessions_list",
|
|
32
|
+
"session_get",
|
|
33
|
+
"session_events",
|
|
34
|
+
"session_create",
|
|
35
|
+
"session_send_message",
|
|
36
|
+
"session_pause",
|
|
37
|
+
"session_resume",
|
|
38
|
+
"session_steer",
|
|
39
|
+
"set_other_session_title",
|
|
40
|
+
"variable_set_list",
|
|
41
|
+
"environment_list",
|
|
42
|
+
"variable_set_set_variable",
|
|
43
|
+
"environment_set_variable",
|
|
44
|
+
"github_connect_link",
|
|
45
|
+
"github_token",
|
|
46
|
+
"github_repositories_list",
|
|
47
|
+
"social_connections_list",
|
|
48
|
+
"social_posts_recent",
|
|
49
|
+
"social_daily_analysis_context",
|
|
50
|
+
"scheduled_tasks_list",
|
|
51
|
+
"scheduled_tasks_get",
|
|
52
|
+
"scheduled_tasks_create",
|
|
53
|
+
"scheduled_tasks_update",
|
|
54
|
+
"scheduled_tasks_pause",
|
|
55
|
+
"scheduled_tasks_resume",
|
|
56
|
+
"scheduled_tasks_trigger",
|
|
57
|
+
"scheduled_tasks_delete",
|
|
58
|
+
"scheduled_task_runs_list",
|
|
59
|
+
"slack_bot_list_channels",
|
|
60
|
+
"slack_bot_channel_history",
|
|
61
|
+
"slack_bot_list_users",
|
|
62
|
+
"slack_bot_post_message"
|
|
63
|
+
]'::jsonb;
|
|
64
|
+
|
|
65
|
+
UPDATE "sessions"
|
|
66
|
+
SET "first_party_mcp_tools" = DEFAULT
|
|
67
|
+
WHERE "first_party_mcp_tools" IS NULL;
|
|
68
|
+
|
|
69
|
+
SET CONSTRAINTS ALL IMMEDIATE;
|
|
70
|
+
|
|
71
|
+
ALTER TABLE "sessions"
|
|
72
|
+
ALTER COLUMN "first_party_mcp_tools" SET NOT NULL;
|
|
73
|
+
|
|
74
|
+
UPDATE "sessions"
|
|
75
|
+
SET "tool_policy" = jsonb_build_object(
|
|
76
|
+
'mode', 'explicit',
|
|
77
|
+
'inheritedFromSessionId', "parent_session_id"
|
|
78
|
+
)
|
|
79
|
+
WHERE "tool_policy" IS NULL
|
|
80
|
+
OR "tool_policy" ->> 'mode' = 'legacy';
|
|
81
|
+
|
|
82
|
+
SET CONSTRAINTS ALL IMMEDIATE;
|
|
83
|
+
|
|
84
|
+
ALTER TABLE "sessions"
|
|
85
|
+
ALTER COLUMN "tool_policy" SET NOT NULL;
|
|
86
|
+
|
|
87
|
+
ALTER TABLE "sessions"
|
|
88
|
+
DROP CONSTRAINT IF EXISTS "sessions_tool_policy_shape_check";
|
|
89
|
+
|
|
90
|
+
ALTER TABLE "sessions"
|
|
91
|
+
ADD CONSTRAINT "sessions_tool_policy_shape_check"
|
|
92
|
+
CHECK (
|
|
93
|
+
jsonb_typeof("tool_policy") = 'object'
|
|
94
|
+
AND "tool_policy" ? 'mode'
|
|
95
|
+
AND ("tool_policy" ->> 'mode') IN ('workspace_default', 'explicit', 'inherited')
|
|
96
|
+
AND "tool_policy" ? 'inheritedFromSessionId'
|
|
97
|
+
AND (
|
|
98
|
+
("tool_policy" ->> 'inheritedFromSessionId') IS NULL
|
|
99
|
+
OR ("tool_policy" ->> 'inheritedFromSessionId') ~ '^[0-9a-fA-F-]{36}$'
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
-- Existing-session drafts no longer carry a one-turn tool policy. Keep only
|
|
104
|
+
-- the message, resources, model, and effort represented by the current API.
|
|
105
|
+
UPDATE "composer_drafts"
|
|
106
|
+
SET "tools" = '[]'::jsonb,
|
|
107
|
+
"tools_provided" = false
|
|
108
|
+
WHERE "tools" <> '[]'::jsonb
|
|
109
|
+
OR "tools_provided" = true;
|