fuli-context 0.7.4-beta.3 → 0.7.6

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 (130) hide show
  1. package/README.md +77 -6
  2. package/README.zh-CN.md +69 -6
  3. package/compose.graphiti.yml +6 -6
  4. package/dist/web/assets/AboutPage-sLV9WChi.js +1 -0
  5. package/dist/web/assets/ConnectionsPage-BWn4ywGJ.js +1 -0
  6. package/dist/web/assets/KnowledgeEditDialog-CZ5ziPrD.js +1 -0
  7. package/dist/web/assets/KnowledgeInspector-CRQWOaos.js +1 -0
  8. package/dist/web/assets/KnowledgeOrganizerPage-Dfj3vIpU.js +1 -0
  9. package/dist/web/assets/KnowledgePage-BRYC9S5Y.js +1 -0
  10. package/dist/web/assets/KnowledgeWorkspace-ChEB5Bwk.js +4 -0
  11. package/dist/web/assets/OverviewPage-Cd66M0RT.js +1 -0
  12. package/dist/web/assets/PersonalProfilePage-RCFHL0Wz.js +1 -0
  13. package/dist/web/assets/PersonalProjectsPage-DEh8XWby.js +1 -0
  14. package/dist/web/assets/ProjectAgentsPage-Crh7PrXa.css +1 -0
  15. package/dist/web/assets/ProjectAgentsPage-DPnaH-TR.js +11 -0
  16. package/dist/web/assets/PublicProjectsPage-mstPEjHe.js +1 -0
  17. package/dist/web/assets/ReviewPage-6Y1SmfZy.js +1 -0
  18. package/dist/web/assets/SearchableSelect-D3HM8YF8.js +1 -0
  19. package/dist/web/assets/SettingsPage--LdTMUm7.js +1 -0
  20. package/dist/web/assets/SettingsPage-CwZp2ka4.css +1 -0
  21. package/dist/web/assets/WritingTastePage-CIpKswvs.js +1 -0
  22. package/dist/web/assets/{console-D_2zC4lm.js → console-BT1P2Db4.js} +1 -1
  23. package/dist/web/assets/{conversation-launcher-settings-DQmMH2j7.js → conversation-launcher-settings-DrJEotdf.js} +1 -1
  24. package/dist/web/assets/i18n-js6gfc7j.js +9 -0
  25. package/dist/web/assets/{identity-DmGcY3Y6.js → identity-CfDfanpa.js} +1 -1
  26. package/dist/web/assets/index-BnH5mcZx.css +1 -0
  27. package/dist/web/assets/index-GqJf1xqg.js +2 -0
  28. package/dist/web/assets/{model-CVoOdRsL.js → model-DJkLAJsg.js} +1 -1
  29. package/dist/web/assets/{useApi-CROJJdhE-CBNg4CdH.js → useApi-CROJJdhE-BdSti7Y2.js} +1 -1
  30. package/dist/web/assets/vue-router-Kk67EaCP.js +1 -0
  31. package/dist/web/index.html +6 -6
  32. package/graph-provider/fuli_graph/app.py +8 -0
  33. package/graph-provider/fuli_graph/collaboration_context.py +69 -6
  34. package/graph-provider/fuli_graph/knowledge_search.py +84 -5
  35. package/graph-provider/fuli_graph/model_validation.py +130 -0
  36. package/graph-provider/fuli_graph/models.py +24 -5
  37. package/graph-provider/fuli_graph/project_agent_access.py +54 -0
  38. package/graph-provider/fuli_graph/project_agent_coordination_models.py +22 -0
  39. package/graph-provider/fuli_graph/project_agent_executor_models.py +635 -0
  40. package/graph-provider/fuli_graph/project_agent_models.py +278 -0
  41. package/graph-provider/fuli_graph/project_agent_routes.py +626 -0
  42. package/graph-provider/fuli_graph/project_agent_task_models.py +545 -0
  43. package/graph-provider/fuli_graph/runtime.py +259 -0
  44. package/graph-provider/fuli_graph/search_projection.py +3 -0
  45. package/graph-provider/fuli_graph/store.py +6 -0
  46. package/graph-provider/fuli_graph/store_knowledge.py +62 -9
  47. package/graph-provider/fuli_graph/store_project_agent_coordination_policy.py +122 -0
  48. package/graph-provider/fuli_graph/store_project_agent_executor_learning.py +756 -0
  49. package/graph-provider/fuli_graph/store_project_agent_executor_routing.py +601 -0
  50. package/graph-provider/fuli_graph/store_project_agent_executors.py +1087 -0
  51. package/graph-provider/fuli_graph/store_project_agent_task_reads.py +458 -0
  52. package/graph-provider/fuli_graph/store_project_agent_task_recruitment.py +705 -0
  53. package/graph-provider/fuli_graph/store_project_agent_task_staffing.py +586 -0
  54. package/graph-provider/fuli_graph/store_project_agent_tasks.py +1151 -0
  55. package/graph-provider/fuli_graph/store_project_agents.py +965 -0
  56. package/graph-provider/pyproject.toml +2 -1
  57. package/npm-shrinkwrap.json +2 -2
  58. package/package.json +1 -1
  59. package/skills/capturing-session-knowledge/SKILL.md +39 -0
  60. package/src/adaptive-runtime/executor-pool.js +127 -0
  61. package/src/adaptive-runtime/graph-services.js +166 -0
  62. package/src/adaptive-runtime/lease-client.js +335 -0
  63. package/src/adaptive-runtime/runtime-broker.js +318 -0
  64. package/src/adaptive-runtime/settings.js +111 -0
  65. package/src/adaptive-runtime/state.js +74 -0
  66. package/src/agent-tools/graph-definitions.js +419 -0
  67. package/src/agent-tools/graph-handlers.js +65 -0
  68. package/src/agent-tools/project-agent-definitions.js +307 -0
  69. package/src/backup/graph-backup.js +289 -0
  70. package/src/backup/identity-reconciliation.js +208 -0
  71. package/src/backup/runtime-adapters.js +269 -0
  72. package/src/cli/command-registry.js +6 -2
  73. package/src/cli/graph-data-command.js +112 -0
  74. package/src/cli/local-runtime-command.js +16 -2
  75. package/src/cli/setup-command.js +19 -3
  76. package/src/cli/update-command.js +4 -0
  77. package/src/cli.js +6 -0
  78. package/src/graphiti/collaboration-preference-projection.js +29 -1
  79. package/src/graphiti/collaboration-preference-workflow.js +121 -0
  80. package/src/graphiti/federated-application.js +53 -90
  81. package/src/graphiti/project-agent-control-plane.js +275 -0
  82. package/src/graphiti/project-agent-mapping.js +1024 -0
  83. package/src/graphiti/project-agent-workflows.js +576 -0
  84. package/src/graphiti/provider-client.js +282 -1
  85. package/src/http/api-router.js +63 -9
  86. package/src/http/graph-api-router.js +290 -0
  87. package/src/local-runtime/lifecycle.js +46 -10
  88. package/src/mcp/context-resources.js +15 -6
  89. package/src/mcp/create-mcp-server.js +51 -16
  90. package/src/mcp/instructions.js +7 -5
  91. package/src/mcp/runtime.js +17 -5
  92. package/src/mcp/session-id.js +38 -1
  93. package/src/mcp/tool-annotations.js +71 -0
  94. package/src/mcp-server.js +23 -6
  95. package/src/native-runtime/runtime.js +717 -0
  96. package/src/server.js +6 -2
  97. package/src/setup/agent-installation-status.js +7 -1
  98. package/src/setup/agents.js +3 -1
  99. package/src/setup/claude-code-config.js +3 -1
  100. package/src/setup/codex-bootstrap.js +11 -10
  101. package/src/setup/codex-config.js +7 -1
  102. package/src/setup/cursor-config.js +3 -1
  103. package/src/setup/graph-runtime.js +158 -13
  104. package/src/setup/neo4j-memory-profile.js +43 -0
  105. package/src/setup/options.js +38 -2
  106. package/src/setup/paths.js +14 -0
  107. package/src/setup/setup.js +37 -1
  108. package/src/system/resource-monitor.js +181 -16
  109. package/src/system/runtime-settings.js +10 -1
  110. package/src/system/system-service.js +27 -2
  111. package/dist/web/assets/AboutPage-Dpf5fRWv.js +0 -1
  112. package/dist/web/assets/ConnectionsPage-D21aUDCP.js +0 -1
  113. package/dist/web/assets/KnowledgeEditDialog-u7lpfN3j.js +0 -1
  114. package/dist/web/assets/KnowledgeInspector-k4xnHtXd.js +0 -1
  115. package/dist/web/assets/KnowledgeOrganizerPage-Bdj7Rn84.js +0 -1
  116. package/dist/web/assets/KnowledgePage-UHVAbC1W.js +0 -1
  117. package/dist/web/assets/KnowledgeWorkspace-Lq3d-MeC.js +0 -4
  118. package/dist/web/assets/OverviewPage-CycAgA1V.js +0 -1
  119. package/dist/web/assets/PersonalProfilePage-U9oIV5FT.js +0 -1
  120. package/dist/web/assets/PersonalProjectsPage-C5RpXKcA.js +0 -1
  121. package/dist/web/assets/PublicProjectsPage-DiWxm35E.js +0 -1
  122. package/dist/web/assets/ReviewPage-jxRfGSJK.js +0 -1
  123. package/dist/web/assets/SearchableSelect-B3-5IPup.js +0 -1
  124. package/dist/web/assets/SettingsPage-BqfGDOho.js +0 -1
  125. package/dist/web/assets/SettingsPage-CAfz4qiV.css +0 -1
  126. package/dist/web/assets/WritingTastePage-BJxhMqJR.js +0 -1
  127. package/dist/web/assets/i18n-CwqXDI1C.js +0 -5
  128. package/dist/web/assets/index-IUGLt4lG.js +0 -2
  129. package/dist/web/assets/index-X2j29j8i.css +0 -1
  130. package/dist/web/assets/vue-router-CWSsUUio.js +0 -1
