@open-mercato/enterprise 0.10.1-develop.7961.1.d65694a8e6 → 0.10.1-develop.7972.1.03f813eaaf

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.
@@ -10,6 +10,35 @@ function stableScheduleUuid(stableKey) {
10
10
  const hex = createHash("sha256").update(stableKey).digest("hex");
11
11
  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
12
12
  }
13
+ async function ensureMetricRollupSchedule(ctx) {
14
+ const cradle = ctx.container;
15
+ if (typeof cradle.hasRegistration !== "function" || !cradle.hasRegistration("schedulerService")) return;
16
+ try {
17
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId };
18
+ const schedulerService = ctx.container.resolve("schedulerService");
19
+ await schedulerService.register({
20
+ id: stableScheduleUuid(`agent_orchestrator:metric-rollup:${ctx.organizationId}`),
21
+ name: "Agent metric rollup",
22
+ description: "Precomputes per-agent KPI windows into append-only rollup rows every 300s.",
23
+ scopeType: "organization",
24
+ organizationId: ctx.organizationId,
25
+ tenantId: ctx.tenantId,
26
+ scheduleType: "interval",
27
+ scheduleValue: "300s",
28
+ timezone: "UTC",
29
+ targetType: "queue",
30
+ targetQueue: AGENT_ORCHESTRATOR_METRIC_ROLLUP_QUEUE,
31
+ targetPayload: { scope },
32
+ sourceType: "module",
33
+ sourceModule: "agent_orchestrator",
34
+ isEnabled: true
35
+ });
36
+ } catch (error) {
37
+ logger.warn("failed to register metric-rollup schedule", {
38
+ error: error instanceof Error ? error.message : String(error)
39
+ });
40
+ }
41
+ }
13
42
  const setup = {
14
43
  // Mirrors the frozen ACL feature set (mvp/00-overview.md §ACL features):
15
44
  // agents.view · agents.run · proposals.view · proposals.dispose · workflows.author
@@ -98,36 +127,9 @@ const setup = {
98
127
  tenantId: ctx.tenantId,
99
128
  organizationId: ctx.organizationId
100
129
  });
101
- const cradle = ctx.container;
102
- if (typeof cradle.hasRegistration !== "function" || !cradle.hasRegistration("schedulerService")) {
103
- return;
104
- }
105
- try {
106
- const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId };
107
- const schedulerService = ctx.container.resolve("schedulerService");
108
- await schedulerService.register({
109
- id: stableScheduleUuid(`agent_orchestrator:metric-rollup:${ctx.organizationId}`),
110
- name: "Agent metric rollup",
111
- description: "Precomputes per-agent KPI windows into append-only rollup rows every 300s.",
112
- scopeType: "organization",
113
- organizationId: ctx.organizationId,
114
- tenantId: ctx.tenantId,
115
- scheduleType: "interval",
116
- scheduleValue: "300s",
117
- timezone: "UTC",
118
- targetType: "queue",
119
- targetQueue: AGENT_ORCHESTRATOR_METRIC_ROLLUP_QUEUE,
120
- targetPayload: { scope },
121
- sourceType: "module",
122
- sourceModule: "agent_orchestrator",
123
- isEnabled: true
124
- });
125
- } catch (error) {
126
- logger.warn("failed to register metric-rollup schedule", {
127
- error: error instanceof Error ? error.message : String(error)
128
- });
129
- }
130
+ await ensureMetricRollupSchedule(ctx);
130
131
  },
132
+ onOrganizationCreated: ensureMetricRollupSchedule,
131
133
  // Gated demo seed (skipped with --no-examples). Idempotent + tenant-scoped:
132
134
  // lands the demo workflow definition and 2 demo deals (via the audited
