plugin-agent-orchestrator 1.1.4 → 1.1.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 (148) hide show
  1. package/README.md +204 -114
  2. package/dist/client/index.js +1 -1
  3. package/dist/client-v2/117.7565cff57c39318a.js +10 -0
  4. package/dist/client-v2/214.106635011859dede.js +10 -0
  5. package/dist/client-v2/418.41ed200e7d6da332.js +10 -0
  6. package/dist/client-v2/53.349fff8db80b19d4.js +10 -0
  7. package/dist/client-v2/981.e4a1f41cfc94a856.js +10 -0
  8. package/dist/client-v2/index.js +1 -1
  9. package/dist/externalVersion.js +7 -8
  10. package/dist/locale/en-US.json +226 -170
  11. package/dist/locale/vi-VN.json +226 -170
  12. package/dist/locale/zh-CN.json +226 -170
  13. package/dist/server/collections/agent-execution-spans.js +8 -0
  14. package/dist/server/collections/agent-loop-action-approvals.js +1 -0
  15. package/dist/server/collections/agent-loop-runs.js +7 -1
  16. package/dist/server/collections/agent-loop-steps.js +7 -0
  17. package/dist/server/collections/skill-executions.js +8 -0
  18. package/dist/server/plugin.js +3 -1
  19. package/dist/server/resources/agent-harness-profile.js +117 -0
  20. package/dist/server/resources/agent-knowledge-insights.js +1 -3
  21. package/dist/server/resources/agent-loop-approval.js +25 -0
  22. package/dist/server/resources/agent-loop.js +3 -1
  23. package/dist/server/services/AgentMemoryContextService.js +34 -0
  24. package/dist/server/services/HarnessCompiler.js +35 -2
  25. package/dist/server/services/HarnessProfileService.js +74 -9
  26. package/dist/server/services/HarnessSchema.js +30 -3
  27. package/dist/server/services/LoopPatternSchema.js +16 -1
  28. package/dist/server/services/LoopRunRepository.js +80 -0
  29. package/dist/server/services/LoopRunStateMachine.js +92 -3
  30. package/dist/server/services/LoopTriggerService.js +37 -0
  31. package/dist/server/services/LoopWorkerService.js +261 -23
  32. package/dist/server/services/NativeSubAgentObserver.js +165 -23
  33. package/dist/server/services/PluginAiRuntimeAdapter.js +16 -5
  34. package/dist/server/services/ToolLoopDetectionService.js +210 -0
  35. package/dist/server/services/VerificationService.js +66 -0
  36. package/dist/server/services/harness-runtime-policy.js +139 -0
  37. package/dist/server/skill-hub/plugin.js +36 -3
  38. package/dist/server/skill-hub/tasks/SkillExecutionTask.js +29 -0
  39. package/package.json +53 -53
  40. package/src/client/ApprovalsTab.tsx +2 -0
  41. package/src/client/OrchestratorSettings.tsx +11 -0
  42. package/src/client/skill-hub/components/GitSkillImport.tsx +3 -3
  43. package/src/client/skill-hub/components/SkillMetrics.tsx +15 -10
  44. package/src/client/skill-hub/index.tsx +0 -52
  45. package/src/client-v2/components/AgentRunsTab.tsx +576 -576
  46. package/src/client-v2/components/ApprovalsTab.tsx +337 -0
  47. package/src/client-v2/components/HarnessProfilesTab.tsx +385 -105
  48. package/src/client-v2/components/MemoryInspectorTab.tsx +141 -141
  49. package/src/client-v2/components/TracingTab.tsx +515 -515
  50. package/src/client-v2/hooks/useApiRequest.ts +141 -141
  51. package/src/client-v2/pages/ApprovalsPage.tsx +10 -0
  52. package/src/client-v2/plugin.tsx +6 -6
  53. package/src/client-v2/skill-hub/components/SkillMetrics.tsx +5 -2
  54. package/src/locale/en-US.json +226 -174
  55. package/src/locale/vi-VN.json +226 -174
  56. package/src/locale/zh-CN.json +226 -174
  57. package/src/server/__tests__/circuit-breaker.test.ts +248 -248
  58. package/src/server/__tests__/harness-compiler.test.ts +83 -0
  59. package/src/server/__tests__/harness-profile-service.test.ts +51 -0
  60. package/src/server/__tests__/harness-runtime-policy.test.ts +293 -0
  61. package/src/server/__tests__/harness-tool-plan.test.ts +24 -0
  62. package/src/server/__tests__/loop-approval-decision.test.ts +512 -0
  63. package/src/server/__tests__/loop-approval-expiry.test.ts +258 -0
  64. package/src/server/__tests__/loop-budget-service.test.ts +255 -255
  65. package/src/server/__tests__/loop-control-plane-backfill.test.ts +266 -266
  66. package/src/server/__tests__/loop-pattern-schema.test.ts +18 -1
  67. package/src/server/__tests__/loop-pattern-service.test.ts +148 -148
  68. package/src/server/__tests__/loop-run-state-machine.test.ts +11 -0
  69. package/src/server/__tests__/loop-trigger-service.test.ts +148 -0
  70. package/src/server/__tests__/loop-worker-claim.test.ts +341 -341
  71. package/src/server/__tests__/loop-worker-execution.test.ts +82 -1
  72. package/src/server/__tests__/native-sub-agent-observer.test.ts +288 -4
  73. package/src/server/__tests__/path-lock-service.test.ts +254 -254
  74. package/src/server/__tests__/skill-execution-task-policy.test.ts +140 -0
  75. package/src/server/__tests__/smoke.test.ts +162 -162
  76. package/src/server/__tests__/tool-loop-detection.test.ts +275 -0
  77. package/src/server/collections/agent-execution-spans.ts +8 -0
  78. package/src/server/collections/agent-harness-profile-versions.ts +26 -26
  79. package/src/server/collections/agent-harness-profiles.ts +71 -71
  80. package/src/server/collections/agent-loop-action-approvals.ts +1 -0
  81. package/src/server/collections/agent-loop-artifacts.ts +25 -25
  82. package/src/server/collections/agent-loop-circuit-states.ts +23 -23
  83. package/src/server/collections/agent-loop-control-settings.ts +21 -21
  84. package/src/server/collections/agent-loop-events.ts +98 -98
  85. package/src/server/collections/agent-loop-path-locks.ts +27 -27
  86. package/src/server/collections/agent-loop-patterns.ts +42 -42
  87. package/src/server/collections/agent-loop-runs.ts +7 -1
  88. package/src/server/collections/agent-loop-steps.ts +7 -0
  89. package/src/server/collections/agent-loop-usage-buckets.ts +22 -22
  90. package/src/server/collections/agent-loop-worktrees.ts +25 -25
  91. package/src/server/collections/skill-executions.ts +8 -0
  92. package/src/server/migrations/20260427000002-change-packages-to-text.ts +52 -52
  93. package/src/server/migrations/20260429000000-add-llm-fields.ts +47 -47
  94. package/src/server/migrations/20260429000001-fix-inputargs-json-to-text.ts +45 -45
  95. package/src/server/migrations/20260503000000-add-orchestrator-trace-fields.ts +33 -33
  96. package/src/server/migrations/20260524000000-add-agent-loop-fields-to-skill-executions.ts +31 -31
  97. package/src/server/migrations/20260803010000-backfill-loop-control-plane-data.ts +293 -293
  98. package/src/server/plugin.ts +3 -1
  99. package/src/server/resources/agent-harness-profile.ts +94 -0
  100. package/src/server/resources/agent-knowledge-insights.ts +5 -3
  101. package/src/server/resources/agent-loop-approval.ts +32 -0
  102. package/src/server/resources/agent-loop-artifact.ts +56 -56
  103. package/src/server/resources/agent-loop-events-stream.ts +105 -105
  104. package/src/server/resources/agent-loop.ts +3 -1
  105. package/src/server/resources/resource-helpers.ts +33 -33
  106. package/src/server/resources/tracing.ts +266 -266
  107. package/src/server/services/AgentMemoryContextService.ts +44 -0
  108. package/src/server/services/DurableCircuitBreakerService.ts +239 -239
  109. package/src/server/services/ExecutionSpanService.ts +2 -0
  110. package/src/server/services/HarnessCompiler.ts +37 -0
  111. package/src/server/services/HarnessProfileService.ts +92 -10
  112. package/src/server/services/HarnessSchema.ts +31 -0
  113. package/src/server/services/LoopBudgetService.ts +275 -275
  114. package/src/server/services/LoopControlService.ts +124 -124
  115. package/src/server/services/LoopPatternSchema.ts +19 -1
  116. package/src/server/services/LoopPatternService.ts +143 -143
  117. package/src/server/services/LoopRunRepository.ts +99 -0
  118. package/src/server/services/LoopRunStateMachine.ts +100 -3
  119. package/src/server/services/LoopSchedulerService.ts +199 -199
  120. package/src/server/services/LoopTriggerService.ts +42 -0
  121. package/src/server/services/LoopWorkerService.ts +327 -27
  122. package/src/server/services/NativeSubAgentObserver.ts +186 -21
  123. package/src/server/services/PathLockService.ts +321 -321
  124. package/src/server/services/PluginAiRuntimeAdapter.ts +24 -7
  125. package/src/server/services/ToolLoopDetectionService.ts +213 -0
  126. package/src/server/services/VerificationSchema.ts +31 -31
  127. package/src/server/services/VerificationService.ts +81 -2
  128. package/src/server/services/harness-runtime-policy.ts +141 -0
  129. package/src/server/skill-hub/plugin.ts +41 -3
  130. package/src/server/skill-hub/services/RegistrySkillSnapshotService.ts +235 -235
  131. package/src/server/skill-hub/services/__tests__/RegistrySkillSnapshotService.test.ts +61 -61
  132. package/src/server/skill-hub/tasks/SkillExecutionTask.ts +43 -2
  133. package/src/server/utils/ensure-indexes.ts +96 -96
  134. package/src/server/utils/logging.ts +62 -62
  135. package/src/server/utils/loop-pattern-context.ts +20 -20
  136. package/dist/client-v2/214.b063f33ba044a808.js +0 -10
  137. package/dist/client-v2/373.f5d5292e53c4e832.js +0 -10
  138. package/dist/client-v2/418.58fa350f5496efd3.js +0 -10
  139. package/dist/client-v2/53.9a10455323390f14.js +0 -10
  140. package/dist/client-v2/677.a991ce0250ff5c77.js +0 -10
  141. package/dist/client-v2/925.e5925bf21ed68e7a.js +0 -10
  142. package/src/client/AIEmployeeSelect.tsx +0 -47
  143. package/src/client/AIEmployeesContext.tsx +0 -102
  144. package/src/client/RulesTab.tsx +0 -2
  145. package/src/client/TracingTab.tsx +0 -436
  146. package/src/client/skill-hub/components/ExecutionProgress.tsx +0 -51
  147. package/src/client-v2/components/RulesTab.tsx +0 -2
  148. package/src/client-v2/pages/AgentRunsPage.tsx +0 -13
