fuli-context 0.7.4-beta.2 → 0.7.5

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 (133) hide show
  1. package/README.md +93 -7
  2. package/README.zh-CN.md +84 -7
  3. package/compose.graphiti.yml +6 -6
  4. package/dist/web/assets/AboutPage-ByCUor-j.js +1 -0
  5. package/dist/web/assets/ConnectionsPage-DkdkZ40Q.js +1 -0
  6. package/dist/web/assets/KnowledgeEditDialog-DSe3Gwep.js +1 -0
  7. package/dist/web/assets/KnowledgeInspector-CYAjAb9J.js +1 -0
  8. package/dist/web/assets/KnowledgeOrganizerPage-CV4F54R_.js +1 -0
  9. package/dist/web/assets/KnowledgePage-vYYXipOi.js +1 -0
  10. package/dist/web/assets/KnowledgeWorkspace-z4u5mXOG.js +4 -0
  11. package/dist/web/assets/OverviewPage-BWOfeS6k.js +1 -0
  12. package/dist/web/assets/PersonalProfilePage-c3w4-h7a.js +1 -0
  13. package/dist/web/assets/PersonalProjectsPage-B7AlLEwf.js +1 -0
  14. package/dist/web/assets/ProjectAgentsPage-CgftpIPB.css +1 -0
  15. package/dist/web/assets/ProjectAgentsPage-DTHcL_ox.js +11 -0
  16. package/dist/web/assets/PublicProjectsPage-DdH0oGB3.js +1 -0
  17. package/dist/web/assets/ReviewPage-BYIpcIHG.js +1 -0
  18. package/dist/web/assets/SearchableSelect-Dz13ClQb.js +1 -0
  19. package/dist/web/assets/SettingsPage-2VkbXgZi.js +1 -0
  20. package/dist/web/assets/SettingsPage-CwZp2ka4.css +1 -0
  21. package/dist/web/assets/WritingTastePage-BOPQZuva.js +1 -0
  22. package/dist/web/assets/{console-DMvHxKf9.js → console-BlAhujsH.js} +1 -1
  23. package/dist/web/assets/{conversation-launcher-settings-Dnlcw7Rj.js → conversation-launcher-settings-DTYxiLJt.js} +1 -1
  24. package/dist/web/assets/i18n-Ci3heuiL.js +9 -0
  25. package/dist/web/assets/{identity-C9mLdR8L.js → identity-4_-v6cB7.js} +1 -1
  26. package/dist/web/assets/index-BnH5mcZx.css +1 -0
  27. package/dist/web/assets/index-C67Q0JY2.js +2 -0
  28. package/dist/web/assets/{model-CsYAR8O3.js → model-yG0YqUyZ.js} +1 -1
  29. package/dist/web/assets/{useApi-CROJJdhE-BLQiPVw0.js → useApi-CROJJdhE-twhdZArA.js} +1 -1
  30. package/dist/web/assets/vue-router-C-wot_Di.js +1 -0
  31. package/dist/web/index.html +6 -6
  32. package/docs/public-personal-architecture.md +73 -0
  33. package/graph-provider/fuli_graph/app.py +8 -0
  34. package/graph-provider/fuli_graph/collaboration_context.py +69 -6
  35. package/graph-provider/fuli_graph/knowledge_search.py +84 -5
  36. package/graph-provider/fuli_graph/model_validation.py +134 -0
  37. package/graph-provider/fuli_graph/models.py +24 -5
  38. package/graph-provider/fuli_graph/project_agent_access.py +54 -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 +597 -0
  42. package/graph-provider/fuli_graph/project_agent_task_models.py +542 -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_executor_learning.py +756 -0
  48. package/graph-provider/fuli_graph/store_project_agent_executor_routing.py +601 -0
  49. package/graph-provider/fuli_graph/store_project_agent_executors.py +1087 -0
  50. package/graph-provider/fuli_graph/store_project_agent_task_reads.py +458 -0
  51. package/graph-provider/fuli_graph/store_project_agent_task_recruitment.py +699 -0
  52. package/graph-provider/fuli_graph/store_project_agent_task_staffing.py +409 -0
  53. package/graph-provider/fuli_graph/store_project_agent_tasks.py +1144 -0
  54. package/graph-provider/fuli_graph/store_project_agents.py +965 -0
  55. package/graph-provider/pyproject.toml +2 -1
  56. package/npm-shrinkwrap.json +2 -2
  57. package/package.json +2 -1
  58. package/skills/capturing-session-knowledge/SKILL.md +43 -2
  59. package/src/adaptive-runtime/executor-pool.js +127 -0
  60. package/src/adaptive-runtime/graph-services.js +166 -0
  61. package/src/adaptive-runtime/lease-client.js +335 -0
  62. package/src/adaptive-runtime/runtime-broker.js +318 -0
  63. package/src/adaptive-runtime/settings.js +111 -0
  64. package/src/adaptive-runtime/state.js +74 -0
  65. package/src/agent-tools/graph-definitions.js +396 -0
  66. package/src/agent-tools/graph-handlers.js +61 -0
  67. package/src/agent-tools/project-agent-definitions.js +307 -0
  68. package/src/backup/graph-backup.js +289 -0
  69. package/src/backup/identity-reconciliation.js +208 -0
  70. package/src/backup/runtime-adapters.js +269 -0
  71. package/src/cli/command-registry.js +7 -2
  72. package/src/cli/graph-data-command.js +112 -0
  73. package/src/cli/local-runtime-command.js +16 -2
  74. package/src/cli/setup-command.js +19 -3
  75. package/src/cli/update-command.js +4 -0
  76. package/src/cli/workspace-connection-command.js +333 -0
  77. package/src/cli.js +11 -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 +74 -112
  81. package/src/graphiti/knowledge-provider-mapping.js +7 -1
  82. package/src/graphiti/project-agent-control-plane.js +263 -0
  83. package/src/graphiti/project-agent-mapping.js +1003 -0
  84. package/src/graphiti/project-agent-workflows.js +557 -0
  85. package/src/graphiti/provider-client.js +270 -1
  86. package/src/graphiti/runtime-config.js +6 -1
  87. package/src/graphiti/workspace-provider-client.js +403 -0
  88. package/src/http/api-router.js +63 -9
  89. package/src/http/graph-api-router.js +278 -0
  90. package/src/local-runtime/lifecycle.js +46 -10
  91. package/src/mcp/context-resources.js +15 -6
  92. package/src/mcp/create-mcp-server.js +51 -16
  93. package/src/mcp/instructions.js +7 -5
  94. package/src/mcp/runtime.js +17 -5
  95. package/src/mcp/session-id.js +38 -1
  96. package/src/mcp/tool-annotations.js +69 -0
  97. package/src/mcp-server.js +23 -6
  98. package/src/native-runtime/runtime.js +717 -0
  99. package/src/server.js +6 -2
  100. package/src/setup/agent-installation-status.js +7 -1
  101. package/src/setup/agents.js +3 -1
  102. package/src/setup/claude-code-config.js +3 -1
  103. package/src/setup/codex-bootstrap.js +11 -10
  104. package/src/setup/codex-config.js +7 -1
  105. package/src/setup/cursor-config.js +3 -1
  106. package/src/setup/graph-runtime.js +158 -13
  107. package/src/setup/neo4j-memory-profile.js +43 -0
  108. package/src/setup/options.js +38 -2
  109. package/src/setup/paths.js +14 -0
  110. package/src/setup/setup.js +37 -1
  111. package/src/system/resource-monitor.js +181 -16
  112. package/src/system/runtime-settings.js +10 -1
  113. package/src/system/system-service.js +27 -2
  114. package/dist/web/assets/AboutPage-CftRexSY.js +0 -1
  115. package/dist/web/assets/ConnectionsPage-D5J91x6d.js +0 -1
  116. package/dist/web/assets/KnowledgeEditDialog-wotVahvr.js +0 -1
  117. package/dist/web/assets/KnowledgeInspector-BzkW0mVs.js +0 -1
  118. package/dist/web/assets/KnowledgeOrganizerPage-BebUDiHt.js +0 -1
  119. package/dist/web/assets/KnowledgePage-OUT07aKH.js +0 -1
  120. package/dist/web/assets/KnowledgeWorkspace-1pHJ0MNZ.js +0 -4
  121. package/dist/web/assets/OverviewPage-CHE6XhdS.js +0 -1
  122. package/dist/web/assets/PersonalProfilePage-CXXiabUy.js +0 -1
  123. package/dist/web/assets/PersonalProjectsPage-d2wYGW8n.js +0 -1
  124. package/dist/web/assets/PublicProjectsPage-hxLShtnZ.js +0 -1
  125. package/dist/web/assets/ReviewPage-DUeyu7E8.js +0 -1
  126. package/dist/web/assets/SearchableSelect-C5RiB5F8.js +0 -1
  127. package/dist/web/assets/SettingsPage-BMuASSzQ.js +0 -1
  128. package/dist/web/assets/SettingsPage-CAfz4qiV.css +0 -1
  129. package/dist/web/assets/WritingTastePage-B9BCYIwQ.js +0 -1
  130. package/dist/web/assets/i18n-CWfd8Dtt.js +0 -5
  131. package/dist/web/assets/index-X2j29j8i.css +0 -1
  132. package/dist/web/assets/index-nP5p5OaY.js +0 -2
  133. package/dist/web/assets/vue-router-DN8x6iY1.js +0 -1