133
135
  // customers command path), and verifies the code-defined `deals.health_check`
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/agent_orchestrator/setup.ts"],
4
- "sourcesContent": ["import { createHash } from 'node:crypto'\nimport type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport { seedAgentOrchestratorExamples } from './lib/seeds'\nimport { seedDefaultEvalAssertions } from './lib/eval/defaultAssertions'\nimport { seedDefaultAgentIcons } from './lib/settings/agentSettings'\nimport { syncGroundingSets } from './lib/guardrails/syncGroundingSets'\nimport { AGENT_ORCHESTRATOR_METRIC_ROLLUP_QUEUE } from './lib/queue'\n\nconst logger = createLogger('agent_orchestrator').child({ component: 'setup' })\n\n/** Mirrors the @open-mercato/scheduler ScheduleRegistration field names. */\ntype SchedulerServiceLike = {\n register: (registration: {\n id: string\n name: string\n scopeType: 'system' | 'organization' | 'tenant'\n organizationId?: string\n tenantId?: string\n scheduleType: 'cron' | 'interval'\n scheduleValue: string\n timezone?: string\n targetType: 'queue' | 'command'\n targetQueue?: string\n targetPayload?: unknown\n sourceType?: 'user' | 'module'\n sourceModule?: string\n isEnabled?: boolean\n description?: string\n }) => Promise<void>\n}\n\n/**\n * `scheduled_jobs.id` is a uuid column, so a module-owned schedule's stable\n * registration key must be hashed into a uuid \u2014 this keeps register() an\n * idempotent upsert across seedDefaults re-runs.\n */\nfunction stableScheduleUuid(stableKey: string): string {\n const hex = createHash('sha256').update(stableKey).digest('hex')\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`\n}\n\nexport const setup: ModuleSetupConfig = {\n // Mirrors the frozen ACL feature set (mvp/00-overview.md \u00A7ACL features):\n // agents.view \u00B7 agents.run \u00B7 proposals.view \u00B7 proposals.dispose \u00B7 workflows.author\n // Every concrete feature appears under at least one role (the wildcard\n // `agent_orchestrator.*` is the contract per packages/core/AGENTS.md \u00A7 ACL).\n //\n // Persona mapping:\n // superadmin / admin \u2014 full wildcard.\n // operator \u2014 works the My caseload queue and disposes proposals; cannot run\n // the playground or author workflows.\n // engineer \u2014 runs the Playground, authors the INVOKE_AGENT builder node, and\n // reads proposals; does NOT dispose (HITL stays with the operator).\n //\n // NOTE: the standard default roles created by auth setup are superadmin/admin/\n // employee (see auth/lib/setup-app.ts DEFAULT_ROLE_NAMES). `operator` and\n // `engineer` are NOT default roles, so those grants are picked up by\n // ensureDefaultRoleAcls' custom-role branch only when a deployment actually\n // creates those roles (the demo runbook step 0 creates them); listing them is\n // a safe no-op otherwise. `employee` mirrors the operator caseload grants so a\n // stock tenant still gets a usable disposition persona out of the box.\n defaultRoleFeatures: {\n superadmin: ['agent_orchestrator.*'],\n admin: ['agent_orchestrator.*'],\n employee: [\n 'agent_orchestrator.agents.view',\n 'agent_orchestrator.proposals.view',\n 'agent_orchestrator.proposals.dispose',\n 'agent_orchestrator.trace.view',\n 'agent_orchestrator.trace.correct',\n 'agent_orchestrator.guardrail.read',\n 'agent_orchestrator.context.read',\n 'agent_orchestrator.identity.read',\n 'agent_orchestrator.processes.view',\n 'agent_orchestrator.processes.run',\n ],\n operator: [\n 'agent_orchestrator.agents.view',\n 'agent_orchestrator.proposals.view',\n 'agent_orchestrator.proposals.dispose',\n 'agent_orchestrator.trace.view',\n 'agent_orchestrator.trace.correct',\n 'agent_orchestrator.guardrail.read',\n 'agent_orchestrator.context.read',\n 'agent_orchestrator.identity.read',\n 'agent_orchestrator.processes.view',\n 'agent_orchestrator.processes.run',\n ],\n engineer: [\n 'agent_orchestrator.agents.view',\n 'agent_orchestrator.agents.run',\n 'agent_orchestrator.agents.manage',\n 'agent_orchestrator.proposals.view',\n 'agent_orchestrator.workflows.author',\n 'agent_orchestrator.trace.view',\n 'agent_orchestrator.eval.manage',\n 'agent_orchestrator.eval.run',\n 'agent_orchestrator.eval.export',\n 'agent_orchestrator.guardrail.read',\n 'agent_orchestrator.guardrail.manage',\n 'agent_orchestrator.context.read',\n 'agent_orchestrator.identity.read',\n 'agent_orchestrator.identity.manage',\n 'agent_orchestrator.processes.view',\n 'agent_orchestrator.processes.manage',\n 'agent_orchestrator.processes.run',\n ],\n },\n\n // The auto-approve threshold is NOT seeded here (it lives in the INVOKE_AGENT\n // node config; the shared `module_configs` store is global, not tenant-scoped,\n // so a threshold row there would leak across tenants \u2014 see area 03).\n //\n // The trace-eval overlay DOES seed default deterministic eval assertions: these\n // are real per-(tenant, organization) `agent_eval_assertions` rows (properly\n // tenant-scoped, unlike module_configs), so a stock tenant evaluates runs out\n // of the box. Idempotent \u2014 re-running creates nothing new.\n seedDefaults: async (ctx) => {\n await seedDefaultEvalAssertions(ctx.em, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n\n // Per-agent presentation icons \u2192 `agent_settings`. Idempotent: only inserts\n // rows for agent ids that have none yet, so a tenant's later edits survive\n // re-running setup. Gives a stock tenant recognisable agent glyphs (instead\n // of initials) out of the box across the agents list + overview trust card.\n await seedDefaultAgentIcons(ctx.em, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n\n // Wave 3, Phase 4: sync the per-capability grounding guardrail SETS to\n // `agent_guardrail_sets`, content-hash idempotent (re-run with no body change\n // writes nothing; editing a body produces a new append-only version). The\n // synced `version` is recorded on every grounding AgentGuardrailCheck.\n await syncGroundingSets(ctx.em, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n\n // F2: register the per-org metric-rollup interval job. Best-effort + guarded\n // \u2014 a deployment without the scheduler module is a safe no-op, and a\n // scheduler failure must not abort tenant init for every other module. The\n // schedule id is a deterministic uuid so re-runs upsert idempotently.\n const cradle = ctx.container as { hasRegistration?: (name: string) => boolean }\n if (typeof cradle.hasRegistration !== 'function' || !cradle.hasRegistration('schedulerService')) {\n return\n }\n try {\n const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }\n const schedulerService = ctx.container.resolve('schedulerService') as SchedulerServiceLike\n await schedulerService.register({\n id: stableScheduleUuid(`agent_orchestrator:metric-rollup:${ctx.organizationId}`),\n name: 'Agent metric rollup',\n description: 'Precomputes per-agent KPI windows into append-only rollup rows every 300s.',\n scopeType: 'organization',\n organizationId: ctx.organizationId,\n tenantId: ctx.tenantId,\n scheduleType: 'interval',\n scheduleValue: '300s',\n timezone: 'UTC',\n targetType: 'queue',\n targetQueue: AGENT_ORCHESTRATOR_METRIC_ROLLUP_QUEUE,\n targetPayload: { scope },\n sourceType: 'module',\n sourceModule: 'agent_orchestrator',\n isEnabled: true,\n })\n } catch (error) {\n logger.warn('failed to register metric-rollup schedule', {\n error: error instanceof Error ? error.message : String(error),\n })\n }\n },\n\n // Gated demo seed (skipped with --no-examples). Idempotent + tenant-scoped:\n // lands the demo workflow definition and 2 demo deals (via the audited\n // customers command path), and verifies the code-defined `deals.health_check`\n // agent resolves. Re-running creates nothing new.\n seedExamples: async (ctx) => {\n await seedAgentOrchestratorExamples(ctx.em, ctx.container, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n },\n}\n\nexport default setup\n"],
5
- "mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,oBAAoB;AAC7B,SAAS,qCAAqC;AAC9C,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAClC,SAAS,8CAA8C;AAEvD,MAAM,SAAS,aAAa,oBAAoB,EAAE,MAAM,EAAE,WAAW,QAAQ,CAAC;AA4B9E,SAAS,mBAAmB,WAA2B;AACrD,QAAM,MAAM,WAAW,QAAQ,EAAE,OAAO,SAAS,EAAE,OAAO,KAAK;AAC/D,SAAO,GAAG,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,MAAM,GAAG,EAAE,CAAC,IAAI,IAAI,MAAM,IAAI,EAAE,CAAC,IAAI,IAAI,MAAM,IAAI,EAAE,CAAC,IAAI,IAAI,MAAM,IAAI,EAAE,CAAC;AAC9G;AAEO,MAAM,QAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBtC,qBAAqB;AAAA,IACnB,YAAY,CAAC,sBAAsB;AAAA,IACnC,OAAO,CAAC,sBAAsB;AAAA,IAC9B,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA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MACb,CAAC;AAAA,IACH,SAAS,OAAO;AACd,aAAO,KAAK,6CAA6C;AAAA,QACvD,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAC9D,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc,OAAO,QAAQ;AAC3B,UAAM,8BAA8B,IAAI,IAAI,IAAI,WAAW;AAAA,MACzD,UAAU,IAAI;AAAA,MACd,gBAAgB,IAAI;AAAA,IACtB,CAAC;AAAA,EACH;AACF;AAEA,IAAO,gBAAQ;",
4
+ "sourcesContent": ["import { createHash } from 'node:crypto'\nimport type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport { seedAgentOrchestratorExamples } from './lib/seeds'\nimport { seedDefaultEvalAssertions } from './lib/eval/defaultAssertions'\nimport { seedDefaultAgentIcons } from './lib/settings/agentSettings'\nimport { syncGroundingSets } from './lib/guardrails/syncGroundingSets'\nimport { AGENT_ORCHESTRATOR_METRIC_ROLLUP_QUEUE } from './lib/queue'\n\nconst logger = createLogger('agent_orchestrator').child({ component: 'setup' })\n\n/** Mirrors the @open-mercato/scheduler ScheduleRegistration field names. */\ntype SchedulerServiceLike = {\n register: (registration: {\n id: string\n name: string\n scopeType: 'system' | 'organization' | 'tenant'\n organizationId?: string\n tenantId?: string\n scheduleType: 'cron' | 'interval'\n scheduleValue: string\n timezone?: string\n targetType: 'queue' | 'command'\n targetQueue?: string\n targetPayload?: unknown\n sourceType?: 'user' | 'module'\n sourceModule?: string\n isEnabled?: boolean\n description?: string\n }) => Promise<void>\n}\n\n/**\n * `scheduled_jobs.id` is a uuid column, so a module-owned schedule's stable\n * registration key must be hashed into a uuid \u2014 this keeps register() an\n * idempotent upsert across seedDefaults re-runs.\n */\nfunction stableScheduleUuid(stableKey: string): string {\n const hex = createHash('sha256').update(stableKey).digest('hex')\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`\n}\n\nasync function ensureMetricRollupSchedule(ctx: {\n container: import('awilix').AwilixContainer\n tenantId: string\n organizationId: string\n}): Promise<void> {\n const cradle = ctx.container as { hasRegistration?: (name: string) => boolean }\n if (typeof cradle.hasRegistration !== 'function' || !cradle.hasRegistration('schedulerService')) return\n\n try {\n const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }\n const schedulerService = ctx.container.resolve('schedulerService') as SchedulerServiceLike\n await schedulerService.register({\n id: stableScheduleUuid(`agent_orchestrator:metric-rollup:${ctx.organizationId}`),\n name: 'Agent metric rollup',\n description: 'Precomputes per-agent KPI windows into append-only rollup rows every 300s.',\n scopeType: 'organization',\n organizationId: ctx.organizationId,\n tenantId: ctx.tenantId,\n scheduleType: 'interval',\n scheduleValue: '300s',\n timezone: 'UTC',\n targetType: 'queue',\n targetQueue: AGENT_ORCHESTRATOR_METRIC_ROLLUP_QUEUE,\n targetPayload: { scope },\n sourceType: 'module',\n sourceModule: 'agent_orchestrator',\n isEnabled: true,\n })\n } catch (error) {\n logger.warn('failed to register metric-rollup schedule', {\n error: error instanceof Error ? error.message : String(error),\n })\n }\n}\n\nexport const setup: ModuleSetupConfig = {\n // Mirrors the frozen ACL feature set (mvp/00-overview.md \u00A7ACL features):\n // agents.view \u00B7 agents.run \u00B7 proposals.view \u00B7 proposals.dispose \u00B7 workflows.author\n // Every concrete feature appears under at least one role (the wildcard\n // `agent_orchestrator.*` is the contract per packages/core/AGENTS.md \u00A7 ACL).\n //\n // Persona mapping:\n // superadmin / admin \u2014 full wildcard.\n // operator \u2014 works the My caseload queue and disposes proposals; cannot run\n // the playground or author workflows.\n // engineer \u2014 runs the Playground, authors the INVOKE_AGENT builder node, and\n // reads proposals; does NOT dispose (HITL stays with the operator).\n //\n // NOTE: the standard default roles created by auth setup are superadmin/admin/\n // employee (see auth/lib/setup-app.ts DEFAULT_ROLE_NAMES). `operator` and\n // `engineer` are NOT default roles, so those grants are picked up by\n // ensureDefaultRoleAcls' custom-role branch only when a deployment actually\n // creates those roles (the demo runbook step 0 creates them); listing them is\n // a safe no-op otherwise. `employee` mirrors the operator caseload grants so a\n // stock tenant still gets a usable disposition persona out of the box.\n defaultRoleFeatures: {\n superadmin: ['agent_orchestrator.*'],\n admin: ['agent_orchestrator.*'],\n employee: [\n 'agent_orchestrator.agents.view',\n 'agent_orchestrator.proposals.view',\n 'agent_orchestrator.proposals.dispose',\n 'agent_orchestrator.trace.view',\n 'agent_orchestrator.trace.correct',\n 'agent_orchestrator.guardrail.read',\n 'agent_orchestrator.context.read',\n 'agent_orchestrator.identity.read',\n 'agent_orchestrator.processes.view',\n 'agent_orchestrator.processes.run',\n ],\n operator: [\n 'agent_orchestrator.agents.view',\n 'agent_orchestrator.proposals.view',\n 'agent_orchestrator.proposals.dispose',\n 'agent_orchestrator.trace.view',\n 'agent_orchestrator.trace.correct',\n 'agent_orchestrator.guardrail.read',\n 'agent_orchestrator.context.read',\n 'agent_orchestrator.identity.read',\n 'agent_orchestrator.processes.view',\n 'agent_orchestrator.processes.run',\n ],\n engineer: [\n 'agent_orchestrator.agents.view',\n 'agent_orchestrator.agents.run',\n 'agent_orchestrator.agents.manage',\n 'agent_orchestrator.proposals.view',\n 'agent_orchestrator.workflows.author',\n 'agent_orchestrator.trace.view',\n 'agent_orchestrator.eval.manage',\n 'agent_orchestrator.eval.run',\n 'agent_orchestrator.eval.export',\n 'agent_orchestrator.guardrail.read',\n 'agent_orchestrator.guardrail.manage',\n 'agent_orchestrator.context.read',\n 'agent_orchestrator.identity.read',\n 'agent_orchestrator.identity.manage',\n 'agent_orchestrator.processes.view',\n 'agent_orchestrator.processes.manage',\n 'agent_orchestrator.processes.run',\n ],\n },\n\n // The auto-approve threshold is NOT seeded here (it lives in the INVOKE_AGENT\n // node config; the shared `module_configs` store is global, not tenant-scoped,\n // so a threshold row there would leak across tenants \u2014 see area 03).\n //\n // The trace-eval overlay DOES seed default deterministic eval assertions: these\n // are real per-(tenant, organization) `agent_eval_assertions` rows (properly\n // tenant-scoped, unlike module_configs), so a stock tenant evaluates runs out\n // of the box. Idempotent \u2014 re-running creates nothing new.\n seedDefaults: async (ctx) => {\n await seedDefaultEvalAssertions(ctx.em, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n\n // Per-agent presentation icons \u2192 `agent_settings`. Idempotent: only inserts\n // rows for agent ids that have none yet, so a tenant's later edits survive\n // re-running setup. Gives a stock tenant recognisable agent glyphs (instead\n // of initials) out of the box across the agents list + overview trust card.\n await seedDefaultAgentIcons(ctx.em, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n\n // Wave 3, Phase 4: sync the per-capability grounding guardrail SETS to\n // `agent_guardrail_sets`, content-hash idempotent (re-run with no body change\n // writes nothing; editing a body produces a new append-only version). The\n // synced `version` is recorded on every grounding AgentGuardrailCheck.\n await syncGroundingSets(ctx.em, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n\n // F2: register the per-org metric-rollup interval job. Best-effort + guarded\n // \u2014 a deployment without the scheduler module is a safe no-op, and a\n // scheduler failure must not abort tenant init for every other module. The\n // schedule id is a deterministic uuid so re-runs upsert idempotently.\n await ensureMetricRollupSchedule(ctx)\n },\n\n onOrganizationCreated: ensureMetricRollupSchedule,\n\n // Gated demo seed (skipped with --no-examples). Idempotent + tenant-scoped:\n // lands the demo workflow definition and 2 demo deals (via the audited\n // customers command path), and verifies the code-defined `deals.health_check`\n // agent resolves. Re-running creates nothing new.\n seedExamples: async (ctx) => {\n await seedAgentOrchestratorExamples(ctx.em, ctx.container, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n },\n}\n\nexport default setup\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,oBAAoB;AAC7B,SAAS,qCAAqC;AAC9C,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAClC,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CAAC;AAAA,EACH;AACF;AAEA,IAAO,gBAAQ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/enterprise",
3
- "version": "0.10.1-develop.7961.1.d65694a8e6",
3
+ "version": "0.10.1-develop.7972.1.03f813eaaf",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -70,12 +70,12 @@
70
70
  "@dnd-kit/core": "^6.3.1",
71
71
  "@dnd-kit/sortable": "^10.0.0",
72
72
  "@dnd-kit/utilities": "^3.2.2",
73
- "@open-mercato/ai-assistant": "0.10.1-develop.7961.1.d65694a8e6",
74
- "@open-mercato/core": "0.10.1-develop.7961.1.d65694a8e6",
75
- "@open-mercato/queue": "0.10.1-develop.7961.1.d65694a8e6",
76
- "@open-mercato/scheduler": "0.10.1-develop.7961.1.d65694a8e6",
77
- "@open-mercato/ui": "0.10.1-develop.7961.1.d65694a8e6",
78
- "@open-mercato/web-research": "0.10.1-develop.7961.1.d65694a8e6",
73
+ "@open-mercato/ai-assistant": "0.10.1-develop.7972.1.03f813eaaf",
74
+ "@open-mercato/core": "0.10.1-develop.7972.1.03f813eaaf",
75
+ "@open-mercato/queue": "0.10.1-develop.7972.1.03f813eaaf",
76
+ "@open-mercato/scheduler": "0.10.1-develop.7972.1.03f813eaaf",
77
+ "@open-mercato/ui": "0.10.1-develop.7972.1.03f813eaaf",
78
+ "@open-mercato/web-research": "0.10.1-develop.7972.1.03f813eaaf",
79
79
  "@simplewebauthn/browser": "^13.3.0",
80
80
  "@simplewebauthn/server": "^13.3.2",
81
81
  "@simplewebauthn/types": "^12.0.0",
@@ -87,13 +87,13 @@
87
87
  },
