remote-codex 0.1.6 → 0.1.7

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 (34) hide show
  1. package/apps/supervisor-api/dist/index.js +6786 -5630
  2. package/apps/supervisor-web/dist/assets/{highlighted-body-OFNGDK62-DvEvXPo5.js → highlighted-body-OFNGDK62-0cYcfOfd.js} +1 -1
  3. package/apps/supervisor-web/dist/assets/index-CbIt0KnL.css +32 -0
  4. package/apps/supervisor-web/dist/assets/index-nH6a8Wwn.js +377 -0
  5. package/apps/supervisor-web/dist/assets/{xterm-CWQ1ih_R.js → xterm-DisVWgDR.js} +1 -1
  6. package/apps/supervisor-web/dist/index.html +2 -2
  7. package/package.json +5 -1
  8. package/packages/agent-runtime/src/index.ts +2 -0
  9. package/packages/agent-runtime/src/registry.ts +44 -0
  10. package/packages/agent-runtime/src/types.ts +531 -0
  11. package/packages/codex/src/appServerManager.test.ts +328 -0
  12. package/packages/codex/src/appServerManager.ts +656 -0
  13. package/packages/codex/src/historyItems.ts +1185 -0
  14. package/packages/codex/src/hookHistory.ts +224 -0
  15. package/packages/codex/src/index.ts +6 -0
  16. package/packages/codex/src/jsonrpc.test.ts +58 -0
  17. package/packages/codex/src/jsonrpc.ts +198 -0
  18. package/packages/codex/src/requestMapper.test.ts +127 -0
  19. package/packages/codex/src/requestMapper.ts +511 -0
  20. package/packages/codex/src/runtimeAdapter.ts +692 -0
  21. package/packages/codex/src/types.ts +403 -0
  22. package/packages/db/migrations/0015_agent_provider_fields.sql +14 -0
  23. package/packages/db/migrations/0016_remove_codex_thread_goal_id.sql +46 -0
  24. package/packages/db/migrations/0017_remove_codex_thread_columns.sql +85 -0
  25. package/packages/db/src/client.ts +53 -0
  26. package/packages/db/src/index.ts +5 -0
  27. package/packages/db/src/migrate.test.ts +36 -0
  28. package/packages/db/src/migrate.ts +84 -0
  29. package/packages/db/src/repositories.ts +893 -0
  30. package/packages/db/src/schema.ts +177 -0
  31. package/packages/db/src/seed.ts +51 -0
  32. package/packages/shared/src/index.ts +878 -0
  33. package/apps/supervisor-web/dist/assets/index-CQu6sRq7.css +0 -32
  34. package/apps/supervisor-web/dist/assets/index-MELw9ga_.js +0 -377