@@ -0,0 +1,1003 @@
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 providerProjectAgentRecruitmentDecision(input) {
616
+ return {
617
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
618
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
619
+ recruitment_id: input.recruitmentId ?? input.recruitment_id,
620
+ expected_revision: input.expectedRevision ?? input.expected_revision,
621
+ decision: input.decision,
622
+ reason: input.reason
623
+ };
624
+ }
625
+
626
+ function providerExecutorModel(value = {}) {
627
+ return withoutUndefined({
628
+ provider: value.provider,
629
+ model: value.model,
630
+ capabilities: value.capabilities ?? [],
631
+ strategy_modes: value.strategyModes ?? value.strategy_modes ?? [],
632
+ reasoning_efforts: value.reasoningEfforts ?? value.reasoning_efforts ?? [],
633
+ available: value.available ?? true,
634
+ observed_at: value.observedAt ?? value.observed_at,
635
+ source_application: value.sourceApplication ?? value.source_application,
636
+ unavailable_reason: value.unavailableReason ?? value.unavailable_reason
637
+ });
638
+ }
639
+
640
+ function executorModelRecord(value = {}) {
641
+ return withoutUndefined({
642
+ provider: value.provider,
643
+ model: value.model,
644
+ capabilities: value.capabilities ?? [],
645
+ strategyModes: value.strategy_modes ?? value.strategyModes ?? [],
646
+ reasoningEfforts: value.reasoning_efforts ?? value.reasoningEfforts ?? [],
647
+ available: value.available,
648
+ observedAt: value.observed_at ?? value.observedAt,
649
+ sourceApplication: value.source_application ?? value.sourceApplication,
650
+ unavailableReason: value.unavailable_reason ?? value.unavailableReason
651
+ });
652
+ }
653
+
654
+ export function providerExecutorAuthorization(input) {
655
+ return withoutUndefined({
656
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
657
+ executor_id: input.executorId ?? input.executor_id,
658
+ status: input.status,
659
+ reason: input.reason,
660
+ expected_revision: input.expectedRevision ?? input.expected_revision,
661
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key
662
+ });
663
+ }
664
+
665
+ export function providerExecutorHealth(input) {
666
+ return withoutUndefined({
667
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
668
+ executor_id: input.executorId ?? input.executor_id,
669
+ status: input.status,
670
+ reason: input.reason,
671
+ checked_at: input.checkedAt ?? input.checked_at,
672
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
673
+ source_application: input.sourceApplication ?? input.source_application,
674
+ source_session_id: input.sourceSessionId ?? input.source_session_id
675
+ });
676
+ }
677
+
678
+ export function providerExecutor(input) {
679
+ return withoutUndefined({
680
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
681
+ executor_id: input.executorId ?? input.executor_id,
682
+ display_name: input.displayName ?? input.display_name ?? input.name,
683
+ executor_kind: input.executorKind ?? input.executor_kind ??
684
+ input.executorType ?? input.executor_type ?? 'external',
685
+ capabilities: input.capabilities ?? [],
686
+ advertised_models: (input.advertisedModels ?? input.advertised_models ?? [])
687
+ .map(providerExecutorModel),
688
+ global_priority: input.globalPriority ?? input.global_priority,
689
+ health_required: input.healthRequired ?? input.health_required,
690
+ expected_revision: input.expectedRevision ?? input.expected_revision,
691
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
692
+ source_application: input.sourceApplication ?? input.source_application ??
693
+ input.client,
694
+ source_session_id: input.sourceSessionId ?? input.source_session_id,
695
+ test_source: input.testSource ?? input.test_source,
696
+ cleanup_eligible: input.cleanupEligible ?? input.cleanup_eligible
697
+ });
698
+ }
699
+
700
+ export function executorRecord(value = {}) {
701
+ return withoutUndefined({
702
+ executorId: value.executor_id,
703
+ personalSpaceId: value.personal_space_id,
704
+ displayName: value.display_name ?? value.name,
705
+ executorKind: value.executor_kind ?? value.executor_type,
706
+ capabilities: value.capabilities ?? [],
707
+ advertisedModels: (value.advertised_models ?? []).map(executorModelRecord),
708
+ availableModels: (value.available_models ?? []).map(executorModelRecord),
709
+ globalPriority: value.global_priority,
710
+ healthRequired: value.health_required,
711
+ registrationStatus: value.registration_status,
712
+ permissionStatus: value.permission_status,
713
+ preflightStatus: value.preflight_status,
714
+ healthStatus: value.health_status,
715
+ workspacePermission: value.workspace_permission,
716
+ revision: value.revision,
717
+ permissionRevision: value.permission_revision,
718
+ preflightAt: value.preflight_at,
719
+ healthCheckedAt: value.health_checked_at,
720
+ registeredAt: value.registered_at ?? value.created_at,
721
+ updatedAt: value.updated_at,
722
+ testSource: value.test_source,
723
+ cleanupEligible: value.cleanup_eligible,
724
+ // These are observations only. In particular, omit `connected` when the
725
+ // Provider did not return it instead of deriving an online state.
726
+ allowed: value.allowed,
727
+ observed: value.observed,
728
+ connected: value.connected,
729
+ actualExecutor: value.actual_executor_id ?? value.actual_executor,
730
+ actualModelProvider: value.actual_model_provider,
731
+ actualModel: value.actual_model,
732
+ routingRuleId: value.matched_executor_rule_id ?? value.routing_rule_id,
733
+ fallbackReason: value.executor_fallback_reason ?? value.fallback_reason,
734
+ fallbackUsed: value.fallback_used,
735
+ auditId: value.audit_id
736
+ });
737
+ }
738
+
739
+ export function providerExecutorRoutingRule(input) {
740
+ return withoutUndefined({
741
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
742
+ scope: input.scope,
743
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
744
+ task_id: input.taskId ?? input.task_id,
745
+ work_kind: input.workKind ?? input.work_kind,
746
+ required_capabilities: input.requiredCapabilities ?? input.required_capabilities ?? [],
747
+ executor_ids: input.executorIds ?? input.executor_ids ??
748
+ input.executorAllowList ?? input.executor_allow_list ?? [],
749
+ model_strategy: providerModelStrategy(input.modelStrategy ?? input.model_strategy),
750
+ priority: input.priority,
751
+ reason: input.reason,
752
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key
753
+ });
754
+ }
755
+
756
+ export function providerExecutorRoutingRuleUpdate(input) {
757
+ return withoutUndefined({
758
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
759
+ rule_id: input.ruleId ?? input.rule_id,
760
+ expected_revision: input.expectedRevision ?? input.expected_revision,
761
+ status: input.status,
762
+ reason: input.reason,
763
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key
764
+ });
765
+ }
766
+
767
+ export function executorRoutingRuleRecord(value = {}) {
768
+ return withoutUndefined({
769
+ ruleId: value.rule_id,
770
+ personalSpaceId: value.personal_space_id,
771
+ scope: value.scope,
772
+ personalProjectId: value.personal_project_id,
773
+ taskId: value.task_id,
774
+ workKind: value.work_kind,
775
+ requiredCapabilities: value.required_capabilities ?? [],
776
+ executorIds: value.executor_ids ?? value.executor_allow_list ?? [],
777
+ modelStrategy: projectAgentModelStrategy(value.model_strategy),
778
+ priority: value.priority,
779
+ status: value.status,
780
+ revision: value.revision,
781
+ reason: value.reason,
782
+ createdAt: value.created_at,
783
+ updatedAt: value.updated_at,
784
+ actualExecutor: value.actual_executor_id ?? value.actual_executor,
785
+ actualModelProvider: value.actual_model_provider,
786
+ actualModel: value.actual_model,
787
+ routingRuleId: value.matched_executor_rule_id ?? value.routing_rule_id,
788
+ fallbackReason: value.executor_fallback_reason ?? value.fallback_reason,
789
+ fallbackUsed: value.fallback_used,
790
+ auditId: value.audit_id,
791
+ // Preserve the explicit Agent allow-list when a compatible Provider adds
792
+ // it, without manufacturing one for the canonical rule model.
793
+ agentId: value.agent_id,
794
+ lockedAgentIds: value.locked_agent_ids,
795
+ source: value.source,
796
+ owner: value.owner,
797
+ enabled: value.enabled,
798
+ conditions: value.conditions
799
+ });
800
+ }
801
+
802
+ export function providerExecutorPreflight(input) {
803
+ return withoutUndefined({
804
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
805
+ executor_id: input.executorId ?? input.executor_id,
806
+ status: input.status,
807
+ workspace_permission: input.workspacePermission ?? input.workspace_permission,
808
+ capabilities: input.capabilities ?? [],
809
+ available_models: (input.availableModels ?? input.available_models ?? [])
810
+ .map(providerExecutorModel),
811
+ reason: input.reason,
812
+ checked_at: input.checkedAt ?? input.checked_at,
813
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
814
+ source_application: input.sourceApplication ?? input.source_application,
815
+ source_session_id: input.sourceSessionId ?? input.source_session_id
816
+ });
817
+ }
818
+
819
+ export function executorPreflightRecord(value = {}) {
820
+ return withoutUndefined({
821
+ executorId: value.executor_id,
822
+ personalSpaceId: value.personal_space_id,
823
+ displayName: value.display_name,
824
+ executorKind: value.executor_kind,
825
+ registrationStatus: value.registration_status,
826
+ permissionStatus: value.permission_status,
827
+ preflightStatus: value.preflight_status,
828
+ healthStatus: value.health_status,
829
+ healthRequired: value.health_required,
830
+ globalPriority: value.global_priority,
831
+ revision: value.revision,
832
+ registeredAt: value.registered_at,
833
+ updatedAt: value.updated_at,
834
+ status: value.status,
835
+ available: value.available,
836
+ workspacePermission: value.workspace_permission,
837
+ capabilities: value.capabilities ?? [],
838
+ availableModels: (value.available_models ?? value.advertised_models ?? [])
839
+ .map(executorModelRecord),
840
+ checkedAt: value.checked_at ?? value.preflight_at,
841
+ connected: value.connected,
842
+ reason: value.reason,
843
+ testSource: value.test_source,
844
+ cleanupEligible: value.cleanup_eligible
845
+ });
846
+ }
847
+
848
+ export function providerExecutorActualReport(input) {
849
+ return withoutUndefined({
850
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
851
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
852
+ task_id: input.taskId ?? input.task_id,
853
+ run_id: input.runId ?? input.run_id,
854
+ agent_id: input.agentId ?? input.agent_id,
855
+ executor_id: input.executorId ?? input.executor_id,
856
+ provider: input.provider,
857
+ model: input.model,
858
+ model_strategy: providerModelStrategy(
859
+ input.modelStrategy ?? input.model_strategy ?? {}
860
+ ),
861
+ model_strategy_source: input.modelStrategySource ?? input.model_strategy_source ?? 'agent',
862
+ matched_rule_id: input.matchedRuleId ?? input.matched_rule_id,
863
+ fallback_reason: input.fallbackReason ?? input.fallback_reason,
864
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
865
+ occurred_at: input.occurredAt ?? input.occurred_at,
866
+ source_application: input.sourceApplication ?? input.source_application,
867
+ source_session_id: input.sourceSessionId ?? input.source_session_id
868
+ });
869
+ }
870
+
871
+ export function executorActualReportRecord(value = {}) {
872
+ return withoutUndefined({
873
+ personalSpaceId: value.personal_space_id,
874
+ personalProjectId: value.personal_project_id,
875
+ taskId: value.task_id,
876
+ runId: value.run_id,
877
+ agentId: value.agent_id,
878
+ executorId: value.executor_id,
879
+ provider: value.provider,
880
+ model: value.model,
881
+ modelStrategy: projectAgentModelStrategy(value.model_strategy),
882
+ modelStrategySource: value.model_strategy_source,
883
+ matchedRuleId: value.matched_rule_id,
884
+ fallbackReason: value.fallback_reason,
885
+ idempotencyKey: value.idempotency_key,
886
+ occurredAt: value.occurred_at,
887
+ sourceApplication: value.source_application,
888
+ sourceSessionId: value.source_session_id
889
+ });
890
+ }
891
+
892
+ export function providerProjectAgentTaskOutcome(input) {
893
+ return withoutUndefined({
894
+ personal_space_id: input.personalSpaceId ?? input.personal_space_id,
895
+ personal_project_id: input.personalProjectId ?? input.personal_project_id,
896
+ work_kind: input.workKind ?? input.work_kind,
897
+ agent_id: input.agentId ?? input.agent_id,
898
+ executor_id: input.executorId ?? input.executor_id,
899
+ task_id: input.taskId ?? input.task_id,
900
+ run_id: input.runId ?? input.run_id,
901
+ model_strategy: providerModelStrategy(
902
+ input.modelStrategy ?? input.model_strategy ?? {}
903
+ ),
904
+ idempotency_key: input.idempotencyKey ?? input.idempotency_key,
905
+ evidence_kind: input.evidenceKind ?? input.evidence_kind,
906
+ source: input.source,
907
+ terminal_outcome: input.terminalOutcome ?? input.terminal_outcome,
908
+ rating: input.rating,
909
+ reference_ids: input.referenceIds ?? input.reference_ids ?? [],
910
+ note: input.note ?? input.summary ?? input.reason,
911
+ occurred_at: input.occurredAt ?? input.occurred_at
912
+ });
913
+ }
914
+
915
+ export function projectAgentTaskOutcomeRecord(value = {}) {
916
+ return withoutUndefined({
917
+ evidenceId: value.evidence_id,
918
+ personalSpaceId: value.personal_space_id,
919
+ personalProjectId: value.personal_project_id,
920
+ workKind: value.work_kind,
921
+ agentId: value.agent_id,
922
+ executorId: value.executor_id,
923
+ taskId: value.task_id,
924
+ runId: value.run_id ?? null,
925
+ modelStrategy: projectAgentModelStrategy(value.model_strategy),
926
+ evidenceKind: value.evidence_kind,
927
+ source: value.source,
928
+ terminalOutcome: value.terminal_outcome ?? null,
929
+ rating: value.rating ?? null,
930
+ referenceIds: value.reference_ids ?? [],
931
+ note: value.note ?? null,
932
+ idempotencyKey: value.idempotency_key,
933
+ occurredAt: value.occurred_at,
934
+ ignored: value.ignored ?? false,
935
+ ignoredReason: value.ignored_reason ?? null,
936
+ createdAt: value.created_at
937
+ });
938
+ }
939
+
940
+ export function routingLearningRecord(value = {}) {
941
+ return withoutUndefined({
942
+ learningId: value.learning_id ?? value.evidence_id,
943
+ personalSpaceId: value.personal_space_id,
944
+ personalProjectId: value.personal_project_id,
945
+ workKind: value.work_kind,
946
+ agentId: value.agent_id,
947
+ executorId: value.executor_id,
948
+ modelStrategy: projectAgentModelStrategy(value.model_strategy),
949
+ modelStrategyKey: value.model_strategy_key,
950
+ routingRuleId: value.routing_rule_id,
951
+ evidenceKind: value.evidence_kind,
952
+ source: value.source,
953
+ evidence: value.evidence,
954
+ signal: value.signal,
955
+ value: value.value,
956
+ decayWeight: value.decay_weight,
957
+ weight: value.weight,
958
+ contribution: value.contribution ?? value.decay_weight,
959
+ asOf: value.as_of,
960
+ halfLife: value.half_life ?? value.decay_half_life_days,
961
+ status: value.status,
962
+ ignored: value.ignored,
963
+ resetAt: value.reset_at,
964
+ taskId: value.task_id,
965
+ sampleCount: value.sample_count,
966
+ recentCount: value.recent_count,
967
+ successCount: value.success_count,
968
+ reworkCount: value.rework_count,
969
+ failureCount: value.failure_count,
970
+ ratingCount: value.rating_count,
971
+ averageRating: value.average_rating,
972
+ neutralDueToInsufficientEvidence: value.neutral_due_to_insufficient_evidence,
973
+ weightedSuccess: value.weighted_success,
974
+ weightedFailure: value.weighted_failure,
975
+ evidenceRefs: value.evidence_refs,
976
+ evidenceContributions: (value.evidence_contributions ?? []).map((item) => ({
977
+ evidenceId: item.evidence_id,
978
+ evidenceKind: item.evidence_kind,
979
+ signal: item.signal,
980
+ value: item.value,
981
+ decayWeight: item.decay_weight,
982
+ occurredAt: item.occurred_at,
983
+ referenceIds: item.reference_ids ?? []
984
+ })),
985
+ sourceApplication: value.source_application,
986
+ createdAt: value.created_at,
987
+ updatedAt: value.updated_at
988
+ });
989
+ }
990
+
991
+ function hasAny(value, keys) {
992
+ return keys.some((key) => Object.hasOwn(value, key));
993
+ }
994
+
995
+ function copyOptional(target, key, value, include) {
996
+ if (include) target[key] = value;
997
+ }
998
+
999
+ function withoutUndefined(value) {
1000
+ return Object.fromEntries(
1001
+ Object.entries(value).filter(([, item]) => item !== undefined)
1002
+ );
1003
+ }