@@ -67,6 +67,13 @@ export default defineCollection({
67
67
  type: 'string',
68
68
  length: 200,
69
69
  },
70
+ {
71
+ // The AI conversation an invocation step drove; lets run-level guards (tool loop
72
+ // detection) enumerate every session belonging to the run.
73
+ name: 'sessionId',
74
+ type: 'uuid',
75
+ allowNull: true,
76
+ },
70
77
  {
71
78
  name: 'inputHash',
72
79
  type: 'string',
@@ -1,22 +1,22 @@
1
- import { defineCollection } from '@nocobase/database';
2
-
3
- export default defineCollection({
4
- name: 'agentLoopUsageBuckets',
5
- title: 'Agent Loop Usage Buckets',
6
- fields: [
7
- { name: 'id', type: 'bigInt', autoIncrement: true, primaryKey: true },
8
- { name: 'patternId', type: 'bigInt', allowNull: false },
9
- { name: 'pattern', type: 'belongsTo', target: 'agentLoopPatterns', foreignKey: 'patternId', allowNull: false },
10
- { name: 'bucketDate', type: 'dateOnly', allowNull: false },
11
- { name: 'invocationCount', type: 'integer', defaultValue: 0 },
12
- { name: 'toolCallCount', type: 'integer', defaultValue: 0 },
13
- { name: 'delegationCount', type: 'integer', defaultValue: 0 },
14
- { name: 'inputTokens', type: 'integer', defaultValue: 0 },
15
- { name: 'outputTokens', type: 'integer', defaultValue: 0 },
16
- { name: 'totalTokens', type: 'integer', defaultValue: 0 },
17
- { name: 'totalCost', type: 'float', defaultValue: 0 },
18
- { name: 'createdAt', type: 'date' },
19
- { name: 'updatedAt', type: 'date' },
20
- ],
21
- indexes: [{ unique: true, fields: ['patternId', 'bucketDate'] }, { fields: ['bucketDate'] }],
22
- });
1
+ import { defineCollection } from '@nocobase/database';
2
+
3
+ export default defineCollection({
4
+ name: 'agentLoopUsageBuckets',
5
+ title: 'Agent Loop Usage Buckets',
6
+ fields: [
7
+ { name: 'id', type: 'bigInt', autoIncrement: true, primaryKey: true },
8
+ { name: 'patternId', type: 'bigInt', allowNull: false },
9
+ { name: 'pattern', type: 'belongsTo', target: 'agentLoopPatterns', foreignKey: 'patternId', allowNull: false },
10
+ { name: 'bucketDate', type: 'dateOnly', allowNull: false },
11
+ { name: 'invocationCount', type: 'integer', defaultValue: 0 },
12
+ { name: 'toolCallCount', type: 'integer', defaultValue: 0 },
13
+ { name: 'delegationCount', type: 'integer', defaultValue: 0 },
14
+ { name: 'inputTokens', type: 'integer', defaultValue: 0 },
15
+ { name: 'outputTokens', type: 'integer', defaultValue: 0 },
16
+ { name: 'totalTokens', type: 'integer', defaultValue: 0 },
17
+ { name: 'totalCost', type: 'float', defaultValue: 0 },
18
+ { name: 'createdAt', type: 'date' },
19
+ { name: 'updatedAt', type: 'date' },
20
+ ],
21
+ indexes: [{ unique: true, fields: ['patternId', 'bucketDate'] }, { fields: ['bucketDate'] }],
22
+ });
@@ -1,25 +1,25 @@
1
- import { defineCollection } from '@nocobase/database';
2
-
3
- export default defineCollection({
4
- name: 'agentLoopWorktrees',
5
- title: 'Agent Loop Worktrees',
6
- fields: [
7
- { name: 'id', type: 'bigInt', autoIncrement: true, primaryKey: true },
8
- { name: 'runId', type: 'bigInt', allowNull: false },
9
- { name: 'run', type: 'belongsTo', target: 'agentLoopRuns', foreignKey: 'runId', allowNull: false },
10
- { name: 'repositoryKey', type: 'string', length: 200, allowNull: false },
11
- { name: 'repositoryRoot', type: 'string', length: 1000, allowNull: false },
12
- { name: 'baseRef', type: 'string', length: 200, allowNull: false },
13
- { name: 'branchName', type: 'string', length: 300, allowNull: false },
14
- { name: 'worktreePath', type: 'string', length: 1500, allowNull: false },
15
- { name: 'provider', type: 'string', length: 40, defaultValue: 'git' },
16
- { name: 'status', type: 'string', length: 30, defaultValue: 'creating' },
17
- { name: 'patchArtifactId', type: 'bigInt' },
18
- { name: 'cleanupReason', type: 'text' },
19
- { name: 'createdAt', type: 'date' },
20
- { name: 'activatedAt', type: 'date' },
21
- { name: 'removedAt', type: 'date' },
22
- { name: 'updatedAt', type: 'date' },
23
- ],
24
- indexes: [{ unique: true, fields: ['runId'] }, { fields: ['repositoryKey', 'status'] }, { fields: ['worktreePath'] }],
25
- });
1
+ import { defineCollection } from '@nocobase/database';
2
+
3
+ export default defineCollection({
4
+ name: 'agentLoopWorktrees',
5
+ title: 'Agent Loop Worktrees',
6
+ fields: [
7
+ { name: 'id', type: 'bigInt', autoIncrement: true, primaryKey: true },
8
+ { name: 'runId', type: 'bigInt', allowNull: false },
9
+ { name: 'run', type: 'belongsTo', target: 'agentLoopRuns', foreignKey: 'runId', allowNull: false },
10
+ { name: 'repositoryKey', type: 'string', length: 200, allowNull: false },
11
+ { name: 'repositoryRoot', type: 'string', length: 1000, allowNull: false },
12
+ { name: 'baseRef', type: 'string', length: 200, allowNull: false },
13
+ { name: 'branchName', type: 'string', length: 300, allowNull: false },
14
+ { name: 'worktreePath', type: 'string', length: 1500, allowNull: false },
15
+ { name: 'provider', type: 'string', length: 40, defaultValue: 'git' },
16
+ { name: 'status', type: 'string', length: 30, defaultValue: 'creating' },
17
+ { name: 'patchArtifactId', type: 'bigInt' },
18
+ { name: 'cleanupReason', type: 'text' },
19
+ { name: 'createdAt', type: 'date' },
20
+ { name: 'activatedAt', type: 'date' },
21
+ { name: 'removedAt', type: 'date' },
22
+ { name: 'updatedAt', type: 'date' },
23
+ ],
24
+ indexes: [{ unique: true, fields: ['runId'] }, { fields: ['repositoryKey', 'status'] }, { fields: ['worktreePath'] }],
25
+ });
@@ -138,6 +138,14 @@ export default {
138
138
  target: 'users',
139
139
  foreignKey: 'triggeredById',
140
140
  },
141
+ {
142
+ // Harness-derived overrides resolved when the execution is queued, e.g.
143
+ // { timeoutSeconds, spillMaxInlineBytes }. The worker applies them on top of the skill's
144
+ // own defaults; storing them here keeps the worker from needing harness access.
145
+ name: 'runtimePolicy',
146
+ type: 'json',
147
+ allowNull: true,
148
+ },
141
149
  {
142
150
  name: 'createdAt',
143
151
  type: 'date',
@@ -1,52 +1,52 @@
1
- import { Migration } from '@nocobase/server';
2
-
3
- export default class ChangePackagesToTextMigration extends Migration {
4
- on = 'afterLoad';
5
- appVersion = '>=0.1.0';
6
-
7
- async up() {
8
- const queryInterface = (this as any).db.sequelize.getQueryInterface();
9
- const tableName = `${(this as any).db.options.tablePrefix || ''}skillDefinitions`;
10
-
11
- try {
12
- const tableExists = await queryInterface.tableExists(tableName);
13
- if (!tableExists) return;
14
-
15
- const tableDesc = await queryInterface.describeTable(tableName);
16
- const columnsToChange = ['packages', 'inputSchema', 'interactionSchema'];
17
- const fieldRepo = (this as any).db.getRepository('fields');
18
- const collectionName = 'skillDefinitions';
19
-
20
- for (const col of columnsToChange) {
21
- if (tableDesc[col]) {
22
- // Change physical column type in Postgres if needed
23
- const dialect = (this as any).db.sequelize.getDialect();
24
- if (dialect === 'postgres') {
25
- await (this as any).db.sequelize.query(
26
- `ALTER TABLE "${tableName}" ALTER COLUMN "${col}" TYPE text USING "${col}"::text;`,
27
- );
28
- } else {
29
- await queryInterface.changeColumn(tableName, col, {
30
- type: 'TEXT',
31
- });
32
- }
33
-
34
- // Also update NocoBase metadata
35
- const fieldMeta = await fieldRepo.findOne({
36
- filter: { name: col, collectionName },
37
- });
38
-
39
- if (fieldMeta) {
40
- await fieldRepo.update({
41
- filterByTk: fieldMeta.get('id'),
42
- values: { type: 'text' },
43
- });
44
- }
45
- (this as any).app.logger.info(`[skill-hub] Changed ${col} column type to text to support markdown`);
46
- }
47
- }
48
- } catch (error) {
49
- (this as any).app.logger.error(`[skill-hub] Failed to change packages field type: ${error.message}`);
50
- }
51
- }
52
- }
1
+ import { Migration } from '@nocobase/server';
2
+
3
+ export default class ChangePackagesToTextMigration extends Migration {
4
+ on = 'afterLoad';
5
+ appVersion = '>=0.1.0';
6
+
7
+ async up() {
8
+ const queryInterface = (this as any).db.sequelize.getQueryInterface();
9
+ const tableName = `${(this as any).db.options.tablePrefix || ''}skillDefinitions`;
10
+
11
+ try {
12
+ const tableExists = await queryInterface.tableExists(tableName);
13
+ if (!tableExists) return;
14
+
15
+ const tableDesc = await queryInterface.describeTable(tableName);
16
+ const columnsToChange = ['packages', 'inputSchema', 'interactionSchema'];
17
+ const fieldRepo = (this as any).db.getRepository('fields');
18
+ const collectionName = 'skillDefinitions';
19
+
20
+ for (const col of columnsToChange) {
21
+ if (tableDesc[col]) {
22
+ // Change physical column type in Postgres if needed
23
+ const dialect = (this as any).db.sequelize.getDialect();
24
+ if (dialect === 'postgres') {
25
+ await (this as any).db.sequelize.query(
26
+ `ALTER TABLE "${tableName}" ALTER COLUMN "${col}" TYPE text USING "${col}"::text;`,
27
+ );
28
+ } else {
29
+ await queryInterface.changeColumn(tableName, col, {
30
+ type: 'TEXT',
31
+ });
32
+ }
33
+
34
+ // Also update NocoBase metadata
35
+ const fieldMeta = await fieldRepo.findOne({
36
+ filter: { name: col, collectionName },
37
+ });
38
+
39
+ if (fieldMeta) {
40
+ await fieldRepo.update({
41
+ filterByTk: fieldMeta.get('id'),
42
+ values: { type: 'text' },
43
+ });
44
+ }
45
+ (this as any).app.logger.info(`[skill-hub] Changed ${col} column type to text to support markdown`);
46
+ }
47
+ }
48
+ } catch (error) {
49
+ (this as any).app.logger.error(`[skill-hub] Failed to change packages field type: ${error.message}`);
50
+ }
51
+ }
52
+ }
@@ -1,47 +1,47 @@
1
- import { Migration } from '@nocobase/server';
2
- import { DataTypes } from '@nocobase/database';
3
-
4
- export default class AddLlmFieldsToOrchestratorConfig extends Migration {
5
- on = 'afterLoad';
6
- appVersion = '>=0.1.0';
7
-
8
- async up() {
9
- const queryInterface = (this as any).db.sequelize.getQueryInterface();
10
- const tablePrefix = (this as any).db.options.tablePrefix || '';
11
- const tableName = `${tablePrefix}orchestratorConfig`;
12
-
13
- const tableExists = await queryInterface.tableExists(tableName);
14
- if (!tableExists) return;
15
-
16
- const tableDesc = await queryInterface.describeTable(tableName);
17
-
18
- if (!tableDesc['llmService']) {
19
- await queryInterface.addColumn(tableName, 'llmService', {
20
- type: DataTypes.STRING(255),
21
- allowNull: true,
22
- });
23
- console.log(`[AgentOrchestrator] Added llmService column to ${tableName}`);
24
- }
25
-
26
- if (!tableDesc['model']) {
27
- await queryInterface.addColumn(tableName, 'model', {
28
- type: DataTypes.STRING(255),
29
- allowNull: true,
30
- });
31
- console.log(`[AgentOrchestrator] Added model column to ${tableName}`);
32
- }
33
-
34
- if (!tableDesc['recursionLimit']) {
35
- await queryInterface.addColumn(tableName, 'recursionLimit', {
36
- type: 'INTEGER',
37
- allowNull: true,
38
- defaultValue: 50,
39
- });
40
- console.log(`[AgentOrchestrator] Added recursionLimit column to ${tableName}`);
41
- }
42
- }
43
-
44
- async down() {
45
- // No rollback
46
- }
47
- }
1
+ import { Migration } from '@nocobase/server';
2
+ import { DataTypes } from '@nocobase/database';
3
+
4
+ export default class AddLlmFieldsToOrchestratorConfig extends Migration {
5
+ on = 'afterLoad';
6
+ appVersion = '>=0.1.0';
7
+
8
+ async up() {
9
+ const queryInterface = (this as any).db.sequelize.getQueryInterface();
10
+ const tablePrefix = (this as any).db.options.tablePrefix || '';
11
+ const tableName = `${tablePrefix}orchestratorConfig`;
12
+
13
+ const tableExists = await queryInterface.tableExists(tableName);
14
+ if (!tableExists) return;
15
+
16
+ const tableDesc = await queryInterface.describeTable(tableName);
17
+
18
+ if (!tableDesc['llmService']) {
19
+ await queryInterface.addColumn(tableName, 'llmService', {
20
+ type: DataTypes.STRING(255),
21
+ allowNull: true,
22
+ });
23
+ console.log(`[AgentOrchestrator] Added llmService column to ${tableName}`);
24
+ }
25
+
26
+ if (!tableDesc['model']) {
27
+ await queryInterface.addColumn(tableName, 'model', {
28
+ type: DataTypes.STRING(255),
29
+ allowNull: true,
30
+ });
31
+ console.log(`[AgentOrchestrator] Added model column to ${tableName}`);
32
+ }
33
+
34
+ if (!tableDesc['recursionLimit']) {
35
+ await queryInterface.addColumn(tableName, 'recursionLimit', {
36
+ type: 'INTEGER',
37
+ allowNull: true,
38
+ defaultValue: 50,
39
+ });
40
+ console.log(`[AgentOrchestrator] Added recursionLimit column to ${tableName}`);
41
+ }
42
+ }
43
+
44
+ async down() {
45
+ // No rollback
46
+ }
47
+ }
@@ -1,45 +1,45 @@
1
- import { Migration } from '@nocobase/server';
2
- import { DataTypes } from '@nocobase/database';
3
-
4
- /**
5
- * Fix: inputArgs column in skillExecutions was json type but should be text.
6
- *
7
- * Root cause: The column was created as `json` from an older schema version,
8
- * but the collection defines it as `text`. The `stringifyJsonText()` utility
9
- * wraps values in markdown code fences (```json\n...\n```) which PostgreSQL
10
- * rejects as invalid JSON syntax, causing SequelizeDatabaseError on every
11
- * skill execution attempt.
12
- */
13
- export default class FixInputArgsJsonToText extends Migration {
14
- on = 'afterLoad';
15
- appVersion = '>=0.1.0';
16
-
17
- async up() {
18
- const db = (this as any).db;
19
- const queryInterface = db.sequelize.getQueryInterface();
20
- const tableName = `${db.options.tablePrefix || ''}skillExecutions`;
21
-
22
- // Check current column type
23
- const tableDesc = await queryInterface.describeTable(tableName).catch(() => null);
24
- if (!tableDesc) return;
25
-
26
- const col = tableDesc['inputArgs'];
27
- if (!col) return;
28
-
29
- // Only migrate if still json type
30
- if (col.type && col.type.toLowerCase().includes('json')) {
31
- if (db.sequelize.getDialect() === 'postgres') {
32
- await db.sequelize.query(
33
- `ALTER TABLE "${tableName}" ALTER COLUMN "inputArgs" TYPE text USING "inputArgs"::text`,
34
- );
35
- } else {
36
- await queryInterface.changeColumn(tableName, 'inputArgs', { type: DataTypes.TEXT });
37
- }
38
- db.logger?.info?.('[skill-hub] Migration: converted skillExecutions.inputArgs from json to text');
39
- }
40
- }
41
-
42
- async down() {
43
- // No rollback — keeping as text is safe; json is more restrictive
44
- }
45
- }
1
+ import { Migration } from '@nocobase/server';
2
+ import { DataTypes } from '@nocobase/database';
3
+
4
+ /**
5
+ * Fix: inputArgs column in skillExecutions was json type but should be text.
6
+ *
7
+ * Root cause: The column was created as `json` from an older schema version,
8
+ * but the collection defines it as `text`. The `stringifyJsonText()` utility
9
+ * wraps values in markdown code fences (```json\n...\n```) which PostgreSQL
10
+ * rejects as invalid JSON syntax, causing SequelizeDatabaseError on every
11
+ * skill execution attempt.
12
+ */
13
+ export default class FixInputArgsJsonToText extends Migration {
14
+ on = 'afterLoad';
15
+ appVersion = '>=0.1.0';
16
+
17
+ async up() {
18
+ const db = (this as any).db;
19
+ const queryInterface = db.sequelize.getQueryInterface();
20
+ const tableName = `${db.options.tablePrefix || ''}skillExecutions`;
21
+
22
+ // Check current column type
23
+ const tableDesc = await queryInterface.describeTable(tableName).catch(() => null);
24
+ if (!tableDesc) return;
25
+
26
+ const col = tableDesc['inputArgs'];
27
+ if (!col) return;
28
+
29
+ // Only migrate if still json type
30
+ if (col.type && col.type.toLowerCase().includes('json')) {
31
+ if (db.sequelize.getDialect() === 'postgres') {
32
+ await db.sequelize.query(
33
+ `ALTER TABLE "${tableName}" ALTER COLUMN "inputArgs" TYPE text USING "inputArgs"::text`,
34
+ );
35
+ } else {
36
+ await queryInterface.changeColumn(tableName, 'inputArgs', { type: DataTypes.TEXT });
37
+ }
38
+ db.logger?.info?.('[skill-hub] Migration: converted skillExecutions.inputArgs from json to text');
39
+ }
40
+ }
41
+
42
+ async down() {
43
+ // No rollback — keeping as text is safe; json is more restrictive
44
+ }
45
+ }
@@ -1,33 +1,33 @@
1
- import { Migration } from '@nocobase/server';
2
- import { DataTypes } from '@nocobase/database';
3
-
4
- export default class AddOrchestratorTraceFieldsToSkillExecutions extends Migration {
5
- on = 'afterLoad';
6
- appVersion = '>=0.1.0';
7
-
8
- async up() {
9
- const queryInterface = (this as any).db.sequelize.getQueryInterface();
10
- const tablePrefix = (this as any).db.options.tablePrefix || '';
11
- const tableName = `${tablePrefix}skillExecutions`;
12
- const tableExists = await queryInterface.tableExists(tableName).catch(() => false);
13
- if (!tableExists) return;
14
-
15
- const tableDesc = await queryInterface.describeTable(tableName);
16
- const addIfMissing = async (name: string) => {
17
- if (tableDesc[name]) return;
18
- await queryInterface.addColumn(tableName, name, {
19
- type: DataTypes.STRING(100),
20
- allowNull: true,
21
- });
22
- };
23
-
24
- await addIfMissing('orchestratorRootRunId');
25
- await addIfMissing('orchestratorSpanId');
26
- await addIfMissing('orchestratorParentSpanId');
27
- await addIfMissing('orchestratorToolCallId');
28
- }
29
-
30
- async down() {
31
- // No rollback: keeping nullable trace-link columns is safe.
32
- }
33
- }
1
+ import { Migration } from '@nocobase/server';
2
+ import { DataTypes } from '@nocobase/database';
3
+
4
+ export default class AddOrchestratorTraceFieldsToSkillExecutions extends Migration {
5
+ on = 'afterLoad';
6
+ appVersion = '>=0.1.0';
7
+
8
+ async up() {
9
+ const queryInterface = (this as any).db.sequelize.getQueryInterface();
10
+ const tablePrefix = (this as any).db.options.tablePrefix || '';
11
+ const tableName = `${tablePrefix}skillExecutions`;
12
+ const tableExists = await queryInterface.tableExists(tableName).catch(() => false);
13
+ if (!tableExists) return;
14
+
15
+ const tableDesc = await queryInterface.describeTable(tableName);
16
+ const addIfMissing = async (name: string) => {
17
+ if (tableDesc[name]) return;
18
+ await queryInterface.addColumn(tableName, name, {
19
+ type: DataTypes.STRING(100),
20
+ allowNull: true,
21
+ });
22
+ };
23
+
24
+ await addIfMissing('orchestratorRootRunId');
25
+ await addIfMissing('orchestratorSpanId');
26
+ await addIfMissing('orchestratorParentSpanId');
27
+ await addIfMissing('orchestratorToolCallId');
28
+ }
29
+
30
+ async down() {
31
+ // No rollback: keeping nullable trace-link columns is safe.
32
+ }
33
+ }
@@ -1,31 +1,31 @@
1
- import { Migration } from '@nocobase/server';
2
- import { DataTypes } from '@nocobase/database';
3
-
4
- export default class AddAgentLoopFieldsToSkillExecutions extends Migration {
5
- on = 'afterLoad';
6
- appVersion = '>=0.1.0';
7
-
8
- async up() {
9
- const queryInterface = (this as any).db.sequelize.getQueryInterface();
10
- const tablePrefix = (this as any).db.options.tablePrefix || '';
11
- const tableName = `${tablePrefix}skillExecutions`;
12
- const tableExists = await queryInterface.tableExists(tableName).catch(() => false);
13
- if (!tableExists) return;
14
-
15
- const tableDesc = await queryInterface.describeTable(tableName);
16
- const addIfMissing = async (name: string) => {
17
- if (tableDesc[name]) return;
18
- await queryInterface.addColumn(tableName, name, {
19
- type: DataTypes.STRING(100),
20
- allowNull: true,
21
- });
22
- };
23
-
24
- await addIfMissing('agentLoopRunId');
25
- await addIfMissing('agentLoopStepId');
26
- }
27
-
28
- async down() {
29
- // No rollback: these nullable trace-link columns are backward compatible.
30
- }
31
- }
1
+ import { Migration } from '@nocobase/server';
2
+ import { DataTypes } from '@nocobase/database';
3
+
4
+ export default class AddAgentLoopFieldsToSkillExecutions extends Migration {
5
+ on = 'afterLoad';
6
+ appVersion = '>=0.1.0';
7
+
8
+ async up() {
9
+ const queryInterface = (this as any).db.sequelize.getQueryInterface();
10
+ const tablePrefix = (this as any).db.options.tablePrefix || '';
11
+ const tableName = `${tablePrefix}skillExecutions`;
12
+ const tableExists = await queryInterface.tableExists(tableName).catch(() => false);
13
+ if (!tableExists) return;
14
+
15
+ const tableDesc = await queryInterface.describeTable(tableName);
16
+ const addIfMissing = async (name: string) => {
17
+ if (tableDesc[name]) return;
18
+ await queryInterface.addColumn(tableName, name, {
19
+ type: DataTypes.STRING(100),
20
+ allowNull: true,
21
+ });
22
+ };
23
+
24
+ await addIfMissing('agentLoopRunId');
25
+ await addIfMissing('agentLoopStepId');
26
+ }
27
+
28
+ async down() {
29
+ // No rollback: these nullable trace-link columns are backward compatible.
30
+ }
31
+ }