@@ -0,0 +1,177 @@
1
+ import { integer, sqliteTable, text, uniqueIndex } from 'drizzle-orm/sqlite-core';
2
+
3
+ export const hosts = sqliteTable('hosts', {
4
+ id: text('id').primaryKey(),
5
+ hostname: text('hostname').notNull(),
6
+ platform: text('platform').notNull(),
7
+ tailscaleName: text('tailscale_name'),
8
+ createdAt: text('created_at').notNull(),
9
+ lastSeenAt: text('last_seen_at').notNull()
10
+ });
11
+
12
+ export const workspaces = sqliteTable('workspaces', {
13
+ id: text('id').primaryKey(),
14
+ hostId: text('host_id').notNull(),
15
+ label: text('label').notNull(),
16
+ absPath: text('abs_path').notNull().unique(),
17
+ isFavorite: integer('is_favorite', { mode: 'boolean' }).notNull().default(false),
18
+ createdAt: text('created_at').notNull(),
19
+ lastOpenedAt: text('last_opened_at')
20
+ });
21
+
22
+ export const threads = sqliteTable('threads', {
23
+ id: text('id').primaryKey(),
24
+ workspaceId: text('workspace_id').notNull(),
25
+ provider: text('provider').notNull().default('codex'),
26
+ providerSessionId: text('provider_session_id'),
27
+ providerTurnId: text('provider_turn_id'),
28
+ source: text('source').notNull().default('supervisor'),
29
+ title: text('title').notNull(),
30
+ model: text('model'),
31
+ reasoningEffort: text('reasoning_effort'),
32
+ fastMode: integer('fast_mode', { mode: 'boolean' }).notNull().default(false),
33
+ fastBaseModel: text('fast_base_model'),
34
+ fastBaseReasoningEffort: text('fast_base_reasoning_effort'),
35
+ collaborationMode: text('collaboration_mode').notNull().default('default'),
36
+ approvalMode: text('approval_mode'),
37
+ sandboxMode: text('sandbox_mode'),
38
+ status: text('status'),
39
+ summaryText: text('summary_text'),
40
+ lastError: text('last_error'),
41
+ createdAt: text('created_at').notNull(),
42
+ updatedAt: text('updated_at').notNull(),
43
+ lastTurnStartedAt: text('last_turn_started_at'),
44
+ lastTurnCompletedAt: text('last_turn_completed_at'),
45
+ lastViewedAt: text('last_viewed_at'),
46
+ isPinned: integer('is_pinned', { mode: 'boolean' }).notNull().default(false),
47
+ isConnected: integer('is_connected', { mode: 'boolean' }).notNull().default(true)
48
+ });
49
+
50
+ export const shellSessions = sqliteTable('shell_sessions', {
51
+ id: text('id').primaryKey(),
52
+ workspaceId: text('workspace_id').notNull(),
53
+ threadId: text('thread_id'),
54
+ tmuxSessionName: text('tmux_session_name'),
55
+ cwd: text('cwd').notNull(),
56
+ status: text('status'),
57
+ createdAt: text('created_at').notNull(),
58
+ updatedAt: text('updated_at').notNull(),
59
+ lastActivityAt: text('last_activity_at')
60
+ });
61
+
62
+ export const viewerSessions = sqliteTable('viewer_sessions', {
63
+ id: text('id').primaryKey(),
64
+ threadId: text('thread_id'),
65
+ shellId: text('shell_id'),
66
+ connectedAt: text('connected_at').notNull(),
67
+ lastHeartbeatAt: text('last_heartbeat_at'),
68
+ activeTab: text('active_tab')
69
+ });
70
+
71
+ export const notifications = sqliteTable('notifications', {
72
+ id: text('id').primaryKey(),
73
+ threadId: text('thread_id'),
74
+ kind: text('kind').notNull(),
75
+ severity: text('severity').notNull(),
76
+ title: text('title').notNull(),
77
+ body: text('body').notNull(),
78
+ isRead: integer('is_read', { mode: 'boolean' }).notNull().default(false),
79
+ createdAt: text('created_at').notNull()
80
+ });
81
+
82
+ export const threadTurnMetadata = sqliteTable(
83
+ 'thread_turn_metadata',
84
+ {
85
+ id: text('id').primaryKey(),
86
+ threadId: text('thread_id').notNull(),
87
+ turnId: text('turn_id').notNull(),
88
+ model: text('model'),
89
+ reasoningEffort: text('reasoning_effort'),
90
+ reasoningEffortAvailable: integer('reasoning_effort_available', {
91
+ mode: 'boolean',
92
+ }),
93
+ pricingModelKey: text('pricing_model_key'),
94
+ pricingTierKey: text('pricing_tier_key'),
95
+ tokenUsageJson: text('token_usage_json'),
96
+ createdAt: text('created_at').notNull(),
97
+ updatedAt: text('updated_at').notNull(),
98
+ },
99
+ (table) => ({
100
+ threadTurnUnique: uniqueIndex('thread_turn_metadata_thread_turn_idx').on(
101
+ table.threadId,
102
+ table.turnId,
103
+ ),
104
+ }),
105
+ );
106
+
107
+ export const threadPendingSteers = sqliteTable('thread_pending_steers', {
108
+ id: text('id').primaryKey(),
109
+ threadId: text('thread_id').notNull(),
110
+ turnId: text('turn_id').notNull(),
111
+ clientRequestId: text('client_request_id'),
112
+ displayPrompt: text('display_prompt').notNull(),
113
+ submittedPrompt: text('submitted_prompt').notNull(),
114
+ createdAt: text('created_at').notNull(),
115
+ updatedAt: text('updated_at').notNull(),
116
+ });
117
+
118
+ export const threadHistoryItems = sqliteTable(
119
+ 'thread_history_items',
120
+ {
121
+ id: text('id').primaryKey(),
122
+ threadId: text('thread_id').notNull(),
123
+ turnId: text('turn_id').notNull(),
124
+ itemId: text('item_id').notNull(),
125
+ itemJson: text('item_json').notNull(),
126
+ createdAt: text('created_at').notNull(),
127
+ updatedAt: text('updated_at').notNull(),
128
+ },
129
+ (table) => ({
130
+ threadTurnItemUnique: uniqueIndex('thread_history_items_thread_turn_item_idx').on(
131
+ table.threadId,
132
+ table.turnId,
133
+ table.itemId,
134
+ ),
135
+ }),
136
+ );
137
+
138
+ export const threadActivityNotes = sqliteTable('thread_activity_notes', {
139
+ id: text('id').primaryKey(),
140
+ threadId: text('thread_id').notNull(),
141
+ kind: text('kind').notNull(),
142
+ text: text('text').notNull(),
143
+ anchorTurnId: text('anchor_turn_id'),
144
+ createdAt: text('created_at').notNull(),
145
+ });
146
+
147
+ export const threadForks = sqliteTable('thread_forks', {
148
+ id: text('id').primaryKey(),
149
+ sourceThreadId: text('source_thread_id').notNull(),
150
+ sourceTurnId: text('source_turn_id'),
151
+ sourceTurnIndex: integer('source_turn_index'),
152
+ forkedThreadId: text('forked_thread_id').notNull(),
153
+ createdAt: text('created_at').notNull(),
154
+ });
155
+
156
+ export const threadGoals = sqliteTable('thread_goals', {
157
+ id: text('id').primaryKey(),
158
+ threadId: text('thread_id').notNull(),
159
+ providerSessionId: text('provider_session_id').notNull(),
160
+ objective: text('objective').notNull(),
161
+ status: text('status').notNull(),
162
+ tokenBudget: integer('token_budget'),
163
+ tokensUsed: integer('tokens_used').notNull().default(0),
164
+ timeUsedSeconds: integer('time_used_seconds').notNull().default(0),
165
+ startedAt: text('started_at').notNull(),
166
+ completedAt: text('completed_at'),
167
+ createdAt: text('created_at').notNull(),
168
+ updatedAt: text('updated_at').notNull(),
169
+ });
170
+
171
+ export const policies = sqliteTable('policies', {
172
+ id: text('id').primaryKey(),
173
+ key: text('key').notNull().unique(),
174
+ valueJson: text('value_json').notNull(),
175
+ createdAt: text('created_at').notNull(),
176
+ updatedAt: text('updated_at').notNull()
177
+ });
@@ -0,0 +1,51 @@
1
+ import { eq } from 'drizzle-orm';
2
+
3
+ import { DatabaseClient, getDefaultHostRecord } from './client';
4
+ import { hosts, policies } from './schema';
5
+
6
+ const defaultPolicies = [
7
+ {
8
+ id: 'policy-workspace-root',
9
+ key: 'workspace_root',
10
+ valueJson: JSON.stringify({ enforceWithinRoot: true })
11
+ },
12
+ {
13
+ id: 'policy-dotfiles',
14
+ key: 'tree_defaults',
15
+ valueJson: JSON.stringify({ showHidden: false })
16
+ }
17
+ ];
18
+
19
+ export function seedDefaults(db: DatabaseClient) {
20
+ const host = getDefaultHostRecord();
21
+
22
+ const existingHost = db.select().from(hosts).where(eq(hosts.id, host.id)).get();
23
+
24
+ if (!existingHost) {
25
+ db.insert(hosts).values(host).run();
26
+ } else {
27
+ db.update(hosts)
28
+ .set({
29
+ hostname: host.hostname,
30
+ platform: host.platform,
31
+ lastSeenAt: host.lastSeenAt
32
+ })
33
+ .where(eq(hosts.id, host.id))
34
+ .run();
35
+ }
36
+
37
+ for (const policy of defaultPolicies) {
38
+ const existingPolicy = db.select().from(policies).where(eq(policies.key, policy.key)).get();
39
+
40
+ if (!existingPolicy) {
41
+ const now = new Date().toISOString();
42
+ db.insert(policies)
43
+ .values({
44
+ ...policy,
45
+ createdAt: now,
46
+ updatedAt: now
47
+ })
48
+ .run();
49
+ }
50
+ }
51
+ }