88
88
  "peerDependencies": {
89
89
  "@mikro-orm/core": "^7.0.14",
90
- "@open-mercato/shared": "0.10.1-develop.7961.1.d65694a8e6",
90
+ "@open-mercato/shared": "0.10.1-develop.7972.1.03f813eaaf",
91
91
  "react": "^19.0.0",
92
92
  "react-dom": "^19.0.0",
93
93
  "zod": ">=3.23.0"
94
94
  },
95
95
  "devDependencies": {
96
- "@open-mercato/shared": "0.10.1-develop.7961.1.d65694a8e6",
96
+ "@open-mercato/shared": "0.10.1-develop.7972.1.03f813eaaf",
97
97
  "@types/jest": "^30.0.0",
98
98
  "@types/react": "^19.2.18",
99
99
  "@types/react-dom": "^19.2.5",
@@ -40,6 +40,41 @@ function stableScheduleUuid(stableKey: string): string {
40
40
  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`
41
41
  }
42
42
 
43
+ async function ensureMetricRollupSchedule(ctx: {
44
+ container: import('awilix').AwilixContainer
45
+ tenantId: string
46
+ organizationId: string
47
+ }): Promise<void> {
48
+ const cradle = ctx.container as { hasRegistration?: (name: string) => boolean }
49
+ if (typeof cradle.hasRegistration !== 'function' || !cradle.hasRegistration('schedulerService')) return
50
+
51
+ try {
52
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
53
+ const schedulerService = ctx.container.resolve('schedulerService') as SchedulerServiceLike
54
+ await schedulerService.register({
55
+ id: stableScheduleUuid(`agent_orchestrator:metric-rollup:${ctx.organizationId}`),
56
+ name: 'Agent metric rollup',
57
+ description: 'Precomputes per-agent KPI windows into append-only rollup rows every 300s.',
58
+ scopeType: 'organization',
59
+ organizationId: ctx.organizationId,
60
+ tenantId: ctx.tenantId,
61
+ scheduleType: 'interval',
62
+ scheduleValue: '300s',
63
+ timezone: 'UTC',
64
+ targetType: 'queue',
65
+ targetQueue: AGENT_ORCHESTRATOR_METRIC_ROLLUP_QUEUE,
66
+ targetPayload: { scope },
67
+ sourceType: 'module',
68
+ sourceModule: 'agent_orchestrator',
69
+ isEnabled: true,
70
+ })
71
+ } catch (error) {
72
+ logger.warn('failed to register metric-rollup schedule', {
73
+ error: error instanceof Error ? error.message : String(error),
74
+ })
75
+ }
76
+ }
77
+
43
78
  export const setup: ModuleSetupConfig = {
44
79
  // Mirrors the frozen ACL feature set (mvp/00-overview.md §ACL features):
45
80
  // agents.view · agents.run · proposals.view · proposals.dispose · workflows.author
@@ -144,37 +179,11 @@ export const setup: ModuleSetupConfig = {
144
179
  // — a deployment without the scheduler module is a safe no-op, and a
145
180
  // scheduler failure must not abort tenant init for every other module. The
146
181
  // schedule id is a deterministic uuid so re-runs upsert idempotently.
147
- const cradle = ctx.container as { hasRegistration?: (name: string) => boolean }
148
- if (typeof cradle.hasRegistration !== 'function' || !cradle.hasRegistration('schedulerService')) {
149
- return
150
- }
151
- try {
152
- const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
153
- const schedulerService = ctx.container.resolve('schedulerService') as SchedulerServiceLike
154
- await schedulerService.register({
155
- id: stableScheduleUuid(`agent_orchestrator:metric-rollup:${ctx.organizationId}`),
156
- name: 'Agent metric rollup',
157
- description: 'Precomputes per-agent KPI windows into append-only rollup rows every 300s.',
158
- scopeType: 'organization',
159
- organizationId: ctx.organizationId,
160
- tenantId: ctx.tenantId,
161
- scheduleType: 'interval',
162
- scheduleValue: '300s',
163
- timezone: 'UTC',
164
- targetType: 'queue',
165
- targetQueue: AGENT_ORCHESTRATOR_METRIC_ROLLUP_QUEUE,
166
- targetPayload: { scope },
167
- sourceType: 'module',
168
- sourceModule: 'agent_orchestrator',
169
- isEnabled: true,
170
- })
171
- } catch (error) {
172
- logger.warn('failed to register metric-rollup schedule', {
173
- error: error instanceof Error ? error.message : String(error),
174
- })
175
- }
182
+ await ensureMetricRollupSchedule(ctx)
176
183
  },
177
184
 
185
+ onOrganizationCreated: ensureMetricRollupSchedule,
186
+
178
187
  // Gated demo seed (skipped with --no-examples). Idempotent + tenant-scoped:
179
188
  // lands the demo workflow definition and 2 demo deals (via the audited
180
189
  // customers command path), and verifies the code-defined `deals.health_check`