@@ -0,0 +1,1024 @@
1
+ export function providerProjectAgentProfile(profile) {
2
+ if (!profile || typeof profile !== 'object') {
3
+ throw new TypeError('Project Agent profile is required');
4
+ }
5
+ const result = {
6
+ name: profile.name,
7
+ responsibility: profile.responsibility,
8
+ capabilities: profile.capabilities ?? [],
9
+ initial_preferences: profile.initialPreferences ?? profile.initial_preferences ?? [],
10
+ status: profile.status ?? 'active'
11
+ };
12
+ copyOptional(result, 'occupation_emoji', profile.occupationEmoji !== undefined
13
+ ? profile.occupationEmoji : profile.occupation_emoji,
14
+ hasAny(profile, ['occupationEmoji', 'occupation_emoji']));
15
+ copyOptional(result, 'agent_type', profile.agentType ?? profile.agent_type,
16
+ hasAny(profile, ['agentType', 'agent_type']));
17
+ copyOptional(result, 'work_kinds', profile.workKinds ?? profile.work_kinds,
18
+ hasAny(profile, ['workKinds', 'work_kinds']));
19
+ copyOptional(
20
+ result,
21
+ 'default_model_strategy',
22
+ providerModelStrategy(profile.defaultModelStrategy ?? profile.default_model_strategy),
23
+ hasAny(profile, ['defaultModelStrategy', 'default_model_strategy'])
24
+ );
25
+ copyOptional(result, 'allowed_clients', profile.allowedClients ?? profile.allowed_clients,
26
+ hasAny(profile, ['allowedClients', 'allowed_clients']));
27
+ copyOptional(result, 'test_source', profile.testSource ?? profile.test_source,
28
+ hasAny(profile, ['testSource', 'test_source']));
29
+ copyOptional(result, 'cleanup_eligible', profile.cleanupEligible ?? profile.cleanup_eligible,
30
+ hasAny(profile, ['cleanupEligible', 'cleanup_eligible']));
31
+ copyOptional(
32
+ result,
33
+ 'executor_policy',
34
+ providerExecutorPolicy(profile.executorPolicy ?? profile.executor_policy),
35
+ hasAny(profile, ['executorPolicy', 'executor_policy'])
36
+ );
37
+ return result;
38
+ }
39
+
40
+ export function projectAgentRecord(value) {
41
+ const profile = value.profile ?? {};
42
+ const result = {
43
+ agentId: value.agent_id,
44
+ personalSpaceId: value.personal_space_id,
45
+ personalProjectId: value.personal_project_id,
46
+ profile: {
47
+ name: profile.name,
48
+ responsibility: profile.responsibility,
49
+ capabilities: profile.capabilities ?? [],
50
+ initialPreferences: profile.initial_preferences ?? [],
51
+ status: profile.status
52
+ },
53
+ createdAt: value.created_at,
54
+ updatedAt: value.updated_at
55
+ };
56
+ copyOptional(
57
+ result.profile,
58
+ 'occupationEmoji',
59
+ profile.occupationEmoji !== undefined ? profile.occupationEmoji : profile.occupation_emoji,
60
+ hasAny(profile, ['occupationEmoji', 'occupation_emoji'])
61
+ );
62
+ copyOptional(result.profile, 'agentType', profile.agent_type,
63
+ Object.hasOwn(profile, 'agent_type'));
64
+ copyOptional(result.profile, 'workKinds', profile.work_kinds,
65
+ Object.hasOwn(profile, 'work_kinds'));
66
+ copyOptional(
67
+ result.profile,
68
+ 'defaultModelStrategy',
69
+ projectAgentModelStrategy(profile.default_model_strategy),
70
+ Object.hasOwn(profile, 'default_model_strategy')
71
+ );
72
+ copyOptional(result.profile, 'allowedClients', profile.allowed_clients,
73
+ Object.hasOwn(profile, 'allowed_clients'));
74
+ copyOptional(result.profile, 'testSource', profile.test_source,
75
+ Object.hasOwn(profile, 'test_source'));
76
+ copyOptional(result.profile, 'cleanupEligible', profile.cleanup_eligible,
77
+ Object.hasOwn(profile, 'cleanup_eligible'));
78
+ copyOptional(
79
+ result.profile,
80
+ 'executorPolicy',
81
+ projectAgentExecutorPolicy(profile.executor_policy),
82
+ Object.hasOwn(profile, 'executor_policy')
83
+ );
84
+ copyOptional(
85
+ result,
86
+ 'executorPolicy',
87
+ projectAgentExecutorPolicy(value.executor_policy),
88
+ Object.hasOwn(value, 'executor_policy')
89
+ );
90
+ copyOptional(result, 'memoryScope', value.memory_scope,
91
+ Object.hasOwn(value, 'memory_scope'));
92
+ copyOptional(result, 'assignments', (value.assignments ?? []).map(projectAgentAssignmentRecord),
93
+ Object.hasOwn(value, 'assignments'));
94
+ copyOptional(result, 'recruitmentId', value.recruitment_id,
95
+ Object.hasOwn(value, 'recruitment_id'));
96
+ copyOptional(result, 'temporaryTaskId', value.temporary_task_id,
97
+ Object.hasOwn(value, 'temporary_task_id'));
98
+ copyOptional(result, 'workStatus', value.work_status,
99
+ Object.hasOwn(value, 'work_status'));
100
+ copyOptional(result, 'openTaskCount', value.open_task_count,
101
+ Object.hasOwn(value, 'open_task_count'));
102
+ copyOptional(result, 'currentTaskId', value.current_task_id,
103
+ Object.hasOwn(value, 'current_task_id'));
104
+ copyOptional(result, 'observedClients', value.observed_clients,
105
+ Object.hasOwn(value, 'observed_clients'));
106
+ copyOptional(result, 'recruitedAt', value.recruited_at,
107
+ Object.hasOwn(value, 'recruited_at'));
108
+ copyOptional(result, 'recruitmentReason', value.recruitment_reason,
109
+ Object.hasOwn(value, 'recruitment_reason'));
110
+ copyOptional(result, 'recruitmentSourceApplication', value.recruitment_source_application,
111
+ Object.hasOwn(value, 'recruitment_source_application'));
112
+ copyOptional(
113
+ result,
114
+ 'executionSummary',
115
+ projectAgentExecutionSummary(value.execution_summary ?? value.executionSummary),
116
+ hasAny(value, ['execution_summary', 'executionSummary'])
117
+ );
118
+ return result;
119
+ }
120
+
121
+ export function providerModelStrategy(value) {
122
+ if (value === undefined || value === null) return value ?? null;
123
+ const strategy = {
124
+ mode: value.mode ?? 'adaptive',
125
+ reasoning_effort: value.reasoningEffort ?? value.reasoning_effort ?? 'default',
126
+ capability_hints: value.capabilityHints ?? value.capability_hints ?? []
127
+ };
128
+ return strategy;
129
+ }
130
+
131
+ export function projectAgentModelStrategy(value) {
132
+ if (value === undefined || value === null) return value ?? null;
133
+ return {
134
+ mode: value.mode ?? 'adaptive',
135
+ reasoningEffort: value.reasoning_effort ?? value.reasoningEffort ?? 'default',
136
+ capabilityHints: value.capability_hints ?? value.capabilityHints ?? []
137
+ };
138
+ }
139
+
140
+ export function providerExecutorPolicy(value) {
141
+ if (value === undefined || value === null) return value ?? null;
142
+ return {
143
+ mode: value.mode ?? 'flexible',
144
+ locked_executor_ids: value.lockedExecutorIds ?? value.locked_executor_ids ?? [],
145
+ preferred_executor_ids: value.preferredExecutorIds ?? value.preferred_executor_ids ?? []
146
+ };
147
+ }
148
+
149
+ export function projectAgentExecutorPolicy(value) {
150
+ if (value === undefined || value === null) return value ?? null;
151
+ return {
152
+ mode: value.mode ?? 'flexible',
153
+ lockedExecutorIds: value.locked_executor_ids ?? value.lockedExecutorIds ?? [],
154
+ preferredExecutorIds: value.preferred_executor_ids ?? value.preferredExecutorIds ?? []
155
+ };
156
+ }
157
+
158
+ export function providerProjectAgentAssignment(input) {
159
+ if (!input || typeof input !== 'object') {
160
+ throw new TypeError('Project Agent assignment is required');
161
+ }
162
+ const result = {
163
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
164
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
165
+ agent_id: input.agentId ?? input.agent_id,
166
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
167
+ responsibility: input.responsibility,
168
+ work_kinds: input.workKinds ?? input.work_kinds ?? [],
169
+ capabilities: input.capabilities ?? [],
170
+ model_strategy_override: providerModelStrategy(
171
+ input.modelStrategyOverride ?? input.model_strategy_override
172
+ ),
173
+ executor_policy_override: providerExecutorPolicy(
174
+ input.executorPolicyOverride ?? input.executor_policy_override
175
+ ),
176
+ reason: input.reason,
177
+ source_application: input.sourceApplication ?? input.source_application ?? null,
178
+ source_session_id: input.sourceSessionId ?? input.source_session_id ?? null
179
+ };
180
+ return result;
181
+ }
182
+
183
+ export function providerProjectAgentAssignmentEnd(input) {
184
+ return {
185
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
186
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
187
+ assignment_id: input.assignmentId ?? input.assignment_id,
188
+ expected_revision: input.expectedRevision ?? input.expected_revision,
189
+ reason: input.reason
190
+ };
191
+ }
192
+
193
+ export function providerProjectAgentAssignmentReplace(input) {
194
+ return {
195
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
196
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
197
+ assignment_id: input.assignmentId ?? input.assignment_id,
198
+ expected_revision: input.expectedRevision ?? input.expected_revision,
199
+ replacement_agent_id: input.replacementAgentId ?? input.replacement_agent_id,
200
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
201
+ responsibility: input.responsibility,
202
+ work_kinds: input.workKinds ?? input.work_kinds ?? [],
203
+ capabilities: input.capabilities ?? [],
204
+ model_strategy_override: providerModelStrategy(
205
+ input.modelStrategyOverride ?? input.model_strategy_override
206
+ ),
207
+ executor_policy_override: providerExecutorPolicy(
208
+ input.executorPolicyOverride ?? input.executor_policy_override
209
+ ),
210
+ reason: input.reason,
211
+ source_application: input.sourceApplication ?? input.source_application ?? null,
212
+ source_session_id: input.sourceSessionId ?? input.source_session_id ?? null
213
+ };
214
+ }
215
+
216
+ export function projectAgentAssignmentRecord(value = {}) {
217
+ return {
218
+ assignmentId: value.assignment_id ?? value.id,
219
+ personalSpaceId: value.personal_space_id,
220
+ personalProjectId: value.personal_project_id,
221
+ agentId: value.agent_id,
222
+ responsibility: value.responsibility,
223
+ workKinds: value.work_kinds ?? [],
224
+ capabilities: value.capabilities ?? [],
225
+ modelStrategyOverride: projectAgentModelStrategy(value.model_strategy_override),
226
+ executorPolicyOverride: projectAgentExecutorPolicy(value.executor_policy_override),
227
+ reason: value.reason,
228
+ status: value.status,
229
+ revision: value.revision,
230
+ sourceApplication: value.source_application ?? null,
231
+ sourceSessionId: value.source_session_id ?? null,
232
+ assignedAt: value.assigned_at,
233
+ updatedAt: value.updated_at,
234
+ endedAt: value.ended_at ?? null,
235
+ endReason: value.end_reason ?? null,
236
+ replacedByAssignmentId: value.replaced_by_assignment_id ?? null
237
+ };
238
+ }
239
+
240
+ export function providerProjectAgentTaskSubmit(input) {
241
+ const result = {
242
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
243
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
244
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
245
+ title: input.title,
246
+ objective: input.objective,
247
+ work_kind: input.workKind ?? input.work_kind,
248
+ required_capabilities: input.requiredCapabilities ?? input.required_capabilities ?? [],
249
+ duration: input.duration ?? 'ongoing',
250
+ staffing_intent: input.staffingIntent ?? input.staffing_intent ?? 'reuse_preferred',
251
+ lead_agent_id: input.leadAgentId ?? input.lead_agent_id ?? null,
252
+ collaborator_agent_ids: input.collaboratorAgentIds ?? input.collaborator_agent_ids ?? [],
253
+ coordinator_agent_id: input.coordinatorAgentId ?? input.coordinator_agent_id ?? null,
254
+ complexity_hint: input.complexityHint ?? input.complexity_hint ?? null,
255
+ parallel_plan: providerParallelPlan(input.parallelPlan ?? input.parallel_plan),
256
+ model_strategy_override: providerModelStrategy(
257
+ input.modelStrategyOverride ?? input.model_strategy_override
258
+ ),
259
+ source_application: input.sourceApplication ?? input.source_application ?? null,
260
+ source_session_id: input.sourceSessionId ?? input.source_session_id ?? null,
261
+ routing_reason: input.routingReason ?? input.routing_reason,
262
+ recruitment_profile: input.recruitmentProfile
263
+ ? providerProjectAgentProfile(input.recruitmentProfile)
264
+ : input.recruitment_profile ?? null,
265
+ executor_policy_override: providerExecutorPolicy(
266
+ input.executorPolicyOverride ?? input.executor_policy_override
267
+ )
268
+ };
269
+ return result;
270
+ }
271
+
272
+ export function providerParallelPlan(value) {
273
+ if (value === undefined || value === null) {
274
+ return { enabled: false, independent_verification: false, conflict_free_scopes: false,
275
+ reason: null, workstream_boundaries: [] };
276
+ }
277
+ return {
278
+ enabled: value.enabled ?? false,
279
+ independent_verification: value.independentVerification ?? value.independent_verification ?? false,
280
+ conflict_free_scopes: value.conflictFreeScopes ?? value.conflict_free_scopes ?? false,
281
+ reason: value.reason ?? null,
282
+ workstream_boundaries: value.workstreamBoundaries ?? value.workstream_boundaries ?? []
283
+ };
284
+ }
285
+
286
+ export function projectAgentParallelPlan(value = {}) {
287
+ return {
288
+ enabled: value.enabled ?? false,
289
+ independentVerification: value.independent_verification ?? value.independentVerification ?? false,
290
+ conflictFreeScopes: value.conflict_free_scopes ?? value.conflictFreeScopes ?? false,
291
+ reason: value.reason ?? null,
292
+ workstreamBoundaries: value.workstream_boundaries ?? value.workstreamBoundaries ?? []
293
+ };
294
+ }
295
+
296
+ export function providerProjectAgentTaskActivity(input) {
297
+ const result = withoutUndefined({
298
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
299
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
300
+ task_id: input.taskId ?? input.task_id,
301
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
302
+ expected_revision: input.expectedRevision ?? input.expected_revision,
303
+ status: input.status,
304
+ summary: input.summary,
305
+ agent_id: input.agentId ?? input.agent_id ?? null,
306
+ actor_kind: input.actorKind ?? input.actor_kind ?? 'agent',
307
+ source_application: input.sourceApplication ?? input.source_application ?? null,
308
+ source_session_id: input.sourceSessionId ?? input.source_session_id ?? null,
309
+ actual_model_provider: input.actualModelProvider ?? input.actual_model_provider ?? null,
310
+ actual_model: input.actualModel ?? input.actual_model ?? null,
311
+ actual_executor_id: input.actualExecutorId ?? input.actual_executor_id ??
312
+ input.actualExecutor ?? input.actual_executor ?? null,
313
+ matched_executor_rule_id: input.matchedExecutorRuleId ??
314
+ input.matched_executor_rule_id ?? input.routingRuleId ?? input.routing_rule_id ?? null,
315
+ executor_selection_reason: input.executorSelectionReason ??
316
+ input.executor_selection_reason ?? null,
317
+ executor_fallback_reason: input.executorFallbackReason ??
318
+ input.executor_fallback_reason ?? input.fallbackReason ?? input.fallback_reason ?? null,
319
+ executor_blocked_reason: input.executorBlockedReason ??
320
+ input.executor_blocked_reason ?? null
321
+ });
322
+ if (hasAny(input, [
323
+ 'workerId', 'worker_id', 'workerLabel', 'worker_label',
324
+ 'workerOccupationEmoji', 'worker_occupation_emoji',
325
+ 'workerStatus', 'worker_status'
326
+ ])) {
327
+ Object.assign(result, {
328
+ worker_id: input.workerId ?? input.worker_id ?? null,
329
+ worker_label: input.workerLabel ?? input.worker_label ?? null,
330
+ worker_occupation_emoji: input.workerOccupationEmoji ??
331
+ input.worker_occupation_emoji ?? null,
332
+ worker_status: input.workerStatus ?? input.worker_status ?? null
333
+ });
334
+ }
335
+ return result;
336
+ }
337
+
338
+ export function projectAgentTaskRecord(value = {}) {
339
+ const result = {
340
+ taskId: value.task_id,
341
+ personalSpaceId: value.personal_space_id,
342
+ personalProjectId: value.personal_project_id,
343
+ title: value.title,
344
+ objective: value.objective,
345
+ workKind: value.work_kind,
346
+ requiredCapabilities: value.required_capabilities ?? [],
347
+ duration: value.duration,
348
+ staffingIntent: value.staffing_intent,
349
+ status: value.status,
350
+ revision: value.revision,
351
+ routingOutcome: value.routing_outcome,
352
+ routingReason: value.routing_reason,
353
+ routingExplanation: value.routing_explanation,
354
+ matchBasis: value.match_basis ?? [],
355
+ coordinatorAgentId: value.coordinator_agent_id,
356
+ complexity: value.complexity,
357
+ complexityBasis: value.complexity_basis ?? [],
358
+ routingDecision: value.routing_decision
359
+ ? projectAgentRoutingDecisionRecord(value.routing_decision) : null,
360
+ leadAgentId: value.lead_agent_id ?? null,
361
+ participants: (value.participants ?? []).map(projectAgentTaskParticipantRecord),
362
+ effectiveModelStrategy: projectAgentModelStrategy(value.effective_model_strategy),
363
+ modelStrategySource: value.model_strategy_source,
364
+ executorPolicy: projectAgentExecutorPolicy(value.executor_policy),
365
+ hrAgentId: value.hr_agent_id ?? null,
366
+ recruitmentId: value.recruitment_id ?? null,
367
+ sourceApplication: value.source_application ?? null,
368
+ sourceSessionId: value.source_session_id ?? null,
369
+ resultSummary: value.result_summary ?? null,
370
+ failureReason: value.failure_reason ?? null,
371
+ runId: value.actual_run_id ?? value.run_id ?? null,
372
+ actualExecutor: value.actual_executor_id ?? value.actual_executor ?? null,
373
+ selectedExecutorId: value.selected_executor_id ?? null,
374
+ executorRuleId: value.executor_rule_id ?? value.rule_id ?? null,
375
+ matchedExecutorRuleId: value.matched_executor_rule_id ?? value.routing_rule_id ?? null,
376
+ executorSelectionReason: value.executor_selection_reason ?? null,
377
+ executorFallbackReason: value.executor_fallback_reason ?? null,
378
+ executorFallbackOutcome: value.executor_fallback_outcome ?? null,
379
+ executorBlockedReason: value.executor_blocked_reason ?? null,
380
+ executorDecision: value.executor_decision ?? null,
381
+ auditId: value.audit_id ?? null,
382
+ actualModelProvider: value.actual_model_provider ?? null,
383
+ actualModel: value.actual_model ?? null,
384
+ routingRuleId: value.matched_executor_rule_id ?? value.routing_rule_id ?? null,
385
+ fallbackReason: value.executor_fallback_reason ?? value.fallback_reason ?? null,
386
+ fallbackUsed: value.fallback_used ?? false,
387
+ createdAt: value.created_at,
388
+ updatedAt: value.updated_at,
389
+ completedAt: value.completed_at ?? null,
390
+ events: (value.events ?? []).map(projectAgentTaskEventRecord)
391
+ };
392
+ copyOptional(
393
+ result,
394
+ 'executionSummary',
395
+ projectAgentExecutionSummary(value.execution_summary ?? value.executionSummary),
396
+ hasAny(value, ['execution_summary', 'executionSummary'])
397
+ );
398
+ return result;
399
+ }
400
+
401
+ export function projectAgentTaskParticipantRecord(value = {}) {
402
+ return {
403
+ agentId: value.agent_id,
404
+ role: value.role,
405
+ status: value.status,
406
+ assignmentSummary: value.assignment_summary ?? null,
407
+ joinedAt: value.joined_at,
408
+ updatedAt: value.updated_at,
409
+ endedAt: value.ended_at ?? null
410
+ };
411
+ }
412
+
413
+ export function projectAgentTaskEventRecord(value = {}) {
414
+ return {
415
+ eventId: value.event_id,
416
+ taskId: value.task_id,
417
+ agentId: value.agent_id ?? null,
418
+ status: value.status,
419
+ actorKind: value.actor_kind,
420
+ summary: value.summary,
421
+ sourceApplication: value.source_application ?? null,
422
+ sourceSessionId: value.source_session_id ?? null,
423
+ actualExecutor: value.actual_executor_id ?? value.actual_executor ?? null,
424
+ executorRuleId: value.executor_rule_id ?? value.rule_id ?? null,
425
+ matchedExecutorRuleId: value.matched_executor_rule_id ?? value.routing_rule_id ?? null,
426
+ executorSelectionReason: value.executor_selection_reason ?? null,
427
+ executorFallbackReason: value.executor_fallback_reason ?? null,
428
+ executorBlockedReason: value.executor_blocked_reason ?? null,
429
+ auditId: value.audit_id ?? null,
430
+ actualModelProvider: value.actual_model_provider ?? null,
431
+ actualModel: value.actual_model ?? null,
432
+ workerId: value.worker_id ?? value.workerId ?? null,
433
+ workerLabel: value.worker_label ?? value.workerLabel ?? null,
434
+ workerOccupationEmoji: value.worker_occupation_emoji ??
435
+ value.workerOccupationEmoji ?? null,
436
+ workerStatus: value.worker_status ?? value.workerStatus ?? null,
437
+ routingRuleId: value.matched_executor_rule_id ?? value.routing_rule_id ?? null,
438
+ fallbackReason: value.executor_fallback_reason ?? value.fallback_reason ?? null,
439
+ fallbackUsed: value.fallback_used ?? false,
440
+ createdAt: value.created_at
441
+ };
442
+ }
443
+
444
+ export function projectAgentRoutingDecisionRecord(value = {}) {
445
+ return {
446
+ decisionId: value.decision_id,
447
+ taskId: value.task_id,
448
+ coordinatorAgentId: value.coordinator_agent_id,
449
+ complexity: value.complexity,
450
+ complexityBasis: value.complexity_basis ?? [],
451
+ selectedModelStrategy: projectAgentModelStrategy(value.selected_model_strategy),
452
+ modelStrategySource: value.model_strategy_source,
453
+ outcome: value.outcome,
454
+ reason: value.reason,
455
+ matchBasis: value.match_basis ?? [],
456
+ candidateAgentIds: value.candidate_agent_ids ?? [],
457
+ optimizationPriority: value.optimization_priority ?? [
458
+ 'quality_and_acceptance', 'token_and_cost', 'time'
459
+ ],
460
+ parallelPlan: projectAgentParallelPlan(value.parallel_plan),
461
+ actualExecutor: value.actual_executor_id ?? value.actual_executor ?? null,
462
+ selectedExecutorId: value.selected_executor_id ?? null,
463
+ executorRuleId: value.executor_rule_id ?? value.rule_id ?? null,
464
+ matchedExecutorRuleId: value.matched_executor_rule_id ?? value.routing_rule_id ?? null,
465
+ executorSelectionReason: value.executor_selection_reason ?? null,
466
+ executorFallbackReason: value.executor_fallback_reason ?? null,
467
+ executorFallbackOutcome: value.executor_fallback_outcome ?? null,
468
+ executorBlockedReason: value.executor_blocked_reason ?? null,
469
+ executorDecision: value.executor_decision ?? null,
470
+ executorPolicy: projectAgentExecutorPolicy(value.executor_policy),
471
+ actualModelProvider: value.actual_model_provider ?? null,
472
+ actualModel: value.actual_model ?? null,
473
+ routingRuleId: value.matched_executor_rule_id ?? value.routing_rule_id ?? null,
474
+ fallbackReason: value.executor_fallback_reason ?? value.fallback_reason ?? null,
475
+ fallbackUsed: value.fallback_used ?? false,
476
+ auditId: value.audit_id ?? null,
477
+ createdAt: value.created_at
478
+ };
479
+ }
480
+
481
+ export function projectAgentTaskRouteResult(value = {}) {
482
+ return {
483
+ task: projectAgentTaskRecord(value.task ?? {}),
484
+ assignedAgent: value.assigned_agent ? projectAgentRecord(value.assigned_agent) : null,
485
+ recruitment: value.recruitment ? projectAgentRecruitmentRecord(value.recruitment) : null,
486
+ decision: value.decision,
487
+ mustDiscloseRecruitment: value.must_disclose_recruitment ?? false,
488
+ clientNotice: value.client_notice ?? null
489
+ };
490
+ }
491
+
492
+ export function projectAgentRecruitmentRecord(value = {}) {
493
+ return {
494
+ recruitmentId: value.recruitment_id,
495
+ personalSpaceId: value.personal_space_id,
496
+ personalProjectId: value.personal_project_id,
497
+ taskId: value.task_id,
498
+ coordinatorAgentId: value.coordinator_agent_id,
499
+ hrAgentId: value.hr_agent_id ?? null,
500
+ positionKind: value.position_kind,
501
+ workKind: value.work_kind,
502
+ requiredCapabilities: value.required_capabilities ?? [],
503
+ reasonCode: value.reason_code,
504
+ reason: value.reason,
505
+ status: value.status,
506
+ confirmationMode: value.confirmation_mode,
507
+ proposedAgentId: value.proposed_agent_id,
508
+ proposedProfile: value.proposed_profile
509
+ ? projectAgentProfileRecord(value.proposed_profile) : null,
510
+ triggerSourceApplication: value.trigger_source_application ?? null,
511
+ triggerSourceSessionId: value.trigger_source_session_id ?? null,
512
+ revision: value.revision,
513
+ recruitedAgentId: value.recruited_agent_id ?? null,
514
+ testSource: value.test_source ?? null,
515
+ cleanupEligible: value.cleanup_eligible ?? false,
516
+ createdAt: value.created_at,
517
+ updatedAt: value.updated_at,
518
+ fulfilledAt: value.fulfilled_at ?? null
519
+ };
520
+ }
521
+
522
+ export function projectAgentProfileRecord(profile = {}) {
523
+ return {
524
+ name: profile.name,
525
+ responsibility: profile.responsibility,
526
+ occupationEmoji: profile.occupation_emoji !== undefined
527
+ ? profile.occupation_emoji : profile.occupationEmoji ?? null,
528
+ agentType: profile.agent_type ?? 'durable',
529
+ workKinds: profile.work_kinds ?? [],
530
+ capabilities: profile.capabilities ?? [],
531
+ initialPreferences: profile.initial_preferences ?? [],
532
+ defaultModelStrategy: projectAgentModelStrategy(profile.default_model_strategy),
533
+ executorPolicy: projectAgentExecutorPolicy(profile.executor_policy),
534
+ allowedClients: profile.allowed_clients ?? [],
535
+ testSource: profile.test_source ?? null,
536
+ cleanupEligible: profile.cleanup_eligible ?? false,
537
+ status: profile.status ?? 'active'
538
+ };
539
+ }
540
+
541
+ export function projectAgentExecutionSummary(value) {
542
+ if (!Array.isArray(value)) return [];
543
+ return value.map((entry = {}) => {
544
+ const actualExecutor = entry.actual_executor_id ?? entry.actual_executor ??
545
+ entry.actualExecutor ?? entry.executor_id ?? entry.executor ?? null;
546
+ const workSummary = entry.work_summary ?? entry.workSummary ?? entry.summary ?? null;
547
+ const status = entry.status ?? entry.worker_status ?? entry.workerStatus ?? null;
548
+ return {
549
+ agentId: entry.agent_id ?? entry.agentId ?? null,
550
+ agentName: entry.agent_name ?? entry.agentName ?? null,
551
+ occupationEmoji: entry.occupation_emoji ?? entry.occupationEmoji ?? null,
552
+ workerId: entry.worker_id ?? entry.workerId ?? null,
553
+ workerLabel: entry.worker_label ?? entry.workerLabel ?? null,
554
+ workerOccupationEmoji: entry.worker_occupation_emoji ??
555
+ entry.workerOccupationEmoji ?? null,
556
+ participantRole: entry.participant_role ?? entry.participantRole ?? null,
557
+ executor: entry.executor ?? entry.executor_id ?? entry.executorId ?? actualExecutor,
558
+ executorId: entry.executor_id ?? entry.executorId ?? actualExecutor,
559
+ actualExecutor,
560
+ sourceApplication: entry.source_application ?? entry.sourceApplication ?? null,
561
+ actualModelProvider: entry.actual_model_provider ?? entry.actualModelProvider ?? null,
562
+ actualModel: entry.actual_model ?? entry.actualModel ?? null,
563
+ workSummary,
564
+ summary: workSummary,
565
+ status,
566
+ workerStatus: entry.worker_status ?? entry.workerStatus ?? status
567
+ };
568
+ });
569
+ }
570
+
571
+ export function projectAgentActivityRecord(value = {}) {
572
+ return {
573
+ agentId: value.agent_id,
574
+ personalSpaceId: value.personal_space_id,
575
+ fromDate: value.from_date,
576
+ toDate: value.to_date,
577
+ days: (value.days ?? []).map((day) => ({
578
+ date: day.date,
579
+ completed: day.completed ?? 0,
580
+ failed: day.failed ?? 0,
581
+ cancelled: day.cancelled ?? 0,
582
+ total: day.total ?? 0,
583
+ tasks: (day.tasks ?? []).map((task) => ({
584
+ taskId: task.task_id,
585
+ title: task.title,
586
+ status: task.status,
587
+ summary: task.summary,
588
+ occurredAt: task.occurred_at,
589
+ sourceApplication: task.source_application ?? null,
590
+ actualExecutor: task.actual_executor_id ?? task.actual_executor ?? null,
591
+ matchedExecutorRuleId: task.matched_executor_rule_id ?? task.routing_rule_id ?? null,
592
+ executorSelectionReason: task.executor_selection_reason ?? null,
593
+ auditId: task.audit_id ?? null,
594
+ actualModelProvider: task.actual_model_provider ?? null,
595
+ actualModel: task.actual_model ?? null,
596
+ executionSummary: projectAgentExecutionSummary(
597
+ task.execution_summary ?? task.executionSummary
598
+ ),
599
+ routingRuleId: task.matched_executor_rule_id ?? task.routing_rule_id ?? null,
600
+ fallbackReason: task.executor_fallback_reason ?? task.fallback_reason ?? null,
601
+ fallbackUsed: task.fallback_used ?? false
602
+ }))
603
+ }))
604
+ };
605
+ }
606
+
607
+ export function projectAgentRecruitmentPolicyRecord(value = {}) {
608
+ return {
609
+ personalSpaceId: value.personal_space_id,
610
+ confirmationMode: value.confirmation_mode ?? 'automatic',
611
+ updatedAt: value.updated_at ?? null
612
+ };
613
+ }
614
+
615
+ export function projectAgentCoordinationPolicyRecord(value = {}) {
616
+ return {
617
+ personalSpaceId: value.personal_space_id,
618
+ personalProjectId: value.personal_project_id,
619
+ askBeforeRecruitment: value.ask_before_recruitment ?? true,
620
+ autoReusePreviousAgent: value.auto_reuse_previous_agent ?? true,
621
+ updatedAt: value.updated_at ?? null
622
+ };
623
+ }
624
+
625
+ export function providerProjectAgentCoordinationPolicy(input) {
626
+ return {
627
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
628
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
629
+ ask_before_recruitment:
630
+ input.askBeforeRecruitment ?? input.ask_before_recruitment ?? true,
631
+ auto_reuse_previous_agent:
632
+ input.autoReusePreviousAgent ?? input.auto_reuse_previous_agent ?? true
633
+ };
634
+ }
635
+
636
+ export function providerProjectAgentRecruitmentDecision(input) {
637
+ return {
638
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
639
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
640
+ recruitment_id: input.recruitmentId ?? input.recruitment_id,
641
+ expected_revision: input.expectedRevision ?? input.expected_revision,
642
+ decision: input.decision,
643
+ reason: input.reason
644
+ };
645
+ }
646
+
647
+ function providerExecutorModel(value = {}) {
648
+ return withoutUndefined({
649
+ provider: value.provider,
650
+ model: value.model,
651
+ capabilities: value.capabilities ?? [],
652
+ strategy_modes: value.strategyModes ?? value.strategy_modes ?? [],
653
+ reasoning_efforts: value.reasoningEfforts ?? value.reasoning_efforts ?? [],
654
+ available: value.available ?? true,
655
+ observed_at: value.observedAt ?? value.observed_at,
656
+ source_application: value.sourceApplication ?? value.source_application,
657
+ unavailable_reason: value.unavailableReason ?? value.unavailable_reason
658
+ });
659
+ }
660
+
661
+ function executorModelRecord(value = {}) {
662
+ return withoutUndefined({
663
+ provider: value.provider,
664
+ model: value.model,
665
+ capabilities: value.capabilities ?? [],
666
+ strategyModes: value.strategy_modes ?? value.strategyModes ?? [],
667
+ reasoningEfforts: value.reasoning_efforts ?? value.reasoningEfforts ?? [],
668
+ available: value.available,
669
+ observedAt: value.observed_at ?? value.observedAt,
670
+ sourceApplication: value.source_application ?? value.sourceApplication,
671
+ unavailableReason: value.unavailable_reason ?? value.unavailableReason
672
+ });
673
+ }
674
+
675
+ export function providerExecutorAuthorization(input) {
676
+ return withoutUndefined({
677
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
678
+ executor_id: input.executorId ?? input.executor_id,
679
+ status: input.status,
680
+ reason: input.reason,
681
+ expected_revision: input.expectedRevision ?? input.expected_revision,
682
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key
683
+ });
684
+ }
685
+
686
+ export function providerExecutorHealth(input) {
687
+ return withoutUndefined({
688
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
689
+ executor_id: input.executorId ?? input.executor_id,
690
+ status: input.status,
691
+ reason: input.reason,
692
+ checked_at: input.checkedAt ?? input.checked_at,
693
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
694
+ source_application: input.sourceApplication ?? input.source_application,
695
+ source_session_id: input.sourceSessionId ?? input.source_session_id
696
+ });
697
+ }
698
+
699
+ export function providerExecutor(input) {
700
+ return withoutUndefined({
701
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
702
+ executor_id: input.executorId ?? input.executor_id,
703
+ display_name: input.displayName ?? input.display_name ?? input.name,
704
+ executor_kind: input.executorKind ?? input.executor_kind ??
705
+ input.executorType ?? input.executor_type ?? 'external',
706
+ capabilities: input.capabilities ?? [],
707
+ advertised_models: (input.advertisedModels ?? input.advertised_models ?? [])
708
+ .map(providerExecutorModel),
709
+ global_priority: input.globalPriority ?? input.global_priority,
710
+ health_required: input.healthRequired ?? input.health_required,
711
+ expected_revision: input.expectedRevision ?? input.expected_revision,
712
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
713
+ source_application: input.sourceApplication ?? input.source_application ??
714
+ input.client,
715
+ source_session_id: input.sourceSessionId ?? input.source_session_id,
716
+ test_source: input.testSource ?? input.test_source,
717
+ cleanup_eligible: input.cleanupEligible ?? input.cleanup_eligible
718
+ });
719
+ }
720
+
721
+ export function executorRecord(value = {}) {
722
+ return withoutUndefined({
723
+ executorId: value.executor_id,
724
+ personalSpaceId: value.personal_space_id,
725
+ displayName: value.display_name ?? value.name,
726
+ executorKind: value.executor_kind ?? value.executor_type,
727
+ capabilities: value.capabilities ?? [],
728
+ advertisedModels: (value.advertised_models ?? []).map(executorModelRecord),
729
+ availableModels: (value.available_models ?? []).map(executorModelRecord),
730
+ globalPriority: value.global_priority,
731
+ healthRequired: value.health_required,
732
+ registrationStatus: value.registration_status,
733
+ permissionStatus: value.permission_status,
734
+ preflightStatus: value.preflight_status,
735
+ healthStatus: value.health_status,
736
+ workspacePermission: value.workspace_permission,
737
+ revision: value.revision,
738
+ permissionRevision: value.permission_revision,
739
+ preflightAt: value.preflight_at,
740
+ healthCheckedAt: value.health_checked_at,
741
+ registeredAt: value.registered_at ?? value.created_at,
742
+ updatedAt: value.updated_at,
743
+ testSource: value.test_source,
744
+ cleanupEligible: value.cleanup_eligible,
745
+ // These are observations only. In particular, omit `connected` when the
746
+ // Provider did not return it instead of deriving an online state.
747
+ allowed: value.allowed,
748
+ observed: value.observed,
749
+ connected: value.connected,
750
+ actualExecutor: value.actual_executor_id ?? value.actual_executor,
751
+ actualModelProvider: value.actual_model_provider,
752
+ actualModel: value.actual_model,
753
+ routingRuleId: value.matched_executor_rule_id ?? value.routing_rule_id,
754
+ fallbackReason: value.executor_fallback_reason ?? value.fallback_reason,
755
+ fallbackUsed: value.fallback_used,
756
+ auditId: value.audit_id
757
+ });
758
+ }
759
+
760
+ export function providerExecutorRoutingRule(input) {
761
+ return withoutUndefined({
762
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
763
+ scope: input.scope,
764
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
765
+ task_id: input.taskId ?? input.task_id,
766
+ work_kind: input.workKind ?? input.work_kind,
767
+ required_capabilities: input.requiredCapabilities ?? input.required_capabilities ?? [],
768
+ executor_ids: input.executorIds ?? input.executor_ids ??
769
+ input.executorAllowList ?? input.executor_allow_list ?? [],
770
+ model_strategy: providerModelStrategy(input.modelStrategy ?? input.model_strategy),
771
+ priority: input.priority,
772
+ reason: input.reason,
773
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key
774
+ });
775
+ }
776
+
777
+ export function providerExecutorRoutingRuleUpdate(input) {
778
+ return withoutUndefined({
779
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
780
+ rule_id: input.ruleId ?? input.rule_id,
781
+ expected_revision: input.expectedRevision ?? input.expected_revision,
782
+ status: input.status,
783
+ reason: input.reason,
784
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key
785
+ });
786
+ }
787
+
788
+ export function executorRoutingRuleRecord(value = {}) {
789
+ return withoutUndefined({
790
+ ruleId: value.rule_id,
791
+ personalSpaceId: value.personal_space_id,
792
+ scope: value.scope,
793
+ personalProjectId: value.personal_project_id,
794
+ taskId: value.task_id,
795
+ workKind: value.work_kind,
796
+ requiredCapabilities: value.required_capabilities ?? [],
797
+ executorIds: value.executor_ids ?? value.executor_allow_list ?? [],
798
+ modelStrategy: projectAgentModelStrategy(value.model_strategy),
799
+ priority: value.priority,
800
+ status: value.status,
801
+ revision: value.revision,
802
+ reason: value.reason,
803
+ createdAt: value.created_at,
804
+ updatedAt: value.updated_at,
805
+ actualExecutor: value.actual_executor_id ?? value.actual_executor,
806
+ actualModelProvider: value.actual_model_provider,
807
+ actualModel: value.actual_model,
808
+ routingRuleId: value.matched_executor_rule_id ?? value.routing_rule_id,
809
+ fallbackReason: value.executor_fallback_reason ?? value.fallback_reason,
810
+ fallbackUsed: value.fallback_used,
811
+ auditId: value.audit_id,
812
+ // Preserve the explicit Agent allow-list when a compatible Provider adds
813
+ // it, without manufacturing one for the canonical rule model.
814
+ agentId: value.agent_id,
815
+ lockedAgentIds: value.locked_agent_ids,
816
+ source: value.source,
817
+ owner: value.owner,
818
+ enabled: value.enabled,
819
+ conditions: value.conditions
820
+ });
821
+ }
822
+
823
+ export function providerExecutorPreflight(input) {
824
+ return withoutUndefined({
825
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
826
+ executor_id: input.executorId ?? input.executor_id,
827
+ status: input.status,
828
+ workspace_permission: input.workspacePermission ?? input.workspace_permission,
829
+ capabilities: input.capabilities ?? [],
830
+ available_models: (input.availableModels ?? input.available_models ?? [])
831
+ .map(providerExecutorModel),
832
+ reason: input.reason,
833
+ checked_at: input.checkedAt ?? input.checked_at,
834
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
835
+ source_application: input.sourceApplication ?? input.source_application,
836
+ source_session_id: input.sourceSessionId ?? input.source_session_id
837
+ });
838
+ }
839
+
840
+ export function executorPreflightRecord(value = {}) {
841
+ return withoutUndefined({
842
+ executorId: value.executor_id,
843
+ personalSpaceId: value.personal_space_id,
844
+ displayName: value.display_name,
845
+ executorKind: value.executor_kind,
846
+ registrationStatus: value.registration_status,
847
+ permissionStatus: value.permission_status,
848
+ preflightStatus: value.preflight_status,
849
+ healthStatus: value.health_status,
850
+ healthRequired: value.health_required,
851
+ globalPriority: value.global_priority,
852
+ revision: value.revision,
853
+ registeredAt: value.registered_at,
854
+ updatedAt: value.updated_at,
855
+ status: value.status,
856
+ available: value.available,
857
+ workspacePermission: value.workspace_permission,
858
+ capabilities: value.capabilities ?? [],
859
+ availableModels: (value.available_models ?? value.advertised_models ?? [])
860
+ .map(executorModelRecord),
861
+ checkedAt: value.checked_at ?? value.preflight_at,
862
+ connected: value.connected,
863
+ reason: value.reason,
864
+ testSource: value.test_source,
865
+ cleanupEligible: value.cleanup_eligible
866
+ });
867
+ }
868
+
869
+ export function providerExecutorActualReport(input) {
870
+ return withoutUndefined({
871
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
872
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
873
+ task_id: input.taskId ?? input.task_id,
874
+ run_id: input.runId ?? input.run_id,
875
+ agent_id: input.agentId ?? input.agent_id,
876
+ executor_id: input.executorId ?? input.executor_id,
877
+ provider: input.provider,
878
+ model: input.model,
879
+ model_strategy: providerModelStrategy(
880
+ input.modelStrategy ?? input.model_strategy ?? {}
881
+ ),
882
+ model_strategy_source: input.modelStrategySource ?? input.model_strategy_source ?? 'agent',
883
+ matched_rule_id: input.matchedRuleId ?? input.matched_rule_id,
884
+ fallback_reason: input.fallbackReason ?? input.fallback_reason,
885
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
886
+ occurred_at: input.occurredAt ?? input.occurred_at,
887
+ source_application: input.sourceApplication ?? input.source_application,
888
+ source_session_id: input.sourceSessionId ?? input.source_session_id
889
+ });
890
+ }
891
+
892
+ export function executorActualReportRecord(value = {}) {
893
+ return withoutUndefined({
894
+ personalSpaceId: value.personal_space_id,
895
+ personalProjectId: value.personal_project_id,
896
+ taskId: value.task_id,
897
+ runId: value.run_id,
898
+ agentId: value.agent_id,
899
+ executorId: value.executor_id,
900
+ provider: value.provider,
901
+ model: value.model,
902
+ modelStrategy: projectAgentModelStrategy(value.model_strategy),
903
+ modelStrategySource: value.model_strategy_source,
904
+ matchedRuleId: value.matched_rule_id,
905
+ fallbackReason: value.fallback_reason,
906
+ idempotencyKey: value.idempotency_key,
907
+ occurredAt: value.occurred_at,
908
+ sourceApplication: value.source_application,
909
+ sourceSessionId: value.source_session_id
910
+ });
911
+ }
912
+
913
+ export function providerProjectAgentTaskOutcome(input) {
914
+ return withoutUndefined({
915
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
916
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
917
+ work_kind: input.workKind ?? input.work_kind,
918
+ agent_id: input.agentId ?? input.agent_id,
919
+ executor_id: input.executorId ?? input.executor_id,
920
+ task_id: input.taskId ?? input.task_id,
921
+ run_id: input.runId ?? input.run_id,
922
+ model_strategy: providerModelStrategy(
923
+ input.modelStrategy ?? input.model_strategy ?? {}
924
+ ),
925
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
926
+ evidence_kind: input.evidenceKind ?? input.evidence_kind,
927
+ source: input.source,
928
+ terminal_outcome: input.terminalOutcome ?? input.terminal_outcome,
929
+ rating: input.rating,
930
+ reference_ids: input.referenceIds ?? input.reference_ids ?? [],
931
+ note: input.note ?? input.summary ?? input.reason,
932
+ occurred_at: input.occurredAt ?? input.occurred_at
933
+ });
934
+ }
935
+
936
+ export function projectAgentTaskOutcomeRecord(value = {}) {
937
+ return withoutUndefined({
938
+ evidenceId: value.evidence_id,
939
+ personalSpaceId: value.personal_space_id,
940
+ personalProjectId: value.personal_project_id,
941
+ workKind: value.work_kind,
942
+ agentId: value.agent_id,
943
+ executorId: value.executor_id,
944
+ taskId: value.task_id,
945
+ runId: value.run_id ?? null,
946
+ modelStrategy: projectAgentModelStrategy(value.model_strategy),
947
+ evidenceKind: value.evidence_kind,
948
+ source: value.source,
949
+ terminalOutcome: value.terminal_outcome ?? null,
950
+ rating: value.rating ?? null,
951
+ referenceIds: value.reference_ids ?? [],
952
+ note: value.note ?? null,
953
+ idempotencyKey: value.idempotency_key,
954
+ occurredAt: value.occurred_at,
955
+ ignored: value.ignored ?? false,
956
+ ignoredReason: value.ignored_reason ?? null,
957
+ createdAt: value.created_at
958
+ });
959
+ }
960
+
961
+ export function routingLearningRecord(value = {}) {
962
+ return withoutUndefined({
963
+ learningId: value.learning_id ?? value.evidence_id,
964
+ personalSpaceId: value.personal_space_id,
965
+ personalProjectId: value.personal_project_id,
966
+ workKind: value.work_kind,
967
+ agentId: value.agent_id,
968
+ executorId: value.executor_id,
969
+ modelStrategy: projectAgentModelStrategy(value.model_strategy),
970
+ modelStrategyKey: value.model_strategy_key,
971
+ routingRuleId: value.routing_rule_id,
972
+ evidenceKind: value.evidence_kind,
973
+ source: value.source,
974
+ evidence: value.evidence,
975
+ signal: value.signal,
976
+ value: value.value,
977
+ decayWeight: value.decay_weight,
978
+ weight: value.weight,
979
+ contribution: value.contribution ?? value.decay_weight,
980
+ asOf: value.as_of,
981
+ halfLife: value.half_life ?? value.decay_half_life_days,
982
+ status: value.status,
983
+ ignored: value.ignored,
984
+ resetAt: value.reset_at,
985
+ taskId: value.task_id,
986
+ sampleCount: value.sample_count,
987
+ recentCount: value.recent_count,
988
+ successCount: value.success_count,
989
+ reworkCount: value.rework_count,
990
+ failureCount: value.failure_count,
991
+ ratingCount: value.rating_count,
992
+ averageRating: value.average_rating,
993
+ neutralDueToInsufficientEvidence: value.neutral_due_to_insufficient_evidence,
994
+ weightedSuccess: value.weighted_success,
995
+ weightedFailure: value.weighted_failure,
996
+ evidenceRefs: value.evidence_refs,
997
+ evidenceContributions: (value.evidence_contributions ?? []).map((item) => ({
998
+ evidenceId: item.evidence_id,
999
+ evidenceKind: item.evidence_kind,
1000
+ signal: item.signal,
1001
+ value: item.value,
1002
+ decayWeight: item.decay_weight,
1003
+ occurredAt: item.occurred_at,
1004
+ referenceIds: item.reference_ids ?? []
1005
+ })),
1006
+ sourceApplication: value.source_application,
1007
+ createdAt: value.created_at,
1008
+ updatedAt: value.updated_at
1009
+ });
1010
+ }
1011
+
1012
+ function hasAny(value, keys) {
1013
+ return keys.some((key) => Object.hasOwn(value, key));
1014
+ }
1015
+
1016
+ function copyOptional(target, key, value, include) {
1017
+ if (include) target[key] = value;
1018
+ }
1019
+
1020
+ function withoutUndefined(value) {
1021
+ return Object.fromEntries(
1022
+ Object.entries(value).filter(([, item]) => item !== undefined)
1023
+ );
1024
+ }